~rbdr/grita

5573b3c2672a04d58a91ce1c74f9c543e14fb423 — Ben Beltran 13 years ago a7ac219
Gemfile.lock y nuevas revisiones.

yadda yadda yadda.
6 files changed, 89 insertions(+), 12 deletions(-)

M Gemfile
A Gemfile.lock
M grita.rb
A views/error.haml
A views/grito.haml
M views/index.haml
M Gemfile => Gemfile +4 -2
@@ 3,5 3,7 @@ source :rubygems
gem 'sinatra', ">=1.1.0"
gem 'haml', ">=3.0.0"
gem 'less', ">=1.2.0"
gem 'mongo', ">=1.1.0"
gem 'rdiscount', ">=1.6.5"
\ No newline at end of file
gem 'rdiscount', ">=1.6.5"
gem 'dm-core', ">=1.0"
gem 'dm-timestamps', ">=1.0"
gem 'dm-mysql-adapter', ">=1.0"
\ No newline at end of file

A Gemfile.lock => Gemfile.lock +46 -0
@@ 0,0 1,46 @@
GEM
  remote: http://rubygems.org/
  specs:
    addressable (2.2.2)
    data_objects (0.10.2)
      addressable (~> 2.1)
    dm-core (1.0.2)
      addressable (~> 2.2)
      extlib (~> 0.9.15)
    dm-do-adapter (1.0.2)
      data_objects (~> 0.10.2)
      dm-core (~> 1.0.2)
    dm-mysql-adapter (1.0.2)
      dm-do-adapter (~> 1.0.2)
      do_mysql (~> 0.10.2)
    dm-timestamps (1.0.2)
      dm-core (~> 1.0.2)
    do_mysql (0.10.2)
      data_objects (= 0.10.2)
    extlib (0.9.15)
    haml (3.0.24)
    less (1.2.21)
      mutter (>= 0.4.2)
      treetop (>= 1.4.2)
    mutter (0.5.3)
    polyglot (0.3.1)
    rack (1.2.1)
    rdiscount (1.6.5)
    sinatra (1.1.0)
      rack (~> 1.1)
      tilt (~> 1.1)
    tilt (1.1)
    treetop (1.4.9)
      polyglot (>= 0.3.1)

PLATFORMS
  ruby

DEPENDENCIES
  dm-core (>= 1.0)
  dm-mysql-adapter (>= 1.0)
  dm-timestamps (>= 1.0)
  haml (>= 3.0.0)
  less (>= 1.2.0)
  rdiscount (>= 1.6.5)
  sinatra (>= 1.1.0)

M grita.rb => grita.rb +21 -2
@@ 1,7 1,8 @@
require 'sinatra'
require 'haml'
require 'less'
require 'mongo'
require 'dm-core'
require 'dm-timestamps'

#config
set :haml, :format => :html5


@@ 11,10 12,28 @@ get '/' do
  haml :index
end

post '/' do
  @grito = Grito.first_or_create(:title => params[:title], :text => params[:text])
  haml :index
end

get '/style.css' do
  less :style
end

not_found do
  "Estos no son los droides que estás buscando."
  haml :error
end

DataMapper.setup(:default, ENV['DATABASE_URL'] || 'mysql://root:root@localhost/grita')
class Grito
  include DataMapper::Resource
  property :id,           Serial
  property :title,        String,  :required => true
  property :text,         Text,  :required => true
  property :created_at,   DateTime
  
  def geturl() 
    self.id.to_s(36)
  end
end
\ No newline at end of file

A views/error.haml => views/error.haml +2 -0
@@ 0,0 1,2 @@
%h1 ERROR
%p Un error ha ocurrido. Revisa que la página esté bien escrita.
\ No newline at end of file

A views/grito.haml => views/grito.haml +8 -0
@@ 0,0 1,8 @@
%h1 The Sorrows of Young Werther
%p
	:markdown
		A **wonderful serenity** has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine.

		I am so happy, *my dear friend*, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now.

		When, while the lovely valley teems with vapour around me, and the meridian sun strikes the upper surface of the impenetrable foliage of my trees, and but a few stray gleams steal into the inner sanctuary, I throw myself down among the tall grass by the trickling stream; and, as I lie close to the earth, a thousand unknown plants are noticed by me: when I hear the buzz of the little world among the stalks, and grow familiar with the countless indescribable forms of the insects and flies, then I feel the presence of the Almighty, who formed us in his own image,
\ No newline at end of file

M views/index.haml => views/index.haml +8 -8
@@ 1,8 1,8 @@
%h1 The Sorrows of Young Werther
%p
	:markdown
		A **wonderful serenity** has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine.

		I am so happy, *my dear friend*, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now.

		When, while the lovely valley teems with vapour around me, and the meridian sun strikes the upper surface of the impenetrable foliage of my trees, and but a few stray gleams steal into the inner sanctuary, I throw myself down among the tall grass by the trickling stream; and, as I lie close to the earth, a thousand unknown plants are noticed by me: when I hear the buzz of the little world among the stalks, and grow familiar with the countless indescribable forms of the insects and flies, then I feel the presence of the Almighty, who formed us in his own image,
\ No newline at end of file
%form{:method => 'post', :action => '/'}
	%h1 Título
	%input{:type => 'text', :name => 'title', :class => 'title'}
	%br
	%h1 Texto
	%textarea{:name => 'text', :class => 'text', :cols => '100'}
	%br
	%input{:type => 'submit', :value => 'Gritalo!'}
\ No newline at end of file