webui templates or not?
Hi all,
the plans in http://wiki.list.org/display/DEV/TemplatingNotes and http://wiki.list.org/display/DEV/StyledPages sound great, but mean a lot of work.
For example there is options.py with functions for rendering output named options_page and loginpage.
options_page supports the old template mechanism using options.html However loginpage has hard-coded tables including "BGCOLOR" and such ugly things.
I don't know if someone is still working on the new template mechanism and I couldn't find any changes on options.py either. (What I think is fundamentally necessary for a complete template mechanism.) (I looked in http://bazaar.launchpad.net/~mailman-coders/mailman/2.2/files and http://bazaar.launchpad.net/~mailman-coders/mailman/3.0/files)
So my plan is: For a customer I want to customize more than the standard pages (for example the function loginpage from options.py). I will use the old template system (like in function options_page in options.py), using new template names like <SCRIPT>_<FUNCTION>.html As I think this is useful for others it could maybe be merged in mailman.
So what do you think, is it a waste of time because code for the old template mechanism will never get merged?
I'm looking forward to your suggestions.
bye, Frank
-- Frank Schubert Systemadministration EsPresto AG Breite Str. 30-31 10178 Berlin/Germany Tel: +49.(0)30.90 226.750 Fax: +49.(0)30.90 226.760 f.schubert@espresto.com
HRB 77554 AG - Berlin-Charlottenburg Vorstand: Alexander Biersack, Maya Biersack, Peter Biersack Vorsitzender des Aufsichtsrats: Oli Kai Paulus
Hi,
I started with Cgi/confirm.py
I removed bad_confirmation and replaced it with a more general method (show_informational_message) that takes an optional argument. The optional argument is a message that can be rendered for the web-user.
All directly rendered messages - outside the methods mentioned below - are changed to use the new method show_informational_message.
Because show_informational_message can be used when mlist is unavailable, it searches for a template-file in the default template directory with the default language. (e.g. /var/lib/mailman/templates/en)
The attached patch does *not* cover the following methods, because another template-file is needed for them:
- ask_for_cookie
- subscription_prompt
- unsubscription_prompt
- addrchange_prompt
- heldmsg_prompt
- reenable_prompt
I will cover these with the following patches.
It is my first work with python and Mailman and surly not ready for inclusion. I wanted to get this out as fast as possible to have a base to work on - so please bear with me.
Bye, Frank
-- Frank Schubert Systemadministration EsPresto AG Breite Str. 30-31 10178 Berlin/Germany Tel: +49.(0)30.90 226.750 Fax: +49.(0)30.90 226.760 f.schubert@espresto.com
HRB 77554 AG - Berlin-Charlottenburg Vorstand: Alexander Biersack, Maya Biersack, Peter Biersack Vorsitzender des Aufsichtsrats: Oli Kai Paulus
22a23
import re 51,52c52 < bad_confirmation(doc) < doc.AddItem(MailmanLogo())
show_informational_message(doc)
62,63c62 < bad_confirmation(doc, _('No such list <em>%(safelistname)s</em>')) < doc.AddItem(MailmanLogo())
show_informational_message(doc, _('No such list <em>%(safelistname)s</em>'))
83,84c82 < bad_confirmation(doc) < doc.AddItem(mlist.GetMailmanFooter())
show_informational_message(doc)
107,108c105 < bad_confirmation(doc, badconfirmstr) < doc.AddItem(mlist.GetMailmanFooter())
show_informational_message(doc, badconfirmstr)
165c162 < bad_confirmation(doc, _('System error, bad content: %(content)s'))
show_informational_message(doc, _('System error, bad content: %(content)s'))
167c164 < bad_confirmation(doc, badconfirmstr)
show_informational_message(doc, badconfirmstr)
169d165 < doc.AddItem(mlist.GetMailmanFooter()) 171a168,198
# # Method for showing a simple message with (optionally) a more detailed description # this uses a site-wide template because we have no ml-name # (I replaced all bad_confirmation method calls with show_informational_message) # @author Frank Schubert <f.schubert@espresto.com> #
def show_informational_message(doc, extra=''): doc.suppress_head = 1
message = _('Handling your request:') # Do replacements replacements = { } #replacements['<mm-results>'] = Bold(FontSize('+2', message)).Format() replacements['<mm-results>'] = message replacements['<mm-results-detailed>'] = extra text = Utils.maketext('confirm_show_informational_message.html') parts = re.split('(</?[Mm][Mm]-[^>]*>)', text) i = 1 while i < len(parts): tag = parts[i].lower() if replacements.has_key(tag): repl = replacements[tag] if isinstance(repl, type(u'')): repl = repl.encode(charset, 'replace') parts[i] = repl else: parts[i] = '' i = i + 2 output = EMPTYSTRING.join(parts) doc.AddItem(output)
175,179c202 < title = _('Bad confirmation string') < doc.SetTitle(title) < doc.AddItem(Header(3, Bold(FontAttr(title, color='#ff0000', size='+2')))) < doc.AddItem(extra) <
show_informational_message(doc, extra)
321c344 < doc.AddItem(_('You have canceled your subscription request.'))
show_informational_message(doc, _('You have canceled your subscription request.'))
359,363c382,385
< title = _('Awaiting moderator approval')
< doc.SetTitle(title)
< doc.AddItem(Header(3, Bold(FontAttr(title, size='+2'))))
< doc.AddItem(_("""
< You have successfully confirmed your subscription request to the
show_informational_message(doc, _("""\ <b>Awaiting moderator approval</b> <p>You have successfully confirmed your subscription request to the
367c389 < of the moderator's decision."""))
of the moderator's decision.</p>"""))
369c391 < bad_confirmation(doc, _('''Invalid confirmation string. It is
show_informational_message(doc, _('''Invalid confirmation string. It is
373c395 < doc.addError(_("You are already a member of this mailing list!"))
show_informational_message(doc, _("You are already a member of this mailing list!"))
376c398 < doc.addError(_("""You are currently banned from subscribing to
show_informational_message(doc, _("""<p>You are currently banned from subscribing to
378c400 < contact the list owners at %(owneraddr)s."""))
contact the list owners at %(owneraddr)s.</p>"""))
380,381c402,403
< doc.addError(_("""
< You were not invited to this mailing list. The invitation has
show_informational_message(doc, _("""\ <p>You were not invited to this mailing list. The invitation has
383c405 < alerted."""))
alerted.</p>"""))
392,395c414,415
< doc.SetTitle(title)
< doc.AddItem(Header(3, Bold(FontAttr(title, size='+2'))))
< doc.AddItem(_('''
< You have successfully confirmed your subscription request for
show_informational_message(doc, _('''\ <p>You have successfully confirmed your subscription request for
398c418 < with your password, and other useful information and links.
with your password, and other useful information and links.</p>
412c432 < doc.AddItem(_('You have canceled your unsubscription request.'))
show_informational_message(doc, _('You have canceled your unsubscription request.'))
434c454 < bad_confirmation(doc, _('''Invalid confirmation string. It is
show_informational_message(doc, _('''Invalid confirmation string. It is
440d459
< title = _('Unsubscription request confirmed')
442,445c461,463
< doc.SetTitle(title)
< doc.AddItem(Header(3, Bold(FontAttr(title, size='+2'))))
< doc.AddItem(_("""
< You have successfully unsubscribed from the %(listname)s mailing
show_informational_message(doc, _("""\ <b>Unsubscription request confirmed</b> <p>You have successfully unsubscribed from the %(listname)s mailing
447c465 < information page</a>."""))
information page</a></p>."""))
500c518 < doc.AddItem(_('You have canceled your change of address request.'))
show_informational_message(doc, _('You have canceled your change of address request.'))
523c541 < bad_confirmation(doc, _('''Invalid confirmation string. It is
show_informational_message(doc, _('''<p>Invalid confirmation string. It is
525c543 < address that has already been unsubscribed.'''))
address that has already been unsubscribed.</p>'''))
529c547 < doc.addError(_("""%(newaddr)s is banned from subscribing to the
show_informational_message(doc, _("""<p>%(newaddr)s is banned from subscribing to the
531c549 < please contact the list owners at %(owneraddr)s."""))
please contact the list owners at %(owneraddr)s.</p>"""))
535d552
< title = _('Change of address request confirmed')
537,540c554,556
< doc.SetTitle(title)
< doc.AddItem(Header(3, Bold(FontAttr(title, size='+2'))))
< doc.AddItem(_("""
< You have successfully changed your address on the %(listname)s
show_informational_message(doc, _("""\ <b>Change of address request confirmed</b> <p>You have successfully changed your address on the %(listname)s
543c559 < login page</a>."""))
login page</a>.</p>"""))
603,608d618 < title = _('Continue awaiting approval') < doc.SetTitle(title) < table = Table(border=0, width='100%') < table.AddRow([Center(Bold(FontAttr(title, size='+1')))]) < table.AddCellInfo(table.GetCurrentRowIndex(), 0, < bgcolor=mm_cfg.WEB_HEADER_COLOR) 611,613c621,624 < table.AddRow([_('''Okay, the list moderator will still have the < opportunity to approve or reject this message.''')]) < doc.AddItem(table)
show_informational_message(doc, _('''\ <b>Continue awaiting approval</b> <p>Okay, the list moderator will still have the opportunity to approve or reject this message.</p>'''))
639c650 < bad_confirmation(doc, _('''The held message with the Subject:
show_informational_message(doc, _('''<p>The held message with the Subject:
643c654 < time.'''))
time.</p>'''))
647,651c658,660
< title = _('Posted message canceled')
< doc.SetTitle(title)
< doc.AddItem(Header(3, Bold(FontAttr(title, size='+2'))))
< doc.AddItem(_('''
< You have successfully canceled the posting of your message with
show_informational_message(doc, _('''\ <b>Posted message canceled</b> <p>You have successfully canceled the posting of your message with
653c662 < %(listname)s.'''))
%(listname)s.</p>'''))
686c695 < bad_confirmation(doc, _("""The held message you were referred to has
show_informational_message(doc, _("""The held message you were referred to has
728c737 < doc.AddItem(_("""You have canceled the re-enabling of your membership. If
show_informational_message(doc, _("""<p>You have canceled the re-enabling of your membership. If
730c739 < this mailing list."""))
this mailing list.</p>"""))
752c761 < bad_confirmation(doc, _('''Invalid confirmation string. It is
show_informational_message(doc, _('''Invalid confirmation string. It is
758d766
< title = _('Membership re-enabled.')
760,763c768,770
< doc.SetTitle(title)
< doc.AddItem(Header(3, Bold(FontAttr(title, size='+2'))))
< doc.AddItem(_("""
< You have successfully re-enabled your membership in the
show_informational_message(doc, _("""\ <b>Membership re-enabled.</b> <p>You have successfully re-enabled your membership in the
765c772 < href="%(optionsurl)s">visit your member options page</a>.
href="%(optionsurl)s">visit your member options page</a>.</p>
participants (1)
-
Frank Schubert