Skip to content
Sample Store
JavaScript Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
public
views
Gemfile
Gemfile.lock
Procfile
README.md
config.ru
database.rb
lamp.rb
server.rb

README.md

I Love Lamps - A Sample Sinatra App

I Love Lamps.com is a simple store for buying lamps of all kinds. You can see which lamps are available, view details about a particular lamp, and if you like, purchase a lamp.

Files

Ruby Files

  • server.rb - The Sinatra server. Routes requests to particular actions and chooses which pages to render. Accesses the database of lamps.
  • lamp.rb - A Lamp model. Contains logic for dealing with a particular lamp.
    • id
    • name
    • price
    • color
    • quantity
    • picture url

Template Files

  • layout.erb - Boilerplate html for all pages. Page structure and common elements are contained here.
  • header.erb - Logo and top navigation bar.
  • index.erb - The front page, commonly called the "index" page. Lists all the available lamps a customer could buy and links to the details page.
  • lamp.erb - Details for a particular lamp. Requires an id in the url to decide which lamp to display. Shows all properties of a lamp.
  • buy.erb - Lamp purchasing page. If a lamp is in stock, shows a form to allow the user to purchase the lamp. Also requires an id in the url.
  • thankyou.erb - Success page shown after the user purchases a lamp.

Other Files

  • README.md - This file. Simple documentation file in a slightly structured format.
  • Gemfile - File listing all dependencies needed to run the app. Run the bundle command to install dependencies.
  • styles.css - Style settings for the site.
  • public/img/lamps/ - Directory containing images of lamps. Filenames correspond to lamp_id.

Other files really aren't important for now. The Gemfile.lock is generated by the bundle command. Files named Bootstrap can be used to make the site look nicer. Glyphicons are used by Bootstrap.

TODO / Feature List

  • Show Available Lamps on the front page
  • Simple Header with Logo
  • Simple Page to Show Lamp Details
  • Abstract Lamp into a Model
  • Add critical info about the lamps: color, price, picture
  • Create form to Buy Lamps
  • Process Purchases on the Server (decrement quantity)
  • Create Order Confirmation Page
  • Resize the logo to fit the header.
  • Add "back" links to Details and Buy pages.
  • Don't let someone try to order if there are 0 lamps in stock.
  • Create a "database" abstraction instead of a global array.
  • Show error message if out-of-stock race condition occurs.
  • Add "Restock Lamps" page under secret admin route: /admins/restock/:lamp_id
  • Add Lamp Images to the Index and Buy page as Thumbnails
  • Add Lamp Accessories: bulbs
  • Track quantity of lamps sold per day. Show on /admins/sales
  • Collect user information: Name, Email, Favorite Movie involving Lamps, Shipping Address
  • Apply Bootstrap to the site. Create better nav bar. Center page.
  • Add "Sale" item to front page. Special emphasis with pitch.
Something went wrong with that request. Please try again.