Commit a46df3c92c510aa94bdd7f57142b131f97379f0e
Exists in
master
and in
27 other branches
Merge branch 'master' into rails3
Showing
11 changed files
with
83 additions
and
658 deletions
Show diff stats
app/controllers/admin/admin_panel_controller.rb
| ... | ... | @@ -7,6 +7,7 @@ class AdminPanelController < AdminController |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | def site_info |
| 10 | + @no_design_blocks = true | |
| 10 | 11 | if request.post? |
| 11 | 12 | if params[:environment][:languages] |
| 12 | 13 | params[:environment][:languages] = params[:environment][:languages].map {|lang, value| lang if value=='true'}.compact | ... | ... |
app/models/categories_block.rb
app/models/environment.rb
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | # domains. |
| 4 | 4 | class Environment < ActiveRecord::Base |
| 5 | 5 | |
| 6 | - attr_accessible :name, :is_default, :signup_welcome_text_subject, :signup_welcome_text_body, :terms_of_use, :message_for_disabled_enterprise, :news_amount_by_folder, :default_language, :languages, :description, :organization_approval_method, :enabled_plugins, :enabled_features, :redirection_after_login, :redirection_after_signup, :contact_email, :theme, :reports_lower_bound | |
| 6 | + attr_accessible :name, :is_default, :signup_welcome_text_subject, :signup_welcome_text_body, :terms_of_use, :message_for_disabled_enterprise, :news_amount_by_folder, :default_language, :languages, :description, :organization_approval_method, :enabled_plugins, :enabled_features, :redirection_after_login, :redirection_after_signup, :contact_email, :theme, :reports_lower_bound, :noreply_email, :signup_welcome_screen_body | |
| 7 | 7 | |
| 8 | 8 | has_many :users |
| 9 | 9 | |
| ... | ... | @@ -298,6 +298,12 @@ class Environment < ActiveRecord::Base |
| 298 | 298 | settings_items :access_control_allow_origin, :type => Array, :default => [] |
| 299 | 299 | settings_items :access_control_allow_methods, :type => String |
| 300 | 300 | |
| 301 | + settings_items :signup_welcome_screen_body, :type => String | |
| 302 | + | |
| 303 | + def has_custom_welcome_screen? | |
| 304 | + settings[:signup_welcome_screen_body].present? | |
| 305 | + end | |
| 306 | + | |
| 301 | 307 | def news_amount_by_folder=(amount) |
| 302 | 308 | settings[:news_amount_by_folder] = amount.to_i |
| 303 | 309 | end | ... | ... |
app/views/account/signup.html.erb
| 1 | 1 | <% if @register_pending %> |
| 2 | -<div id='thanks-for-signing'> | |
| 3 | - <h1><%= _("Welcome to %s!") % environment.name %></h1> | |
| 4 | - <h3><%= _("Thanks for signing up, we're thrilled to have you on our social network!") %></h3> | |
| 5 | - <p><%= _("Firstly, some tips for getting started:") %></p> | |
| 6 | - <h4><%= _("Confirm your account!") %></h4> | |
| 7 | - <p><%= _("You should receive a welcome email from us shortly. Please take a second to follow the link within to confirm your account.") %></p> | |
| 8 | - <p><%= _("You won't appear as %s until your account is confirmed.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %></p> | |
| 9 | - <h4><%= _("What to do next?") %></h4> | |
| 10 | - <p><%= _("%s. Upload an avatar and let your friends find you easily :)") % link_to(_('Customize your profile'), {:controller => 'doc', :section => 'user', :topic => 'editing-person-info'}, :target => '_blank') %></p> | |
| 11 | - <p><%= _("Learn the guidelines. Read the %s for more details on how to use this social network!") % link_to(_('Documentation'), {:controller => 'doc'}, :target => '_blank') %></p> | |
| 12 | - <p><%= _("%s your Gmail, Yahoo and Hotmail contacts!") % link_to(_('Invite and find'), {:controller => 'doc', :section => 'user', :topic => 'invite-contacts'}, :target => '_blank') %></p> | |
| 13 | - <p><%= _("Start exploring and have fun!") %></p> | |
| 14 | -</div> | |
| 2 | + <div id='thanks-for-signing'> | |
| 3 | + <% if environment.has_custom_welcome_screen? %> | |
| 4 | + <%= environment.settings[:signup_welcome_screen_body].html_safe %> | |
| 5 | + <% else %> | |
| 6 | + <h1><%= _("Welcome to %s!") % environment.name %></h1> | |
| 7 | + <h3><%= _("Thanks for signing up, we're thrilled to have you on our social network!") %></h3> | |
| 8 | + <p><%= _("Firstly, some tips for getting started:") %></p> | |
| 9 | + <h4><%= _("Confirm your account!") %></h4> | |
| 10 | + <p><%= _("You should receive a welcome email from us shortly. Please take a second to follow the link within to confirm your account.") %></p> | |
| 11 | + <p><%= _("You won't appear as %s until your account is confirmed.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %></p> | |
| 12 | + <h4><%= _("What to do next?") %></h4> | |
| 13 | + <p><%= _("%s. Upload an avatar and let your friends find you easily :)") % link_to(_('Customize your profile'), {:controller => 'doc', :section => 'user', :topic => 'editing-person-info'}, :target => '_blank') %></p> | |
| 14 | + <p><%= _("Learn the guidelines. Read the %s for more details on how to use this social network!") % link_to(_('Documentation'), {:controller => 'doc'}, :target => '_blank') %></p> | |
| 15 | + <p><%= _("%s your Gmail, Yahoo and Hotmail contacts!") % link_to(_('Invite and find'), {:controller => 'doc', :section => 'user', :topic => 'invite-contacts'}, :target => '_blank') %></p> | |
| 16 | + <p><%= _("Start exploring and have fun!") %></p> | |
| 17 | + <% end %> | |
| 18 | + </div> | |
| 15 | 19 | <% else %> |
| 16 | 20 | <h1><%= _('Sign up for %s!') % environment.name %></h1> |
| 17 | 21 | <%= render :partial => 'signup_form' %> | ... | ... |
| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | +<div class='description'> | |
| 2 | + <%= _('This text will be showed as a welcome message to users after signup') %><br/><br/> | |
| 3 | +</div> | |
| 4 | + | |
| 5 | +<%= labelled_form_field(_('Body'), text_area(:environment, :signup_welcome_screen_body, :cols => 40, :style => 'width: 100%', :class => 'mceEditor')) %> | ... | ... |
app/views/admin_panel/site_info.html.erb
| ... | ... | @@ -12,6 +12,8 @@ |
| 12 | 12 | :content => (render :partial => 'terms_of_use', :locals => {:f => f})} %> |
| 13 | 13 | <% tabs << {:title => _('Signup welcome text'), :id => 'signup-welcome-text', |
| 14 | 14 | :content => (render :partial => 'signup_welcome_text', :locals => {:f => f})} %> |
| 15 | + <% tabs << {:title => _('Signup welcome message'), :id => 'signup-welcome-message', | |
| 16 | + :content => (render :partial => 'signup_welcome_screen', :locals => {:f => f}) }%> | |
| 15 | 17 | <%= render_tabs(tabs) %> |
| 16 | 18 | <% button_bar do %> |
| 17 | 19 | <%= submit_button(:save, _('Save'), :cancel => {:action => 'index'}) %> | ... | ... |
features/categories_block.feature
| ... | ... | @@ -28,7 +28,8 @@ Feature: categories_block |
| 28 | 28 | |
| 29 | 29 | @selenium |
| 30 | 30 | Scenario: List just product categories |
| 31 | - Given I follow "Edit" within ".categories-block" | |
| 31 | + Given display ".button-bar" | |
| 32 | + And I follow "Edit" within ".categories-block" | |
| 32 | 33 | And I check "Product" |
| 33 | 34 | When I press "Save" |
| 34 | 35 | Then I should see "Food" |
| ... | ... | @@ -39,7 +40,8 @@ Feature: categories_block |
| 39 | 40 | |
| 40 | 41 | @selenium |
| 41 | 42 | Scenario: Show submenu if it exists |
| 42 | - Given I follow "Edit" within ".categories-block" | |
| 43 | + Given display ".button-bar" | |
| 44 | + And I follow "Edit" within ".categories-block" | |
| 43 | 45 | And I check "Product" |
| 44 | 46 | And I press "Save" |
| 45 | 47 | Then I should see "Food" |
| ... | ... | @@ -56,7 +58,8 @@ Feature: categories_block |
| 56 | 58 | |
| 57 | 59 | @selenium |
| 58 | 60 | Scenario: Show only one submenu per time |
| 59 | - Given I follow "Edit" within ".categories-block" | |
| 61 | + Given display ".button-bar" | |
| 62 | + And I follow "Edit" within ".categories-block" | |
| 60 | 63 | And I check "Product" |
| 61 | 64 | And I press "Save" |
| 62 | 65 | Then I should see "Book" |
| ... | ... | @@ -66,14 +69,16 @@ Feature: categories_block |
| 66 | 69 | |
| 67 | 70 | @selenium |
| 68 | 71 | Scenario: List just general categories |
| 69 | - Given I follow "Edit" within ".categories-block" | |
| 72 | + Given display ".button-bar" | |
| 73 | + And I follow "Edit" within ".categories-block" | |
| 70 | 74 | And I check "Generic category" |
| 71 | 75 | When I press "Save" |
| 72 | 76 | Then I should see "Wood" |
| 73 | 77 | |
| 74 | 78 | @selenium |
| 75 | 79 | Scenario: List just regions |
| 76 | - Given I follow "Edit" within ".categories-block" | |
| 80 | + Given display ".button-bar" | |
| 81 | + And I follow "Edit" within ".categories-block" | |
| 77 | 82 | And I check "Region" |
| 78 | 83 | When I press "Save" |
| 79 | 84 | Then I should see "Bahia" | ... | ... |
features/publish_article.feature
| ... | ... | @@ -56,6 +56,7 @@ Feature: publish article |
| 56 | 56 | And I am on mariasilva's control panel |
| 57 | 57 | And I follow "Manage Content" |
| 58 | 58 | And I follow "New content" |
| 59 | + And I should see "Text article with Textile markup language" | |
| 59 | 60 | And I follow "Text article with Textile markup language" |
| 60 | 61 | And I fill in the following: |
| 61 | 62 | | Title | Sample Article | | ... | ... |
lib/noosfero/plugin.rb.orig
| ... | ... | @@ -1,639 +0,0 @@ |
| 1 | -require 'noosfero' | |
| 2 | - | |
| 3 | -class Noosfero::Plugin | |
| 4 | - | |
| 5 | - attr_accessor :context | |
| 6 | - | |
| 7 | - def initialize(context=nil) | |
| 8 | - self.context = context | |
| 9 | - end | |
| 10 | - | |
| 11 | - class << self | |
| 12 | - | |
| 13 | - attr_writer :should_load | |
| 14 | - | |
| 15 | - def should_load | |
| 16 | - @should_load.nil? && true || @boot | |
| 17 | - end | |
| 18 | - | |
| 19 | -<<<<<<< HEAD | |
| 20 | - def initialize! | |
| 21 | - return if !should_load | |
| 22 | - enabled.each do |plugin_dir| | |
| 23 | - plugin_name = File.basename(plugin_dir) | |
| 24 | - plugin = load_plugin(plugin_name) | |
| 25 | - load_plugin_extensions(plugin_dir) | |
| 26 | - load_plugin_filters(plugin) | |
| 27 | - end | |
| 28 | - end | |
| 29 | - | |
| 30 | - def setup(config) | |
| 31 | - return if !should_load | |
| 32 | - enabled.each do |dir| | |
| 33 | - setup_plugin(dir, config) | |
| 34 | -======= | |
| 35 | - def init_system | |
| 36 | - available_plugins.each do |dir| | |
| 37 | - load_plugin dir | |
| 38 | ->>>>>>> rails235 | |
| 39 | - end | |
| 40 | - end | |
| 41 | - | |
| 42 | - def setup_plugin(dir, config) | |
| 43 | - plugin_name = File.basename(dir) | |
| 44 | - | |
| 45 | - plugin_dependencies_ok = true | |
| 46 | - plugin_dependencies_file = File.join(dir, 'dependencies.rb') | |
| 47 | - if File.exists?(plugin_dependencies_file) | |
| 48 | - begin | |
| 49 | - require plugin_dependencies_file | |
| 50 | - rescue LoadError => ex | |
| 51 | - plugin_dependencies_ok = false | |
| 52 | - $stderr.puts "W: Noosfero plugin #{plugin_name} failed to load (#{ex})" | |
| 53 | - end | |
| 54 | - end | |
| 55 | - | |
| 56 | - if plugin_dependencies_ok | |
| 57 | - %w[ | |
| 58 | - controllers | |
| 59 | - controllers/public | |
| 60 | - controllers/profile | |
| 61 | - controllers/myprofile | |
| 62 | - controllers/admin | |
| 63 | - ].each do |folder| | |
| 64 | - config.autoload_paths << File.join(dir, folder) | |
| 65 | - end | |
| 66 | - [ config.autoload_paths, $:].each do |path| | |
| 67 | - path << File.join(dir, 'models') | |
| 68 | - path << File.join(dir, 'lib') | |
| 69 | - # load vendor/plugins | |
| 70 | - Dir.glob(File.join(dir, '/vendor/plugins/*')).each do |vendor_plugin| | |
| 71 | - path << "#{vendor_plugin}/lib" | |
| 72 | - init = "#{vendor_plugin}/init.rb" | |
| 73 | - require init.gsub(/.rb$/, '') if File.file? init | |
| 74 | - end | |
| 75 | - end | |
| 76 | - | |
| 77 | - # add view path | |
| 78 | - ActionController::Base.view_paths.unshift(File.join(dir, 'views')) | |
| 79 | - end | |
| 80 | - end | |
| 81 | - | |
| 82 | - def load_plugin(plugin_name) | |
| 83 | - (plugin_name.to_s.camelize + 'Plugin').constantize | |
| 84 | - end | |
| 85 | - | |
| 86 | - # This is a generic method that initialize any possible filter defined by a | |
| 87 | - # plugin to a specific controller | |
| 88 | - def load_plugin_filters(plugin) | |
| 89 | - plugin_methods = plugin.instance_methods.select {|m| m.to_s.end_with?('_filters')} | |
| 90 | - plugin_methods.each do |plugin_method| | |
| 91 | - controller_class = plugin_method.to_s.gsub('_filters', '').camelize.constantize | |
| 92 | - filters = plugin.new.send(plugin_method) | |
| 93 | - filters = [filters] if !filters.kind_of?(Array) | |
| 94 | - | |
| 95 | - filters.each do |plugin_filter| | |
| 96 | - filter_method = (plugin.name.underscore.gsub('/','_') + '_' + plugin_filter[:method_name]).to_sym | |
| 97 | - controller_class.send(plugin_filter[:type], filter_method, (plugin_filter[:options] || {})) | |
| 98 | - controller_class.send(:define_method, filter_method) do | |
| 99 | - instance_eval(&plugin_filter[:block]) if environment.plugin_enabled?(plugin) | |
| 100 | - end | |
| 101 | - end | |
| 102 | - end | |
| 103 | - end | |
| 104 | - | |
| 105 | - def load_plugin_extensions(dir) | |
| 106 | - Rails.configuration.to_prepare do | |
| 107 | - Dir[File.join(dir, 'lib', 'ext', '*.rb')].each {|file| require_dependency file } | |
| 108 | - end | |
| 109 | - end | |
| 110 | - | |
| 111 | - def enabled | |
| 112 | - @enabled ||= | |
| 113 | - begin | |
| 114 | - plugins = Dir.glob(Rails.root.join('config', 'plugins', '*')) | |
| 115 | - if Rails.env.test? && !plugins.include?(Rails.root.join('config', 'plugins', 'foo')) | |
| 116 | - plugins << Rails.root.join('plugins', 'foo') | |
| 117 | - end | |
| 118 | - plugins.select do |entry| | |
| 119 | - File.directory?(entry) | |
| 120 | - end | |
| 121 | - end | |
| 122 | - end | |
| 123 | - | |
| 124 | -<<<<<<< HEAD | |
| 125 | - | |
| 126 | - def all | |
| 127 | - @all ||= [] | |
| 128 | -======= | |
| 129 | - def available_plugins | |
| 130 | - unless @available_plugins | |
| 131 | - path = File.join(Rails.root, 'config', 'plugins', '*') | |
| 132 | - @available_plugins = Dir.glob(path).select{ |i| File.directory?(i) } | |
| 133 | - if Rails.env.test? && !@available_plugins.include?(File.join(Rails.root, 'config', 'plugins', 'foo')) | |
| 134 | - @available_plugins << File.join(Rails.root, 'plugins', 'foo') | |
| 135 | - end | |
| 136 | - end | |
| 137 | - @available_plugins | |
| 138 | ->>>>>>> rails235 | |
| 139 | - end | |
| 140 | - | |
| 141 | - def all | |
| 142 | - @all ||= available_plugins.map{ |dir| (File.basename(dir) + "_plugin").camelize } | |
| 143 | - end | |
| 144 | - | |
| 145 | - def public_name | |
| 146 | - self.name.underscore.gsub('_plugin','') | |
| 147 | - end | |
| 148 | - | |
| 149 | - def public_path(file = '') | |
| 150 | - File.join('/plugins', public_name, file) | |
| 151 | - end | |
| 152 | - | |
| 153 | - def root_path | |
| 154 | - Rails.root.join('plugins', public_name) | |
| 155 | - end | |
| 156 | - | |
| 157 | - def view_path | |
| 158 | - File.join(root_path,'views') | |
| 159 | - end | |
| 160 | - | |
| 161 | - # Here the developer should specify the meta-informations that the plugin can | |
| 162 | - # inform. | |
| 163 | - def plugin_name | |
| 164 | - self.name.underscore.humanize | |
| 165 | - end | |
| 166 | - def plugin_description | |
| 167 | - _("No description informed.") | |
| 168 | - end | |
| 169 | - | |
| 170 | - def admin_url | |
| 171 | - {:controller => "#{name.underscore}_admin", :action => 'index'} | |
| 172 | - end | |
| 173 | - | |
| 174 | - def has_admin_url? | |
| 175 | - File.exists?(File.join(root_path, 'controllers', "#{name.underscore}_admin_controller.rb")) | |
| 176 | - end | |
| 177 | - end | |
| 178 | - | |
| 179 | - def expanded_template(file_path, locals = {}) | |
| 180 | - views_path = Rails.root.join('plugins', "#{self.class.public_name}", 'views') | |
| 181 | - ERB.new(File.read("#{views_path}/#{file_path}")).result(binding) | |
| 182 | - end | |
| 183 | - | |
| 184 | - def extra_blocks(params = {}) | |
| 185 | - return [] if self.class.extra_blocks.nil? | |
| 186 | - blocks = self.class.extra_blocks.map do |block, options| | |
| 187 | - type = options[:type] | |
| 188 | - type = type.is_a?(Array) ? type : [type].compact | |
| 189 | - type = type.map do |x| | |
| 190 | - x.is_a?(String) ? x.capitalize.constantize : x | |
| 191 | - end | |
| 192 | - raise "This is not a valid type" if !type.empty? && ![Person, Community, Enterprise, Environment].detect{|m| type.include?(m)} | |
| 193 | - | |
| 194 | - position = options[:position] | |
| 195 | - position = position.is_a?(Array) ? position : [position].compact | |
| 196 | - position = position.map{|p| p.to_i} | |
| 197 | - raise "This is not a valid position" if !position.empty? && ![1,2,3].detect{|m| position.include?(m)} | |
| 198 | - | |
| 199 | - if !type.empty? && (params[:type] != :all) | |
| 200 | - block = type.include?(params[:type]) ? block : nil | |
| 201 | - end | |
| 202 | - | |
| 203 | - if !position.empty? && !params[:position].nil? | |
| 204 | - block = position.detect{ |p| [params[:position]].flatten.include?(p)} ? block : nil | |
| 205 | - end | |
| 206 | - | |
| 207 | - block | |
| 208 | - end | |
| 209 | - blocks.compact! | |
| 210 | - blocks || [] | |
| 211 | - end | |
| 212 | - | |
| 213 | - def macros | |
| 214 | - self.class.constants.map do |constant_name| | |
| 215 | - self.class.const_get(constant_name) | |
| 216 | - end.select {|const| const.is_a?(Class) && const < Noosfero::Plugin::Macro} | |
| 217 | - end | |
| 218 | - | |
| 219 | - # Here the developer may specify the events to which the plugins can | |
| 220 | - # register and must return true or false. The default value must be false. | |
| 221 | - # Must also explicitly define its returning variables. | |
| 222 | - | |
| 223 | - # -> If true, noosfero will include plugin_dir/public/style.css into | |
| 224 | - # application | |
| 225 | - def stylesheet? | |
| 226 | - false | |
| 227 | - end | |
| 228 | - | |
| 229 | - # -> Adds buttons to the control panel | |
| 230 | - # returns = { :title => title, :icon => icon, :url => url } | |
| 231 | - # title = name that will be displayed. | |
| 232 | - # icon = css class name (for customized icons include them in a css file). | |
| 233 | - # url = url or route to which the button will redirect. | |
| 234 | - def control_panel_buttons | |
| 235 | - nil | |
| 236 | - end | |
| 237 | - | |
| 238 | - # -> Customize profile block design and behavior | |
| 239 | - # (overwrites profile_image_link function) | |
| 240 | - # returns = lambda block that creates html code. | |
| 241 | - def profile_image_link(profile, size, tag, extra_info) | |
| 242 | - nil | |
| 243 | - end | |
| 244 | - | |
| 245 | - # -> Adds tabs to the profile | |
| 246 | - # returns = { :title => title, :id => id, :content => content, :start => start } | |
| 247 | - # title = name that will be displayed. | |
| 248 | - # id = div id. | |
| 249 | - # content = lambda block that creates html code. | |
| 250 | - # start = boolean that specifies if the tab must come before noosfero tabs (optional). | |
| 251 | - def profile_tabs | |
| 252 | - nil | |
| 253 | - end | |
| 254 | - | |
| 255 | - # -> Adds plugin-specific content types to CMS | |
| 256 | - # returns = [ContentClass1, ContentClass2, ...] | |
| 257 | - def content_types | |
| 258 | - nil | |
| 259 | - end | |
| 260 | - | |
| 261 | - # -> Adds content to calalog item | |
| 262 | - # returns = lambda block that creates html code | |
| 263 | - def catalog_item_extras(item) | |
| 264 | - nil | |
| 265 | - end | |
| 266 | - | |
| 267 | - # -> Adds content to profile editor info and settings | |
| 268 | - # returns = lambda block that creates html code or raw rhtml/html.erb | |
| 269 | - def profile_editor_extras | |
| 270 | - nil | |
| 271 | - end | |
| 272 | - | |
| 273 | - # -> Adds content to calalog list item | |
| 274 | - # returns = lambda block that creates html code | |
| 275 | - def catalog_list_item_extras(item) | |
| 276 | - nil | |
| 277 | - end | |
| 278 | - | |
| 279 | - # -> Adds content to products info | |
| 280 | - # returns = lambda block that creates html code | |
| 281 | - def product_info_extras(product) | |
| 282 | - nil | |
| 283 | - end | |
| 284 | - | |
| 285 | - # -> Adds content to products on asset list | |
| 286 | - # returns = lambda block that creates html code | |
| 287 | - def asset_product_extras(product) | |
| 288 | - nil | |
| 289 | - end | |
| 290 | - | |
| 291 | - # -> Adds a property to the product on asset products | |
| 292 | - # returns = {:name => name, :content => content} | |
| 293 | - # name = Name of the property | |
| 294 | - # content = lambda block that creates an html | |
| 295 | - def asset_product_properties(product) | |
| 296 | - nil | |
| 297 | - end | |
| 298 | - | |
| 299 | - # -> Adds content to the beginning of the page | |
| 300 | - # returns = lambda block that creates html code or raw rhtml/html.erb | |
| 301 | - def body_beginning | |
| 302 | - nil | |
| 303 | - end | |
| 304 | - | |
| 305 | - # -> Adds content to the ending of the page head | |
| 306 | - # returns = lambda block that creates html code or raw rhtml/html.erb | |
| 307 | - def head_ending | |
| 308 | - nil | |
| 309 | - end | |
| 310 | - | |
| 311 | - # -> Adds plugins' javascript files to application | |
| 312 | - # returns = ['example1.js', 'javascripts/example2.js', 'example3.js'] | |
| 313 | - def js_files | |
| 314 | - [] | |
| 315 | - end | |
| 316 | - | |
| 317 | - # -> Adds stuff in user data hash | |
| 318 | - # returns = { :some_data => some_value, :another_data => another_value } | |
| 319 | - def user_data_extras | |
| 320 | - {} | |
| 321 | - end | |
| 322 | - | |
| 323 | - # -> Parse and possibly make changes of content (article, block, etc) during HTML rendering | |
| 324 | - # returns = content as string after parser and changes | |
| 325 | - def parse_content(html, source) | |
| 326 | - [html, source] | |
| 327 | - end | |
| 328 | - | |
| 329 | - # -> Adds links to the admin panel | |
| 330 | - # returns = {:title => title, :url => url} | |
| 331 | - # title = name that will be displayed in the link | |
| 332 | - # url = url or route to which the link will redirect to. | |
| 333 | - def admin_panel_links | |
| 334 | - nil | |
| 335 | - end | |
| 336 | - | |
| 337 | - # -> Adds buttons to manage members page | |
| 338 | - # returns = { :title => title, :icon => icon, :url => url } | |
| 339 | - # title = name that will be displayed. | |
| 340 | - # icon = css class name (for customized icons include them in a css file). | |
| 341 | - # url = url or route to which the button will redirect. | |
| 342 | - def manage_members_extra_buttons | |
| 343 | - nil | |
| 344 | - end | |
| 345 | - | |
| 346 | - # This method will be called just before a comment is saved to the database. | |
| 347 | - # | |
| 348 | - # It can modify the comment in several ways. In special, a plugin can call | |
| 349 | - # reject! on the comment and that will cause the comment to not be saved. | |
| 350 | - # | |
| 351 | - # example: | |
| 352 | - # | |
| 353 | - # def filter_comment(comment) | |
| 354 | - # if user_not_logged_in | |
| 355 | - # comment.reject! | |
| 356 | - # end | |
| 357 | - # end | |
| 358 | - # | |
| 359 | - def filter_comment(comment) | |
| 360 | - end | |
| 361 | - | |
| 362 | - # Define custom logic to filter loaded comments. | |
| 363 | - # | |
| 364 | - # Example: | |
| 365 | - # | |
| 366 | - # def unavailable_comments(scope) | |
| 367 | - # scope.without_spams | |
| 368 | - # end | |
| 369 | - # | |
| 370 | - def unavailable_comments(scope) | |
| 371 | - scope | |
| 372 | - end | |
| 373 | - | |
| 374 | - # -> Allows plugins to check weather object is a spam | |
| 375 | - def check_for_spam(object) | |
| 376 | - end | |
| 377 | - | |
| 378 | - # -> Allows plugins to know when an object is marked as a spam | |
| 379 | - def marked_as_spam(object) | |
| 380 | - end | |
| 381 | - | |
| 382 | - # -> Allows plugins to know when an object is marked as a ham | |
| 383 | - def marked_as_ham(object) | |
| 384 | - end | |
| 385 | - | |
| 386 | - # Adds extra actions for comments | |
| 387 | - # returns = list of hashes or lambda block that creates a list of hashes | |
| 388 | - # example: | |
| 389 | - # | |
| 390 | - # def comment_actions(comment) | |
| 391 | - # [{:link => link_to_function(...)}] | |
| 392 | - # end | |
| 393 | - # | |
| 394 | - def comment_actions(comment) | |
| 395 | - nil | |
| 396 | - end | |
| 397 | - | |
| 398 | - # This method is called when the user click on comment actions menu. | |
| 399 | - # returns = list or lambda block that return ids of enabled menu items for comments | |
| 400 | - # example: | |
| 401 | - # | |
| 402 | - # def check_comment_actions(comment) | |
| 403 | - # ['#action1', '#action2'] | |
| 404 | - # end | |
| 405 | - # | |
| 406 | - def check_comment_actions(comment) | |
| 407 | - [] | |
| 408 | - end | |
| 409 | - | |
| 410 | - # -> Adds adicional content to article | |
| 411 | - # returns = lambda block that creates html code | |
| 412 | - def article_extra_contents(article) | |
| 413 | - nil | |
| 414 | - end | |
| 415 | - | |
| 416 | - # -> Adds fields to the signup form | |
| 417 | - # returns = lambda block that creates html code | |
| 418 | - def signup_extra_contents | |
| 419 | - nil | |
| 420 | - end | |
| 421 | - | |
| 422 | - # -> Adds adicional content to profile info | |
| 423 | - # returns = lambda block that creates html code | |
| 424 | - def profile_info_extra_contents | |
| 425 | - nil | |
| 426 | - end | |
| 427 | - | |
| 428 | - # -> Removes the invite friend button from the friends controller | |
| 429 | - # returns = boolean | |
| 430 | - def remove_invite_friends_button | |
| 431 | - nil | |
| 432 | - end | |
| 433 | - | |
| 434 | - # -> Extends organization list of members | |
| 435 | - # returns = An instance of ActiveRecord::NamedScope::Scope retrieved through | |
| 436 | - # Person.members_of method. | |
| 437 | - def organization_members(organization) | |
| 438 | - nil | |
| 439 | - end | |
| 440 | - | |
| 441 | - # -> Extends person memberships list | |
| 442 | - # returns = An instance of ActiveRecord::NamedScope::Scope retrived through | |
| 443 | - # Person.memberships_of method. | |
| 444 | - def person_memberships(person) | |
| 445 | - nil | |
| 446 | - end | |
| 447 | - | |
| 448 | - # -> Extends person permission access | |
| 449 | - # returns = boolean | |
| 450 | - def has_permission?(person, permission, target) | |
| 451 | - nil | |
| 452 | - end | |
| 453 | - | |
| 454 | - # -> Adds hidden_fields to the new community view | |
| 455 | - # returns = {key => value} | |
| 456 | - def new_community_hidden_fields | |
| 457 | - nil | |
| 458 | - end | |
| 459 | - | |
| 460 | - # -> Adds hidden_fields to the enterprise registration view | |
| 461 | - # returns = {key => value} | |
| 462 | - def enterprise_registration_hidden_fields | |
| 463 | - nil | |
| 464 | - end | |
| 465 | - | |
| 466 | - # -> Add an alternative authentication method. | |
| 467 | - # Your plugin have to make the access control and return the logged user. | |
| 468 | - # returns = User | |
| 469 | - def alternative_authentication | |
| 470 | - nil | |
| 471 | - end | |
| 472 | - | |
| 473 | - # -> Adds adicional link to make the user authentication | |
| 474 | - # returns = lambda block that creates html code | |
| 475 | - def alternative_authentication_link | |
| 476 | - nil | |
| 477 | - end | |
| 478 | - | |
| 479 | - # -> Allow or not user registration | |
| 480 | - # returns = boolean | |
| 481 | - def allow_user_registration | |
| 482 | - true | |
| 483 | - end | |
| 484 | - | |
| 485 | - # -> Allow or not password recovery by users | |
| 486 | - # returns = boolean | |
| 487 | - def allow_password_recovery | |
| 488 | - true | |
| 489 | - end | |
| 490 | - | |
| 491 | - # -> Adds fields to the login form | |
| 492 | - # returns = lambda block that creates html code | |
| 493 | - def login_extra_contents | |
| 494 | - nil | |
| 495 | - end | |
| 496 | - | |
| 497 | - # -> Adds adicional content to comment form | |
| 498 | - # returns = lambda block that creates html code | |
| 499 | - def comment_form_extra_contents(args) | |
| 500 | - nil | |
| 501 | - end | |
| 502 | - | |
| 503 | - # -> Adds adicional content to article header | |
| 504 | - # returns = lambda block that creates html code | |
| 505 | - def article_header_extra_contents(article) | |
| 506 | - nil | |
| 507 | - end | |
| 508 | - | |
| 509 | - # -> Adds adittional content to comment visualization | |
| 510 | - # returns = lambda block that creates html code | |
| 511 | - def comment_extra_contents(args) | |
| 512 | - nil | |
| 513 | - end | |
| 514 | - | |
| 515 | - # This method is called when the user clicks to send a comment. | |
| 516 | - # A plugin can add new content to comment form and this method can process the params sent to avoid creating field on core tables. | |
| 517 | - # returns = params after processed by plugins | |
| 518 | - # example: | |
| 519 | - # | |
| 520 | - # def process_extra_comment_params(params) | |
| 521 | - # params.delete(:extra_field) | |
| 522 | - # end | |
| 523 | - # | |
| 524 | - def process_extra_comment_params(params) | |
| 525 | - params | |
| 526 | - end | |
| 527 | - | |
| 528 | - # -> Finds objects by their contents | |
| 529 | - # returns = {:results => [a, b, c, ...], ...} | |
| 530 | - # P.S.: The plugin might add other informations on the return hash for its | |
| 531 | - # own use in specific views | |
| 532 | - def find_by_contents(asset, scope, query, paginate_options={}, options={}) | |
| 533 | - end | |
| 534 | - | |
| 535 | - # -> Adds aditional fields for change_password | |
| 536 | - # returns = [{:field => 'field1', :name => 'field 1 name', :model => 'person'}, {...}] | |
| 537 | - def change_password_fields | |
| 538 | - nil | |
| 539 | - end | |
| 540 | - | |
| 541 | - # -> Adds additional blocks to profiles and environments. | |
| 542 | - # Your plugin must implements a class method called 'extra_blocks' | |
| 543 | - # that returns a hash with the following syntax. | |
| 544 | - # { | |
| 545 | - # 'block_name' => | |
| 546 | - # { | |
| 547 | - # :type => 'for which holder the block will be available', | |
| 548 | - # :position => 'where the block could be displayed' | |
| 549 | - # } | |
| 550 | - # } | |
| 551 | - # | |
| 552 | - # Where: | |
| 553 | - # | |
| 554 | - # - block_name: Name of the new block added to the blocks list | |
| 555 | - # - type: Might have some of the values | |
| 556 | - # - 'environment' or Environment: If the block is available only for Environment models | |
| 557 | - # - 'community' or Community: If the block is available only for Community models | |
| 558 | - # - 'enterprise' or Enterprise: If the block is available only for Enterprise models | |
| 559 | - # - 'person' or Person: If the block is available only for Person models | |
| 560 | - # - nil: If no type parameter is passed the block will be available for all types | |
| 561 | - # - position: Is the layout position of the block. It should be: | |
| 562 | - # - '1' or 1: Area 1 of layout | |
| 563 | - # - '2' or 2: Area 2 of layout | |
| 564 | - # - '3' or 3: Area 3 of layout | |
| 565 | - # - nil: If no position parameter is passed the block will be available for all positions | |
| 566 | - # | |
| 567 | - # OBS: Area 1 is where stay the main content of layout. Areas 2 and 3 are the sides of layout. | |
| 568 | - # | |
| 569 | - # examples: | |
| 570 | - # | |
| 571 | - # def self.extra_blocks(params) | |
| 572 | - # { | |
| 573 | - # #Display 'CustomBlock1' only for 'Person' on position '1' | |
| 574 | - # CustomBlock1 => {:type => 'person', :position => '1' }, | |
| 575 | - # | |
| 576 | - # #Display 'CustomBlock2' only for 'Community' on position '2' | |
| 577 | - # CustomBlock2 => {:type => Community, :position => '2' }, | |
| 578 | - # | |
| 579 | - # #Display 'CustomBlock3' only for 'Enterprise' on position '3' | |
| 580 | - # CustomBlock3 => {:type => 'enterprise', :position => 3 }, | |
| 581 | - # | |
| 582 | - # #Display 'CustomBlock2' for 'Environment' and 'Person' on positions '1' and '3' | |
| 583 | - # CustomBlock4 => {:type => ['environment', Person], :position => ['1','3'] }, | |
| 584 | - # | |
| 585 | - # #Display 'CustomBlock5' for all types and all positions | |
| 586 | - # CustomBlock5 => {}, | |
| 587 | - # } | |
| 588 | - # end | |
| 589 | - # | |
| 590 | - # OBS: The default value is a empty hash. | |
| 591 | - def self.extra_blocks | |
| 592 | - {} | |
| 593 | - end | |
| 594 | - | |
| 595 | - def method_missing(method, *args, &block) | |
| 596 | - # This is a generic hotspot for all controllers on Noosfero. | |
| 597 | - # If any plugin wants to define filters to run on any controller, the name of | |
| 598 | - # the hotspot must be in the following form: <underscored_controller_name>_filters. | |
| 599 | - # Example: for ProfileController the hotspot is profile_controller_filters | |
| 600 | - # | |
| 601 | - # -> Adds a filter to a controller | |
| 602 | - # returns = { :type => type, | |
| 603 | - # :method_name => method_name, | |
| 604 | - # :options => {:opt1 => opt1, :opt2 => opt2}, | |
| 605 | - # :block => Proc or lambda block} | |
| 606 | - # type = 'before_filter' or 'after_filter' | |
| 607 | - # method_name = The name of the filter | |
| 608 | - # option = Filter options, like :only or :except | |
| 609 | - # block = Block that the filter will call | |
| 610 | - if method.to_s =~ /^(.+)_controller_filters$/ | |
| 611 | - [] | |
| 612 | - # -> Removes the action button from the content | |
| 613 | - # returns = boolean | |
| 614 | - elsif method.to_s =~ /^content_remove_(#{content_actions.join('|')})$/ | |
| 615 | - nil | |
| 616 | - # -> Expire the action button from the content | |
| 617 | - # returns = string with reason of expiration | |
| 618 | - elsif method.to_s =~ /^content_expire_(#{content_actions.join('|')})$/ | |
| 619 | - nil | |
| 620 | - else | |
| 621 | - super | |
| 622 | - end | |
| 623 | - end | |
| 624 | - | |
| 625 | - private | |
| 626 | - | |
| 627 | - def content_actions | |
| 628 | - #FIXME 'new' and 'upload' only works for content_remove. It should work for | |
| 629 | - #content_expire too. | |
| 630 | - %w[edit delete spread locale suggest home new upload] | |
| 631 | - end | |
| 632 | - | |
| 633 | -end | |
| 634 | - | |
| 635 | -require 'noosfero/plugin/hot_spot' | |
| 636 | -require 'noosfero/plugin/manager' | |
| 637 | -require 'noosfero/plugin/active_record' | |
| 638 | -require 'noosfero/plugin/mailer_base' | |
| 639 | -require 'noosfero/plugin/settings' |
test/functional/admin_panel_controller_test.rb
| ... | ... | @@ -73,6 +73,7 @@ class AdminPanelControllerTest < ActionController::TestCase |
| 73 | 73 | assert_tag :tag => 'textarea', :attributes => { :name => 'environment[terms_of_use]'} |
| 74 | 74 | assert_tag :tag => 'input', :attributes => { :name => 'environment[signup_welcome_text_subject]'} |
| 75 | 75 | assert_tag :tag => 'textarea', :attributes => { :name => 'environment[signup_welcome_text_body]'} |
| 76 | + assert_tag :tag => 'textarea', :attributes => { :name => 'environment[signup_welcome_screen_body]'} | |
| 76 | 77 | end |
| 77 | 78 | |
| 78 | 79 | should 'display form for editing message for disabled enterprise' do |
| ... | ... | @@ -381,4 +382,13 @@ class AdminPanelControllerTest < ActionController::TestCase |
| 381 | 382 | assert_not_includes environment.languages, 'en' |
| 382 | 383 | end |
| 383 | 384 | |
| 385 | + should 'save body of signup welcome screen' do | |
| 386 | + body = "This is my welcome body" | |
| 387 | + post :site_info, :environment => { :signup_welcome_screen_body => body } | |
| 388 | + assert_redirected_to :action => 'index' | |
| 389 | + | |
| 390 | + assert_equal body, Environment.default.signup_welcome_screen_body | |
| 391 | + assert !Environment.default.signup_welcome_screen_body.blank? | |
| 392 | + end | |
| 393 | + | |
| 384 | 394 | end | ... | ... |
test/unit/environment_test.rb
| ... | ... | @@ -1382,4 +1382,32 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 1382 | 1382 | environment.save! |
| 1383 | 1383 | assert_equal ['en', 'pt'], environment.available_locales |
| 1384 | 1384 | end |
| 1385 | + | |
| 1386 | + should 'not consider custom welcome screen text if not defined' do | |
| 1387 | + env = Environment.default | |
| 1388 | + assert !env.has_custom_welcome_screen? | |
| 1389 | + end | |
| 1390 | + | |
| 1391 | + should 'not consider custom welcome screen text if nil' do | |
| 1392 | + env = Environment.default | |
| 1393 | + | |
| 1394 | + env.signup_welcome_screen_body = nil | |
| 1395 | + assert !env.has_custom_welcome_screen? | |
| 1396 | + end | |
| 1397 | + | |
| 1398 | + should 'consider signup welcome screen if body is defined' do | |
| 1399 | + env = Environment.default | |
| 1400 | + env.signup_welcome_screen_body = 'Welcome to the environment' | |
| 1401 | + assert env.has_custom_welcome_screen? | |
| 1402 | + end | |
| 1403 | + | |
| 1404 | + should 'store custom welcome screen body' do | |
| 1405 | + environment = Environment.default | |
| 1406 | + | |
| 1407 | + environment.signup_welcome_screen_body = 'Welcome to the environment' | |
| 1408 | + environment.save | |
| 1409 | + environment.reload | |
| 1410 | + | |
| 1411 | + assert_equal 'Welcome to the environment', environment.signup_welcome_screen_body | |
| 1412 | + end | |
| 1385 | 1413 | end | ... | ... |