aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/alaveteli_text_masker.rb35
-rw-r--r--lib/configuration.rb12
2 files changed, 34 insertions, 13 deletions
diff --git a/lib/alaveteli_text_masker.rb b/lib/alaveteli_text_masker.rb
index 68ff0d318..5d836f66c 100644
--- a/lib/alaveteli_text_masker.rb
+++ b/lib/alaveteli_text_masker.rb
@@ -28,9 +28,7 @@ module AlaveteliTextMasker
end
def apply_pdf_masks!(text, options = {})
- uncompressed_text = nil
- uncompressed_text = AlaveteliExternalCommand.run("pdftk", "-", "output", "-", "uncompress",
- :stdin_string => text)
+ uncompressed_text = uncompress_pdf(text)
# if we managed to uncompress the PDF...
if !uncompressed_text.blank?
# then censor stuff (making a copy so can compare again in a bit)
@@ -39,19 +37,13 @@ module AlaveteliTextMasker
# if the censor rule removed something...
if censored_uncompressed_text != uncompressed_text
# then use the altered file (recompressed)
- recompressed_text = nil
- if AlaveteliConfiguration::use_ghostscript_compression == true
- command = ["gs", "-sDEVICE=pdfwrite", "-dCompatibilityLevel=1.4", "-dPDFSETTINGS=/screen", "-dNOPAUSE", "-dQUIET", "-dBATCH", "-sOutputFile=-", "-"]
- else
- command = ["pdftk", "-", "output", "-", "compress"]
- end
- recompressed_text = AlaveteliExternalCommand.run(*(command + [{:stdin_string=>censored_uncompressed_text}]))
+ recompressed_text = compress_pdf(censored_uncompressed_text)
if recompressed_text.blank?
# buggy versions of pdftk sometimes fail on
# compression, I don't see it's a disaster in
# these cases to save an uncompressed version?
recompressed_text = censored_uncompressed_text
- logger.warn "Unable to compress PDF; problem with your pdftk version?"
+ Rails.logger.warn "Unable to compress PDF; problem with your pdftk version?"
end
if !recompressed_text.blank?
text.replace recompressed_text
@@ -62,6 +54,27 @@ module AlaveteliTextMasker
private
+ def uncompress_pdf(text)
+ AlaveteliExternalCommand.run("pdftk", "-", "output", "-", "uncompress", :stdin_string => text)
+ end
+
+ def compress_pdf(text)
+ if AlaveteliConfiguration::use_ghostscript_compression
+ command = ["gs",
+ "-sDEVICE=pdfwrite",
+ "-dCompatibilityLevel=1.4",
+ "-dPDFSETTINGS=/screen",
+ "-dNOPAUSE",
+ "-dQUIET",
+ "-dBATCH",
+ "-sOutputFile=-",
+ "-"]
+ else
+ command = ["pdftk", "-", "output", "-", "compress"]
+ end
+ AlaveteliExternalCommand.run(*(command + [ :stdin_string => text ]))
+ end
+
# Replace text in place
def apply_binary_masks!(text, options = {})
# Keep original size, so can check haven't resized it
diff --git a/lib/configuration.rb b/lib/configuration.rb
index 90fd30d5f..7921b93fa 100644
--- a/lib/configuration.rb
+++ b/lib/configuration.rb
@@ -52,6 +52,7 @@ module AlaveteliConfiguration
:MTA_LOG_TYPE => 'exim',
:NEW_RESPONSE_REMINDER_AFTER_DAYS => [3, 10, 24],
:OVERRIDE_ALL_PUBLIC_BODY_REQUEST_EMAILS => '',
+ :PRODUCTION_MAILER_DELIVERY_METHOD => 'sendmail',
:PUBLIC_BODY_STATISTICS_PAGE => false,
:PUBLIC_BODY_LIST_FALLBACK_TO_DEFAULT_LOCALE => false,
:RAW_EMAILS_LOCATION => 'files/raw_emails',
@@ -63,6 +64,13 @@ module AlaveteliConfiguration
:RESPONSIVE_STYLING => true,
:SITE_NAME => 'Alaveteli',
:SKIP_ADMIN_AUTH => false,
+ :SMTP_MAILER_ADDRESS => 'localhost',
+ :SMTP_MAILER_PORT => 25,
+ :SMTP_MAILER_DOMAIN => '',
+ :SMTP_MAILER_USER_NAME => '',
+ :SMTP_MAILER_PASSWORD => '',
+ :SMTP_MAILER_AUTHENTICATION => 'plain',
+ :SMTP_MAILER_ENABLE_STARTTLS_AUTO => true,
:SPECIAL_REPLY_VERY_LATE_AFTER_DAYS => 60,
:THEME_BRANCH => false,
:THEME_URL => "",
@@ -77,9 +85,9 @@ module AlaveteliConfiguration
:USE_MAILCATCHER_IN_DEVELOPMENT => true,
:UTILITY_SEARCH_PATH => ["/usr/bin", "/usr/local/bin"],
:VARNISH_HOST => '',
- :WORKING_OR_CALENDAR_DAYS => 'working',
+ :WORKING_OR_CALENDAR_DAYS => 'working'
}
- end
+ end
def AlaveteliConfiguration.method_missing(name)
key = name.to_s.upcase