[Git][noosfero/noosfero][master] 5 commits: navigation: Use environment host
Rodrigo Souto
gitlab at mg.gitlab.com
Tue Mar 8 11:19:07 BRT 2016
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
52e81c77 by Braulio Bhavamitra at 2016-03-08T09:19:32-03:00
navigation: Use environment host
For profiles with specific domains registered, the navigation should use
the URL for the environment, which are right the context of the navigation
links
Closes !484
- - - - -
00863a6e by Braulio Bhavamitra at 2016-03-08T09:19:32-03:00
Avoid fetch of profile in link_to_homepage
Closes !467
Signed-off-by: Braulio Bhavamitra <brauliobo at gmail.com>
Signed-off-by: Rodrigo Souto <rodrigo at colivre.coop.br>
- - - - -
320f1f19 by Braulio Bhavamitra at 2016-03-08T09:19:32-03:00
Don't crash with invalid parameters
For example http://cirandas.net/dtygel/blog?month=10&year=2011/wp-login.php
crashes on date parsing
Answering request as if no date arguments were passed.
Closes !419
Signed-off-by: Rodrigo Souto <rodrigo at colivre.coop.br>
Signed-off-by: Braulio Bhavamitra <braulio at eita.org.br>
- - - - -
84208b3a by Eduardo Passos at 2016-03-08T09:19:32-03:00
Add checkbox to open highlights block in a new window
Closes !511
- - - - -
e8f4fd2b by dtygel at 2016-03-08T10:58:47-03:00
Small changes in add media in articles for better comprehension by users
- - - - -
14 changed files:
- app/controllers/public/content_viewer_controller.rb
- app/helpers/application_helper.rb
- app/helpers/block_helper.rb
- app/models/highlights_block.rb
- app/views/account/index.html.erb
- app/views/blocks/highlights.html.erb
- app/views/box_organizer/_highlights_block.html.erb
- app/views/cms/_drag_and_drop_note.html.erb
- app/views/cms/_text_editor_sidebar.html.erb
- app/views/region_validators/region.html.erb
- app/views/search/_full_enterprise.html.erb
- app/views/search/_full_product.html.erb
- plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.html.erb
- test/unit/highlights_block_test.rb
Changes:
=====================================
app/controllers/public/content_viewer_controller.rb
=====================================
--- a/app/controllers/public/content_viewer_controller.rb
+++ b/app/controllers/public/content_viewer_controller.rb
@@ -239,8 +239,12 @@ class ContentViewerController < ApplicationController
def get_posts(year = nil, month = nil)
if year && month
- filter_date = DateTime.parse("#{year}-#{month}-01")
- return @page.posts.by_range(filter_date..filter_date.at_end_of_month)
+ begin
+ filter_date = DateTime.parse("#{year}-#{month}-01")
+ return @page.posts.by_range(filter_date..filter_date.at_end_of_month)
+ rescue ArgumentError
+ return @page.posts
+ end
else
return @page.posts
end
=====================================
app/helpers/application_helper.rb
=====================================
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -148,14 +148,8 @@ module ApplicationHelper
link_to text, profile_path(:profile => profile) , options
end
- def link_to_homepage(text, profile = nil, options = {})
- p = if profile
- Profile[profile]
- else
- user
- end
-
- link_to text, p.url, options
+ def link_to_homepage(text, profile, options = {})
+ link_to text, profile.url, options
end
def link_if_permitted(link, permission = nil, target = nil)
@@ -1049,10 +1043,11 @@ module ApplicationHelper
end
def search_contents_menu
+ host = environment.default_hostname
links = [
- {s_('contents|More recent') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_recent'})}},
- {s_('contents|More viewed') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_popular'})}},
- {s_('contents|Most commented') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_comments'})}}
+ {s_('contents|More recent') => {href: url_for({host: host, controller: 'search', action: 'contents', filter: 'more_recent'})}},
+ {s_('contents|More viewed') => {href: url_for({host: host, controller: 'search', action: 'contents', filter: 'more_popular'})}},
+ {s_('contents|Most commented') => {href: url_for({host: host, controller: 'search', action: 'contents', filter: 'more_comments'})}}
]
if logged_in?
links.push(_('New content') => modal_options({:href => url_for({:controller => 'cms', :action => 'new', :profile => current_user.login, :cms => true})}))
@@ -1064,10 +1059,11 @@ module ApplicationHelper
alias :browse_contents_menu :search_contents_menu
def search_people_menu
+ host = environment.default_hostname
links = [
- {s_('people|More recent') => {:href => url_for({:controller => 'search', :action => 'people', :filter => 'more_recent'})}},
- {s_('people|More active') => {:href => url_for({:controller => 'search', :action => 'people', :filter => 'more_active'})}},
- {s_('people|More popular') => {:href => url_for({:controller => 'search', :action => 'people', :filter => 'more_popular'})}}
+ {s_('people|More recent') => {href: url_for({host: host, controller: 'search', action: 'people', filter: 'more_recent'})}},
+ {s_('people|More active') => {href: url_for({host: host, controller: 'search', action: 'people', filter: 'more_active'})}},
+ {s_('people|More popular') => {href: url_for({host: host, controller: 'search', action: 'people', filter: 'more_popular'})}}
]
if logged_in?
links.push(_('My friends') => {:href => url_for({:profile => current_user.login, :controller => 'friends'})})
@@ -1080,10 +1076,11 @@ module ApplicationHelper
alias :browse_people_menu :search_people_menu
def search_communities_menu
+ host = environment.default_hostname
links = [
- {s_('communities|More recent') => {:href => url_for({:controller => 'search', :action => 'communities', :filter => 'more_recent'})}},
- {s_('communities|More active') => {:href => url_for({:controller => 'search', :action => 'communities', :filter => 'more_active'})}},
- {s_('communities|More popular') => {:href => url_for({:controller => 'search', :action => 'communities', :filter => 'more_popular'})}}
+ {s_('communities|More recent') => {href: url_for({host: host, controller: 'search', action: 'communities', filter: 'more_recent'})}},
+ {s_('communities|More active') => {href: url_for({host: host, controller: 'search', action: 'communities', filter: 'more_active'})}},
+ {s_('communities|More popular') => {href: url_for({host: host, controller: 'search', action: 'communities', filter: 'more_popular'})}}
]
if logged_in?
links.push(_('My communities') => {:href => url_for({:profile => current_user.login, :controller => 'memberships'})})
=====================================
app/helpers/block_helper.rb
=====================================
--- a/app/helpers/block_helper.rb
+++ b/app/helpers/block_helper.rb
@@ -14,6 +14,7 @@ module BlockHelper
</td>
<td>#{text_field_tag 'block[images][][address]', image[:address], :class => 'highlight-address', :size => 20}</td>
<td>#{text_field_tag 'block[images][][position]', image[:position], :class => 'highlight-position', :size => 1}</td>
+ <td>#{check_box_tag 'block[images][][new_window]', '1', image[:new_window], :class => 'highlight-new_window', :size => 1}</td>
</tr><tr class=\"image-title\" data-row-number='#{row_number}'>
<td colspan=\"3\"><label>#{
content_tag('span', _('Title')) +
=====================================
app/models/highlights_block.rb
=====================================
--- a/app/models/highlights_block.rb
+++ b/app/models/highlights_block.rb
@@ -15,6 +15,8 @@ class HighlightsBlock < Block
if !Noosfero.root.nil? and !i[:address].start_with?(Noosfero.root + '/')
i[:address] = Noosfero.root + i[:address]
end
+ i[:new_window] = i[:new_window] == '1' ? true : false
+
begin
file = UploadedFile.find(i[:image_id])
i[:image_src] = file.public_filename
=====================================
app/views/account/index.html.erb
=====================================
--- a/app/views/account/index.html.erb
+++ b/app/views/account/index.html.erb
@@ -11,7 +11,7 @@
</p>
<p>
-<%= link_to_homepage(_('My home page.')) %>
+<%= link_to_homepage(_('My home page.'), user) %>
<%= _('See your homepage.') %>
</p>
=====================================
app/views/blocks/highlights.html.erb
=====================================
--- a/app/views/blocks/highlights.html.erb
+++ b/app/views/blocks/highlights.html.erb
@@ -3,7 +3,7 @@
<div class='highlights-border'>
<div class='highlights-container'>
<% block.featured_images.each do |img| %>
- <a href="<%= img[:address] %>" title="<%= img[:title] %>" class="highlights-image-link">
+ <a href="<%= img[:address] %>" <%= 'target="_blank"' if img[:new_window] %> title="<%= img[:title] %>" class="highlights-image-link">
<%= image_tag [Noosfero.root, img[:image_src]].join, alt: img[:title] %>
<p class="highlights-label"><%= img[:title] %></p>
</a>
=====================================
app/views/box_organizer/_highlights_block.html.erb
=====================================
--- a/app/views/box_organizer/_highlights_block.html.erb
+++ b/app/views/box_organizer/_highlights_block.html.erb
@@ -3,7 +3,7 @@
<strong><%= _('Highlights') %></strong>
<table class="noborder"><tbody id="highlights-data-table">
- <tr><th><%= _('Image') %></th><th><%= _('Address') %></th><th><%= _('Position') %></th></tr>
+ <tr><th><%= _('Image') %></th><th><%= _('Address') %></th><th><%= _('Position') %></th><th><%= _('New Window') %></th></tr>
<% @block.images.each_with_index do |image, index| %>
<%= highlights_block_config_image_fields @block, image, index %>
<% end %>
=====================================
app/views/cms/_drag_and_drop_note.html.erb
=====================================
--- a/app/views/cms/_drag_and_drop_note.html.erb
+++ b/app/views/cms/_drag_and_drop_note.html.erb
@@ -1,6 +1,5 @@
<p>
<em>
- <%= _('Drag images to add them to the text.') %>
- <%= _('Click on file names to add links to the text.') %>
+ <%= _('Drag images to add them to the text or click on file names to add links to the text.') %>
</em>
</p>
=====================================
app/views/cms/_text_editor_sidebar.html.erb
=====================================
--- a/app/views/cms/_text_editor_sidebar.html.erb
+++ b/app/views/cms/_text_editor_sidebar.html.erb
@@ -17,8 +17,8 @@
:parent_id, profile, default_folder, {}, {},
"type='Folder' or type='Gallery'"
) %>
+ <%= button(:newfolder, _('New folder'), '#', :id => 'new-folder-button') %>
</div>
- <%= button(:newfolder, _('New folder'), '#', :id => 'new-folder-button') %>
<p><%= file_field_tag('file', :multiple => true) %></p>
<% end %>
</div>
@@ -31,7 +31,7 @@
<div id='published-media' class='text-editor-sidebar-box' data-url='<%= url_for({:controller => 'cms', :action => 'published_media_items', :profile => profile.identifier}) %>'>
<%= select_profile_folder(nil, :parent_id, profile, 'recent-media', {}, {},
"type='Folder' or type='Gallery'", {:root_label => _('Recent media')}) %>
- <%= labelled_form_field _('Search'), text_field_tag('q') %>
+ <%= labelled_form_field _('Search among your uploaded files'), text_field_tag('q', '', placeholder: _('Write words about the file you are looking for')) %>
<%= render :partial => 'drag_and_drop_note' %>
<div class='items'>
<%= render :partial => 'published_media_items' %>
=====================================
app/views/region_validators/region.html.erb
=====================================
--- a/app/views/region_validators/region.html.erb
+++ b/app/views/region_validators/region.html.erb
@@ -5,7 +5,7 @@
<ul>
<% for validator in @region.validators %>
<li>
- <%= link_to_homepage validator.name, validator.identifier %>
+ <%= link_to_homepage validator.name, validator %>
<%= link_to _('Remove validation rights'), { :action => 'remove', :id => @region.id, :validator_id => validator }, :method => 'post' %>
</li>
<% end %>
=====================================
app/views/search/_full_enterprise.html.erb
=====================================
--- a/app/views/search/_full_enterprise.html.erb
+++ b/app/views/search/_full_enterprise.html.erb
@@ -5,7 +5,7 @@
@order == 'more_recent' ? enterprise.send(@order + '_label') + show_date(enterprise.created_at) : enterprise.send(@order + '_label') %>
</div>
<div class="search-enterprise-item-column-right">
- <%= link_to_homepage(enterprise.name, enterprise.identifier, :class => "search-result-title") %>
+ <%= link_to_homepage enterprise.name, enterprise, class: "search-result-title" %>
<div class="search-enterprise-description">
<% if enterprise.description %>
<% body_stripped = strip_tags(enterprise.description) %>
=====================================
app/views/search/_full_product.html.erb
=====================================
--- a/app/views/search/_full_product.html.erb
+++ b/app/views/search/_full_product.html.erb
@@ -44,7 +44,7 @@
<div class="search-product-item-second-column">
<%= link_to_product product, :class => 'search-result-title' %>
<div class="search-product-supplier">
- <span class="search-field-label"><%= _('Supplier') %> </span><%= link_to_homepage(product.enterprise.name, product.enterprise.identifier) %>
+ <span class="search-field-label"><%= _('Supplier') %> </span><%= link_to_homepage product.enterprise.name, product.enterprise %>
</div>
<div class="search-product-description">
<% if product.description %>
=====================================
plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.html.erb
=====================================
--- a/plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.html.erb
+++ b/plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.html.erb
@@ -10,7 +10,7 @@
<%= profile_image_link organization, :big, 'div' %>
</div>
<div class="related-organizations-item-column-right">
- <%= link_to_homepage(organization.name, organization.identifier, :class => "search-result-title") %>
+ <%= link_to_homepage(organization.name, organization, :class => "search-result-title") %>
<div class="related-organizations-description">
<% if organization.description %>
<% body_stripped = strip_tags(organization.description) %>
=====================================
test/unit/highlights_block_test.rb
=====================================
--- a/test/unit/highlights_block_test.rb
+++ b/test/unit/highlights_block_test.rb
@@ -54,7 +54,19 @@ class HighlightsBlockTest < ActiveSupport::TestCase
should 'remove images with blank fields' do
h = HighlightsBlock.new(:images => [{:image_id => 1, :address => '/address', :position => 1, :title => 'address'}, {:image_id => '', :address => '', :position => '', :title => ''}])
h.save!
- assert_equal [{:image_id => 1, :address => '/address', :position => 1, :title => 'address', :image_src => nil}], h.images
+ assert_equal [{:image_id => 1, :address => '/address', :position => 1, :title => 'address', :new_window => false, :image_src => nil}], h.images
+ end
+
+ should 'replace 1 and 0 by true and false in new_window attribute' do
+ image1 = {:image_id => 1, :address => '/address-1', :position => 1, :title => 'address-1', :new_window => '0'}
+ image2 = {:image_id => 2, :address => '/address-2', :position => 2, :title => 'address-2', :new_window => '1'}
+ h = HighlightsBlock.new(:images => [image1, image2])
+ h.save!
+ image1[:new_window] = false
+ image1[:image_src] = nil
+ image2[:new_window] = true
+ image2[:image_src] = nil
+ assert_equivalent [image1, image2], h.images
end
should 'be able to update display setting' do
@@ -84,7 +96,7 @@ class HighlightsBlockTest < ActiveSupport::TestCase
block.save!
block.reload
assert_equal 2, block.images.count
- assert_equal [{:image_id => 1, :address => '/address', :position => 1, :title => 'address', :image_src => 'address'}], block.featured_images
+ assert_equal [{:image_id => 1, :address => '/address', :position => 1, :title => 'address', :new_window => false, :image_src => 'address'}], block.featured_images
end
should 'list images in order' do
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/95cc44e0e00a6fd77f3f8c1e3c919c7256491d4b...e8f4fd2b75a6ad182c74eb9d9cd80eb74f8d895f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160308/7dffdb8a/attachment-0001.html>
More information about the Noosfero-dev
mailing list