aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2016-04-04 14:59:27 +0100
committerLouise Crow <louise.crow@gmail.com>2016-04-06 15:42:42 +0100
commit4bd2c48f7f1f75d71b3eaed73e3893a2b42b0fee (patch)
tree88c6e500c615312a3dc2fc988d071a53064a71ec /lib
parentc596594a6907ea478a3f62a6adfa8688d60412a2 (diff)
Make code customization commented out examples.
Rather than having them be live code.
Diffstat (limited to 'lib')
-rw-r--r--lib/config/custom-routes.rb4
-rw-r--r--lib/controller_patches.rb19
-rw-r--r--lib/customstates.rb50
-rw-r--r--lib/model_patches.rb16
-rw-r--r--lib/views/general/mycontroller.html.erb7
-rw-r--r--lib/views/help/about.es.html.erb8
-rw-r--r--lib/views/help/help_out.html.erb9
-rw-r--r--lib/views/outgoing_mailer/initial_request.text.erb15
8 files changed, 54 insertions, 74 deletions
diff --git a/lib/config/custom-routes.rb b/lib/config/custom-routes.rb
index 5aeb7c2..589154a 100644
--- a/lib/config/custom-routes.rb
+++ b/lib/config/custom-routes.rb
@@ -2,7 +2,7 @@
Rails.application.routes.draw do
# brand new controller example
- match '/mycontroller' => 'general#mycontroller'
+ # match '/mycontroller' => 'general#mycontroller'
# Additional help page example
- match '/help/help_out' => 'help#help_out'
+ # match '/help/help_out' => 'help#help_out'
end
diff --git a/lib/controller_patches.rb b/lib/controller_patches.rb
index 9959f86..6923062 100644
--- a/lib/controller_patches.rb
+++ b/lib/controller_patches.rb
@@ -6,13 +6,14 @@
#
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
- HelpController.class_eval do
- def help_out
- end
- end
+ # 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 c09eb8c..73a1bfa 100644
--- a/lib/customstates.rb
+++ b/lib/customstates.rb
@@ -1,5 +1,5 @@
-# See `doc/THEMES.md` for more explanation of this file
-# This example adds a "transferred" state to requests.
+# See `http://alaveteli.org/docs/customising/themes/#customising-the-request-states`
+# for more explanation of this file
module InfoRequestCustomStates
@@ -19,32 +19,48 @@ module InfoRequestCustomStates
end
# Mixin methods for InfoRequest
- module ClassMethods
+ module ClassMethods
+
+ # 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)
- if status == 'transferred'
- _("Transferred.")
- else
- raise _("unknown status ") + status
- end
+ 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 ['transferred']
+ 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)
- # called after the core describe_state code. It should
- # end by raising an error if the status is unknown
- 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
+ raise "unknown calculate_status " + info_request.calculate_status
end
end
diff --git a/lib/model_patches.rb b/lib/model_patches.rb
index 8abd4e8..1564dc4 100644
--- a/lib/model_patches.rb
+++ b/lib/model_patches.rb
@@ -5,11 +5,13 @@
# See http://stackoverflow.com/questions/7072758/plugin-not-reloading-in-development-mode
#
Rails.configuration.to_prepare do
- 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/views/general/mycontroller.html.erb b/lib/views/general/mycontroller.html.erb
deleted file mode 100644
index ad642d3..0000000
--- a/lib/views/general/mycontroller.html.erb
+++ /dev/null
@@ -1,7 +0,0 @@
-<% @title = "My new controller" %>
-
-<h1>My new controller</h1>
-
-<p>This is a view of a controller that does almost nothing, except output the words <code><%= @say_something %></code></p>
-
-
diff --git a/lib/views/help/about.es.html.erb b/lib/views/help/about.es.html.erb
deleted file mode 100644
index 9588249..0000000
--- a/lib/views/help/about.es.html.erb
+++ /dev/null
@@ -1,8 +0,0 @@
-<% @title = "Sobre" %>
-<%#-*- coding: utf8 -*-%>
-<%= render :partial => 'sidebar' %>
-
-<div id="left_column_flip">
- <h1>¡Bonjiorno amis!</h1>
- <p>Esta sito tu aidare a faire los requestio</p>
-</div>
diff --git a/lib/views/help/help_out.html.erb b/lib/views/help/help_out.html.erb
deleted file mode 100644
index 6fadca4..0000000
--- a/lib/views/help/help_out.html.erb
+++ /dev/null
@@ -1,9 +0,0 @@
-<% @title = "Help out" %>
-
-<%= render :partial => 'sidebar' %>
-<div id="left_column_flip">
- <h1>Help us!</h1>
-
- <p>This is a custom "help out" page, showing how you can add new pages to Alaveteli from within a theme.</p>
-</div>
-
diff --git a/lib/views/outgoing_mailer/initial_request.text.erb b/lib/views/outgoing_mailer/initial_request.text.erb
deleted file mode 100644
index f7878ac..0000000
--- a/lib/views/outgoing_mailer/initial_request.text.erb
+++ /dev/null
@@ -1,15 +0,0 @@
-<%= raw @outgoing_message.body.strip %>
-
--------------------------------------------------------------------
-
-<%= _('This is an FOI request done via the {{site_name}} website. This footer has been overriden by the sample Alaveteli theme.', :site_name => site_name) %>
-
-<%= _('Please use this email address for all replies to this request:')%>
-<%= @info_request.incoming_email %>
-
-<%= _('Is {{email_address}} the wrong address for {{type_of_request}} requests to {{public_body_name}}? If so, please contact us using this form:', :email_address => @info_request.public_body.request_email, :type_of_request => @info_request.law_used_human(:full), :public_body_name => @info_request.public_body.name)%>
-<%= new_change_request_url(:body => @info_request.public_body.url_name) %>
-
-<%= render :partial => 'followup_footer' %>
-
--------------------------------------------------------------------