This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@riddle | |
doctype html | |
html lang="en" | |
head | |
title== @riddle.title | |
meta charset="utf-8" | |
style | |
== scss @riddle.css | |
script | |
== @riddle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/:id' do | |
@riddle = Riddle.get(params[:id]) | |
slim :riddle, layout: false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@show | |
h1.title== @riddle.title | |
#riddle | |
iframe src="/#{@riddle.id}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'sass' | |
require 'slim' | |
get('/css/styles.css'){ scss :styles } | |
get '/' do | |
slim :index | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/finish' do | |
flash.now[:message] = "Thank you for shopping at Flash Farm, please come baaa-ck soon!" | |
slim :index | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/discount' do | |
# discount logic goes here | |
flash.keep | |
flash[:info] = "A discount of 10% was applied to your order" | |
redirect to('/finish') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/finish' do | |
flash[:message] = "Thank you for shopping at Flash Farm, please come baaa-ck soon!" | |
slim :index | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get '/discount' do | |
# discount logic goes here | |
flash[:info] = "A discount of 10% was applied to your order" | |
redirect to('/finish') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
post '/checkout' do | |
n = rand(3) | |
flash[:error] = "There was an error processing your payment" if n == 0 | |
flash[:success] = "Your payment was successful" if n > 0 | |
redirect to('/discount') if n == 2 | |
redirect to('/finish') | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@styles | |
.flash{ | |
width: 600px; | |
padding: 5px; | |
font-weight: bold; | |
margin: 20px; | |
background:#ddd; | |
color:#666;border:1px solid #ccc; | |
} |