Mercurial > moin-europython
comparison europython.py @ 21:c636bfecbb1d
Add a subscribe link next to the page title.
| author | Radomir Dopieralski <sheep@stxnext.pl> |
|---|---|
| date | Tue, 15 Mar 2011 14:58:31 +0100 |
| parents | 824ef25c04fd |
| children | 2be4ac3eeded |
comparison
equal
deleted
inserted
replaced
| 20:677fc5200106 | 21:c636bfecbb1d |
|---|---|
| 66 '{*}': ("{*}", 'star_on.png', 16, 16), | 66 '{*}': ("{*}", 'star_on.png', 16, 16), |
| 67 '{o}': ("{o}", 'star_off.png', 16, 16), | 67 '{o}': ("{o}", 'star_off.png', 16, 16), |
| 68 } | 68 } |
| 69 del _ | 69 del _ |
| 70 | 70 |
| 71 def subscribeLink(self, page): | |
| 72 """ Return subscribe/unsubscribe link to valid users | |
| 73 | |
| 74 @rtype: unicode | |
| 75 @return: subscribe or unsubscribe link | |
| 76 """ | |
| 77 if not ((self.cfg.mail_enabled or | |
| 78 self.cfg.jabber_enabled) and self.request.user.valid): | |
| 79 return '' | |
| 80 | |
| 81 _ = self.request.getText | |
| 82 if self.request.user.isSubscribedTo([page.page_name]): | |
| 83 action, text = 'unsubscribe', _("Unsubscribe") | |
| 84 else: | |
| 85 action, text = 'subscribe', _("Subscribe") | |
| 86 if action in self.request.cfg.actions_excluded: | |
| 87 return '' | |
| 88 return page.link_to(self.request, text=text, | |
| 89 querystr={'action': action}, | |
| 90 css_class='nbsubscribe %s' % action, | |
| 91 rel='nofollow') | |
| 92 | |
| 93 def wikipanel(self, d): | |
| 94 """ Create wiki panel """ | |
| 95 _ = self.request.getText | |
| 96 html = [ | |
| 97 u'<div id="star">', self.subscribeLink(d['page']), '</div>', | |
| 98 u'<div class="sidepanel">', self.navibar(d), u'</div>', | |
| 99 ] | |
| 100 return u'\n'.join(html) | |
| 101 | |
| 71 def execute(request): | 102 def execute(request): |
| 72 return Theme(request) | 103 return Theme(request) |
