Commit ff33db3f3314a8723a846fad24955adca091a5a0
Committed by
Arthur Esposte
1 parent
24429b78
Exists in
event_layout
Improved event display layout
Signed-off-by: André Bernardes <andrebsguedes@gmail.com> Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
Showing
8 changed files
with
159 additions
and
51 deletions
Show diff stats
app/models/event.rb
| ... | ... | @@ -98,47 +98,19 @@ class Event < Article |
| 98 | 98 | start_date..(end_date||start_date) |
| 99 | 99 | end |
| 100 | 100 | |
| 101 | - # FIXME this shouldn't be needed | |
| 102 | - include ActionView::Helpers::TagHelper | |
| 103 | - include ActionView::Helpers::UrlHelper | |
| 104 | - include DatesHelper | |
| 101 | + def first_paragraph | |
| 102 | + paragraphs = Nokogiri::HTML.fragment(self.body).css('p') | |
| 103 | + paragraphs.empty? ? '' : paragraphs.first.to_html | |
| 104 | + end | |
| 105 | 105 | |
| 106 | 106 | def to_html(options = {}) |
| 107 | + event = self | |
| 108 | + format = options[:format] | |
| 107 | 109 | |
| 108 | - result = '' | |
| 109 | - html = ::Builder::XmlMarkup.new(:target => result) | |
| 110 | - | |
| 111 | - html.div(:class => 'event-info' ) { | |
| 112 | - html.ul(:class => 'event-data' ) { | |
| 113 | - html.li(:class => 'event-dates' ) { | |
| 114 | - html.span _('When:') | |
| 115 | - html.text! show_period(start_date, end_date) | |
| 116 | - } if start_date.present? || end_date.present? | |
| 117 | - html.li { | |
| 118 | - html.span _('URL:') | |
| 119 | - html.a(self.link || "", 'href' => self.link || "") | |
| 120 | - } if self.link.present? | |
| 121 | - html.li { | |
| 122 | - html.span _('Address:') | |
| 123 | - html.text! self.address || "" | |
| 124 | - } if self.address.present? | |
| 125 | - } | |
| 126 | - | |
| 127 | - # TODO: some good soul, please clean this ugly hack: | |
| 128 | - if self.body | |
| 129 | - html.div('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', :class => 'event-description') | |
| 130 | - end | |
| 131 | - } | |
| 132 | - | |
| 133 | - if self.body | |
| 134 | - if options[:format] == 'short' | |
| 135 | - result.sub!('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', display_short_format(self)) | |
| 136 | - else | |
| 137 | - result.sub!('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', self.body) | |
| 138 | - end | |
| 110 | + proc do | |
| 111 | + render :file => 'content_viewer/event_page', :locals => { :event => event, | |
| 112 | + :format => format } | |
| 139 | 113 | end |
| 140 | - | |
| 141 | - result | |
| 142 | 114 | end |
| 143 | 115 | |
| 144 | 116 | def duration | ... | ... |
| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | +<div class="event-card"> | |
| 2 | + <div class="event-image"> | |
| 3 | + <% if event.image && event.image.thumbnails_processed %> | |
| 4 | + <%= image_tag(event.image.thumbnails.select{|thumb| thumb.thumbnail == "big"}.first.public_filename) %> | |
| 5 | + <% else %> | |
| 6 | + <%= image_tag("/images/icons-app/image-loading-thumb.png") %> | |
| 7 | + <% end %> | |
| 8 | + </div> | |
| 9 | + <div class="about-event"> | |
| 10 | + <% if event.start_date.present? || event.end_date.present? %> | |
| 11 | + <span class="event-date"> | |
| 12 | + <%= show_period(event.start_date, event.end_date) %> | |
| 13 | + </span> | |
| 14 | + <% end %> | |
| 15 | + <% if event.link.present? %> | |
| 16 | + <span class="event-link"> | |
| 17 | + <%= link_to event.link, event.link %> | |
| 18 | + </span> | |
| 19 | + <% end %> | |
| 20 | + <% if event.address.present? %> | |
| 21 | + <span class="event-address"> | |
| 22 | + <span> | |
| 23 | + <%= event.address %> | |
| 24 | + </span> | |
| 25 | + </span> | |
| 26 | + <% end %> | |
| 27 | + </div> | |
| 28 | +</div> | |
| 29 | + | |
| 30 | +<div class="event-body"> | |
| 31 | + <% if format == 'short' %> | |
| 32 | + <%= display_short_format event, :comments_link => false, :read_more_link => false %> | |
| 33 | + <% else %> | |
| 34 | + <div class="event-lead"> | |
| 35 | + <%= event.article_lead %> | |
| 36 | + </div> | |
| 37 | + <div class="event-content"> | |
| 38 | + <%= event.body %> | |
| 39 | + </div> | |
| 40 | + <% end %> | |
| 41 | +</div> | ... | ... |
features/events.feature
| ... | ... | @@ -17,7 +17,7 @@ Feature: events |
| 17 | 17 | Then I should see "November 2009" within ".current-month" |
| 18 | 18 | |
| 19 | 19 | Scenario: go to next month in global agenda |
| 20 | - Given I am on /assets/events?year=2009&month=11 | |
| 20 | + Given I am on /search/events?year=2009&month=11 | |
| 21 | 21 | When I follow "December" |
| 22 | 22 | Then I should see "December 2009" within ".current-month" |
| 23 | 23 | |
| ... | ... | @@ -27,7 +27,7 @@ Feature: events |
| 27 | 27 | Then I should see "September 2009" within ".current-month" |
| 28 | 28 | |
| 29 | 29 | Scenario: go to previous month in global agenda |
| 30 | - Given I am on /assets/events?year=2009&month=11 | |
| 30 | + Given I am on /search/events?year=2009&month=11 | |
| 31 | 31 | When I follow "October" |
| 32 | 32 | Then I should see "October 2009" within ".current-month" |
| 33 | 33 | |
| ... | ... | @@ -43,7 +43,7 @@ Feature: events |
| 43 | 43 | |
| 44 | 44 | Scenario: go to specific day in global agenda |
| 45 | 45 | Given I am on the homepage |
| 46 | - When I am on /assets/events?year=2009&month=11&day=12 | |
| 46 | + When I am on /search/events?year=2009&month=11&day=12 | |
| 47 | 47 | Then I should see "Events for November, 2009" |
| 48 | 48 | |
| 49 | 49 | Scenario: list events for specific day |
| ... | ... | @@ -88,7 +88,7 @@ Feature: events |
| 88 | 88 | And the following events |
| 89 | 89 | | owner | name | start_date | |
| 90 | 90 | | josemanuel | Manuel Birthday | 2009-10-24 | |
| 91 | - When I am on /assets/events?year=2009&month=10&day=24 | |
| 91 | + When I am on /search/events?year=2009&month=10&day=24 | |
| 92 | 92 | Then I should see "Another Conference" |
| 93 | 93 | And I should see "Manuel Birthday" |
| 94 | 94 | |
| ... | ... | @@ -157,9 +157,10 @@ Feature: events |
| 157 | 157 | Then I should not see "New events" link |
| 158 | 158 | |
| 159 | 159 | Scenario: display environment name in global agenda |
| 160 | - When I am on /assets/events | |
| 160 | + When I am on /search/events | |
| 161 | 161 | Then I should see "Colivre.net's Events" |
| 162 | 162 | |
| 163 | + | |
| 163 | 164 | @selenium |
| 164 | 165 | Scenario: published events should be listed in the agenda too |
| 165 | 166 | Given the following community | ... | ... |
public/designs/themes/base/style.css
| ... | ... | @@ -1401,3 +1401,87 @@ table.profile th { |
| 1401 | 1401 | table#recaptcha_table tr:hover td { |
| 1402 | 1402 | background-color: #fff; |
| 1403 | 1403 | } |
| 1404 | + | |
| 1405 | +/* Noosfero Events */ | |
| 1406 | + | |
| 1407 | +.event-card { | |
| 1408 | + float: left; | |
| 1409 | + padding-top: 33px; | |
| 1410 | + width: 494px; | |
| 1411 | + height: 116px; | |
| 1412 | + background-repeat: no-repeat; | |
| 1413 | +} | |
| 1414 | + | |
| 1415 | +.event-image { | |
| 1416 | + position: relative; | |
| 1417 | + float: left; | |
| 1418 | + padding-right: 22px; | |
| 1419 | + width: 130px; | |
| 1420 | + height: 130px; | |
| 1421 | +} | |
| 1422 | + | |
| 1423 | +.about-event { | |
| 1424 | + position: relative; | |
| 1425 | + float: left; | |
| 1426 | + height: 160px; | |
| 1427 | + width: 300px; | |
| 1428 | + max-width: 300px; | |
| 1429 | +} | |
| 1430 | + | |
| 1431 | +.about-event > span { | |
| 1432 | + display: block; | |
| 1433 | + max-width: inherit; | |
| 1434 | + margin-left: 20px; | |
| 1435 | + padding-left: 21px; | |
| 1436 | + line-height: 13px; | |
| 1437 | + margin-right: 11px; | |
| 1438 | +} | |
| 1439 | + | |
| 1440 | +.about-event .event-date { | |
| 1441 | + margin-top: 3px; | |
| 1442 | +} | |
| 1443 | + | |
| 1444 | +.about-event .event-address { | |
| 1445 | + margin-top: 19px; | |
| 1446 | +} | |
| 1447 | + | |
| 1448 | +.about-event .event-address span { | |
| 1449 | + display: block; | |
| 1450 | + margin-left: 0px; | |
| 1451 | + margin-top: 4.4px; | |
| 1452 | + line-height: 14px; | |
| 1453 | +} | |
| 1454 | + | |
| 1455 | +.event-date { | |
| 1456 | + background: url('/images/calendar_date_select/calendar-icon.png') no-repeat left center; | |
| 1457 | + padding: 5px; | |
| 1458 | +} | |
| 1459 | + | |
| 1460 | +.event-link { | |
| 1461 | + background: url('/images/globe-icon.png') no-repeat left center; | |
| 1462 | + margin-top: 18px; | |
| 1463 | +} | |
| 1464 | + | |
| 1465 | +.event-link a { | |
| 1466 | +} | |
| 1467 | + | |
| 1468 | +.event-address { | |
| 1469 | + background: url('/images/icone_pin.png') no-repeat left top; | |
| 1470 | +} | |
| 1471 | + | |
| 1472 | +.event-body { | |
| 1473 | + float: left; | |
| 1474 | +} | |
| 1475 | + | |
| 1476 | +.event-body .event-lead { | |
| 1477 | + margin-left: 2px; | |
| 1478 | + width: 494px; | |
| 1479 | + font-weight: bold; | |
| 1480 | + margin-bottom: -3px; | |
| 1481 | +} | |
| 1482 | + | |
| 1483 | +.event-body .event-content p { | |
| 1484 | + margin-top: 20px; | |
| 1485 | + width: 494px; | |
| 1486 | + padding-left: 2px; | |
| 1487 | +} | ... | ... |
283 Bytes
464 Bytes
51.9 KB
test/unit/event_test.rb
| ... | ... | @@ -109,17 +109,18 @@ class EventTest < ActiveSupport::TestCase |
| 109 | 109 | end |
| 110 | 110 | |
| 111 | 111 | should 'provide nice display format' do |
| 112 | - e = build(Event, :start_date => Date.new(2008,1,1), :end_date => Date.new(2008,1,1), :link => 'http://www.myevent.org', :body => 'my somewhat short description') | |
| 112 | + event = build(Event, :start_date => Date.new(2008,1,1), :end_date => Date.new(2008,1,1), :link => 'http://www.myevent.org', :body => '<p>my somewhat short description</p>') | |
| 113 | + display = instance_eval(&event.to_html) | |
| 113 | 114 | |
| 114 | - assert_tag_in_string e.to_html, :content => Regexp.new("January 1, 2008") | |
| 115 | - assert_tag_in_string e.to_html, :content => 'my somewhat short description' | |
| 116 | - assert_tag_in_string e.to_html, :tag => 'a', :attributes => { :href => 'http://www.myevent.org' }, :content => 'http://www.myevent.org' | |
| 115 | + assert_tag_in_string display, :content => Regexp.new("January 1, 2008") | |
| 116 | + assert_tag_in_string display, :content => Regexp.new('my somewhat short description') | |
| 117 | + assert_tag_in_string display, :content => Regexp.new('http://www.myevent.org') | |
| 117 | 118 | end |
| 118 | 119 | |
| 119 | 120 | should 'not crash when body is blank' do |
| 120 | 121 | e = Event.new |
| 121 | 122 | assert_nil e.body |
| 122 | - assert_no_match(/_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____/, e.to_html) | |
| 123 | + assert_no_match(/_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____/, instance_eval(&e.to_html)) | |
| 123 | 124 | end |
| 124 | 125 | |
| 125 | 126 | should 'add http:// to the link if not already present' do |
| ... | ... | @@ -141,10 +142,19 @@ class EventTest < ActiveSupport::TestCase |
| 141 | 142 | assert_equal '', a.link |
| 142 | 143 | end |
| 143 | 144 | |
| 145 | + should 'get the first paragraph' do | |
| 146 | + profile = create_user('testuser').person | |
| 147 | + event = create(Event, :profile => profile, :name => 'test', | |
| 148 | + :body => '<p>first paragraph </p><p>second paragraph </p>', | |
| 149 | + :link => 'www.colivre.coop.br', :start_date => Date.today) | |
| 150 | + | |
| 151 | + assert_match '<p>first paragraph </p>', event.first_paragraph | |
| 152 | + end | |
| 153 | + | |
| 144 | 154 | should 'not escape HTML in body' do |
| 145 | 155 | a = build(Event, :body => '<p>a paragraph of text</p>', :link => 'www.gnu.org') |
| 146 | 156 | |
| 147 | - assert_match '<p>a paragraph of text</p>', a.to_html | |
| 157 | + assert_match '<p>a paragraph of text</p>', instance_eval(&a.to_html) | |
| 148 | 158 | end |
| 149 | 159 | |
| 150 | 160 | should 'filter HTML in body' do |
| ... | ... | @@ -324,7 +334,7 @@ class EventTest < ActiveSupport::TestCase |
| 324 | 334 | environment = fast_create(Environment) |
| 325 | 335 | environment.languages = nil |
| 326 | 336 | profile = fast_create(Person, :environment_id => environment.id) |
| 327 | - | |
| 337 | + | |
| 328 | 338 | event = Event.new(:profile => profile) |
| 329 | 339 | |
| 330 | 340 | assert !event.translatable? |
| ... | ... | @@ -337,11 +347,11 @@ class EventTest < ActiveSupport::TestCase |
| 337 | 347 | event = fast_create(Event, :profile_id => profile.id) |
| 338 | 348 | |
| 339 | 349 | assert !event.translatable? |
| 340 | - | |
| 350 | + | |
| 341 | 351 | |
| 342 | 352 | environment.languages = ['en','pt','fr'] |
| 343 | 353 | environment.save |
| 344 | - event.reload | |
| 354 | + event.reload | |
| 345 | 355 | assert event.translatable? |
| 346 | 356 | end |
| 347 | 357 | ... | ... |