Giter VIP home page Giter VIP logo

spa-badge-challenge's Introduction

SPABadge

Let's use JavaScript to make a decoupled single-page app version of BootBadge called SPABadge. The first version has a single cohort: DBC teachers and mentors. Here's the (old version of) BootBadge: http://bootbadge.herokuapp.com/cohorts/63

For a given cohort, each student has a page that contains "badges" with a given catchphrase. Visitors to the site can vote for their favorite badge on each student's page. The badges should appear from most popular at the top to least popular at the bottom.

Directory structure

spa-badge-challenge/
---api/ (your Rails API code)
---app/ (your JavaScript application)

You can find the main page at app/spa-badge.html. Click the Sample Page link to see what a person's badge page should look like.

Release 1

The app will have two servers, a front-end server and a back-end server. We will begin with the front-end. You can use the command ruby -run -e httpd . -p 9000 to run your front-end server containing your static HTML files and your JavaScript. Access the server on localhost:9000. There is a sample API at sample-badges-api.herokuapp.com.

Routes for sample API

GET /teachers --> show all teachers
GET /teachers/1 --> show teacher with ID 1, badges included
POST /badges --> create a new badge, expects phrase and teacher_id as parameters
PUT /badges/:id --> vote for a badge. Expects one param called "vote_type" whose value can be "up" or "down"

Rules

  • Has to be a JavaScript app that utilizes your miniQuery library
  • You can add features to your miniQuery
  • Only XHR (AJAX) requests to the server are allowed except for the initial app load
  • jQuery is banned; any features you want from jQuery must be implemented in your miniQuery
  • Frameworks and libraries such as Angular and React are banned
  • There's an ban exception for templating libraries such as [Handlebars] (http://tutorialzine.com/2015/01/learn-handlebars-in-10-minutes/)
  • All page navigation must be done through JS routing (see Features section)
  • All DOM manipulation should take place on the client

Features

  • Routing. http://myapp.com/#walker should show me Walker's page for example. Check out location.hash, window.onhashchange, and the pushState API for implementation ideas.
  • Keeping track of votes. Use document.cookie to manage how many times a person has voted.

TodoMVC has helpful tips for patterns you could use in your app: https://github.com/tastejs/todomvc/tree/gh-pages/examples/vanillajs

Release 2

Time to create the API. Your back-end server will ONLY serve JSON data. Your Rails application should have ZERO views. Run the back-end server using rails server once inside the api folder. api/README.md contains more information about setting up your back-end.

Rules

  • Data should be persisted on a Rails API backend. Your Rails app should not serve / have any erb or haml files
  • Badges should be sorted by vote count

Features

  • Security. Escape the user's input to avoid XSS attacks. http://www.veracode.com/security/xss. Rails might already take care of this for you. Try naming a badge "<script>alert('lol')</script>" and see what happens.

spa-badge-challenge's People

Contributors

b0uma avatar bootcoder avatar

Watchers

Ted Day-Fratto 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.