diff --git a/app/controllers/admin/edit_template_controller.rb b/app/controllers/admin/edit_template_controller.rb index 8f21b21..bcb5f6d 100644 --- a/app/controllers/admin/edit_template_controller.rb +++ b/app/controllers/admin/edit_template_controller.rb @@ -2,11 +2,9 @@ class EditTemplateController < AdminController design_editor :holder => 'environment', :autosave => true, :block_types => :block_types - #FIXME This is wrong - #See the FavoriteLinksController considerations and choose the better way def block_types %w[ - FavoriteLinks + FavoriteLinksProfile ] end diff --git a/app/controllers/application.rb b/app/controllers/application.rb index acb4730..f71ff90 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -51,6 +51,8 @@ class ApplicationController < ActionController::Base def load_profile @profile = Profile.find_by_identifier(params[:profile]) unless @profile +#raise "bli %s" % @profile.inspect +# @profile = Profile.find_by_identifier(params[:profile]) unless @profile render_not_found unless @profile end diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 53ff0ee..d7d6916 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -4,14 +4,12 @@ class ProfileEditorController < MyProfileController helper :profile - - - design_editor :holder => 'profile', :autosave => true, :block_types => :block_types + design_editor :holder => 'profile',:autosave => true, :block_types => :block_types def block_types %w[ - FavouriteLinks + FavoriteLinksProfile ] end diff --git a/app/design_blocks/favorite_links_profile/controllers/favorite_links_profile_controller.rb b/app/design_blocks/favorite_links_profile/controllers/favorite_links_profile_controller.rb new file mode 100644 index 0000000..caf31a6 --- /dev/null +++ b/app/design_blocks/favorite_links_profile/controllers/favorite_links_profile_controller.rb @@ -0,0 +1,7 @@ +class FavoriteLinksProfileController < FavoriteLinksController + + needs_profile + + acts_as_design_block + +end diff --git a/app/design_blocks/favorite_links_profile/models/favorite_links_profile.rb b/app/design_blocks/favorite_links_profile/models/favorite_links_profile.rb new file mode 100644 index 0000000..c30bef1 --- /dev/null +++ b/app/design_blocks/favorite_links_profile/models/favorite_links_profile.rb @@ -0,0 +1,7 @@ +class FavoriteLinksProfile < FavoriteLinks + + def self.description + _('Favorite Links') + end + +end diff --git a/app/design_blocks/favourite_links/controllers/favourite_links_controller.rb b/app/design_blocks/favourite_links/controllers/favourite_links_controller.rb deleted file mode 100644 index ed15add..0000000 --- a/app/design_blocks/favourite_links/controllers/favourite_links_controller.rb +++ /dev/null @@ -1,73 +0,0 @@ -class FavouriteLinksController < ApplicationController - - - # The methods above are specific for noosfero application. I think - # this it not the correct way to get this method. - # - # We can create a method in the app/controllers/profile_admin folder - # the inherit this method and adds only the two lines above. - # - # With this way we can reuse this block on many others case and each case - # we follow the same way. - # - # Specific for app - needs_profile - design :holder => 'profile' - # End specific for app - - - acts_as_design_block - - CONTROL_ACTION_OPTIONS = { - 'manage_links' => _('Manage Links'), - 'edit' => _('Edit'), - } - - def index - get_favourite_links - design_render - end - - def edit - design_render_on_edit - end - - def save - if @design_block.update_attributes(params[:design_block]) - get_favourite_links - design_render_on_edit :action => 'manage_links' - else - design_render_on_edit :nothing => true - end - end - - def manage_links - get_favourite_links - design_render_on_edit - end - - def add_link - design_render_on_edit - end - - def remove_link - @design_block.delete_link(params[:link]) - get_favourite_links - design_render_on_edit :action => 'manage_links' - end - - def get_favourite_links - favourite_links = @design_block.favourite_links - @favourite_links_pages, @favourite_links = paginate_by_collection favourite_links - end - - def paginate_by_collection(collection, options = {}) - page = params[:page].blank? ? 1 : params[:page].to_i - items_per_page = @design_block.limit_number - offset = (page - 1) * items_per_page - link_pages = Paginator.new(self, collection.size, items_per_page, page) - collection = collection[offset..(offset + items_per_page - 1)] - return link_pages, collection - end - -end diff --git a/app/design_blocks/favourite_links/models/favourite_links.rb b/app/design_blocks/favourite_links/models/favourite_links.rb deleted file mode 100644 index c277b38..0000000 --- a/app/design_blocks/favourite_links/models/favourite_links.rb +++ /dev/null @@ -1,37 +0,0 @@ -class FavouriteLinks < Design::Block - - def self.description - _('Favourite Links') - end - - def limit_number= value - self.settings[:limit_number] = value.to_i - end - - def limit_number - self.settings[:limit_number] || 5 - end - - def favourite_links_limited - self.favourite_links.first(self.limit_number) - end - - def favourite_links - self.settings[:favourite_links] ||= [] - end - - def delete_link link - self.settings[:favourite_links].reject!{ |item| item == link } - self.save - end - - def favourite_link - nil - end - - def favourite_link= link - self.favourite_links.push(link) - self.favourite_links.uniq! - end - -end diff --git a/app/design_blocks/favourite_links/views/add_link.rhtml b/app/design_blocks/favourite_links/views/add_link.rhtml deleted file mode 100644 index c1f62a0..0000000 --- a/app/design_blocks/favourite_links/views/add_link.rhtml +++ /dev/null @@ -1,13 +0,0 @@ -

