Commit 1c7787cfb0a6d7750ab86d5e85d1fca618be7c6b
Committed by
Gabriela Navarro
1 parent
208ec37b
Exists in
article_layout_temp
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
11 changed files
with
136 additions
and
4 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/models/image.rb
| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | +<% if @page.belongs_to_blog? || @page.belongs_to_forum?%> | |
| 2 | + <% unless no_link %> | |
| 3 | + <h1 class="title"> | |
| 4 | + <%= link_to(article.name, article.url) %> | |
| 5 | + </h1> | |
| 6 | + <% else %> | |
| 7 | + <h1 class="title"> | |
| 8 | + <%= h(@page.title) %> | |
| 9 | + </h1> | |
| 10 | + <% end %> | |
| 11 | + <% unless @page.lead.blank? %> | |
| 12 | + <div class="preview"> | |
| 13 | + <%= @page.lead %> | |
| 14 | + </div> | |
| 15 | + <% end %> | |
| 16 | + <span class="created-at"> | |
| 17 | + <span class="date"> | |
| 18 | + <%= show_date(@page.published_at) %> | |
| 19 | + </span> | |
| 20 | + <span class="author"> | |
| 21 | + <%= _(", by %s") % (@page.author ? link_to(@page.author_name, @page.author_url) : @page.author_name) %> | |
| 22 | + </span> | |
| 23 | + <% unless @no_comments %> | |
| 24 | + <span class="comments"> | |
| 25 | + <%= (" - %s") % link_to_comments(@page)%> | |
| 26 | + </span> | |
| 27 | + <% end %> | |
| 28 | + </span> | |
| 29 | +<% else %> | |
| 30 | + <h1 class="title"> | |
| 31 | + <%= h(@page.title) %> | |
| 32 | + </h1> | |
| 33 | +<% 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> | ... | ... |
app/views/content_viewer/view_page.html.erb
| ... | ... | @@ -47,6 +47,12 @@ |
| 47 | 47 | <% cache(@page.cache_key(params, user, language)) do %> |
| 48 | 48 | <div class="<%="article-body article-body-" + @page.css_class_name %>"> |
| 49 | 49 | <% options = @page.image? ? {:gallery_view => true} : {} %> |
| 50 | + <% if @page.image.present? && @page.class != "Event" %> | |
| 51 | + <div class="article-body-img"> | |
| 52 | + <%= image_tag(@page.image.public_filename) %> | |
| 53 | + <p><%= @page.image.label%></p> | |
| 54 | + </div> | |
| 55 | + <% end %> | |
| 50 | 56 | <%= article_to_html(@page, options) %> |
| 51 | 57 | <br style="clear:both" /> |
| 52 | 58 | </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; |
| ... | ... | @@ -1401,3 +1406,31 @@ table.profile th { |
| 1401 | 1406 | table#recaptcha_table tr:hover td { |
| 1402 | 1407 | background-color: #fff; |
| 1403 | 1408 | } |
| 1409 | + | |
| 1410 | +/************************* Article Page *****************************/ | |
| 1411 | + | |
| 1412 | +#article-header .preview { | |
| 1413 | + font-size: 15px; | |
| 1414 | +} | |
| 1415 | + | |
| 1416 | +.article-body-img { | |
| 1417 | + float: left; | |
| 1418 | + margin-right: 20px; | |
| 1419 | + margin-top: 5px; | |
| 1420 | +} | |
| 1421 | + | |
| 1422 | +#content #article .article-body .article-body-img img { | |
| 1423 | + height: auto; | |
| 1424 | + width: auto; | |
| 1425 | + min-height: 120px; | |
| 1426 | + max-height: 180px; | |
| 1427 | + max-width: 250px; | |
| 1428 | + background-position: center center; | |
| 1429 | + background-repeat: no-repeat; | |
| 1430 | +} | |
| 1431 | + | |
| 1432 | +#content #article .article-body .article-body-img p { | |
| 1433 | + margin-bottom: 10px; | |
| 1434 | + font-size: 10px; | |
| 1435 | + min-height: 20px; | |
| 1436 | +} | ... | ... |
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 | + assert_difference 'TinyMceArticle.count' do | |
| 337 | + post :new, :type => 'TinyMceArticle', :profile => profile.identifier, :article => { :name => 'test_label_article', :body => 'test_content', :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :label => 'test_label'}} | |
| 338 | + end | |
| 339 | + article = profile.articles.find_by_name('test_label_article') | |
| 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 | ... | ... |