Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 390
- Log:
Initial import of Canvass, a donations-based poll application.
- Author:
- rool
- Date:
- Mon Mar 21 14:58:04 +0000 2011
- Size:
- 1921 Bytes
1 | ######################################################################## |
2 | # File:: base_mailer.rb |
3 | # (C):: Hipposoft 2010 |
4 | # |
5 | # Purpose:: Support classes which send e-mail messages. |
6 | # ---------------------------------------------------------------------- |
7 | # 22-May-2010 (ADH): Created. |
8 | # 21-Feb-2011 (ADH): Imported from Artisan. |
9 | ######################################################################## |
10 | |
11 | class BaseMailer < ::ActionMailer::Base |
12 | |
13 | # In Artisan, notification messages are sent as plain text. The line width |
14 | # used for word wrap is set below. It should never exceed 80 as this may |
15 | # make it difficult to view the message with some e-mail clients. |
16 | # |
17 | EMAIL_PLAIN_TEXT_LINE_WIDTH = 70 |
18 | |
19 | # Some of the views require apphelp_site_name(), but we can't risk including |
20 | # the Application Helper as it might collide with bits of Devise for the |
21 | # DeviseMailer sub-class. In addition, the site name is used for subject |
22 | # lines in all messages, so we need the helper method from the models too. |
23 | # This method provides a simple way to get at the site name. |
24 | # |
25 | def self.site_name |
26 | I18n.t( :'uk.org.pond.canvass.site_name' ) |
27 | end |
28 | |
29 | # Return a translated string formatted according to e-mail text width |
30 | # restrictions. The "key" parameter is the leaf key to use in the locale |
31 | # file (e.g. "foo" gives "uk.org.pond.canvass.canvass_mailer.foo" if called |
32 | # via the ArtisanMailer class). Pass a translation substitution hash in the |
33 | # optional second parameter. |
34 | # |
35 | def self.formatted( key, translation_data = {} ) |
36 | # The strange 'extend' stuff is a way of calling through to a helper. |
37 | Object.new.extend( ActionView::Helpers::TextHelper ).word_wrap( |
38 | I18n.t( |
39 | "uk.org.pond.canvass.#{ self.name.tableize.singularize }.#{ key }", |
40 | translation_data.merge!( :default => key ) |
41 | ), |
42 | :line_width => EMAIL_PLAIN_TEXT_LINE_WIDTH |
43 | ) |
44 | end |
45 | end |