<%= _('Editing Favourite Links') %>

- -<% design_form_remote_tag( :url => {:action => 'save'}) do %> - -

- - <%= text_field 'design_block', 'favourite_link'%> -

- - <%= submit_tag _('Save') %> - -<% end %> - diff --git a/app/design_blocks/favourite_links/views/edit.rhtml b/app/design_blocks/favourite_links/views/edit.rhtml deleted file mode 100644 index 7568086..0000000 --- a/app/design_blocks/favourite_links/views/edit.rhtml +++ /dev/null @@ -1,29 +0,0 @@ - -

<%= _('Editing Favourite Links') %>

- - <% design_form_remote_tag( :url => {:action => 'save'}) do %> - -

- - <%= text_field 'design_block', 'title'%> -

- -

- - <%= check_box 'design_block', 'display_header', {}, 'true', 'false' %> -

- -

- - <%= check_box 'design_block', 'display_title', {}, 'true', 'false' %> -

- -

- - <%= text_field 'design_block', 'limit_number'%> -

- - <%= submit_tag _('Save') %> - -<% end %> - diff --git a/app/design_blocks/favourite_links/views/index.rhtml b/app/design_blocks/favourite_links/views/index.rhtml deleted file mode 100644 index cf003c5..0000000 --- a/app/design_blocks/favourite_links/views/index.rhtml +++ /dev/null @@ -1,16 +0,0 @@ - -<% if @favourite_links_pages.current.previous%> - <%= design_link_to_remote(_('Previous'), :url => {:action => 'index', :page => @favourite_links_pages.current.previous}) %> -<% end %> -<% if @favourite_links_pages.current.next %> - <%= design_link_to_remote(_('Next'), :url => {:action => 'index', :page => @favourite_links_pages.current.next}) %> -<% end %> - -<% @favourite_links.each do |link| %> - -<% end %> - diff --git a/app/design_blocks/favourite_links/views/manage_links.rhtml b/app/design_blocks/favourite_links/views/manage_links.rhtml deleted file mode 100644 index a5e2a22..0000000 --- a/app/design_blocks/favourite_links/views/manage_links.rhtml +++ /dev/null @@ -1,21 +0,0 @@ - -

- <%= _('Favourite Links') %> - <%= design_link_to_remote(_('Add Link'), :url => {:action => 'add_link'} )%> - -

