This is the source code example for the blog Making a JS widget: a full-stack approach
This repo contains a Ruby on Rails 5.0 project with all the code related to the blog above.
Javasciprt plugin sources
The plugin source code. Which is composed of two files:
- Another ERB template that is used to generate the CSS code _widget.css.erb
And you can see an example web page that shows how the plugin is loaded here: index.html.
A security layer was added by using rack-attack
- Ruby 2.2+
- Rails 5.0+
Running the server
First, ensure you have installed all the requirements listed in the previous section. Then, run the following commands
cd <project-root-path> bundle install rails -s bind 0.0.0.0
After that, you can see the plugin test page in http://localhost:3000/: