aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-05-29 16:27:31 +0100
committerLouise Crow <louise.crow@gmail.com>2013-05-29 16:27:31 +0100
commitbe5e79381f488de84a4d65492f50f8bc1257396b (patch)
tree0ac879ac5d350d242a6ad5dc6a12f8e243afce02
parent29e6847f609ea0480b15d6b974d10c504c008262 (diff)
parentb97e1af431ca491132cbc56d3bc570639482fffc (diff)
Merge branch 'rails-3-develop' into release/0.11
-rw-r--r--config/initializers/alaveteli.rb4
-rw-r--r--lib/willpaginate_extension.rb59
-rwxr-xr-xscript/alert-comment-on-request3
-rwxr-xr-xscript/alert-new-response-reminders3
-rwxr-xr-xscript/alert-not-clarified-request3
-rwxr-xr-xscript/alert-overdue-requests3
-rwxr-xr-xscript/alert-tracks3
-rwxr-xr-xscript/check-recent-requests-sent3
-rwxr-xr-xscript/clear-caches11
-rwxr-xr-xscript/delete-old-things3
-rwxr-xr-xscript/purge-varnish7
-rwxr-xr-xscript/rails-post-deploy14
-rwxr-xr-xscript/stop-new-responses-on-old-requests3
13 files changed, 32 insertions, 87 deletions
diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb
index a9e9d498d..263e5cf7b 100644
--- a/config/initializers/alaveteli.rb
+++ b/config/initializers/alaveteli.rb
@@ -43,15 +43,11 @@ I18n.locale = default_locale
I18n.available_locales = available_locales.map {|locale_name| locale_name.to_sym}
I18n.default_locale = default_locale
-# Customise will_paginate URL generation
-WillPaginate::ViewHelpers.pagination_options[:renderer] = 'WillPaginateExtension::LinkRenderer'
-
# Load monkey patches and other things from lib/
require 'ruby19.rb'
require 'activesupport_cache_extensions.rb'
require 'use_spans_for_errors.rb'
require 'activerecord_errors_extensions.rb'
-require 'willpaginate_extension.rb'
require 'i18n_fixes.rb'
require 'world_foi_websites.rb'
require 'alaveteli_external_command.rb'
diff --git a/lib/willpaginate_extension.rb b/lib/willpaginate_extension.rb
deleted file mode 100644
index fa58bd9f0..000000000
--- a/lib/willpaginate_extension.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# this extension is loaded in environment.rb
-module WillPaginateExtension
- class LinkRenderer < WillPaginate::ActionView::LinkRenderer
- def page_link(page, text, attributes = {})
- # Hack for admin pages, when proxied via https on mySociety servers, they
- # need a relative URL.
- url = url_for(page)
- if url.match(/\/admin.*(\?.*)/)
- url = $1
- end
- # Hack around our type-ahead search magic
- if url.match(/\/body\/search_ahead/)
- url.sub!("/body/search_ahead", "/select_authority")
- end
- @template.link_to text, url, attributes
- end
-
- # Returns URL params for +page_link_or_span+, taking the current GET params
- # and <tt>:params</tt> option into account.
- def url_for(page)
- page_one = page == 1
- unless @url_string and !page_one
- @url_params = {}
- # page links should preserve GET parameters
- stringified_merge @url_params, @template.params if @template.request.get?
- stringified_merge @url_params, @options[:params] if @options[:params]
- if complex = param_name.index(/[^\w-]/)
- page_param = parse_query_parameters("#{param_name}=#{page}")
-
- stringified_merge @url_params, page_param
- else
- @url_params[param_name] = page_one ? 1 : 2
- end
- # the following line makes pagination work on our specially munged search page
- combined = @template.request.path_parameters["combined"]
- @url_params["combined"] = combined if !combined.nil?
- url = @template.url_for(@url_params)
- return url if page_one
-
- if complex
- @url_string = url.sub(%r!((?:\?|&amp;)#{CGI.escape param_name}=)#{page}!, "\\1\0")
- return url
- else
- @url_string = url
- @url_params[param_name] = 3
- @template.url_for(@url_params).split(//).each_with_index do |char, i|
- if char == '3' and url[i, 1] == '2'
- @url_string[i] = "\0"
- break
- end
- end
- end
- end
- # finally!
- @url_string.sub "\0", page.to_s
- end
-
- end
-end
diff --git a/script/alert-comment-on-request b/script/alert-comment-on-request
index 1222eecf1..849f4a8d8 100755
--- a/script/alert-comment-on-request
+++ b/script/alert-comment-on-request
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'RequestMailer.alert_comment_on_request'
diff --git a/script/alert-new-response-reminders b/script/alert-new-response-reminders
index 97f558f43..148706d49 100755
--- a/script/alert-new-response-reminders
+++ b/script/alert-new-response-reminders
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'RequestMailer.alert_new_response_reminders'
diff --git a/script/alert-not-clarified-request b/script/alert-not-clarified-request
index fb562beeb..8d61c1800 100755
--- a/script/alert-not-clarified-request
+++ b/script/alert-not-clarified-request
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'RequestMailer.alert_not_clarified_request'
diff --git a/script/alert-overdue-requests b/script/alert-overdue-requests
index 9e597d17d..ebc2897a0 100755
--- a/script/alert-overdue-requests
+++ b/script/alert-overdue-requests
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'RequestMailer.alert_overdue_requests'
diff --git a/script/alert-tracks b/script/alert-tracks
index 9fd32f2a1..17426b4e0 100755
--- a/script/alert-tracks
+++ b/script/alert-tracks
@@ -1,5 +1,6 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
if [ "$1" == "--loop" ]
then
bundle exec rails runner 'TrackMailer.alert_tracks_loop'
diff --git a/script/check-recent-requests-sent b/script/check-recent-requests-sent
index 1eb87d498..8f21fb6e7 100755
--- a/script/check-recent-requests-sent
+++ b/script/check-recent-requests-sent
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'MailServerLog.check_recent_requests_have_been_sent'
diff --git a/script/clear-caches b/script/clear-caches
index f97c1f777..20ee3df19 100755
--- a/script/clear-caches
+++ b/script/clear-caches
@@ -1,12 +1,11 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
# Clear the cache of attachment and body text.
-LOC="`dirname "$0"`"
-
bundle exec rails runner "ActiveRecord::Base.connection.execute(\"update incoming_messages set cached_attachment_text_clipped = null, cached_main_body_text_unfolded = null, cached_main_body_text_folded = null, sent_at = null, subject = null, mail_from = null, mail_from_domain = null, valid_to_reply_to = null, last_parsed = null\")"
# Remove page cache (do it in two stages so live site gets cache cleared faster)
-rm -fr $LOC/../old-cache
-mv $LOC/../cache $LOC/../old-cache
-rm -fr $LOC/../old-cache
+rm -fr $TOP_DIR/old-cache
+mv $TOP_DIR/cache $TOP_DIR/old-cache
+rm -fr $TOP_DIR/old-cache
diff --git a/script/delete-old-things b/script/delete-old-things
index 58c144958..a97ba4869 100755
--- a/script/delete-old-things
+++ b/script/delete-old-things
@@ -1,4 +1,5 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'PostRedirect.delete_old_post_redirects'
bundle exec rails runner 'TrackThingsSentEmail.delete_old_track_things_sent_email'
diff --git a/script/purge-varnish b/script/purge-varnish
index 7dcecd4f9..abc6daeaf 100755
--- a/script/purge-varnish
+++ b/script/purge-varnish
@@ -1,11 +1,12 @@
#!/bin/bash
-LOC=`dirname $0`
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
if [ "$1" == "--loop" ]
then
- rails runner 'PurgeRequest.purge_all_loop'
+ bundle exec rails runner 'PurgeRequest.purge_all_loop'
else
- rails runner 'PurgeRequest.purge_all'
+ bundle exec rails runner 'PurgeRequest.purge_all'
fi
diff --git a/script/rails-post-deploy b/script/rails-post-deploy
index a9e239423..4048c852f 100755
--- a/script/rails-post-deploy
+++ b/script/rails-post-deploy
@@ -11,8 +11,8 @@
set -e
#set -x # debug
-APP_DIR="$(readlink -f $(dirname "$BASH_SOURCE")/..)"
-cd "$APP_DIR"
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
# make sure that there is an app directory, so are in a rails app tree
if ! [ -d app ]
@@ -32,11 +32,11 @@ else
fi
# create initial log files
-if [ -e $APP_DIR/../logs ]
+if [ -e $TOP_DIR/../logs ]
then
# mySociety servers have logs dir in level above
rm -f log
- ln -s $APP_DIR/../logs log
+ ln -s $TOP_DIR/../logs log
else
# otherwise just make the directory
if [ -h log ]
@@ -47,10 +47,10 @@ else
mkdir -p log
fi
# link the "downloads" directory in the cache to somewhere it can be served
-if [ ! -e "$APP_DIR/public/download" ]
+if [ ! -e "$TOP_DIR/public/download" ]
then
- mkdir -p "$APP_DIR/cache/zips/download"
- ln -s "$APP_DIR/cache/zips/download" "$APP_DIR/public/"
+ mkdir -p "$TOP_DIR/cache/zips/download"
+ ln -s "$TOP_DIR/cache/zips/download" "$TOP_DIR/public/"
fi
cd log
diff --git a/script/stop-new-responses-on-old-requests b/script/stop-new-responses-on-old-requests
index f317f11ff..07257d6b2 100755
--- a/script/stop-new-responses-on-old-requests
+++ b/script/stop-new-responses-on-old-requests
@@ -1,3 +1,4 @@
#!/bin/bash
-
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
bundle exec rails runner 'InfoRequest.stop_new_responses_on_old_requests'