-<% if @favourite_links_pages.current.previous%> - <%= design_link_to_remote(_('Previous'), :url => {:action => 'manage_links', :page => @favourite_links_pages.current.previous}) %> -<% end %> -<% if @favourite_links_pages.current.next %> - <%= design_link_to_remote(_('Next'), :url => {:action => 'manage_links', :page => @favourite_links_pages.current.next}) %> -<% end %> - -<% @favourite_links.each do |link| %> - -<% end %> diff --git a/config/routes.rb b/config/routes.rb index f049905..9bfc37d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,7 +37,9 @@ ActionController::Routing::Routes.draw do |map| map.category 'cat/*path', :controller => 'category', :action => 'view' ## controllers for blocks - map.controllers 'block/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_from_design_blocks + # FIXME this path didn't works Leandro comments this line and the reference to the controller path on + # /lib/noosfero.rg file. + #map.controllers 'block/:controller/:action/:id', :controller => Noosfero.pattern_for_controllers_from_design_blocks ###################################################### ## Controllers that are profile-specific (for profile admins ) diff --git a/lib/noosfero.rb b/lib/noosfero.rb index 34b6719..5f5232d 100644 --- a/lib/noosfero.rb +++ b/lib/noosfero.rb @@ -9,18 +9,21 @@ module Noosfero Regexp.new(pattern) end - def self.pattern_for_controllers_from_design_blocks - items = Dir.glob(File.join(RAILS_ROOT, 'app', 'design_blocks', '*', 'controllers', '*_controller.rb')).map do |item| - item.gsub(/^.*\/([^\/]+)_controller.rb$/, '\1') - end.join('|') - Regexp.new(items.blank? ? '' : ('(' + items + ')')) - end +# FIXME This path is not working. I put a line deteach on the 'controllers_in_directory' method to meka the blocks +# works +# def self.pattern_for_controllers_from_design_blocks +# items = Dir.glob(File.join(RAILS_ROOT, 'app', 'design_blocks', '*', 'controllers', '*_controller.rb')).map do |item| +# item.gsub(/^.*\/([^\/]+)_controller.rb$/, '\1') +# end.join('|') +# Regexp.new(items.blank? ? '' : ('(' + items + ')')) +# end private def self.controllers_in_directory(dir) app_controller_path = Dir.glob(File.join(RAILS_ROOT, 'app', 'controllers', dir, '*_controller.rb')) - app_controller_path.map do |item| + items = Dir.glob(File.join(RAILS_ROOT, 'app', 'design_blocks', '*', 'controllers', '*_controller.rb')) # FIXME line added to blocks works + (app_controller_path + items).map do |item| item.gsub(/^.*\/([^\/]+)_controller.rb$/, '\1') end end diff --git a/public/designs/templates/default/stylesheets/style.css b/public/designs/templates/default/stylesheets/style.css index 906e188..7fce759 100644 --- a/public/designs/templates/default/stylesheets/style.css +++ b/public/designs/templates/default/stylesheets/style.css @@ -36,24 +36,24 @@ body { height: 145px; } -#boxes { +#design_boxes { position: relative; margin-left: 10px; margin-right: 10px; padding: 0em; } -#box_3 { +#design_box_3 { width: 210px; float: right; } -#box_2 { +#design_box_2 { float: left; width: 280px; } -#box_1 { +#design_box_1 { margin-left: 285px; margin-right: 215px; } diff --git a/public/designs/templates/leftbar/stylesheets/style.css b/public/designs/templates/leftbar/stylesheets/style.css index 532fabb..a6a4717 100644 --- a/public/designs/templates/leftbar/stylesheets/style.css +++ b/public/designs/templates/leftbar/stylesheets/style.css @@ -18,7 +18,7 @@ background: url("../images/bg_header.png") top center no-repeat; height: 135px; } -#boxes { +#design_boxes { position: relative; width: 780px; left: 50%; @@ -26,12 +26,12 @@ margin-left: -390px; padding-top: 1em; } -#box_2 { +#design_box_2 { float: left; width: 200px; } -#box_1 { +#design_box_1 { margin-left: 205px; } diff --git a/public/designs/templates/onecolumn/stylesheets/style.css b/public/designs/templates/onecolumn/stylesheets/style.css index e1d9e9b..8c33003 100644 --- a/public/designs/templates/onecolumn/stylesheets/style.css +++ b/public/designs/templates/onecolumn/stylesheets/style.css @@ -14,14 +14,14 @@ background: url("../images/bg_bgheader.png") top left repeat-x; height: 55px; } -#boxes { +#design_boxes { position: relative; width: auto; margin: 20px; padding: 10px; } -#box_1 { +#design_box_1 { } #spinner { diff --git a/public/designs/templates/rightcolumn/stylesheets/editor.css b/public/designs/templates/rightcolumn/stylesheets/editor.css index 02e2f9f..a6cd548 100644 --- a/public/designs/templates/rightcolumn/stylesheets/editor.css +++ b/public/designs/templates/rightcolumn/stylesheets/editor.css @@ -40,7 +40,7 @@ border: 1px inset #545454; border: 2px dotted #545454; } -#design_editor .box { +#design_editor .design_box { border: 2px solid transparent; } diff --git a/public/designs/templates/rightcolumn/stylesheets/style.css b/public/designs/templates/rightcolumn/stylesheets/style.css index df2fd65..290c932 100644 --- a/public/designs/templates/rightcolumn/stylesheets/style.css +++ b/public/designs/templates/rightcolumn/stylesheets/style.css @@ -36,19 +36,19 @@ body { height: 145px; } -#boxes { +#design_boxes { position: relative; margin-left: 10px; margin-right: 10px; padding: 0em; } -#box_2 { +#design_box_2 { width: 280px; float: right; } -#box_1 { +#design_box_1 { margin-right: 285px; } diff --git a/public/designs/templates/threecolumn/stylesheets/style.css b/public/designs/templates/threecolumn/stylesheets/style.css index 7f49faa..18cc2a9 100644 --- a/public/designs/templates/threecolumn/stylesheets/style.css +++ b/public/designs/templates/threecolumn/stylesheets/style.css @@ -16,7 +16,7 @@ background: url("../images/bg_header.png") top center no-repeat; height: 135px; } -#boxes { +#design_boxes { position: relative; width: 760px; left: 50%; @@ -24,17 +24,17 @@ height: 135px; padding: 0em; } -#box_3 { +#design_box_3 { width: 200px; float: right; } -#box_2 { +#design_box_2 { float: left; width: 200px; } -#box_1 { +#design_box_1 { margin-left: 205px; margin-right: 205px; } diff --git a/public/designs/themes/default/style.css b/public/designs/themes/default/style.css index 2a7a3db..b18d494 100644 --- a/public/designs/themes/default/style.css +++ b/public/designs/themes/default/style.css @@ -1,6 +1,6 @@ /* MacStyle Theme for Blocks */ -div.block +.design_block { background: #FFFFFF; border: 0px; @@ -8,29 +8,24 @@ div.block /* FIXME: esta usando para flutuar */ -.button_block_remove { -position: absolute; -z-index: 999; -} - -ul.block_control_list +ul.design_block_control_list { list-style: none; margin: 0px; padding: 0px; } -div#design_editor h3.block_header { +#design_editor h3.design_block_header { cursor:move; } -h3.block_header +.design_block h3 { position: relative; background: url('images/h3bg.png') repeat-x; font-family: Sans-serif; font-size: 15px; - margin: 0px; + margin: 0px; padding: 0px; overflow: hidden; color: #545454; @@ -39,7 +34,7 @@ h3.block_header vertical-align: top; } -a.button_block span { +a.design_button_block span { display: none; padding: 1px; color: #000; @@ -50,44 +45,48 @@ font-weight: normal; border: 1px inset #545454; } -a.button_block:hover span { -display: inline; +a.design_button_block:hover span { +display: block; position: absolute; margin-top: -20px; +z-index: 100; +float: left; } -a.button_block { -display: block; -float: right; -position: absolute; -width: 20px; -height: 20px; -text-decoration: none; +.design_block a.design_button_block { + display: block !important; + width: 20px !important; + height: 20px !important; + margin-top: 5px !important; + margin-right: 5px !important; + float: right !important; } -div.block a.button_block_hide { -right: 5px; +.design_block a.button_block_hide { background:url('images/button.png') no-repeat; background-position: 0px 0px; } -div.block a:hover.button_block_hide { +.design_block a:hover.button_block_hide { background: url('images/button.png') no-repeat; background-position: 0px -20px; } -div.block a.button_block_remove { -right: 5px; +.design_block a.button_block_remove, +.design_block a.button_block_item_options, +.design_block a.button_block_options { background: url('images/button.png') no-repeat; background-position:-20px 0; } -div.block a:hover.button_block_remove { +.design_block a:hover.button_block_remove, +.design_block a.hover.button_block_item_options, +.design_block a.hover.button_block_options { background: url('images/button.png') no-repeat; background-position:-20px -20px; } -div.block_content +.design_block_content { margin: 0; padding: 5px 10px 9px 10px; diff --git a/public/designs/themes/gray/style.css b/public/designs/themes/gray/style.css index 0f68e16..7a6fbaa 100644 --- a/public/designs/themes/gray/style.css +++ b/public/designs/themes/gray/style.css @@ -1,19 +1,20 @@ /* Default Plain Theme for Blocks */ -div.block +.design_block { background: #FFFFFF; border: 3px solid #000000; margin-bottom: 10px; } -div.block ul +.design_block ul { list-style: none; margin-left: 15px; } -div.block h3 + +.design_block h3 { color: #FFFFFF; background: #545454; @@ -27,15 +28,22 @@ div.block h3 padding-left: 10px; } -div.block span { +a.design_button_block span { display: none; +padding: 1px; +color: #000; +background: #dfdfdf; +font-family: Sans-serif; +font-size: 10px; +font-weight: normal; +border: 1px inset #545454; } -div.block a.button_block_hide:hover span { +.design_block a.desing_button_block:hover span { display: inline; position: absolute; -color: #dfdfdf; -background: #000000; +color: white; +background: #009900; font-family: Sans-serif; font-size: 13px; font-weight: normal; @@ -44,47 +52,51 @@ padding-left: 5px; padding-right: 5px; } -div.block a.button_block { -display: block !important; -width: 10px !important; -height: 10px !important; -margin-top: 10px !important; -margin-right: 5px !important; -float: right !important; +.design_block a.design_button_block { + display: block !important; + width: 20px !important; + height: 20px !important; + margin-top: 3px !important; + margin-right: 5px !important; + float: right !important; } -div.block a.button_block_hide { +.design_block a.button_block_hide { border-bottom: 2px solid #dfdfdf; } -div.block a:hover.button_block_hide { +.design_block a:hover.button_block_hide { border-bottom: 2px solid #000000; } -div.block a.button_block_remove { -background: #dfdfdf; +.design_block a.button_block_remove, +.design_block a.button_block_item_options, +.design_block a.button_block_options { + background: #dfdfdf; } -div.block a:hover.button_block_remove { -background: #000000; +.design_block a:hover.button_block_remove, +.design_block a.hover.button_block_item_options, +.design_block a.hover.button_block_options { + background: #000000; } -div.block_content +.design_block_content { padding: 5px; } -div.block ul { +.design_block ul { padding-left: 0px; margin: 0px; } -div.block ul li a:link, -div.block ul li a:hover { +.design_block ul li a:link, +.design_block ul li a:hover { display: block; color: #000; } -div.block ul li a:hover { +.design_block ul li a:hover { background: #ddd; - color: red; } + diff --git a/public/designs/themes/green/style.css b/public/designs/themes/green/style.css index cf547fa..a01f902 100644 --- a/public/designs/themes/green/style.css +++ b/public/designs/themes/green/style.css @@ -1,19 +1,19 @@ /* Green Theme for Blocks */ -div.block +.design_block { background: #FFFFFF; border: 3px solid #060; margin-bottom: 10px; } -div.block ul +.design_block ul { list-style: none; margin-left: 15px; } -div.block h3 +.design_block h3 { color: #afa; background: green; @@ -27,11 +27,18 @@ div.block h3 padding-left: 10px; } -div.block span { +a.design_button_block span { display: none; +padding: 1px; +color: #000; +background: #dfdfdf; +font-family: Sans-serif; +font-size: 10px; +font-weight: normal; +border: 1px inset #545454; } -div.block a.button_block_hide:hover span { +.design_block a.design_button_block:hover span { display: inline; position: absolute; color: white; @@ -44,48 +51,52 @@ padding-left: 5px; padding-right: 5px; } -div.block a.button_block { -display: block; -width: 10px; -height: 10px; -margin-top: 10px; -margin-right: 5px; -float: right; -} +.design_block a.design_button_block { + display: block !important; + width: 20px !important; + height: 20px !important; + margin-top: 3px !important; + margin-right: 5px !important; + float: right !important; +} + -div.block a.button_block_hide { +.design_block a.button_block_hide { border-bottom: 2px solid #dfdfdf; } -div.block a:hover.button_block_hide { +.design_block a:hover.button_block_hide { border-bottom: 2px solid #000000; } -div.block a.button_block_remove { -background: #dfdfdf; +.design_block a.button_block_remove, +.design_block a.button_block_item_options, +.design_block a.button_block_options { + background: #dfdfdf; } -div.block a:hover.button_block_remove { -background: #000000; +.design_block a:hover.button_block_remove, +.design_block a.hover.button_block_item_options, +.design_block a.hover.button_block_options { + background: #000000; } -div.block_content +.design_block_content { padding: 5px; } -div.block ul { +.design_block ul { padding-left: 0px; margin: 0px; } -div.block ul li a:link, -div.block ul li a:hover { +.design_block ul li a:link, +.design_block ul li a:hover { display: block; color: #000; } -div.block ul li a:hover { +.design_block ul li a:hover { background: #ddd; - color: red; } -- libgit2 0.21.2