aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/views/admin_censor_rule/new.html.erb2
-rw-r--r--app/views/request/_sidebar.html.erb4
-rw-r--r--app/views/user/set_crop_profile_photo.html.erb2
-rw-r--r--config/initializers/theme_loader.rb21
-rw-r--r--lib/configuration.rb111
-rw-r--r--lib/tasks/gettext.rake4
-rwxr-xr-xscript/handle-mail-replies.rb4
-rw-r--r--spec/controllers/request_controller_spec.rb2
-rw-r--r--vendor/plugins/acts_as_xapian/README.txt40
-rw-r--r--vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb16
10 files changed, 106 insertions, 100 deletions
diff --git a/app/views/admin_censor_rule/new.html.erb b/app/views/admin_censor_rule/new.html.erb
index 1694308f3..77d22990c 100644
--- a/app/views/admin_censor_rule/new.html.erb
+++ b/app/views/admin_censor_rule/new.html.erb
@@ -1,4 +1,4 @@
-<% @title = 'New censor rule' %>
+<% @title = _('New censor rule') %>
<h1><%=@title%></h1>
diff --git a/app/views/request/_sidebar.html.erb b/app/views/request/_sidebar.html.erb
index e0b01924d..4bc8826fd 100644
--- a/app/views/request/_sidebar.html.erb
+++ b/app/views/request/_sidebar.html.erb
@@ -36,8 +36,8 @@
<h2><%= _("Act on what you've learnt") %></h2>
<div class="act_link">
- <% tweet_link = "https://twitter.com/share?url=#{h(request.url)}&via=#{h(AlaveteliConfiguration::twitter_username)}&text='#{h(@info_request.title)}'&related=#{_('alaveteli_foi:The software that runs {{site_name}}', :site_name => h(site_name))}" %>
- <%= link_to tweet_link do %>
+ <% tweet_link = "https://twitter.com/share?" + {:url => request.url, :via => AlaveteliConfiguration::twitter_username, :text => "'#{@info_request.title}'", :related => _('alaveteli_foi:The software that runs {{site_name}}', :site_name => site_name)}.to_query %>
+ <% link_to tweet_link do %>
<%= image_tag "twitter-16.png", :alt => "twitter icon" %>
<% end %>
<%= link_to _("Tweet this request"), tweet_link %>
diff --git a/app/views/user/set_crop_profile_photo.html.erb b/app/views/user/set_crop_profile_photo.html.erb
index fea7ccab8..0a22d36dc 100644
--- a/app/views/user/set_crop_profile_photo.html.erb
+++ b/app/views/user/set_crop_profile_photo.html.erb
@@ -37,7 +37,7 @@
<p>
<%= hidden_field_tag 'submitted_crop_profile_photo', 1 %>
- <%= submit_tag _("Done") + " &gt;&gt;" %>
+ <%= submit_tag _("Done &gt;&gt;") %>
</p>
<% end %>
diff --git a/config/initializers/theme_loader.rb b/config/initializers/theme_loader.rb
index 4c8967c97..1ad2d01f1 100644
--- a/config/initializers/theme_loader.rb
+++ b/config/initializers/theme_loader.rb
@@ -2,12 +2,23 @@
# It is used by our config/routes.rb to decide which route extension files to load.
$alaveteli_route_extensions = []
-if ENV["RAILS_ENV"] != "test" # Don't let the themes interfere with Alaveteli specs
+def require_theme(theme_name)
+ theme_main_include = File.expand_path "../../../vendor/plugins/#{theme_name}/lib/alavetelitheme.rb", __FILE__
+ if File.exists? theme_main_include
+ require theme_main_include
+ end
+end
+
+if Rails.env == "test"
+ # By setting this ALAVETELI_TEST_THEME to a theme name, theme tests can run in the Rails
+ # context with the theme loaded. Otherwise the themes from the config aren't loaded in testing
+ # so they don't interfere with core Alaveteli tests
+ if defined? ALAVETELI_TEST_THEME
+ require_theme(ALAVETELI_TEST_THEME)
+ end
+else
for url in AlaveteliConfiguration::theme_urls.reverse
theme_name = url.sub(/.*\/(.*).git/, "\\1")
- theme_main_include = File.expand_path "../../../vendor/plugins/#{theme_name}/lib/alavetelitheme.rb", __FILE__
- if File.exists? theme_main_include
- require theme_main_include
- end
+ require_theme(theme_name)
end
end
diff --git a/lib/configuration.rb b/lib/configuration.rb
index cc85f0db3..88890856b 100644
--- a/lib/configuration.rb
+++ b/lib/configuration.rb
@@ -13,60 +13,63 @@ MySociety::Config.load_default
# TODO: Make this return different values depending on the current rails environment
module AlaveteliConfiguration
- DEFAULTS = {
- :ADMIN_PASSWORD => '',
- :ADMIN_USERNAME => '',
- :AVAILABLE_LOCALES => '',
- :BLACKHOLE_PREFIX => 'do-not-reply-to-this-address',
- :BLOG_FEED => '',
- :CONTACT_EMAIL => 'contact@localhost',
- :CONTACT_NAME => 'Alaveteli',
- :COOKIE_STORE_SESSION_SECRET => 'this default is insecure as code is open source, please override for live sites in config/general; this will do for local development',
- :DEBUG_RECORD_MEMORY => false,
- :DEFAULT_LOCALE => '',
- :DISABLE_EMERGENCY_USER => false,
- :DOMAIN => 'localhost:3000',
- :EXCEPTION_NOTIFICATIONS_FROM => '',
- :EXCEPTION_NOTIFICATIONS_TO => '',
- :FORCE_REGISTRATION_ON_NEW_REQUEST => false,
- :FORCE_SSL => true,
- :FORWARD_NONBOUNCE_RESPONSES_TO => 'user-support@localhost',
- :FRONTPAGE_PUBLICBODY_EXAMPLES => '',
- :GA_CODE => '',
- :GAZE_URL => '',
- :HTML_TO_PDF_COMMAND => '',
- :INCLUDE_DEFAULT_LOCALE_IN_URLS => true,
- :INCOMING_EMAIL_DOMAIN => 'localhost',
- :INCOMING_EMAIL_PREFIX => '',
- :INCOMING_EMAIL_SECRET => 'dummysecret',
- :ISO_COUNTRY_CODE => 'GB',
- :MAX_REQUESTS_PER_USER_PER_DAY => '',
- :MTA_LOG_TYPE => 'exim',
- :NEW_RESPONSE_REMINDER_AFTER_DAYS => [3, 10, 24],
- :OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS => '',
- :RAW_EMAILS_LOCATION => 'files/raw_emails',
- :READ_ONLY => '',
- :RECAPTCHA_PRIVATE_KEY => 'x',
- :RECAPTCHA_PUBLIC_KEY => 'x',
- :REPLY_LATE_AFTER_DAYS => 20,
- :REPLY_VERY_LATE_AFTER_DAYS => 40,
- :SITE_NAME => 'Alaveteli',
- :SKIP_ADMIN_AUTH => false,
- :SPECIAL_REPLY_VERY_LATE_AFTER_DAYS => 60,
- :THEME_BRANCH => false,
- :THEME_URL => "",
- :THEME_URLS => [],
- :TIME_ZONE => "UTC",
- :TRACK_SENDER_EMAIL => 'contact@localhost',
- :TRACK_SENDER_NAME => 'Alaveteli',
- :TWITTER_USERNAME => '',
- :TWITTER_WIDGET_ID => false,
- :USE_DEFAULT_BROWSER_LANGUAGE => true,
- :USE_GHOSTSCRIPT_COMPRESSION => false,
- :UTILITY_SEARCH_PATH => ["/usr/bin", "/usr/local/bin"],
- :VARNISH_HOST => '',
- :WORKING_OR_CALENDAR_DAYS => 'working',
- }
+ if !const_defined?(:DEFAULTS)
+
+ DEFAULTS = {
+ :ADMIN_PASSWORD => '',
+ :ADMIN_USERNAME => '',
+ :AVAILABLE_LOCALES => '',
+ :BLACKHOLE_PREFIX => 'do-not-reply-to-this-address',
+ :BLOG_FEED => '',
+ :CONTACT_EMAIL => 'contact@localhost',
+ :CONTACT_NAME => 'Alaveteli',
+ :COOKIE_STORE_SESSION_SECRET => 'this default is insecure as code is open source, please override for live sites in config/general; this will do for local development',
+ :DEBUG_RECORD_MEMORY => false,
+ :DEFAULT_LOCALE => '',
+ :DISABLE_EMERGENCY_USER => false,
+ :DOMAIN => 'localhost:3000',
+ :EXCEPTION_NOTIFICATIONS_FROM => '',
+ :EXCEPTION_NOTIFICATIONS_TO => '',
+ :FORCE_REGISTRATION_ON_NEW_REQUEST => false,
+ :FORCE_SSL => true,
+ :FORWARD_NONBOUNCE_RESPONSES_TO => 'user-support@localhost',
+ :FRONTPAGE_PUBLICBODY_EXAMPLES => '',
+ :GA_CODE => '',
+ :GAZE_URL => '',
+ :HTML_TO_PDF_COMMAND => '',
+ :INCLUDE_DEFAULT_LOCALE_IN_URLS => true,
+ :INCOMING_EMAIL_DOMAIN => 'localhost',
+ :INCOMING_EMAIL_PREFIX => '',
+ :INCOMING_EMAIL_SECRET => 'dummysecret',
+ :ISO_COUNTRY_CODE => 'GB',
+ :MAX_REQUESTS_PER_USER_PER_DAY => '',
+ :MTA_LOG_TYPE => 'exim',
+ :NEW_RESPONSE_REMINDER_AFTER_DAYS => [3, 10, 24],
+ :OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS => '',
+ :RAW_EMAILS_LOCATION => 'files/raw_emails',
+ :READ_ONLY => '',
+ :RECAPTCHA_PRIVATE_KEY => 'x',
+ :RECAPTCHA_PUBLIC_KEY => 'x',
+ :REPLY_LATE_AFTER_DAYS => 20,
+ :REPLY_VERY_LATE_AFTER_DAYS => 40,
+ :SITE_NAME => 'Alaveteli',
+ :SKIP_ADMIN_AUTH => false,
+ :SPECIAL_REPLY_VERY_LATE_AFTER_DAYS => 60,
+ :THEME_BRANCH => false,
+ :THEME_URL => "",
+ :THEME_URLS => [],
+ :TIME_ZONE => "UTC",
+ :TRACK_SENDER_EMAIL => 'contact@localhost',
+ :TRACK_SENDER_NAME => 'Alaveteli',
+ :TWITTER_USERNAME => '',
+ :TWITTER_WIDGET_ID => false,
+ :USE_DEFAULT_BROWSER_LANGUAGE => true,
+ :USE_GHOSTSCRIPT_COMPRESSION => false,
+ :UTILITY_SEARCH_PATH => ["/usr/bin", "/usr/local/bin"],
+ :VARNISH_HOST => '',
+ :WORKING_OR_CALENDAR_DAYS => 'working',
+ }
+ end
def AlaveteliConfiguration.method_missing(name)
key = name.to_s.upcase
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
index c73c2584e..ace7205ae 100644
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -1,7 +1,3 @@
-# Rails won't automatically load rakefiles from gems - see
-# http://stackoverflow.com/questions/1878640/including-rake-tasks-in-gems
-Dir["#{Gem.searcher.find('gettext_i18n_rails').full_gem_path}/lib/tasks/**/*.rake"].each { |ext| load ext }
-
namespace :gettext do
desc 'Rewrite .po files into a consistent msgmerge format'
diff --git a/script/handle-mail-replies.rb b/script/handle-mail-replies.rb
index 7a68e22e3..be6bd10da 100755
--- a/script/handle-mail-replies.rb
+++ b/script/handle-mail-replies.rb
@@ -14,8 +14,12 @@
# config file ourselves.
$alaveteli_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
$:.push(File.join($alaveteli_dir, "commonlib", "rblib"))
+load 'config.rb'
$:.push(File.join($alaveteli_dir, "lib"))
$:.push(File.join($alaveteli_dir, "lib", "mail_handler"))
+load 'configuration.rb'
+MySociety::Config.set_file(File.join($alaveteli_dir, 'config', 'general'), true)
+MySociety::Config.load_default
require 'mail_handler'
def main(in_test_mode)
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 20420b96d..657837c72 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -907,6 +907,7 @@ describe RequestController, "when searching for an authority" do
# so we make sure we're logged in, just in case
before do
@user = users(:bob_smith_user)
+ get_fixtures_xapian_index
end
it "should return nothing for the empty query string" do
@@ -918,7 +919,6 @@ describe RequestController, "when searching for an authority" do
end
it "should return matching bodies" do
- get_fixtures_xapian_index
session[:user_id] = @user.id
get :select_authority, :query => "Quango"
diff --git a/vendor/plugins/acts_as_xapian/README.txt b/vendor/plugins/acts_as_xapian/README.txt
index 62cef2f24..a1d22ef3f 100644
--- a/vendor/plugins/acts_as_xapian/README.txt
+++ b/vendor/plugins/acts_as_xapian/README.txt
@@ -14,7 +14,7 @@ copied from the README.txt file.
Contents
========
-* a. Introduction to acts_as_xapian
+* a. Introduction to acts_as_xapian
* b. Installation
* c. Comparison to acts_as_solr (as on 24 April 2008)
* d. Documentation - indexing
@@ -33,14 +33,14 @@ alternative to acts_as_solr, acts_as_ferret, Ultrasphinx, acts_as_indexed,
acts_as_searchable or acts_as_tsearch.
acts_as_xapian is deployed in production on these websites.
-* "WhatDoTheyKnow":http://www.whatdotheyknow.com
+* "WhatDoTheyKnow":http://www.whatdotheyknow.com
* "MindBites":http://www.mindbites.com
-The section "c. Comparison to acts_as_solr" below will give you an idea of
+The section "c. Comparison to acts_as_solr" below will give you an idea of
acts_as_xapian's features.
acts_as_xapian was started by Francis Irving in May 2008 for search and email
-alerts in WhatDoTheyKnow, and so was supported by "mySociety":http://www.mysociety.org
+alerts in WhatDoTheyKnow, and so was supported by "mySociety":http://www.mysociety.org
and initially paid for by the "JRSST Charitable Trust":http://www.jrrt.org.uk/jrsstct.htm
@@ -52,11 +52,11 @@ this command within your Rails app.
git clone git://github.com/frabcus/acts_as_xapian.git vendor/plugins/acts_as_xapian
-Xapian 1.0.5 and associated Ruby bindings are also required.
+Xapian 1.0.5 and associated Ruby bindings are also required.
-Debian or Ubuntu - install the packages libxapian15 and libxapian-ruby1.8.
+Debian or Ubuntu - install the packages libxapian15 and libxapian-ruby1.8.
-Mac OSX - follow the instructions for installing from source on
+Mac OSX - follow the instructions for installing from source on
the "Installing Xapian":http://xapian.org/docs/install.html page - you need the
Xapian library and bindings (you don't need Omega).
@@ -102,7 +102,7 @@ Solr getting in the way whenever you want to use a new feature from Lucene.
* No Java - an advantage if you're more used to working in the rest of the
open source world. acts_as_xapian, it's pure Ruby and C++.
-* Xapian's awesome email list - the kids over at
+* Xapian's awesome email list - the kids over at
"xapian-discuss":http://lists.xapian.org/mailman/listinfo/xapian-discuss
are super helpful. Useful if you need to extend and improve acts_as_xapian. The
Ruby bindings are mature and well maintained as part of Xapian.
@@ -131,11 +131,11 @@ Here's how to add indexing to your Rails app:
Options must include:
-* :texts, an array of fields for indexing with full text search.
+* :texts, an array of fields for indexing with full text search.
e.g. :texts => [ :title, :body ]
-* :values, things which have a range of values for sorting, or for collapsing.
-Specify an array quadruple of [ field, identifier, prefix, type ] where
+* :values, things which have a range of values for sorting, or for collapsing.
+Specify an array quadruple of [ field, identifier, prefix, type ] where
** identifier is an arbitary numeric identifier for use in the Xapian database
** prefix is the part to use in search queries that goes before the :
** type can be any of :string, :number or :date
@@ -143,8 +143,8 @@ Specify an array quadruple of [ field, identifier, prefix, type ] where
e.g. :values => [ [ :created_at, 0, "created_at", :date ],
[ :size, 1, "size", :string ] ]
-* :terms, things which come with a prefix (before a :) in search queries.
-Specify an array triple of [ field, char, prefix ] where
+* :terms, things which come with a prefix (before a :) in search queries.
+Specify an array triple of [ field, char, prefix ] where
** char is an arbitary single upper case char used in the Xapian database, just
pick any single uppercase character, but use a different one for each prefix.
** prefix is the part to use in search queries that goes before the :
@@ -152,7 +152,7 @@ For example, if you were making Google and indexing to be able to later do a
query like "site:www.whatdotheyknow.com", then the prefix would be "site".
e.g. :terms => [ [ :variety, 'V', "variety" ] ]
-
+
A 'field' is a symbol referring to either an attribute or a function which
returns the text, date or number to index. Both 'identifier' and 'char' must be
the same for the same prefix in different models.
@@ -170,7 +170,7 @@ object isn't indexed
3. Call 'rake xapian:rebuild_index models="ModelName1 ModelName2"' to build the index
the first time (you must specify all your indexed models). It's put in a
-development/test/production dir in acts_as_xapian/xapiandbs. See f. Configuration
+development/test/production dir in acts_as_xapian/xapiandbs. See f. Configuration
below if you want to change this.
4. Then from a cron job or a daemon, or by hand regularly!, call 'rake xapian:update_index'
@@ -201,10 +201,10 @@ And then a hash of options:
* :sort_by_ascending - Default true (documents with higher values better/earlier), set to false for descending sort
* :collapse_by_prefix - Optionally, prefix of value to collapse by (i.e. only return most relevant result from group)
-Google like query syntax is as described in
+Google like query syntax is as described in
"Xapian::QueryParser Syntax":http://www.xapian.org/docs/queryparser.html
Queries can include prefix:value parts, according to what you indexed in the
-acts_as_xapian part above. You can also say things like model:InfoRequestEvent
+acts_as_xapian part above. You can also say things like model:InfoRequestEvent
to constrain by model in more complex ways than the :model parameter, or
modelid:InfoRequestEvent-100 to only find one specific object.
@@ -236,12 +236,12 @@ f. Configuration
================
If you want to customise the configuration of acts_as_xapian, it will look for
-a file called 'xapian.yml' under RAILS_ROOT/config. As is familiar from the
+a file called 'xapian.yml' under Rails.root/config. As is familiar from the
format of the database.yml file, separate :development, :test and :production
sections are expected.
The following options are available:
-* base_db_path - specifies the directory, relative to RAILS_ROOT, in which
+* base_db_path - specifies the directory, relative to Rails.root, in which
acts_as_xapian stores its search index databases. Default is the directory
xapiandbs within the acts_as_xapian directory.
@@ -264,7 +264,7 @@ temporarily add this to the end of your config/environment.rb
h. Support
==========
-Please ask any questions on the
+Please ask any questions on the
"acts_as_xapian Google Group":http://groups.google.com/group/acts_as_xapian
The official home page and repository for acts_as_xapian are the
diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
index 725f53512..d45308fec 100644
--- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
+++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
@@ -92,12 +92,12 @@ module ActsAsXapian
raise "Set RAILS_ENV, so acts_as_xapian can find the right Xapian database" if not environment
# check for a config file
- config_file = Rails.root.to_s + "/config/xapian.yml"
+ config_file = Rails.root.join("config","xapian.yml")
@@config = File.exists?(config_file) ? YAML.load_file(config_file)[environment] : {}
# figure out where the DBs should go
if config['base_db_path']
- db_parent_path = RAILS_ROOT + "/" + config['base_db_path']
+ db_parent_path = Rails.root.join(config['base_db_path'])
else
db_parent_path = File.join(File.dirname(__FILE__), '../xapiandbs/')
end
@@ -717,16 +717,8 @@ module ActsAsXapian
if not $?.success?
raise "batch fork child failed, exiting also"
end
-
- # FIXME: Under Rails 3.1 we get "SSL error: decryption failed or bad record mac", this works around it
- retry_count = 0
- begin
- # database connection doesn't survive a fork, rebuild it
- ActiveRecord::Base.connection.reconnect!
- rescue
- retry_count += 1
- retry_count > 3 ? raise : retry
- end
+ # database connection doesn't survive a fork, rebuild it
+ ActiveRecord::Base.connection.reconnect!
else
# fully reopen the database each time (with a new object)