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.
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.
- picture url
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
idin 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
idin the url.
thankyou.erb- Success page shown after the user purchases a lamp.
README.md- This file. Simple documentation file in a slightly structured format.
Gemfile- File listing all dependencies needed to run the app. Run the
bundlecommand to install dependencies.
styles.css- Style settings for the site.
public/img/lamps/- Directory containing images of lamps. Filenames correspond to
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.