See the project online at hamlet.timstack.com.
Hamlet, cleverly named after the play of which it is the subject, is a Backbone.js application built with a RESTful Sinatra JSON API backend.
Using Shakespeare's masterpiece as its subject, Hamlet is an attempt to build a modern e-reader application with social features, an uncluttered reading experience, and a modern interface. Conceived and built to solve one problem well, the scope of the application's design is limited to creating an enriched reading experience for a great work of literature that is often read in groups and discussed as it is read.
Commenting is the primary feaure of the application. Users may create an account and create comments on each individual line of the play, and then upvote or downvote comments for their perceived quality.
The most difficult aspect of building this project was making the best use of Backbone.js. Backbone by its very nature is a very light-weight, low-level JavaScript MVC framework that is quite unopinionated. For a newcomer to this framework, the learning curve of the API is fairly short, but the user is left to construct their own approach to application structure, inter-component messaging, and global state management.
Beware the sirens of stateful DOM might beckon your craft onto the rocky lee.
In a second pass, I would like to rearchitect the application's components to take better advantage of Backbone.js's inbuilt messaging interface. In addition, the following features have yet to be addressed in full:
- Adding in the footnotes from the original text
- Replies to comments
- Dynamic sorting of comments upon upvoting/downvoting
- A richer social experience with personalized profiles and chat
- Greater navigational clarity
- Deeper exploration of securing JWTs
- Backbone.js (depends on Underscore.js and jQuery)
- Sinatra (RESTful JSON API)
- Gulp.js (frontend development automation)
- Self-hosted on Digital Ocean using Unicorn
- JWT-based authentication
- hiredis-rb - a Ruby wrapper for hiredis, used for a high-performance key/value store for managing JWTs
- jwt - a JSON Web Token implementation in Ruby
- pony - The express way to send mail from Ruby.
- hiredis Ruby wrapper for hiredis
- Git clone into an empty directory.
- Run
bundle install && npm install && bower install
with appropriate permissions. - Using the
config-example/
folder as a guide, create a folder in the root of the project called.config/
. This folder is ignored by git by default to prevent publishing login credentials to GitHub or a public environment. Use the included example files as a template and complete with config parameters appropriate for your environment. - Run a redis server and a postgresql server, ideally as daemonized services.
- Open the postgres terminal (
psql
in terminal) and run your migration by using the following command:\i "/path/to/project/migrations/migrations.sql"
- Quit postgres and run
bundle exec rackup
in the root folder of the project - Navigate to
localhost:9292
, or whatever URL you've configured Rack/Unicorn/etc. to serve the project to. - Read Hamlet and cry into your sherry.
For this project, I used a public domain version of Shakespeare's Hamlet found on Project Gutenberg. This version of the play was heavily edited by Charles Kean, F.S.A. for a performance of the play on January 10, 1859. The primary revisions were for modernization of spelling, not for content or phraseology.
In addition to the modernized language in the Project Gutenberg source text, Charles Kean wrote extensive footnotes. These have yet to be implemented in the project, but will be the next feature added to the application in future versions.