Commit 685e99136b15e2d7e5a2d90267f80a80a8d8b373
1 parent
ff4e90f8
Exists in
master
and in
23 other branches
Displaying image title at <title> tag
ActionItem1416 (fixed live at Noosfero fisl11 talk)
Showing
6 changed files
with
26 additions
and
3 deletions
Show diff stats
app/helpers/application_helper.rb
| @@ -901,7 +901,7 @@ module ApplicationHelper | @@ -901,7 +901,7 @@ module ApplicationHelper | ||
| 901 | end | 901 | end |
| 902 | 902 | ||
| 903 | def page_title | 903 | def page_title |
| 904 | - (@page ? @page.name + ' - ' : '') + | 904 | + (@page ? @page.title + ' - ' : '') + |
| 905 | (profile ? profile.short_name + ' - ' : '') + | 905 | (profile ? profile.short_name + ' - ' : '') + |
| 906 | (@topic ? @topic.title + ' - ' : '') + | 906 | (@topic ? @topic.title + ' - ' : '') + |
| 907 | (@section ? @section.title + ' - ' : '') + | 907 | (@section ? @section.title + ' - ' : '') + |
app/helpers/content_viewer_helper.rb
| @@ -30,7 +30,7 @@ module ContentViewerHelper | @@ -30,7 +30,7 @@ module ContentViewerHelper | ||
| 30 | end | 30 | end |
| 31 | 31 | ||
| 32 | def image_label(image) | 32 | def image_label(image) |
| 33 | - text = image.title || image.abstract | 33 | + text = image.abstract || image.title |
| 34 | text && (text.first(40) + (text.size > 40 ? '…' : '')) | 34 | text && (text.first(40) + (text.size > 40 ? '…' : '')) |
| 35 | end | 35 | end |
| 36 | 36 |
app/models/uploaded_file.rb
| @@ -5,6 +5,11 @@ | @@ -5,6 +5,11 @@ | ||
| 5 | class UploadedFile < Article | 5 | class UploadedFile < Article |
| 6 | 6 | ||
| 7 | settings_items :title, :type => 'string' | 7 | settings_items :title, :type => 'string' |
| 8 | + def title_with_default | ||
| 9 | + title_without_default || name | ||
| 10 | + end | ||
| 11 | + alias_method_chain :title, :default | ||
| 12 | + | ||
| 8 | validates_size_of :title, :maximum => 60, :if => (lambda { |file| !file.title.blank? }) | 13 | validates_size_of :title, :maximum => 60, :if => (lambda { |file| !file.title.blank? }) |
| 9 | 14 | ||
| 10 | def display_title | 15 | def display_title |
features/gallery_navigation.feature
| @@ -63,3 +63,12 @@ Feature: gallery_navigation | @@ -63,3 +63,12 @@ Feature: gallery_navigation | ||
| 63 | Then I should see "Go back to my-gallery" | 63 | Then I should see "Go back to my-gallery" |
| 64 | When I follow "Go back to my-gallery" | 64 | When I follow "Go back to my-gallery" |
| 65 | Then I should be on /marciopunk/my-gallery | 65 | Then I should be on /marciopunk/my-gallery |
| 66 | + | ||
| 67 | + Scenario: image title in window title | ||
| 68 | + Given I am logged in as "marciopunk" | ||
| 69 | + And I go to /marciopunk/my-gallery/rails.png?view=true | ||
| 70 | + When I follow "Edit" | ||
| 71 | + And I fill in "Title" with "Rails is cool" | ||
| 72 | + And I press "Save" | ||
| 73 | + And I go to /marciopunk/my-gallery/rails.png?view=true | ||
| 74 | + And The page title should contain "Rails is cool" |
features/step_definitions/noosfero_steps.rb
| @@ -202,4 +202,6 @@ Given /^(.+) is disabled$/ do |enterprise_name| | @@ -202,4 +202,6 @@ Given /^(.+) is disabled$/ do |enterprise_name| | ||
| 202 | enterprise.save | 202 | enterprise.save |
| 203 | end | 203 | end |
| 204 | 204 | ||
| 205 | - | 205 | +Then /^The page title should contain "(.*)"$/ do |text| |
| 206 | + response.should have_selector("title:contains('#{text}')") | ||
| 207 | +end |
test/unit/uploaded_file_test.rb
| @@ -143,4 +143,11 @@ class UploadedFileTest < Test::Unit::TestCase | @@ -143,4 +143,11 @@ class UploadedFileTest < Test::Unit::TestCase | ||
| 143 | assert_equal 'test.txt', upload.display_title | 143 | assert_equal 'test.txt', upload.display_title |
| 144 | end | 144 | end |
| 145 | 145 | ||
| 146 | + should 'use name as title by default' do | ||
| 147 | + upload = UploadedFile.new | ||
| 148 | + upload.stubs(:name).returns('test.txt') | ||
| 149 | + | ||
| 150 | + assert_equal 'test.txt', upload.title | ||
| 151 | + end | ||
| 152 | + | ||
| 146 | end | 153 | end |