aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2011-07-14 08:43:40 +0100
committerSeb Bacon <seb.bacon@gmail.com>2011-07-14 08:43:40 +0100
commitbb790631de2973f8009af558cc9d9a6a70a6efc9 (patch)
treef8b4eea6246690b724a45adb522d45e1c6708b55
parent13885a4933e7ac4c9e54116dc216e2132ada77da (diff)
parent4f3f88db01057af00db2796cd5a996e7f69fc8cd (diff)
Merge branch 'master' of github.com:sebbacon/alaveteli
Conflicts: app/views/request/_request_listing_single.rhtml
-rw-r--r--app/models/incoming_message.rb52
m---------commonlib0
-rw-r--r--config/general-example89
-rw-r--r--config/packages1
-rw-r--r--config/routes.rb6
-rw-r--r--spec/controllers/admin_general_controller_spec.rb1
-rw-r--r--spec/controllers/admin_request_controller_spec.rb3
-rw-r--r--spec/controllers/admin_user_controller_spec.rb1
8 files changed, 39 insertions, 114 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 4d3c08df3..0ad668afb 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -1144,27 +1144,12 @@ class IncomingMessage < ActiveRecord::Base
end
elsif content_type == 'application/zip'
# recurse into zip files
- zip_file = Zip::ZipFile.open(tempfile.path)
- for entry in zip_file
- if entry.file?
- filename = entry.to_s
- begin
- body = entry.get_input_stream.read
- rescue
- # move to next attachment silently if there were problems
- # XXX really should reduce this to specific exceptions?
- # e.g. password protected
- next
- end
- calc_mime = AlaveteliFileTypes.filename_to_mimetype(filename)
- if calc_mime
- content_type = calc_mime
- else
- content_type = 'application/octet-stream'
- end
-
- text += _get_attachment_text_internal_one_file(content_type, body)
- end
+ begin
+ zip_file = Zip::ZipFile.open(tempfile.path)
+ text += _get_attachment_text_from_zip_file(zip_file)
+ zip_file.close()
+ rescue
+ $stderr.puts("Error processing zip file: #{$!.inspect}")
end
end
tempfile.close
@@ -1172,6 +1157,31 @@ class IncomingMessage < ActiveRecord::Base
return text
end
+ def _get_attachment_text_from_zip_file(zip_file)
+ text = ""
+ for entry in zip_file
+ if entry.file?
+ filename = entry.to_s
+ begin
+ body = entry.get_input_stream.read
+ rescue
+ # move to next attachment silently if there were problems
+ # XXX really should reduce this to specific exceptions?
+ # e.g. password protected
+ next
+ end
+ calc_mime = AlaveteliFileTypes.filename_to_mimetype(filename)
+ if calc_mime
+ content_type = calc_mime
+ else
+ content_type = 'application/octet-stream'
+ end
+
+ text += _get_attachment_text_internal_one_file(content_type, body)
+ end
+ end
+ return text
+ end
def _get_attachment_text_internal
# Extract text from each attachment
text = ''
diff --git a/commonlib b/commonlib
-Subproject 6f3c48c96be88c3f20b15a1488bd35c00c2448f
+Subproject a87ebeae21166b3b4a8a66b32399861fcd6d0c4
diff --git a/config/general-example b/config/general-example
deleted file mode 100644
index 981e118ca..000000000
--- a/config/general-example
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-/*
- * general-example:
- * Example values for the "general" config file.
- *
- * Configuration parameters, in PHP syntax. Configuration parameters are set
- * using the PHP define('OPTION_...', '...') function. Both perl and PHP code
- * parse this properly, so you can use comments and conditionals and whatnot,
- * but unless essential it's better to keep it simple....
- *
- * Copy this file to one called "general" in the same directory. Or
- * have multiple config files and use a symlink to change between them.
- *
- * NOTE ON USE IN RAILS: So that people don't have to have PHP installed just
- * to run this stuff, by convention we always provide a default config value
- * in the source code when reading the config option. The Rails application
- * should run fine without the general config file, it is a bug if it does not.
- *
- * Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
- * Email: francis@mysociety.org; WWW: http://www.mysociety.org
- *
- * $Id: general-example,v 1.18 2009-02-09 10:37:13 francis Exp $
- *
- */
-
-// Doesn't do anything right now.
-define('OPTION_STAGING_SITE', 1);
-
-// Domain used in URLs generated by scripts (e.g. for going in some emails)
-define('OPTION_DOMAIN', '127.0.0.1:3000');
-
-// Domain used in URLs generated by scripts (e.g. for going in some emails)
-define('OPTION_SITE_NAME', 'Alaveteli');
-define('OPTION_CONTACT_EMAIL', 'postmaster@localhost');
-define('OPTION_CONTACT_NAME', 'Alaveteli Webmaster');
-
-// Workflow settings
-define('OPTION_REPLY_LATE_AFTER_DAYS', 20);
-
-// Blog and Twitter
-define('OPTION_BLOG_FEED', 'http://www.mysociety.org/category/projects/whatdotheyknow/feed/');
-define('OPTION_TWITTER_USERNAME', 'whatdotheyknow');
-
-
-// Incoming email
-define('OPTION_INCOMING_EMAIL_DOMAIN', 'localhost'); // e.g. 'foifa.com'
-define('OPTION_INCOMING_EMAIL_PREFIX', ''); // e.g. 'foi+'
-define('OPTION_INCOMING_EMAIL_SECRET', 'xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx'); // used for hash in request email address
-define('OPTION_BLACKHOLE_PREFIX', 'do-not-reply-to-this-address'); // used as envelope from at the incoming email domain for cases where we don't care about failure
-
-// Administration
-// To completely skip admin authentication, set these to empty strings
-define('OPTION_ADMIN_USERNAME', 'adminxxxx');
-define('OPTION_ADMIN_PASSWORD', 'passwordx');
-
-define('OPTION_ADMIN_BASE_URL', '/admin/');
-
-
-
-// Where /stylesheets sits under for admin pages. See asset_host in
-// config/environment.rb. Can be full domain or relative path (not an absolute path beginning with /).
-define('OPTION_ADMIN_PUBLIC_URL', '');
-
-// Secret key for signing cookie_store sessions
-define('OPTION_COOKIE_STORE_SESSION_SECRET', 'your secret key here, make it long and random');
-
-// If present, puts the site in read only mode, and uses the text as reason
-// (whole paragraph). Please use a read-only database user as well, as it only
-// checks in a few obvious places.
-define('OPTION_READ_ONLY', '');
-
-// Recaptcha, for detecting humans. Get keys here: http://recaptcha.net/whyrecaptcha.html
-define('OPTION_RECAPTCHA_PUBLIC_KEY', 'x');
-define('OPTION_RECAPTCHA_PRIVATE_KEY', 'x');
-
-// Locales we wish to support in this app
-define('OPTION_AVAILABLE_LOCALES', 'en es');
-define('DEFAULT_LOCALE', 'en');
-
-// example searches for the home page, semicolon delimited
-define('OPTION_FRONTPAGE_SEARCH_EXAMPLES', 'Geraldine Quango; Department for Humpadinking');
-
-// example public bodies for the home page, semicolon delimited - short_names
-define('OPTION_FRONTPAGE_PUBLICBODY_EXAMPLES', 'tgq');
-
-// URL of theme to install
-define('OPTION_THEME_URL', 'git://github.com/mysociety/whatdotheyknow-theme.git');
-
-?>
diff --git a/config/packages b/config/packages
index 95c3dcfed..4695ea828 100644
--- a/config/packages
+++ b/config/packages
@@ -39,3 +39,4 @@ memcached
rubygems
libfcgi-dev
gettext
+python-yaml
diff --git a/config/routes.rb b/config/routes.rb
index ec0e24f67..175a37a82 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -17,7 +17,7 @@ ActionController::Routing::Routes.draw do |map|
map.with_options :controller => 'general' do |general|
general.frontpage '/', :action => 'frontpage'
general.blog '/blog', :action => 'blog'
- general.custom_css '/stylesheets/custom.css', :action => 'custom_css'
+ general.custom_css '/stylesheets/custom.css', :action => 'custom_css'
general.search_redirect '/search', :action => 'search_redirect'
# XXX combined is the search query, and then if sorted a "/newest" at the end.
# Couldn't find a way to do this in routes which also picked up multiple other slashes
@@ -114,8 +114,8 @@ ActionController::Routing::Routes.draw do |map|
help.help_officers '/help/officers', :action => 'officers'
help.help_requesting '/help/requesting', :action => 'requesting'
help.help_privacy '/help/privacy', :action => 'privacy'
- help.help_api '/help/api', :action => 'api'
- help.help_credits '/help/credits', :action => 'credits'
+ help.help_api '/help/api', :action => 'api'
+ help.help_credits '/help/credits', :action => 'credits'
help.help_general '/help/:action', :action => :action
end
diff --git a/spec/controllers/admin_general_controller_spec.rb b/spec/controllers/admin_general_controller_spec.rb
index d1ac4cbb2..4c3708268 100644
--- a/spec/controllers/admin_general_controller_spec.rb
+++ b/spec/controllers/admin_general_controller_spec.rb
@@ -2,6 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminGeneralController, "when viewing front page of admin interface" do
integrate_views
+ before { basic_auth_login @request }
it "should render the front page" do
get :index
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb
index c6e9ca5bb..d82e4a49c 100644
--- a/spec/controllers/admin_request_controller_spec.rb
+++ b/spec/controllers/admin_request_controller_spec.rb
@@ -3,7 +3,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminRequestController, "when administering requests" do
integrate_views
fixtures :info_requests, :outgoing_messages, :users, :info_request_events
-
+ before { basic_auth_login @request }
+
it "shows the index/list page" do
get :index
end
diff --git a/spec/controllers/admin_user_controller_spec.rb b/spec/controllers/admin_user_controller_spec.rb
index a9159f529..313f3f328 100644
--- a/spec/controllers/admin_user_controller_spec.rb
+++ b/spec/controllers/admin_user_controller_spec.rb
@@ -3,6 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe AdminUserController, "when administering users" do
integrate_views
fixtures :users
+ before { basic_auth_login @request }
it "shows the index/list page" do
get :index