diff options
author | petterreinholdtsen <pere@hungry.com> | 2016-11-04 15:19:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-04 15:19:22 +0100 |
commit | 996bae955f7edcd49c9b3e8ffbcb31bce4e574e1 (patch) | |
tree | 29f04afff3c167312cfb889a1542adf4e4b38264 | |
parent | 32968e39cb9b29b0e84051a9a5333db287f1c5af (diff) | |
parent | 427b100104ec5637aa5bc614c6308d94b3beafbf (diff) |
Merge pull request #5 from petterreinholdtsen/norwegian-top-quoters
Improve handling of Norwegian top quoters.
-rw-r--r-- | lib/model_patches.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/model_patches.rb b/lib/model_patches.rb index 7f3b4de..a4ca42e 100644 --- a/lib/model_patches.rb +++ b/lib/model_patches.rb @@ -14,4 +14,24 @@ Rails.configuration.to_prepare do # "If you uncomment this line, this text will appear as default text in every message" # end # end + + # Based on alaveteli/app/models/incoming_message.rb, see + # https://github.com/mysociety/alaveteli/issues/2662 + InfoRequest.class_eval do + def self.remove_quoted_sections(text, replacement = "FOLDED_QUOTED_SECTION") + text = text.dup + replacement = "\n" + replacement + "\n" + + # To end of message sections + original_message = + '(' + + # Used in https://www.mimesbronn.no/request/innsyn_i_arkivplan + '''----*\s*Opprinnelig melding\s*----*''' + + ')' + # Could have a ^ at start here, but see messed up formatting here: + # http://www.whatdotheyknow.com/request/refuse_and_recycling_collection#incoming-842 + text.gsub!(/(#{original_message}\n.*)$/mi, replacement) + return text + end + end end |