diff --git a/README b/README index f50c0ff..c2093f3 100644 --- a/README +++ b/README @@ -1,4 +1,10 @@ Toopaste ======== -A simple (and tiny) Pastie clone written using Sinatra and DataMapper. +A simple (and tiny) Pastie clone written by Nick Plante using Sinatra and DataMapper. + +This version has been modified by Dave Everitt as follows: + +- updated Snippet DataMapper model replaces deprecated :serial and :nullable +- Snippet 'title' field added, with modified view +- subtle changes to CSS diff --git a/toopaste.rb b/toopaste.rb old mode 100644 new mode 100755 index 2eb7980..1856f86 --- a/toopaste.rb +++ b/toopaste.rb @@ -1,3 +1,5 @@ +#!/usr/local/bin/ruby -rubygems + require 'sinatra' require 'dm-core' require 'dm-validations' @@ -9,22 +11,25 @@ class Snippet include DataMapper::Resource - property :id, Integer, :serial => true # primary serial key - property :body, Text, :nullable => false # cannot be null + property :id, Serial # primary serial key + property :title, String, :required => true, :length => 32 + property :body, Text, :required => true property :created_at, DateTime property :updated_at, DateTime - - #validates_present :body - #validates_length :body, :minimum => 1 - + + # validates_present :body + # validates_length :body, :minimum => 1 + Syntaxi.line_number_method = 'floating' Syntaxi.wrap_at_column = 80 #Syntaxi.wrap_enabled = false - + def formatted_body replacer = Time.now.strftime('[code-%d]') - html = Syntaxi.new("[code lang='ruby']#{self.body.gsub('[/code]', replacer)}[/code]").process - "