diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/alavetelitheme.rb | 34 | ||||
| -rw-r--r-- | lib/config/custom-routes.rb | 8 | ||||
| -rw-r--r-- | lib/controller_patches.rb | 22 | ||||
| -rw-r--r-- | lib/customstates.rb | 100 | ||||
| -rw-r--r-- | lib/model_patches.rb | 16 | ||||
| -rw-r--r-- | lib/patch_mailer_paths.rb | 8 | 
6 files changed, 94 insertions, 94 deletions
diff --git a/lib/alavetelitheme.rb b/lib/alavetelitheme.rb index c8611d5..c245617 100644 --- a/lib/alavetelitheme.rb +++ b/lib/alavetelitheme.rb @@ -3,15 +3,15 @@ theme_name.gsub!('-', '_')  THEME_NAME = theme_name  class ActionController::Base -    # The following prepends the path of the current theme's views to -    # the "filter_path" that Rails searches when deciding which -    # template to use for a view.  It does so by creating a method -    # uniquely named for this theme. -    path_function_name = "set_view_paths_for_#{THEME_NAME}" -    before_filter path_function_name.to_sym -    send :define_method, path_function_name do -        self.prepend_view_path File.join(File.dirname(__FILE__), "views") -    end +  # The following prepends the path of the current theme's views to +  # the "filter_path" that Rails searches when deciding which +  # template to use for a view.  It does so by creating a method +  # uniquely named for this theme. +  path_function_name = "set_view_paths_for_#{THEME_NAME}" +  before_filter path_function_name.to_sym +  send :define_method, path_function_name do +    self.prepend_view_path File.join(File.dirname(__FILE__), "views") +  end  end  # In order to have the theme lib/ folder ahead of the main app one, @@ -27,7 +27,7 @@ end  for patch in ['controller_patches.rb',                'model_patches.rb',                'patch_mailer_paths.rb'] -    require File.expand_path "../#{patch}", __FILE__ +  require File.expand_path "../#{patch}", __FILE__  end  # Note you should rename the file at "config/custom-routes.rb" to @@ -36,19 +36,19 @@ $alaveteli_route_extensions << 'custom-routes.rb'  # Prepend the asset directories in this theme to the asset path:  ['stylesheets', 'images', 'javascripts'].each do |asset_type| -    theme_asset_path = File.join(File.dirname(__FILE__), -                                 '..', -                                 'assets', -                                 asset_type) -    Rails.application.config.assets.paths.unshift theme_asset_path +  theme_asset_path = File.join(File.dirname(__FILE__), +                               '..', +                               'assets', +                               asset_type) +  Rails.application.config.assets.paths.unshift theme_asset_path  end  # Tell FastGettext about the theme's translations: look in the theme's  # locale-theme directory for a translation in the first place, and if  # it isn't found, look in the Alaveteli locale directory next:  repos = [ -    FastGettext::TranslationRepository.build('app', :path=>File.join(File.dirname(__FILE__), '..', 'locale-theme'), :type => :po), -    FastGettext::TranslationRepository.build('app', :path=>'locale', :type => :po) +  FastGettext::TranslationRepository.build('app', :path=>File.join(File.dirname(__FILE__), '..', 'locale-theme'), :type => :po), +  FastGettext::TranslationRepository.build('app', :path=>'locale', :type => :po)  ]  FastGettext.add_text_domain 'app', :type=>:chain, :chain=>repos  FastGettext.default_text_domain = 'app' diff --git a/lib/config/custom-routes.rb b/lib/config/custom-routes.rb index 589154a..6d4cda4 100644 --- a/lib/config/custom-routes.rb +++ b/lib/config/custom-routes.rb @@ -1,8 +1,8 @@  # Here you can override or add to the pages in the core website  Rails.application.routes.draw do -    # brand new controller example -    # match '/mycontroller' => 'general#mycontroller' -    # Additional help page example -    # match '/help/help_out' => 'help#help_out' +  # brand new controller example +  # match '/mycontroller' => 'general#mycontroller' +  # Additional help page example +  # match '/help/help_out' => 'help#help_out'  end diff --git a/lib/controller_patches.rb b/lib/controller_patches.rb index 6923062..5c48e70 100644 --- a/lib/controller_patches.rb +++ b/lib/controller_patches.rb @@ -5,15 +5,15 @@  # See http://stackoverflow.com/questions/7072758/plugin-not-reloading-in-development-mode  #  Rails.configuration.to_prepare do -    # Example adding an instance variable to the frontpage controller -    # GeneralController.class_eval do -    #     def mycontroller -    #         @say_something = "Greetings friend" -    #     end -    # end -    # Example adding a new action to an existing controller -    # HelpController.class_eval do -    #     def help_out -    #     end -    # end +  # Example adding an instance variable to the frontpage controller +  # GeneralController.class_eval do +  #   def mycontroller +  #     @say_something = "Greetings friend" +  #   end +  # end +  # Example adding a new action to an existing controller +  # HelpController.class_eval do +  #   def help_out +  #   end +  # end  end diff --git a/lib/customstates.rb b/lib/customstates.rb index 73a1bfa..d801c92 100644 --- a/lib/customstates.rb +++ b/lib/customstates.rb @@ -3,64 +3,64 @@  module InfoRequestCustomStates -    def self.included(base) -        base.extend(ClassMethods) -    end - -    # Work out what the situation of the request is. In addition to -    # values of self.described_state, in base Alaveteli can return -    # these (calculated) values: -    #   waiting_classification -    #   waiting_response_overdue -    #   waiting_response_very_overdue -    def theme_calculate_status -        # just fall back to the core calculation -        return self.base_calculate_status -    end +  def self.included(base) +    base.extend(ClassMethods) +  end -    # Mixin methods for InfoRequest -    module ClassMethods +  # Work out what the situation of the request is. In addition to +  # values of self.described_state, in base Alaveteli can return +  # these (calculated) values: +  #   waiting_classification +  #   waiting_response_overdue +  #   waiting_response_very_overdue +  def theme_calculate_status +    # just fall back to the core calculation +    return self.base_calculate_status +  end -        # Return the name of a custom status. -        # Example of how to add a custom status: -        # def theme_display_status(status) -        #     if status == 'transferred' -        #         _("Transferred.") -        #     else -        #         raise _("unknown status ") + status -        #     end -        # end -        def theme_display_status(status) -            raise _("unknown status ") + status -        end +  # Mixin methods for InfoRequest +  module ClassMethods -        # Return the list of custom statuses added by the theme. -        # Example of how to add a custom status: -        # def theme_extra_states -        #     return ['transferred'] -        # end -        def theme_extra_states -            return [] -        end +    # Return the name of a custom status. +    # Example of how to add a custom status: +    # def theme_display_status(status) +    #     if status == 'transferred' +    #         _("Transferred.") +    #     else +    #         raise _("unknown status ") + status +    #     end +    # end +    def theme_display_status(status) +      raise _("unknown status ") + status +    end +    # Return the list of custom statuses added by the theme. +    # Example of how to add a custom status: +    # def theme_extra_states +    #     return ['transferred'] +    # end +    def theme_extra_states +      return []      end + +  end  end  module RequestControllerCustomStates -    # `theme_describe_state` is called after the core describe_state code. -    # It should end by raising an error if the status is unknown. -    # Example of how to add a custom status: -    # def theme_describe_state(info_request) -    #     if info_request.calculate_status == 'transferred' -    #         flash[:notice] = _("Authority has transferred your request to a different public body.") -    #         redirect_to request_url(@info_request) -    #     else -    #         raise "unknown calculate_status " + info_request.calculate_status -    #     end -    # end -    def theme_describe_state(info_request) -        raise "unknown calculate_status " + info_request.calculate_status -    end +  # `theme_describe_state` is called after the core describe_state code. +  # It should end by raising an error if the status is unknown. +  # Example of how to add a custom status: +  # def theme_describe_state(info_request) +  #   if info_request.calculate_status == 'transferred' +  #     flash[:notice] = _("Authority has transferred your request to a different public body.") +  #       redirect_to request_url(@info_request) +  #   else +  #     raise "unknown calculate_status " + info_request.calculate_status +  #   end +  # end +  def theme_describe_state(info_request) +    raise "unknown calculate_status " + info_request.calculate_status +  end  end diff --git a/lib/model_patches.rb b/lib/model_patches.rb index 1564dc4..7f3b4de 100644 --- a/lib/model_patches.rb +++ b/lib/model_patches.rb @@ -6,12 +6,12 @@  #  Rails.configuration.to_prepare do -    # Example of adding a default text to each message -    # OutgoingMessage.class_eval do -    #     # Add intro paragraph to new request template -    #     def default_letter -    #         return nil if self.message_type == 'followup' -    #         "If you uncomment this line, this text will appear as default text in every message" -    #     end -    # end +  # Example of adding a default text to each message +  # OutgoingMessage.class_eval do +  #   # Add intro paragraph to new request template +  #   def default_letter +  #     return nil if self.message_type == 'followup' +  #     "If you uncomment this line, this text will appear as default text in every message" +  #   end +  # end  end diff --git a/lib/patch_mailer_paths.rb b/lib/patch_mailer_paths.rb index 7a524fa..99da10a 100644 --- a/lib/patch_mailer_paths.rb +++ b/lib/patch_mailer_paths.rb @@ -3,8 +3,8 @@  # See http://stackoverflow.com/questions/7072758/plugin-not-reloading-in-development-mode  #  Rails.configuration.to_prepare do -    # Override mailer templates with theme ones. Note doing this in a before_filter, -    # as we do with the controller paths, doesn't seem to have any effect when -    # running in production -    ActionMailer::Base.prepend_view_path File.join(File.dirname(__FILE__), "views") +  # Override mailer templates with theme ones. Note doing this in a before_filter, +  # as we do with the controller paths, doesn't seem to have any effect when +  # running in production +  ActionMailer::Base.prepend_view_path File.join(File.dirname(__FILE__), "views")  end  | 
