Sha256: 64c30e05711bbf2b1f780981b74b5fb9f2320f40cdad77c62b897e753ec9b758
Contents?: true
Size: 860 Bytes
Versions: 2
Compression:
Stored size: 860 Bytes
Contents
require 'byebug' require 'sinatra/base' require 'sinatra/activerecord' require 'github/markdown' require 'pushnote/models/note' module Pushnote class App < Sinatra::Base register Sinatra::ActiveRecordExtension configure do set :database_file, '../../config/database.yml' end helpers do def date(date) date.strftime('%B %d, %Y %T') end def gfm(input) GitHub::Markdown.render_gfm(input) end end get '/' do @notes = Note.all erb :index end get '/:id' do @notes = Note.all @note = Note.find(params[:id]) erb :show end post '/' do Note.create!(parsed_body) status(201) end protected def parsed_body @parsed_body ||= begin body = request.body.read JSON.parse(body) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pushnote-1.0.1 | lib/pushnote/app.rb |
pushnote-1.0.0 | lib/pushnote/app.rb |