| |   |
| 10 | 10 | |
| 11 | 11 | class Event < DataMapper::Base |
| 12 | 12 | property :name, :string |
| 13 | property :description, :text |
| 13 | 14 | end |
| 14 | 15 | Event.table.create! |
| 15 | 16 | |
| … | … | |
| 22 | 22 | haml(layout('Events', %q{ |
| 23 | 23 | %h1= "Events" |
| 24 | 24 | %form{:action => '/events', :method => 'POST'} |
| 25 | | %table |
| 26 | | %tr |
| 27 | | %th Name |
| 28 | | %td |
| 29 | | %input{:type => 'text', :name => 'name', :size => 30} |
| 30 | | %tr |
| 31 | | %td |
| 32 | | %td |
| 33 | | %input{:type => 'submit', :value => 'Create Event'} |
| 25 | %fieldset |
| 26 | %legend New Event |
| 27 | |
| 28 | %label{:for => 'name'} Name |
| 29 | %input{:type => 'text', :name => 'name', :id => 'name', :size => 30} |
| 30 | %br |
| 31 | |
| 32 | %label{:for => 'description'} Description |
| 33 | %textarea{:type => 'description', :name => 'description', :id => 'description', :cols => 30, :rows => 4} |
| 34 | %br |
| 35 | |
| 36 | %input{:type => 'submit', :class => 'submit', :value => 'Create'} |
| 34 | 37 | - if @events.empty? |
| 35 | 38 | %p No events found. |
| 36 | 39 | - else |
| 37 | | %table.long |
| 38 | | - c = 'even' |
| 40 | %table |
| 41 | %caption Events |
| 42 | %tr{:class => 'odd'} |
| 43 | %th{:class => 'name', :scope => 'col'} Name |
| 44 | - c = 'odd' |
| 39 | 45 | - @events.each do |e| |
| 40 | 46 | %tr{:class => (c == 'even' ? c = 'odd' : c = 'even') } |
| 41 | | %td |
| 42 | | %a{:href => "/event/#{e.id}" } |
| 43 | | %code= e.name |
| 47 | %td{:class => 'name'} |
| 48 | %a{:href => '#'}= e.name |
| 49 | = e.description |
| 44 | 50 | })) |
| 45 | 51 | end |
| 46 | 52 | |
| 47 | 53 | post '/events' do |
| 48 | 54 | name = params[:name].to_s.strip |
| 49 | | x = Event.new(:name => name).save |
| 55 | description = params[:description].to_s.strip |
| 56 | x = Event.new(:name => name, :description => description).save |
| 50 | 57 | redirect '/events' |
| 51 | 58 | end |
| 52 | 59 | |
| … | … | |
| 78 | 78 | family: Verdana, Arial, "Bitstream Vera Sans", Helvetica, sans-serif |
| 79 | 79 | color: black |
| 80 | 80 | line-height: 160% |
| 81 | | background-color: white |
| 82 | | margin: 2em |
| 81 | background: #b5b5b5 |
| 82 | margin: 0 |
| 83 | padding: 30px |
| 83 | 84 | |
| 84 | | #navigation |
| 85 | | a |
| 86 | | background-color: #e0e0e0 |
| 87 | | color: black |
| 88 | | text-decoration: none |
| 89 | | padding: 2px |
| 90 | | padding: 5px |
| 91 | | border-bottom: 1px black solid |
| 92 | | |
| 93 | | #action |
| 94 | | text-align: right |
| 95 | | |
| 96 | | .addtag |
| 97 | | padding: 5px 0 |
| 98 | | |
| 99 | 85 | h1 |
| 100 | 86 | display: block |
| 101 | 87 | padding-bottom: 5px |
| 102 | 88 | |
| 103 | 89 | a |
| 104 | 90 | color: black |
| 105 | | a.exists |
| 106 | | font-weight: bold |
| 107 | | a.unknown |
| 108 | | font-style: italic |
| 109 | | |
| 110 | | .comments |
| 111 | | margin: 10px 20px |
| 112 | | .comment |
| 113 | | .head |
| 114 | | background: #eee |
| 115 | | padding: 4px |
| 116 | | .comment-text |
| 117 | | padding: 10px |
| 118 | | color: #333 |
| 91 | |
| 92 | form |
| 93 | label |
| 94 | float: left |
| 95 | text-align: right |
| 96 | width: 200px |
| 97 | :font |
| 98 | weight: bold |
| 119 | 99 | |
| 120 | | table.long |
| 100 | input, textarea |
| 101 | margin-left: 210px |
| 102 | display: block |
| 103 | margin-bottom: 0pt |
| 104 | width: 300px |
| 105 | |
| 106 | table |
| 121 | 107 | width: 100% |
| 108 | border: 1px solid #000 |
| 109 | background: #fff |
| 110 | border-collapse: collapse |
| 122 | 111 | |
| 123 | | table |
| 124 | | tr.even |
| 125 | | td |
| 126 | | background: #eee |
| 112 | caption |
| 113 | margin: 0 |
| 114 | padding: 8px 20px |
| 115 | text-align: left |
| 116 | border: 1px solid #000 |
| 117 | border-bottom: none |
| 118 | background: #fff |
| 119 | th, td |
| 120 | margin: 0 |
| 121 | padding: 8px 20px |
| 122 | text-align: center |
| 123 | border-bottom: 1px solid #b5b5b5 |
| 124 | th.name, td.name |
| 125 | text-align: left |
| 126 | th |
| 127 | color: #999 |
| 127 | 128 | tr.odd |
| 128 | | td |
| 129 | | background: #fff |
| 130 | | |
| 131 | | table |
| 132 | | tr |
| 133 | | th |
| 134 | | text-align: left |
| 135 | | padding: 3px |
| 136 | | vertical-align: top |
| 137 | | td.open |
| 138 | | background: #ada |
| 139 | | td.resolved |
| 140 | | background: #abd |
| 141 | | td.hold |
| 142 | | background: #dda |
| 143 | | td.invalid |
| 144 | | background: #aaa |
| 129 | background: #e6e6e6 |
| 130 | tr.even |
| 131 | background: #f1f1f1 |
| 132 | td |
| 133 | a |
| 134 | display: block |
| 135 | :font |
| 136 | weight: bold |
| 145 | 137 | |
| 146 | 138 | .submit |
| 147 | 139 | font-size: large |
| toggle raw diff |
--- a/sinatra/events.rb
+++ b/sinatra/events.rb
@@ -10,6 +10,7 @@ DataMapper::Database.setup({
class Event < DataMapper::Base
property :name, :string
+ property :description, :text
end
Event.table.create!
@@ -21,31 +22,38 @@ get '/events' do
haml(layout('Events', %q{
%h1= "Events"
%form{:action => '/events', :method => 'POST'}
- %table
- %tr
- %th Name
- %td
- %input{:type => 'text', :name => 'name', :size => 30}
- %tr
- %td
- %td
- %input{:type => 'submit', :value => 'Create Event'}
+ %fieldset
+ %legend New Event
+
+ %label{:for => 'name'} Name
+ %input{:type => 'text', :name => 'name', :id => 'name', :size => 30}
+ %br
+
+ %label{:for => 'description'} Description
+ %textarea{:type => 'description', :name => 'description', :id => 'description', :cols => 30, :rows => 4}
+ %br
+
+ %input{:type => 'submit', :class => 'submit', :value => 'Create'}
- if @events.empty?
%p No events found.
- else
- %table.long
- - c = 'even'
+ %table
+ %caption Events
+ %tr{:class => 'odd'}
+ %th{:class => 'name', :scope => 'col'} Name
+ - c = 'odd'
- @events.each do |e|
%tr{:class => (c == 'even' ? c = 'odd' : c = 'even') }
- %td
- %a{:href => "/event/#{e.id}" }
- %code= e.name
+ %td{:class => 'name'}
+ %a{:href => '#'}= e.name
+ = e.description
}))
end
post '/events' do
name = params[:name].to_s.strip
- x = Event.new(:name => name).save
+ description = params[:description].to_s.strip
+ x = Event.new(:name => name, :description => description).save
redirect '/events'
end
@@ -70,70 +78,62 @@ body
family: Verdana, Arial, "Bitstream Vera Sans", Helvetica, sans-serif
color: black
line-height: 160%
- background-color: white
- margin: 2em
+ background: #b5b5b5
+ margin: 0
+ padding: 30px
-#navigation
- a
- background-color: #e0e0e0
- color: black
- text-decoration: none
- padding: 2px
- padding: 5px
- border-bottom: 1px black solid
-
-#action
- text-align: right
-
-.addtag
- padding: 5px 0
-
h1
display: block
padding-bottom: 5px
a
color: black
-a.exists
- font-weight: bold
-a.unknown
- font-style: italic
-
-.comments
- margin: 10px 20px
- .comment
- .head
- background: #eee
- padding: 4px
- .comment-text
- padding: 10px
- color: #333
+
+form
+ label
+ float: left
+ text-align: right
+ width: 200px
+ :font
+ weight: bold
-table.long
+ input, textarea
+ margin-left: 210px
+ display: block
+ margin-bottom: 0pt
+ width: 300px
+
+table
width: 100%
+ border: 1px solid #000
+ background: #fff
+ border-collapse: collapse
-table
- tr.even
- td
- background: #eee
+ caption
+ margin: 0
+ padding: 8px 20px
+ text-align: left
+ border: 1px solid #000
+ border-bottom: none
+ background: #fff
+ th, td
+ margin: 0
+ padding: 8px 20px
+ text-align: center
+ border-bottom: 1px solid #b5b5b5
+ th.name, td.name
+ text-align: left
+ th
+ color: #999
tr.odd
- td
- background: #fff
-
-table
- tr
- th
- text-align: left
- padding: 3px
- vertical-align: top
- td.open
- background: #ada
- td.resolved
- background: #abd
- td.hold
- background: #dda
- td.invalid
- background: #aaa
+ background: #e6e6e6
+ tr.even
+ background: #f1f1f1
+ td
+ a
+ display: block
+ :font
+ weight: bold
.submit
font-size: large |