diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb
index 46edb6e..46e62e0 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/helpers/comment_helper.rb b/app/helpers/comment_helper.rb
index c8e780a..9a471ce 100644
--- a/app/helpers/comment_helper.rb
+++ b/app/helpers/comment_helper.rb
@@ -16,7 +16,7 @@ module CommentHelper
content_tag('span', show_date(article.published_at), :class => 'date') +
content_tag('span', [_(", by %s") % link_to(article.author_name, article.author_url)], :class => 'author') +
content_tag('span', comments, :class => 'comments'),
- :class => 'created-at'
+ :class => 'publishing-info'
)
end
title
diff --git a/app/helpers/content_viewer_helper.rb b/app/helpers/content_viewer_helper.rb
index e51841b..cdeacad 100644
--- a/app/helpers/content_viewer_helper.rb
+++ b/app/helpers/content_viewer_helper.rb
@@ -30,7 +30,7 @@ module ContentViewerHelper
date_format +
content_tag('span', _(", by %s") % (article.author ? link_to(article.author_name, article.author_url) : article.author_name), :class => 'author') +
content_tag('span', comments, :class => 'comments'),
- :class => 'created-at'
+ :class => 'publishing-info'
)
end
title
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..36eaea9
--- /dev/null
+++ b/app/views/content_viewer/_article_title.html.erb
@@ -0,0 +1,20 @@
+<% if @page.belongs_to_blog? || @page.belongs_to_forum?%>
+
+ <% if no_link %>
+ <%= h(@page.title) %>
+ <% else %>
+ <%= link_to(@page.name, @page.url) %>
+ <% end %>
+
+ <%= render :partial => "publishing_info" %>
+ <% unless @page.abstract.blank? %>
+
+ <%= @page.lead %>
+
+ <% end %>
+<% else %>
+
+ <%= h(@page.title) %>
+
+ <%= render :partial => "publishing_info" %>
+<% 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/_publishing_info.html.erb b/app/views/content_viewer/_publishing_info.html.erb
new file mode 100644
index 0000000..a6eef9c
--- /dev/null
+++ b/app/views/content_viewer/_publishing_info.html.erb
@@ -0,0 +1,29 @@
+
+
+ <%= show_date(@page.published_at) %>
+
+
+ <%= _(", by %s") % (@page.author ? link_to(@page.author_name, @page.author_url) : @page.author_name) %>
+
+<% unless @no_comments %>
+
+<% end %>
+
+
+<% if @page.display_hits? || @page.license.present? %>
+
+ <% if @page.display_hits? %>
+
+ <%= n_('Viewed one time', 'Viewed %{num} times', @page.hits) % { :num => @page.hits } %>
+
+ <% end %>
+
+ <% if @page.license.present? %>
+
+ <%= _('Licensed under %s') % (@page.license.url.present? ? link_to(@page.license.name, @page.license.url, :target => '_blank') : @page.license.name) %>
+
+ <% end %>
+
+<% end %>
diff --git a/app/views/content_viewer/view_page.html.erb b/app/views/content_viewer/view_page.html.erb
index 650646e..4dca979 100644
--- a/app/views/content_viewer/view_page.html.erb
+++ b/app/views/content_viewer/view_page.html.erb
@@ -24,22 +24,6 @@
<%= render :partial => 'article_toolbar' %>
-<% if @page.display_hits? || @page.license.present? %>
-
- <% if @page.display_hits? %>
-
- <%= n_('Viewed one time', 'Viewed %{num} times', @page.hits) % { :num => @page.hits } %>
-
- <% end %>
-
- <% if @page.license.present? %>
-
- <%= _('Licensed under %s') % (@page.license.url.present? ? link_to(@page.license.name, @page.license.url, :target => '_blank') : @page.license.name) %>
-
- <% end %>
-
-<% end %>
-
<% if NOOSFERO_CONF['addthis_enabled'] %>
<%= render :partial => 'addthis' %>
<% end %>
@@ -47,6 +31,12 @@
<% cache(@page.cache_key(params, user, language)) do %>
">
<% options = @page.image? ? {:gallery_view => true} : {} %>
+ <% if @page.image.present? && @page.class != "Event" %>
+
+ <%= 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 30d73f9..ca4c896 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;
@@ -1415,3 +1420,30 @@ table#recaptcha_table tr:hover td {
color:#333;
}
+/************************* 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 89d9a67..b5e6fd8 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..c797238 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
+ image = fast_create(Image, :content_type => 'image/png', :filename => 'event-image.png', :label => 'test_label', :size => 1014)
+ article = fast_create(Article, :profile_id => profile.id, :name => 'test_label_article', :body => 'test_content')
+ article.image = image
+ article.save
+ 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 c2031de..3006e97 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