# Copyright (C) 1998,1999,2000,2001 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""Routines for presentation of list-specific HTML text."""
import re
from Mailman import mm_cfg
from Mailman import Utils
from Mailman.htmlformat import *
from Mailman.i18n import _
EMPTYSTRING = ''
BR = '
'
NL = '\n'
class HTMLFormatter:
def GetMailmanFooter(self):
owners_html = Container()
for i in range(len(self.owner)):
owner = self.owner[i]
owners_html.AddItem(Link('mailto:%s' % owner, owner))
if i + 1 <> len(self.owner):
owners_html.AddItem(', ')
# Remove the .Format() when htmlformat conversion is done.
realname = self.real_name
return Container(
'
', MailmanLogo()))).Format() def FormatUsers(self, digest, lang=None): if lang is None: lang = self.preferred_language conceal_sub = mm_cfg.ConcealSubscription people = [] if digest: digestmembers = self.GetDigestMembers() for dm in digestmembers: if not self.GetUserOption(dm, conceal_sub): people.append(dm) num_concealed = len(digestmembers) - len(people) else: members = self.GetMembers() for m in members: if not self.GetUserOption(m, conceal_sub): people.append(m) num_concealed = len(members) - len(people) people.sort() if (num_concealed > 0): plu = (((num_concealed > 1) and "s") or "") concealed = _( "(%(num_concealed)d private member%(plu)s not shown)") else: concealed = "" ObscureEmail = Utils.ObscureEmail disdel = mm_cfg.DisableDelivery items = [] for person in people: id = ObscureEmail(person) url = self.GetOptionsURL(person) if self.obscure_addresses: showing = ObscureEmail(person, for_text=1) else: showing = person got = Link(url, showing) if self.GetUserOption(person, disdel): got = Italic("(", got, ")") items.append(got) # Just return the .Format() so this works until I finish # converting everything to htmlformat... return (concealed + apply(UnorderedList, tuple(items)).Format()) def FormatOptionButton(self, type, value, user): users_val = self.GetUserOption(user, type) if users_val == value: checked = ' CHECKED' else: checked = '' name = {mm_cfg.DontReceiveOwnPosts : 'dontreceive', mm_cfg.DisableDelivery : 'disablemail', mm_cfg.DisableMime : 'mime', mm_cfg.AcknowledgePosts : 'ackposts', mm_cfg.Digests : 'digest', mm_cfg.ConcealSubscription : 'conceal', mm_cfg.SuppressPasswordReminder : 'remind', }[type] return '' % ( name, value, checked) def FormatDigestButton(self): if self.digest_is_default: checked = ' CHECKED' else: checked = '' return '' % checked def FormatDisabledNotice(self, user): if self.GetUserOption(user, mm_cfg.DisableDelivery): note = FontSize('+1', _( 'Note: your list delivery is currently disabled.')).Format() link = Link('#disable', _('Mail delivery')).Format() mailto = Link('mailto:' + self.GetOwnerEmail(), _('the list administrator')).Format() return _('''
%(note)s
You may have disabled list delivery intentionally, or it may have been triggered by bounces from your email address. In either case, to re-enable delivery, change the %(link)s option below. Contact %(mailto)s if you have any questions or need assistance.''') else: return '' def FormatUmbrellaNotice(self, user, type): addr = self.GetMemberAdminEmail(user) if self.umbrella_list: return _("(Note - you are subscribing to a list of mailing lists, " "so the %(type)s notice will be sent to the admin address" " for your membership, %(addr)s.)
") else: return "" def FormatSubscriptionMsg(self): "Tailor to approval, roster privacy, and web vetting requirements." msg = "" also = "" if self.subscribe_policy == 1: msg = msg + _("You will be sent email requesting confirmation, " "to prevent others from gratuitously subscribing " "you. ") if self.subscribe_policy == 2: msg = msg + _("This is a closed list, which means your " "subscription will be held for approval. You will " "be notified of the administrator's decision by " "email. ") also = _("also ") if self.subscribe_policy == 3: msg = msg + _("You will be sent email requesting confirmation, " "to prevent others from gratuitously subscribing " "you. Once confirmation is received, your " "request will be held for approval by the list " "administrator. You will be notified of the " "administrator's decision by email. ") also = _("also ") if self.private_roster == 1: msg = msg + _("This is %(also)sa private list, which means that " "the members list is not available to non-" "members. ") elif self.private_roster: msg = msg + _("This is %(also)sa hidden list, which means that " "the members list is available only to the " "list administrator. ") else: msg = msg + _("This is %(also)sa public list, which means that the" " members list is openly available") if self.obscure_addresses: msg = msg + _(" (but we obscure the addresses so they are " "not easily recognizable by spammers). ") else: msg = msg + ". " if self.umbrella_list: sfx = self.umbrella_member_suffix msg = msg + _("
(Note that this is an umbrella list, intended to" " have only other mailing lists as members. Among" " other things, this means that your confirmation" " request will be sent to the '%(sfx)s' account for" " your address.)") return msg def FormatUndigestButton(self): if self.digest_is_default: checked = '' else: checked = ' CHECKED' return '' % checked def FormatMimeDigestsButton(self): if self.mime_is_default_digest: checked = ' CHECKED' else: checked = '' return '' % checked def FormatPlainDigestsButton(self): if self.mime_is_default_digest: checked = '' else: checked = ' CHECKED' return '' % checked def FormatEditingOption(self, lang): "Present editing options, according to list privacy." if self.private_roster == 0: either = _('either ') else: either = '' realname = self.real_name text = _('''To change your subscription (set options like digest and delivery modes, get a reminder of your password, or unsubscribe from %(realname)s) %(either)senter your subscription email address:
... or select your entry from " " the subscribers list (see above).") return text def RestrictedListMessage(self, which, restriction): if not restriction: return '' elif restriction == 1: return _( '''(The %(which)s is only available to the list members.)''') else: return _('''(The %(which)s is only available to the list administrator.)''') def FormatRosterOptionForUser(self, lang): return self.RosterOption(lang).Format() def RosterOption(self, lang): "Provide avenue to subscribers roster, contingent to .private_roster." container = Container() if not self.private_roster: container.AddItem(_("Click here for the list of ") + self.real_name + _(" subscribers: ")) container.AddItem(SubmitButton('SubscriberRoster', _("Visit Subscriber list"))) else: if self.private_roster == 1: only = _('members') whom = _('Address:') else: only = _('the list administrator') whom = _('Admin address:') # Solicit the user and password. container.AddItem(self.RestrictedListMessage(_('subscribers list'), self.private_roster) + _("
Enter your ") + whom[:-1].lower() + _(" and password to visit" " the subscribers list: