From 7a758a657e10c5b6a11355c9dad205178342096f Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 27 Jan 2012 13:15:34 +0000 Subject: Add examples of how a user might customise: * routes * gettext translations * categories --- lib/alavetelitheme.rb | 13 +++++++++++++ lib/config/custom-routes.rb | 8 ++++++++ lib/gettext_setup.rb | 14 ++++++++++++++ lib/public_body_categories_en.rb | 7 +++++++ lib/views/help/_sidebar.rhtml | 21 +++++++++++++++++++++ lib/views/help/help_out.rhml | 9 +++++++++ lib/views/help/help_out.rhtml | 9 +++++++++ 7 files changed, 81 insertions(+) create mode 100644 lib/config/custom-routes.rb create mode 100644 lib/gettext_setup.rb create mode 100644 lib/public_body_categories_en.rb create mode 100644 lib/views/help/_sidebar.rhtml create mode 100644 lib/views/help/help_out.rhml create mode 100644 lib/views/help/help_out.rhtml (limited to 'lib') diff --git a/lib/alavetelitheme.rb b/lib/alavetelitheme.rb index fa2749c..58defaa 100644 --- a/lib/alavetelitheme.rb +++ b/lib/alavetelitheme.rb @@ -5,3 +5,16 @@ class ActionController::Base 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, +# inspired in Ruby Guides explanation: http://guides.rubyonrails.org/plugins.html +%w{ . }.each do |dir| + path = File.join(File.dirname(__FILE__), dir) + $LOAD_PATH.insert(0, path) + ActiveSupport::Dependencies.autoload_paths << path + ActiveSupport::Dependencies.autoload_once_paths.delete(path) +end + + +# Plug theme-specific locale strings +require 'gettext_setup.rb' diff --git a/lib/config/custom-routes.rb b/lib/config/custom-routes.rb new file mode 100644 index 0000000..2c1b9cc --- /dev/null +++ b/lib/config/custom-routes.rb @@ -0,0 +1,8 @@ +# Here you can override or add to the pages in the core website + +ActionController::Routing::Routes.draw do |map| + # Additional help page example + map.with_options :controller => 'help' do |help| + help.help_out '/help/help_out', :action => 'help_out' + end +end diff --git a/lib/gettext_setup.rb b/lib/gettext_setup.rb new file mode 100644 index 0000000..5b7a455 --- /dev/null +++ b/lib/gettext_setup.rb @@ -0,0 +1,14 @@ +# Add a callback - to be executed before each request in development, +# and at startup in production - to plug in theme locale strings. +require 'dispatcher' +Dispatcher.to_prepare do + repos = [ + 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' +end + + + diff --git a/lib/public_body_categories_en.rb b/lib/public_body_categories_en.rb new file mode 100644 index 0000000..f3c0aa4 --- /dev/null +++ b/lib/public_body_categories_en.rb @@ -0,0 +1,7 @@ +PublicBodyCategories.add(:en, [ + "Silly ministries", + [ "useless_agency", "Useless ministries", "a useless ministry" ], + [ "lonely_agency", "Lonely agencies", "a lonely agency"], + "Popular agencies", + [ "popular_agency", "Popular agencies", "a lonely agency"] +]) diff --git a/lib/views/help/_sidebar.rhtml b/lib/views/help/_sidebar.rhtml new file mode 100644 index 0000000..92dd49a --- /dev/null +++ b/lib/views/help/_sidebar.rhtml @@ -0,0 +1,21 @@ +
+

Help pages

+ + +

Contact us

+

If your question isn't answered here, or you just wanted to let us know + something about the site, contact us. +

+
+ + diff --git a/lib/views/help/help_out.rhml b/lib/views/help/help_out.rhml new file mode 100644 index 0000000..6744a27 --- /dev/null +++ b/lib/views/help/help_out.rhml @@ -0,0 +1,9 @@ +<% @title = "Help out" %> + +<%= render :partial => 'sidebar' %> + +

Help us!

+ +

This is a custom "help out" page, showing how you can add new pages to Alaveteli from a theme. There's no navigation to it, though! You'd need to add that in your own custom _sidebar.rhtml

+ + diff --git a/lib/views/help/help_out.rhtml b/lib/views/help/help_out.rhtml new file mode 100644 index 0000000..6fadca4 --- /dev/null +++ b/lib/views/help/help_out.rhtml @@ -0,0 +1,9 @@ +<% @title = "Help out" %> + +<%= render :partial => 'sidebar' %> +
+

Help us!

+ +

This is a custom "help out" page, showing how you can add new pages to Alaveteli from within a theme.

+
+ -- cgit v1.2.3