Giter VIP home page Giter VIP logo

canvas_shim's Introduction

CanvasShim

Canvas Shim is a rails engine that allows us to add functionality to Canvas LMS without changing the code base. Additionally it provides services like Pipeline, see corresponding docs like PIPELINE_SERVICE_README.md to learn more about services.

Usage

This Rails engine now allows decorating classes/modules/etc in Canvas LMS without altering Canvas's files

It can also be used as a standard Rails engine with it's own routes/controllers/views/etc

To decorate controllers, helpers, models, lib stuff from CanvasLMS

  • Create an almost same named file using format "{filename}_decorator.rb" under Shim's /app/decorators following the same CanvasLMS path
  • Then use .class_eval to override/extend the class being decorated or use Rails concerns

To decorate a view from CanvasLMS

  • Create the same named file under /app/views following the same CanvasLMS path

    This file will get picked up in the engine first before it's found in CanvasLMS. This overrides the entire file giving you maximum flexibility to make edits, while keeping the original in CanvasLMS for review or later upgrades

To include assets JS/CSS into Canvas LMS

If you're decorating a page in CanvasLMS and need assets

  • In your overriding view wrap your js/css includes in a :strongming_assets block, this block is yielded at the bottom of Canvas's application layout
<% content_for :strongmind_assets do %>
  <%= stylesheet_link_tag    "canvas_shim/application", media: "all" %>
  <%= javascript_include_tag 'canvas_shim/application' %>
<% end %>
  • If you're working in views that are a part of the shim engine, and you want shim to have a unique layout, everything works at a typical Rails app where Shim has it's own layout(s) for it's internal controllers

  • Note that jQuery's ready event doesn't seem to fire with Canvas, you should be able to use window.on 'load' instead

$(window).on("load", function(event) {
  // Some awesome code here
})

Installation

Add this line to your application's Gemfile:

gem 'canvas_shim'

And then execute:

$ bundle

Or install it yourself as:

$ gem install canvas_shim

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.