1 # Copyright (C) 2004-2013 Aaron Swartz
4 # Dmitry Bogatov <KAction@gnu.org>
6 # Etienne Millon <me@emillon.org>
8 # Lindsey Smith <lindsey.smith@gmail.com>
10 # Martin 'Joey' Schulze
12 # W. Trevor King <wking@tremily.us>
14 # This file is part of rss2email.
16 # rss2email is free software: you can redistribute it and/or modify it under
17 # the terms of the GNU General Public License as published by the Free Software
18 # Foundation, either version 2 of the License, or (at your option) version 3 of
21 # rss2email is distributed in the hope that it will be useful, but WITHOUT ANY
22 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
23 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License along with
26 # rss2email. If not, see <http://www.gnu.org/licenses/>.
28 """Per-user rss2email configuration
31 import collections as _collections
32 import configparser as _configparser
34 import html2text as _html2text
37 class Config (_configparser.ConfigParser):
38 def __init__(self, dict_type=_collections.OrderedDict,
39 interpolation=_configparser.ExtendedInterpolation(),
41 super(Config, self).__init__(
42 dict_type=dict_type, interpolation=interpolation, **kwargs)
44 def setup_html2text(self, section='DEFAULT'):
45 """Setup html2text globals to match our configuration
47 Html2text unfortunately uses globals (instead of keyword
48 arguments) to configure its conversion.
50 if section not in self:
52 _html2text.UNICODE_SNOB = self.getboolean(
53 section, 'unicode-snob')
54 _html2text.LINKS_EACH_PARAGRAPH = self.getboolean(
55 section, 'links-after-each-paragraph')
56 _html2text.BODY_WIDTH = self.getint(section, 'body-width')
61 # setup defaults for feeds that don't customize
62 CONFIG['DEFAULT'] = _collections.OrderedDict((
64 # The email address messages are from by default
65 ('from', 'user@rss2email.invalid'),
66 # Transfer-Encoding. For local mailing it is safe and
67 # convient to use 8bit.
68 ('use-8bit', str(False)),
69 # True: Only use the 'from' address.
70 # False: Use the email address specified by the feed, when possible.
71 ('force-from', str(False)),
72 # True: Use the publisher's email if you can't find the author's.
73 # False: Just use the 'from' email instead.
74 ('use-publisher-email', str(False)),
75 # If empty, only use the feed email address rather than
76 # friendly name plus email address. Available attributes may
77 # include 'feed', 'feed-title', 'author', and 'publisher', but
78 # only 'feed' is guaranteed.
79 ('name-format', '{feed-title}: {author}'),
80 # Set this to default To email addresses.
84 # Set an HTTP proxy (e.g. 'http://your.proxy.here:8080/')
86 # Set the timeout (in seconds) for feed server response
87 ('feed-timeout', str(60)),
90 # True: Fetch, process, and email feeds.
91 # False: Don't fetch, process, or email feeds
92 ('active', str(True)),
93 # True: Send a single, multi-entry email per feed per rss2email run.
94 # False: Send a single email per entry.
95 ('digest', str(False)),
96 # True: Generate Date header based on item's date, when possible.
97 # False: Generate Date header based on time sent.
98 ('date-header', str(False)),
99 # A comma-delimited list of some combination of
100 # ('issued', 'created', 'modified', 'expired')
101 # expressing ordered list of preference in dates
102 # to use for the Date header of the email.
103 ('date-header-order', 'modified, issued, created, expired'),
104 # Set this to add bonus headers to all emails
105 # Example: bonus-header = 'Approved: joe@bob.org'
106 ('bonus-header', ''),
107 # True: Receive one email per post.
108 # False: Receive an email every time a post changes.
109 ('trust-guid', str(True)),
110 # True: Receive one email per unique link url.
111 # False: Defer to trust-guid preference.
112 # Toggling this for existing feeds may result in duplicates,
113 # because the old entries will not be recorded under their new
115 ('trust-link', str(False)),
116 # To most correctly encode emails with international
117 # characters, we iterate through the list below and use the
118 # first character set that works.
119 ('encodings', 'US-ASCII, ISO-8859-1, UTF-8, BIG5, ISO-2022-JP'),
120 # User processing hooks. Note the space after the module name.
121 # Example: post-process = 'rss2email.post_process.downcase downcase_message'
122 ('post-process', ''),
123 # User processing hooks for digest messages. If 'digest' is
124 # enabled, the usual 'post-process' hook gets to massage the
125 # per-entry messages, but this hook is called with the full
126 # digest message before it is mailed.
127 # Example: digest-post-process = 'rss2email.post_process.downcase downcase_message'
128 ('digest-post-process', ''),
130 # True: Send text/html messages when possible.
131 # False: Convert HTML to plain text.
132 ('html-mail', str(False)),
133 # Optional CSS styling
134 ('use-css', str(False)),
137 ' font: 18pt Georgia, "Times New Roman";\n'
140 ' font: 12pt Arial;\n'
143 ' font: 12pt Arial;\n'
144 ' font-weight: bold;\n'
148 ' font-family: monospace;\n'
151 ' background: #e0ecff;\n'
152 ' border-bottom: solid 4px #c3d9ff;\n'
154 ' margin-top: 0px;\n'
158 ' font-size: 20px;\n'
159 ' text-decoration: none;\n'
162 ' background: #c3d9ff;\n'
163 ' border-top: solid 4px #c3d9ff;\n'
165 ' margin-bottom: 0px;\n'
168 ' border: solid 4px #c3d9ff;\n'
171 ' margin-left: 5px;\n'
172 ' margin-right: 5px;\n'
175 # Use Unicode characters instead of their ascii psuedo-replacements
176 ('unicode-snob', str(False)),
177 # Put the links after each paragraph instead of at the end.
178 ('links-after-each-paragraph', str(False)),
179 # Wrap long lines at position. 0 for no wrapping.
180 ('body-width', str(0)),
183 # Select protocol from: sendmail, smtp, imap
184 ('email-protocol', 'sendmail'),
185 # True: Use SMTP_SERVER to send mail.
186 # Sendmail (or compatible) configuration
187 ('sendmail', '/usr/sbin/sendmail'), # Path to sendmail (or compatible)
189 ('smtp-auth', str(False)), # set to True to use SMTP AUTH
190 ('smtp-username', 'username'), # username for SMTP AUTH
191 ('smtp-password', 'password'), # password for SMTP AUTH
192 ('smtp-server', 'smtp.yourisp.net:25'),
193 ('smtp-ssl', str(False)), # Connect to the SMTP server using SSL
195 ('imap-auth', str(False)), # set to True to use IMAP auth.
196 ('imap-username', 'username'), # username for IMAP authentication
197 ('imap-password', 'password'), # password for IMAP authentication
198 ('imap-server', 'imap.yourisp.net'),
199 ('imap-port', str(143)),
200 ('imap-ssl', str(False)), # connect to the IMAP server using SSL
201 ('imap-mailbox', 'INBOX'), # where we should store new messages
204 # Verbosity (one of 'error', 'warning', 'info', or 'debug').
205 ('verbose', 'warning'),