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.
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.
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
localhost:9000. There is a sample API at
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"
- 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
- All page navigation must be done through JS routing (see Features section)
- All DOM manipulation should take place on the client
- 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
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/README.md contains more information about setting up your back-end.
- 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
- 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 "" and see what happens.