diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 3559cd5..44d968b 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -101,6 +101,11 @@ class CmsController < MyProfileController record_coming if request.post? @article.image = nil if params[:remove_image] == 'true' + if @article.image.present? && params[:article][:image_builder] && + params[:article][:image_builder][:label] + @article.image.label = params[:article][:image_builder][:label] + @article.image.save! + end @article.last_changed_by = user if @article.update_attributes(params[:article]) if !continue diff --git a/app/models/image.rb b/app/models/image.rb index 2cf4ecd..5a78449 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -23,7 +23,7 @@ class Image < ActiveRecord::Base postgresql_attachment_fu - attr_accessible :uploaded_data + attr_accessible :uploaded_data, :label def current_data File.file?(full_filename) ? File.read(full_filename) : nil diff --git a/app/views/content_viewer/_article_title.html.erb b/app/views/content_viewer/_article_title.html.erb new file mode 100644 index 0000000..7ab4502 --- /dev/null +++ b/app/views/content_viewer/_article_title.html.erb @@ -0,0 +1,33 @@ +<% if @page.belongs_to_blog? || @page.belongs_to_forum?%> + <% unless no_link %> +

+ <%= link_to(article.name, article.url) %> +

+ <% else %> +

+ <%= h(@page.title) %> +

+ <% end %> + <% unless @page.lead.blank? %> +
+ <%= @page.lead %> +
+ <% end %> + + + <%= show_date(@page.published_at) %> + + + <%= _(", by %s") % (@page.author ? link_to(@page.author_name, @page.author_url) : @page.author_name) %> + + <% unless @no_comments %> + + <%= (" - %s") % link_to_comments(@page)%> + + <% end %> + +<% else %> +

+ <%= h(@page.title) %> +

