aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.ruby-version2
-rw-r--r--.travis.yml1
-rw-r--r--Gemfile6
-rw-r--r--Gemfile.lock62
-rw-r--r--Rakefile4
-rw-r--r--app/models/foi_attachment.rb2
-rw-r--r--app/views/admin_public_body/_form.html.erb2
-rw-r--r--config/application.rb1
-rw-r--r--doc/INSTALL.md9
-rw-r--r--doc/THEME-ASSETS-UPGRADE.md5
-rw-r--r--lib/quiet_opener.rb37
-rw-r--r--lib/tasks/themes.rake26
-rwxr-xr-xscript/rails-post-deploy5
-rwxr-xr-xscript/switch-theme.rb25
15 files changed, 122 insertions, 66 deletions
diff --git a/.gitignore b/.gitignore
index 9e9a4b9f7..537a7abf2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,4 +28,5 @@ alaveteli.sublime*
webrat.log
/.rbenv-version
/db/development_structure.sql
+/db/structure.sql
/public/assets
diff --git a/.ruby-version b/.ruby-version
index 2aaf2528c..7fa1d1ef4 100644
--- a/.ruby-version
+++ b/.ruby-version
@@ -1 +1 @@
-ruby-1.9.3-p392
+2.0.0-p353
diff --git a/.travis.yml b/.travis.yml
index 051dc0fae..d6ed72cf6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,6 +6,7 @@ branches:
rvm:
- 1.8.7
- 1.9.3
+ - 2.0.0
before_install:
- gem install rake --version=0.9.2.2
- git submodule update --init --recursive
diff --git a/Gemfile b/Gemfile
index 83042995a..7e33a5f12 100644
--- a/Gemfile
+++ b/Gemfile
@@ -7,7 +7,7 @@ if File.exist? "/etc/debian_version" and File.open("/etc/debian_version").read.s
end
source 'https://rubygems.org'
-gem 'rails', '3.2.15'
+gem 'rails', '3.2.16'
gem 'pg'
@@ -23,7 +23,7 @@ gem 'jquery-ui-rails'
gem 'json'
gem 'mahoro'
gem 'memcache-client'
-gem 'net-http-local'
+gem 'net-http-local', :platforms => [:ruby_18, :ruby_19]
gem 'net-purge'
gem 'newrelic_rpm'
gem 'rack'
@@ -48,7 +48,6 @@ gem 'zip'
gem 'fast_gettext'
gem 'gettext_i18n_rails'
gem 'gettext'
-
gem 'globalize3', :git => 'git://github.com/globalize/globalize.git', :ref => '5fd95f2389dff1'
gem 'locale'
gem 'routing-filter'
@@ -78,6 +77,7 @@ end
group :develop do
gem 'ruby-debug', :platforms => :ruby_18
gem 'debugger', :platforms => :ruby_19
+ gem 'byebug', :platforms => :ruby_20
gem 'annotate'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 46c018352..c5c1fa3b4 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -18,12 +18,12 @@ GIT
GEM
remote: https://rubygems.org/
specs:
- actionmailer (3.2.15)
- actionpack (= 3.2.15)
+ actionmailer (3.2.16)
+ actionpack (= 3.2.16)
mail (~> 2.5.4)
- actionpack (3.2.15)
- activemodel (= 3.2.15)
- activesupport (= 3.2.15)
+ actionpack (3.2.16)
+ activemodel (= 3.2.16)
+ activesupport (= 3.2.16)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
@@ -31,26 +31,29 @@ GEM
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
- activemodel (3.2.15)
- activesupport (= 3.2.15)
+ activemodel (3.2.16)
+ activesupport (= 3.2.16)
builder (~> 3.0.0)
- activerecord (3.2.15)
- activemodel (= 3.2.15)
- activesupport (= 3.2.15)
+ activerecord (3.2.16)
+ activemodel (= 3.2.16)
+ activesupport (= 3.2.16)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.15)
- activemodel (= 3.2.15)
- activesupport (= 3.2.15)
- activesupport (3.2.15)
+ activeresource (3.2.16)
+ activemodel (= 3.2.16)
+ activesupport (= 3.2.16)
+ activesupport (3.2.16)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
annotate (2.5.0)
rake
- arel (3.0.2)
+ arel (3.0.3)
bootstrap-sass (2.3.1.2)
sass (~> 3.2)
builder (3.0.4)
+ byebug (2.3.1)
+ columnize (~> 0.3.6)
+ debugger-linecache (~> 1.2.0)
capistrano (2.15.4)
highline
net-scp (>= 1.0.0)
@@ -113,7 +116,7 @@ GEM
tilt
highline (1.6.19)
hike (1.2.3)
- i18n (0.6.5)
+ i18n (0.6.9)
journey (1.0.4)
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
@@ -139,7 +142,7 @@ GEM
sqlite3 (~> 1.3)
thin (~> 1.5.0)
memcache-client (1.8.5)
- mime-types (1.25)
+ mime-types (1.25.1)
multi_json (1.8.2)
net-http-local (0.1.2)
net-purge (0.1.0)
@@ -166,19 +169,19 @@ GEM
rack
rack-test (0.6.2)
rack (>= 1.0)
- rails (3.2.15)
- actionmailer (= 3.2.15)
- actionpack (= 3.2.15)
- activerecord (= 3.2.15)
- activeresource (= 3.2.15)
- activesupport (= 3.2.15)
+ rails (3.2.16)
+ actionmailer (= 3.2.16)
+ actionpack (= 3.2.16)
+ activerecord (= 3.2.16)
+ activeresource (= 3.2.16)
+ activesupport (= 3.2.16)
bundler (~> 1.0)
- railties (= 3.2.15)
+ railties (= 3.2.16)
rails-i18n (0.7.3)
i18n (~> 0.5)
- railties (3.2.15)
- actionpack (= 3.2.15)
- activesupport (= 3.2.15)
+ railties (3.2.16)
+ actionpack (= 3.2.16)
+ activesupport (= 3.2.16)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@@ -261,7 +264,7 @@ GEM
multi_json (~> 1.0, >= 1.0.2)
unicode (0.4.4)
unidecoder (1.1.2)
- vpim (0.695)
+ vpim (13.11.11)
webrat (0.7.3)
nokogiri (>= 1.2.0)
rack (>= 1.0)
@@ -278,6 +281,7 @@ DEPENDENCIES
acts_as_versioned!
annotate
bootstrap-sass
+ byebug
capistrano
charlock_holmes
coffee-rails (~> 3.2.1)
@@ -306,7 +310,7 @@ DEPENDENCIES
nokogiri
pg
rack
- rails (= 3.2.15)
+ rails (= 3.2.16)
rails-i18n
rake (= 0.9.2.2)
rdoc
diff --git a/Rakefile b/Rakefile
index 5fa2a360d..09582dd77 100644
--- a/Rakefile
+++ b/Rakefile
@@ -5,5 +5,7 @@ require File.expand_path('../config/application', __FILE__)
require 'rake'
Alaveteli::Application.load_tasks
if Rails.env == 'test'
- Dir[File.join(File.dirname(__FILE__),'commonlib','rblib','tests','*.rake')].each { |file| load(file) }
+ Dir[Rails.root.join('commonlib','rblib','tests','*.rake')].each { |file| load(file) }
end
+# Make sure the the acts_as_xapian tasks are also loaded:
+Dir[Rails.root.join('lib','acts_as_xapian','tasks','*.rake')].each { |file| load(file) }
diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb
index 914420a2b..acbfc8a34 100644
--- a/app/models/foi_attachment.rb
+++ b/app/models/foi_attachment.rb
@@ -69,7 +69,7 @@ class FoiAttachment < ActiveRecord::Base
tries = 0
delay = 1
begin
- binary_data = File.open(self.filepath, "rb" ).read
+ binary_data = File.open(self.filepath, "rb" ){ |file| file.read }
if self.content_type =~ /^text/
@cached_body = convert_string_to_utf8_or_binary(binary_data, 'UTF-8')
else
diff --git a/app/views/admin_public_body/_form.html.erb b/app/views/admin_public_body/_form.html.erb
index c577d1e18..18bf1d15b 100644
--- a/app/views/admin_public_body/_form.html.erb
+++ b/app/views/admin_public_body/_form.html.erb
@@ -82,7 +82,7 @@
</div>
</div>
<div class="control-group">
- <label for="public_body_home_page"><%=_("Home page")%></label>
+ <label for="public_body_home_page" class="control-label"><%=_("Home page")%></label>
<div class="controls">
<%= f.text_field :home_page, :class => "span4" %>
<p class="help-block">(of whole authority, not just their FOI page; set to <strong>blank</strong> (empty string) to guess it from the email)</p>
diff --git a/config/application.rb b/config/application.rb
index f2b662abc..dba3a0c57 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -31,6 +31,7 @@ module Alaveteli
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
+ I18n.config.enforce_available_locales = false
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
diff --git a/doc/INSTALL.md b/doc/INSTALL.md
index f39789936..3decb53a3 100644
--- a/doc/INSTALL.md
+++ b/doc/INSTALL.md
@@ -15,11 +15,10 @@ This creates an instance that runs in development mode, so we
wouldn't recommend you use it for a production system without
changing the configuration.
-If you haven't used Amazon Web Services before, then you can get
-a Micro instance which will be
-[free for a year](http://aws.amazon.com/free/). You will find
-that a micro instance isn't powerful enough for anything other
-very basic testing of Alaveteli, however.
+Unfortunately, Alaveteli will not run properly on a free Micro
+instance due to the low amount of memory available on those
+instances; you will need to use at least a Small instance, which
+Amazon will charge for.
The AMI can be found in the EU West (Ireland) region, with the
ID ami-0f24c678 and name “Basic Alaveteli installation
diff --git a/doc/THEME-ASSETS-UPGRADE.md b/doc/THEME-ASSETS-UPGRADE.md
index 66a1e95f4..2c6e49986 100644
--- a/doc/THEME-ASSETS-UPGRADE.md
+++ b/doc/THEME-ASSETS-UPGRADE.md
@@ -67,3 +67,8 @@ should be mentioned in `lib/alavetelitheme.rb` with:
You should be left with nothing in the `public` directory after
making these changes, except possibly custom error pages.
+
+Remove the code that symlinks the theme 'public' directory to a
+subdirectory of the main application's 'public' directory from
+install.rb. Also remove the code from uninstall.rb that removes that
+symlink. The asset pipeline will handle making assets available.
diff --git a/lib/quiet_opener.rb b/lib/quiet_opener.rb
index ae6605c43..16ea27b8e 100644
--- a/lib/quiet_opener.rb
+++ b/lib/quiet_opener.rb
@@ -1,6 +1,8 @@
require 'open-uri'
require 'net-purge'
-require 'net/http/local'
+if RUBY_VERSION.to_f < 2.0
+ require 'net/http/local'
+end
def quietly_try_to_open(url)
begin
@@ -12,17 +14,36 @@ def quietly_try_to_open(url)
return result
end
+# On Ruby versions before 2.0, we need to use the net-http-local gem
+# to force the use of 127.0.0.1 as the local interface for the
+# connection. However, at the time of writing this gem doesn't work
+# on Ruby 2.0 and it's not necessary with that Ruby version - one can
+# supply a :local_host option to Net::HTTP:start. So, this helper
+# function is to abstract away that difference, and can be used as you
+# would Net::HTTP.start(host) when passed a block.
+def http_from_localhost(host)
+ if RUBY_VERSION.to_f >= 2.0
+ Net::HTTP.start(host, :local_host => '127.0.0.1') do |http|
+ yield http
+ end
+ else
+ Net::HTTP.bind '127.0.0.1' do
+ Net::HTTP.start(host) do |http|
+ yield http
+ end
+ end
+ end
+end
+
def quietly_try_to_purge(host, url)
begin
result = ""
result_body = ""
- Net::HTTP.bind '127.0.0.1' do
- Net::HTTP.start(host) {|http|
- request = Net::HTTP::Purge.new(url)
- response = http.request(request)
- result = response.code
- result_body = response.body
- }
+ http_from_localhost(host) do |http|
+ request = Net::HTTP::Purge.new(url)
+ response = http.request(request)
+ result = response.code
+ result_body = response.body
end
rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET, Errno::ENETUNREACH
Rails.logger.warn("PURGE: Unable to reach host #{host}")
diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake
index 78ffe73be..65b142a63 100644
--- a/lib/tasks/themes.rake
+++ b/lib/tasks/themes.rake
@@ -9,6 +9,14 @@ namespace :themes do
File.join(plugin_dir, theme_name)
end
+ def old_theme_dir(theme_name)
+ File.join(Rails.root, "vendor", "plugins", theme_name)
+ end
+
+ def possible_theme_dirs(theme_name)
+ [theme_dir(theme_name), old_theme_dir(theme_name)]
+ end
+
def checkout(commitish)
puts "Checking out #{commitish}" if verbose
system "git checkout #{commitish}"
@@ -61,13 +69,14 @@ namespace :themes do
end
def uninstall(theme_name, verbose=false)
- dir = theme_dir(theme_name)
- if File.directory?(dir)
- run_hook(theme_name, 'uninstall', verbose)
- puts "Removing '#{dir}'" if verbose
- rm_r dir
- else
- puts "Plugin doesn't exist: #{dir}"
+ possible_theme_dirs(theme_name).each do |dir|
+ if File.directory?(dir)
+ run_hook(theme_name, 'uninstall', verbose)
+ puts "Removing '#{dir}'" if verbose
+ rm_r dir
+ else
+ puts "Plugin doesn't exist: #{dir}"
+ end
end
end
@@ -80,10 +89,11 @@ namespace :themes do
end
def installed?(theme_name)
- File.directory?(theme_dir(theme_name))
+ possible_theme_dirs(theme_name).any? { |dir| File.directory? dir }
end
def install_theme(theme_url, verbose, deprecated=false)
+ FileUtils.mkdir_p plugin_dir
deprecation_string = deprecated ? " using deprecated THEME_URL" : ""
theme_name = theme_url_to_theme_name theme_url
puts "Installing theme #{theme_name}#{deprecation_string} from #{theme_url}"
diff --git a/script/rails-post-deploy b/script/rails-post-deploy
index bd5165a72..a88e28b19 100755
--- a/script/rails-post-deploy
+++ b/script/rails-post-deploy
@@ -97,4 +97,7 @@ bundle exec rake db:migrate #--trace
bundle exec rake themes:install
-bundle exec rake assets:precompile
+if [ "$OPTION_STAGING_SITE" = "0" ]
+then
+ bundle exec rake assets:precompile
+fi
diff --git a/script/switch-theme.rb b/script/switch-theme.rb
index e6afcebb9..980853687 100755
--- a/script/switch-theme.rb
+++ b/script/switch-theme.rb
@@ -31,6 +31,7 @@
require 'tempfile'
+$no_theme_name = 'none'
theme_directory = ENV['ALAVETELI_THEMES_DIR']
alaveteli_directory = File.expand_path(File.join(File.dirname(__FILE__),
".."))
@@ -53,7 +54,9 @@ $available_themes = Dir.entries(theme_directory).find_all do |local_theme_name|
next unless File.directory? full_path
next unless File.directory? File.join(full_path, '.git')
local_theme_name
-end
+end.sort
+
+$available_themes.unshift $no_theme_name
if $available_themes.empty?
STDERR.puts "There were no theme directories found in '#{theme_directory}'"
@@ -62,7 +65,7 @@ end
def usage_and_exit
STDERR.puts "Usage: #{$0} <THEME-NAME>"
- $available_themes.sort.each do |theme_name|
+ $available_themes.each do |theme_name|
STDERR.puts " #{theme_name}"
end
exit 1
@@ -108,13 +111,19 @@ symlink(File.basename(theme_filename),
config_directory,
"general.yml")
-symlink(File.join(full_theme_path, 'public'),
- File.join(alaveteli_directory, 'public'),
- 'alavetelitheme')
+public_directory = File.join(alaveteli_directory, 'public')
-symlink(full_theme_path,
- File.join(alaveteli_directory, 'lib', 'themes'),
- requested_theme)
+if requested_theme == $no_theme_name
+ File.unlink File.join(public_directory, 'alavetelitheme')
+else
+ symlink(File.join(full_theme_path, 'public'),
+ public_directory,
+ 'alavetelitheme')
+
+ symlink(full_theme_path,
+ File.join(alaveteli_directory, 'lib', 'themes'),
+ requested_theme)
+end
STDERR.puts """Switched to #{requested_theme}!
You will need to: