Skip to content

Instantly share code, notes, and snippets.

Created September 28, 2013 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6737827 to your computer and use it in GitHub Desktop.
Save anonymous/6737827 to your computer and use it in GitHub Desktop.
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
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