+<% end %> diff --git a/app/views/content_viewer/_article_toolbar.html.erb b/app/views/content_viewer/_article_toolbar.html.erb index 8ea706e..2dbc1ee 100644 --- a/app/views/content_viewer/_article_toolbar.html.erb +++ b/app/views/content_viewer/_article_toolbar.html.erb @@ -64,7 +64,7 @@ <% end %> <%= link_to(image_tag('/images/icons-mime/rss-feed.png'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %> <%= @plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_exec(&content) }.join("") %> - <%= article_title(@page, :no_link => true) %> + <%= render :partial => 'article_title', :locals => {:no_link => true} %> <%= article_translations(@page) %> diff --git a/app/views/content_viewer/view_page.html.erb b/app/views/content_viewer/view_page.html.erb index 650646e..a5f0ba5 100644 --- a/app/views/content_viewer/view_page.html.erb +++ b/app/views/content_viewer/view_page.html.erb @@ -47,6 +47,12 @@ <% cache(@page.cache_key(params, user, language)) do %>
"> <% options = @page.image? ? {:gallery_view => true} : {} %> + <% if @page.image.present? %> +
+ <%= image_tag(@page.image.public_filename) %> +

<%= @page.image.label%>

+
+ <% end %> <%= article_to_html(@page, options) %>
diff --git a/app/views/shared/_change_image.html.erb b/app/views/shared/_change_image.html.erb index 9ac685d..07dd742 100644 --- a/app/views/shared/_change_image.html.erb +++ b/app/views/shared/_change_image.html.erb @@ -1,2 +1,3 @@ - <%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %> - <%= button_to_function(:cancel,_('Cancel'),"jQuery('#change-image-link').show(); jQuery('#change-image').html('')", :id => 'cancel-change-image-link', :style => 'display: none')%> +<%= i.file_field( :uploaded_data, { :onchange => 'updateImg(this.value)' } ) %> +<%= labelled_form_field(_("Image Label:"), i.text_field(:label)) %> +<%= button_to_function(:cancel,_('Cancel'),"jQuery('#change-image-link').show(); jQuery('#change-image').html('')", :id => 'cancel-change-image-link', :style => 'display: none')%> diff --git a/db/migrate/20150603182105_add_label_to_image.rb b/db/migrate/20150603182105_add_label_to_image.rb new file mode 100644 index 0000000..7c9f159 --- /dev/null +++ b/db/migrate/20150603182105_add_label_to_image.rb @@ -0,0 +1,8 @@ +class AddLabelToImage < ActiveRecord::Migration + def up + add_column :images, :label, :string, :default => "" + end + def down + remove_column :images, :label + end +end diff --git a/public/designs/themes/base/style.css b/public/designs/themes/base/style.css index b737daf..6c0b7fb 100644 --- a/public/designs/themes/base/style.css +++ b/public/designs/themes/base/style.css @@ -1064,6 +1064,11 @@ hr.pre-posts, hr.sep-posts { #content .main-block .created-at { text-align: left; color: #AAA; + font-size: 11px; + padding-top: 20px; + border-top: 1px solid #D7D7D7; + margin-top: 30px; + margin-bottom:15px; } #content .main-block .created-at a { color: #AAA; @@ -1401,3 +1406,31 @@ table.profile th { table#recaptcha_table tr:hover td { background-color: #fff; } + +/************************* Article Page *****************************/ + +#article-header .preview { + font-size: 15px; +} + +.article-body-img { + float: left; + margin-right: 20px; + margin-top: 5px; +} + +#content #article .article-body .article-body-img img { + height: auto; + width: auto; + min-height: 120px; + max-height: 180px; + max-width: 250px; + background-position: center center; + background-repeat: no-repeat; +} + +#content #article .article-body .article-body-img p { + margin-bottom: 10px; + font-size: 10px; + min-height: 20px; +} diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index ad00fbf..13eacb7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1052,6 +1052,11 @@ code input { margin-top: 10px; display: none; } + +#change-image { + display: table-caption; +} + .zoomable-image { position: relative; display: inline-block; diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 11d1ed7..3c802ce 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -223,6 +223,20 @@ class CmsControllerTest < ActionController::TestCase assert_equal profile, a.last_changed_by end + should 'be able to set label to article image' do + login_as(profile.identifier) + post :new, :type => TextileArticle.name, :profile => profile.identifier, + :article => { + :name => 'adding-image-label', + :image_builder => { + :uploaded_data => fixture_file_upload('/files/tux.png', 'image/png'), + :label => 'test-label' + } + } + a = Article.last + assert_equal a.image.label, 'test-label' + end + should 'edit by using the correct template to display the editor depending on the mime-type' do a = profile.articles.build(:name => 'test document') a.save! @@ -318,6 +332,20 @@ class CmsControllerTest < ActionController::TestCase end end + should 'be able to edit an image label' do + assert_difference 'TinyMceArticle.count' do + 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'}} + end + article = profile.articles.find_by_name('test_label_article') + assert_not_nil article + assert_not_nil article.image + assert_equal 'test_label', article.image.label + + post :edit, :profile => profile.identifier, :id => article.id, :article => {:image_builder => { :label => 'test_label_modified'}} + article.reload + assert_equal 'test_label_modified', article.image.label + end + should 'be able to upload more than one file at once' do assert_difference 'UploadedFile.count', 2 do post :upload_files, :profile => profile.identifier, :uploaded_files => [fixture_file_upload('/files/test.txt', 'text/plain'), fixture_file_upload('/files/rails.png', 'text/plain')] diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 6a449e0..1192f6d 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -124,6 +124,19 @@ class ContentViewerControllerTest < ActionController::TestCase assert_tag :tag => 'div', :attributes => { :id => 'article-tags' }, :descendant => { :content => /This article's tags:/ } end + should "display image label on article image" do + page = TinyMceArticle.create!( + :profile => profile, + :name => 'myarticle', + :image_builder => { + :uploaded_data => fixture_file_upload('/files/tux.png', 'image/png'), + :label => 'test-label' + } + ) + get :view_page, page.url + assert_match /test-label/, @response.body + end + should "not display current article's tags" do page = profile.articles.create!(:name => 'myarticle', :body => 'test article') -- libgit2 0.21.2