GithubHelp home page GithubHelp logo

isabella232 / javascript-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xmartlabs/javascript-plugin

0.0 0.0 0.0 36 KB

Source Code of blog Making a JS widget: a full-stack approach

License: MIT License

JavaScript 1.96% Ruby 53.91% CSS 1.20% HTML 42.93%

javascript-plugin's Introduction

javascript-plugin

This is the source code example for the blog Making a JS widget: a full-stack approach

Content

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:

  • An ERB template that is used to generate the javascript code widget.js.erb
  • 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.

Rails backend

A rails backend that serves the plugin javascript and a simple endpoint which is called from the plugin simulating the service provided to the client web pages.

Additionally, the backend uses rack-cors to allow cross domain calls. This is needed in order to allow a client web page call our service from the plugin javascript.

A security layer was added by using rack-attack

Usage

Requirements

  • 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/:

widget-test-page

javascript-plugin's People

Contributors

m-revetria avatar

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.