Commit 3cc3114fa49e919de220374d744a8b9484c6000a
Committed by
Gabriela Navarro
1 parent
4eb04441
Exists in
article_layout_refactoring
Refactoring article content visualization
- Added image label - Added image to article body - Changed some minor positioning Signed-off-by: André Bernardes <andrebsguedes@gmail.com> Signed-off-by: Arthur Del Esposte <arthurmde@gmail.com> Signed-off-by: Fábio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
Showing
14 changed files
with
153 additions
and
22 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -101,6 +101,11 @@ class CmsController < MyProfileController |
101 | 101 | record_coming |
102 | 102 | if request.post? |
103 | 103 | @article.image = nil if params[:remove_image] == 'true' |
104 | + if @article.image.present? && params[:article][:image_builder] && | |
105 | + params[:article][:image_builder][:label] | |
106 | + @article.image.label = params[:article][:image_builder][:label] | |
107 | + @article.image.save! | |
108 | + end | |
104 | 109 | @article.last_changed_by = user |
105 | 110 | if @article.update_attributes(params[:article]) |
106 | 111 | if !continue | ... | ... |
app/helpers/comment_helper.rb
... | ... | @@ -16,7 +16,7 @@ module CommentHelper |
16 | 16 | content_tag('span', show_date(article.published_at), :class => 'date') + |
17 | 17 | content_tag('span', [_(", by %s") % link_to(article.author_name, article.author_url)], :class => 'author') + |
18 | 18 | content_tag('span', comments, :class => 'comments'), |
19 | - :class => 'created-at' | |
19 | + :class => 'publishing-info' | |
20 | 20 | ) |
21 | 21 | end |
22 | 22 | title | ... | ... |
app/helpers/content_viewer_helper.rb
... | ... | @@ -30,7 +30,7 @@ module ContentViewerHelper |
30 | 30 | date_format + |
31 | 31 | content_tag('span', _(", by %s") % (article.author ? link_to(article.author_name, article.author_url) : article.author_name), :class => 'author') + |
32 | 32 | content_tag('span', comments, :class => 'comments'), |
33 | - :class => 'created-at' | |
33 | + :class => 'publishing-info' | |
34 | 34 | ) |
35 | 35 | end |
36 | 36 | title | ... | ... |
app/models/image.rb
... | ... | @@ -0,0 +1,20 @@ |
1 | +<% if @page.belongs_to_blog? || @page.belongs_to_forum?%> | |
2 | + <h1 class="title"> | |
3 | + <% if no_link %> | |
4 | + <%= h(@page.title) %> | |
5 | + <% else %> | |
6 | + <%= link_to(@page.name, @page.url) %> | |
7 | + <% end %> | |
8 | + </h1> | |
9 | + <%= render :partial => "publishing_info" %> | |
10 | + <% unless @page.abstract.blank? %> | |
11 | + <div class="preview"> | |
12 | + <%= @page.lead %> | |
13 | + </div> | |
14 | + <% end %> | |
15 | +<% else %> | |
16 | + <h1 class="title"> | |
17 | + <%= h(@page.title) %> | |
18 | + </h1> | |
19 | + <%= render :partial => "publishing_info" %> | |
20 | +<% end %> | ... | ... |
app/views/content_viewer/_article_toolbar.html.erb
... | ... | @@ -64,7 +64,7 @@ |
64 | 64 | <% end %> |
65 | 65 | <%= link_to(image_tag('/images/icons-mime/rss-feed.png'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %> |
66 | 66 | <%= @plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_exec(&content) }.join("") %> |
67 | - <%= article_title(@page, :no_link => true) %> | |
67 | + <%= render :partial => 'article_title', :locals => {:no_link => true} %> | |
68 | 68 | <%= article_translations(@page) %> |
69 | 69 | </div> |
70 | 70 | </div> | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +<span class="publishing-info"> | |
2 | + <span class="date"> | |
3 | + <%= show_date(@page.published_at) %> | |
4 | + </span> | |
5 | + <span class="author"> | |
6 | + <%= _(", by %s") % (@page.author ? link_to(@page.author_name, @page.author_url) : @page.author_name) %> | |
7 | + </span> | |
8 | +<% unless @no_comments %> | |
9 | + <span class="comments"> | |
10 | + <%= (" - %s") % link_to_comments(@page)%> | |
11 | + </span> | |
12 | +<% end %> | |
13 | +</span> | |
14 | + | |
15 | +<% if @page.display_hits? || @page.license.present? %> | |
16 | + <div id='article-sub-header'> | |
17 | + <% if @page.display_hits? %> | |
18 | + <div id="article-hits"> | |
19 | + <%= n_('Viewed one time', 'Viewed %{num} times', @page.hits) % { :num => @page.hits } %> | |
20 | + </div> | |
21 | + <% end %> | |
22 | + | |
23 | + <% if @page.license.present? %> | |
24 | + <div id="article-license"> | |
25 | + <%= _('Licensed under %s') % (@page.license.url.present? ? link_to(@page.license.name, @page.license.url, :target => '_blank') : @page.license.name) %> | |
26 | + </div> | |
27 | + <% end %> | |
28 | + </div> | |
29 | +<% end %> | ... | ... |
app/views/content_viewer/view_page.html.erb
... | ... | @@ -24,22 +24,6 @@ |
24 | 24 | <%= render :partial => 'article_toolbar' %> |
25 | 25 | </div> |
26 | 26 | |
27 | -<% if @page.display_hits? || @page.license.present? %> | |
28 | - <div id='article-sub-header'> | |
29 | - <% if @page.display_hits? %> | |
30 | - <div id="article-hits"> | |
31 | - <%= n_('Viewed one time', 'Viewed %{num} times', @page.hits) % { :num => @page.hits } %> | |
32 | - </div> | |
33 | - <% end %> | |
34 | - | |
35 | - <% if @page.license.present? %> | |
36 | - <div id="article-license"> | |
37 | - <%= _('Licensed under %s') % (@page.license.url.present? ? link_to(@page.license.name, @page.license.url, :target => '_blank') : @page.license.name) %> | |
38 | - </div> | |
39 | - <% end %> | |
40 | - </div> | |
41 | -<% end %> | |
42 | - | |
43 | 27 | <% if NOOSFERO_CONF['addthis_enabled'] %> |
44 | 28 | <%= render :partial => 'addthis' %> |
45 | 29 | <% end %> |
... | ... | @@ -47,6 +31,12 @@ |
47 | 31 | <% cache(@page.cache_key(params, user, language)) do %> |
48 | 32 | <div class="<%="article-body article-body-" + @page.css_class_name %>"> |
49 | 33 | <% options = @page.image? ? {:gallery_view => true} : {} %> |
34 | + <% if @page.image.present? && @page.class != "Event" %> | |
35 | + <div class="article-body-img"> | |
36 | + <%= image_tag(@page.image.public_filename) %> | |
37 | + <p><%= @page.image.label%></p> | |
38 | + </div> | |
39 | + <% end %> | |
50 | 40 | <%= article_to_html(@page, options) %> |
51 | 41 | <br style="clear:both" /> |
52 | 42 | </div> <!-- end class="article-body" --> | ... | ... |
app/views/shared/_change_image.html.erb
1 | - <%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %> | |
2 | - <%= button_to_function(:cancel,_('Cancel'),"jQuery('#change-image-link').show(); jQuery('#change-image').html('')", :id => 'cancel-change-image-link', :style => 'display: none')%> | |
1 | +<%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %> | |
2 | +<%= labelled_form_field(_("Image Label:"), i.text_field(:label)) %> | |
3 | +<%= button_to_function(:cancel,_('Cancel'),"jQuery('#change-image-link').show(); jQuery('#change-image').html('')", :id => 'cancel-change-image-link', :style => 'display: none')%> | ... | ... |
public/designs/themes/base/style.css
... | ... | @@ -1064,6 +1064,11 @@ hr.pre-posts, hr.sep-posts { |
1064 | 1064 | #content .main-block .created-at { |
1065 | 1065 | text-align: left; |
1066 | 1066 | color: #AAA; |
1067 | + font-size: 11px; | |
1068 | + padding-top: 20px; | |
1069 | + border-top: 1px solid #D7D7D7; | |
1070 | + margin-top: 30px; | |
1071 | + margin-bottom:15px; | |
1067 | 1072 | } |
1068 | 1073 | #content .main-block .created-at a { |
1069 | 1074 | color: #AAA; |
... | ... | @@ -1415,3 +1420,30 @@ table#recaptcha_table tr:hover td { |
1415 | 1420 | color:#333; |
1416 | 1421 | } |
1417 | 1422 | |
1423 | +/************************* Article Page *****************************/ | |
1424 | + | |
1425 | +#article-header .preview { | |
1426 | + font-size: 15px; | |
1427 | +} | |
1428 | + | |
1429 | +.article-body-img { | |
1430 | + float: left; | |
1431 | + margin-right: 20px; | |
1432 | + margin-top: 5px; | |
1433 | +} | |
1434 | + | |
1435 | +#content #article .article-body .article-body-img img { | |
1436 | + height: auto; | |
1437 | + width: auto; | |
1438 | + min-height: 120px; | |
1439 | + max-height: 180px; | |
1440 | + max-width: 250px; | |
1441 | + background-position: center center; | |
1442 | + background-repeat: no-repeat; | |
1443 | +} | |
1444 | + | |
1445 | +#content #article .article-body .article-body-img p { | |
1446 | + margin-bottom: 10px; | |
1447 | + font-size: 10px; | |
1448 | + min-height: 20px; | |
1449 | +} | ... | ... |
public/stylesheets/application.css
test/functional/cms_controller_test.rb
... | ... | @@ -223,6 +223,20 @@ class CmsControllerTest < ActionController::TestCase |
223 | 223 | assert_equal profile, a.last_changed_by |
224 | 224 | end |
225 | 225 | |
226 | + should 'be able to set label to article image' do | |
227 | + login_as(profile.identifier) | |
228 | + post :new, :type => TextileArticle.name, :profile => profile.identifier, | |
229 | + :article => { | |
230 | + :name => 'adding-image-label', | |
231 | + :image_builder => { | |
232 | + :uploaded_data => fixture_file_upload('/files/tux.png', 'image/png'), | |
233 | + :label => 'test-label' | |
234 | + } | |
235 | + } | |
236 | + a = Article.last | |
237 | + assert_equal a.image.label, 'test-label' | |
238 | + end | |
239 | + | |
226 | 240 | should 'edit by using the correct template to display the editor depending on the mime-type' do |
227 | 241 | a = profile.articles.build(:name => 'test document') |
228 | 242 | a.save! |
... | ... | @@ -318,6 +332,20 @@ class CmsControllerTest < ActionController::TestCase |
318 | 332 | end |
319 | 333 | end |
320 | 334 | |
335 | + should 'be able to edit an image label' do | |
336 | + image = fast_create(Image, :content_type => 'image/png', :filename => 'event-image.png', :label => 'test_label', :size => 1014) | |
337 | + article = fast_create(Article, :profile_id => profile.id, :name => 'test_label_article', :body => 'test_content') | |
338 | + article.image = image | |
339 | + article.save | |
340 | + assert_not_nil article | |
341 | + assert_not_nil article.image | |
342 | + assert_equal 'test_label', article.image.label | |
343 | + | |
344 | + post :edit, :profile => profile.identifier, :id => article.id, :article => {:image_builder => { :label => 'test_label_modified'}} | |
345 | + article.reload | |
346 | + assert_equal 'test_label_modified', article.image.label | |
347 | + end | |
348 | + | |
321 | 349 | should 'be able to upload more than one file at once' do |
322 | 350 | assert_difference 'UploadedFile.count', 2 do |
323 | 351 | post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain'), fixture_file_upload('/files/rails.png', 'text/plain')] | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -124,6 +124,19 @@ class ContentViewerControllerTest < ActionController::TestCase |
124 | 124 | assert_tag :tag => 'div', :attributes => { :id => 'article-tags' }, :descendant => { :content => /This article's tags:/ } |
125 | 125 | end |
126 | 126 | |
127 | + should "display image label on article image" do | |
128 | + page = TinyMceArticle.create!( | |
129 | + :profile => profile, | |
130 | + :name => 'myarticle', | |
131 | + :image_builder => { | |
132 | + :uploaded_data => fixture_file_upload('/files/tux.png', 'image/png'), | |
133 | + :label => 'test-label' | |
134 | + } | |
135 | + ) | |
136 | + get :view_page, page.url | |
137 | + assert_match /test-label/, @response.body | |
138 | + end | |
139 | + | |
127 | 140 | should "not display current article's tags" do |
128 | 141 | page = profile.articles.create!(:name => 'myarticle', :body => 'test article') |
129 | 142 | ... | ... |