Commit a9a7178e0467fe6453d13c09080c645ccd8b7f10
1 parent
d2638e73
Exists in
master
and in
29 other branches
ActionItem517: better display of events in search results
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2173 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
6 changed files
with
45 additions
and
7 deletions
Show diff stats
app/helpers/dates_helper.rb
... | ... | @@ -17,10 +17,14 @@ module DatesHelper |
17 | 17 | N_('December') |
18 | 18 | ] |
19 | 19 | |
20 | + def month_name(n) | |
21 | + _(MONTHS[n-1]) | |
22 | + end | |
23 | + | |
20 | 24 | # formats a date for displaying. |
21 | 25 | def show_date(date) |
22 | 26 | if date |
23 | - date.strftime(_('%d %B %Y')) | |
27 | + _('%{month} %{day}, %{year}') % { :day => date.day, :month => month_name(date.month), :year => date.year } | |
24 | 28 | else |
25 | 29 | '' |
26 | 30 | end |
... | ... | @@ -66,7 +70,7 @@ module DatesHelper |
66 | 70 | end |
67 | 71 | |
68 | 72 | # FIXME Date#strftime should translate this for us !!! |
69 | - monthname = _(MONTHS[month.to_i - 1]) | |
73 | + monthname = month_name(month.to_i) | |
70 | 74 | |
71 | 75 | _('%{month} %{year}') % { :year => year, :month => monthname } |
72 | 76 | end | ... | ... |
app/models/event.rb
... | ... | @@ -79,10 +79,16 @@ class Event < Article |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - html.div '_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____' | |
82 | + if self.description | |
83 | + html.div '_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____' | |
84 | + end | |
83 | 85 | } |
84 | 86 | |
85 | - result.sub('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', self.description) | |
87 | + if self.description | |
88 | + result.sub!('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', self.description) | |
89 | + end | |
90 | + | |
91 | + result | |
86 | 92 | end |
87 | 93 | |
88 | 94 | def link=(value) | ... | ... |
public/stylesheets/controller_search.css
... | ... | @@ -151,16 +151,20 @@ |
151 | 151 | } |
152 | 152 | |
153 | 153 | #content .search-results-type-article ul, |
154 | -#content .search-results-type-article li { | |
154 | +#content .search-results-type-article ul, | |
155 | +#content .search-results-type-event ul, | |
156 | +#content .search-results-type-event li { | |
155 | 157 | margin: 0px; |
156 | 158 | padding: 0px; |
157 | 159 | list-style: none; |
158 | 160 | } |
159 | -#content .search-results-type-article li { | |
161 | +#content .search-results-type-article li, | |
162 | +#content .search-results-type-event li { | |
160 | 163 | padding: 2px 0px 4px 0px; |
161 | 164 | } |
162 | 165 | |
163 | -.search-results-type-article .item_meta { | |
166 | +.search-results-type-article .item_meta, | |
167 | +.search-results-type-event .item_meta { | |
164 | 168 | font-size: 10px; |
165 | 169 | color: #888; |
166 | 170 | } | ... | ... |
test/unit/dates_helper_test.rb
... | ... | @@ -4,6 +4,17 @@ class DatesHelperTest < Test::Unit::TestCase |
4 | 4 | |
5 | 5 | include DatesHelper |
6 | 6 | |
7 | + should 'translate month names' do | |
8 | + expects(:_).with('January').returns('Janeiro') | |
9 | + assert_equal "Janeiro", month_name(1) | |
10 | + end | |
11 | + | |
12 | + should 'display date with translation' do | |
13 | + expects(:_).with('%{month} %{day}, %{year}').returns('%{day} de %{month} de %{year}') | |
14 | + expects(:_).with('January').returns('Janeiro') | |
15 | + assert_equal '11 de Janeiro de 2008', show_date(Date.new(2008, 1, 11)) | |
16 | + end | |
17 | + | |
7 | 18 | should 'generate period with two dates' do |
8 | 19 | date1 = mock |
9 | 20 | expects(:show_date).with(date1).returns('XXX') | ... | ... |
test/unit/event_test.rb
... | ... | @@ -138,6 +138,12 @@ class EventTest < ActiveSupport::TestCase |
138 | 138 | |
139 | 139 | end |
140 | 140 | |
141 | + should 'not crash when description is blank' do | |
142 | + e = Event.new | |
143 | + assert_nil e.description | |
144 | + assert_no_match(/_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____/, e.to_html) | |
145 | + end | |
146 | + | |
141 | 147 | should 'add http:// to the link if not already present' do |
142 | 148 | a = Event.new(:link => 'www.nohttp.net') |
143 | 149 | assert_equal 'http://www.nohttp.net', a.link | ... | ... |