Created
September 28, 2013 02:42
-
-
Save anonymous/6737827 to your computer and use it in GitHub Desktop.
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 "rdiscount" | |
require "sequel" | |
require "sinatra/base" | |
require "sqlite3" | |
module Blog | |
Sequel.connect('sqlite://blog.db') | |
class Post < Sequel::Model | |
def markdown | |
md = RDiscount.new(content) | |
md.to_html | |
end | |
end | |
class Server < Sinatra::Base | |
attr_reader :posts | |
get "/" do | |
@posts = Post.all | |
haml :home | |
end | |
post "/" do | |
post = Post.new(params) | |
post.save | |
redirect "/" | |
end | |
end | |
end | |
run Blog::Server |
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 "sequel" | |
require "sqlite3" | |
task :default do | |
DB=Sequel.sqlite('blog.db') | |
DB.create_table? :posts do | |
primary_key :id | |
string :title | |
string :category | |
string :content | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment