Mercurial > moin-europython
changeset 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 | 677fc5200106 |
| children | 2be4ac3eeded |
| files | css/screen.css europython.py |
| diffstat | 2 files changed, 47 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/css/screen.css Mon Mar 14 17:21:35 2011 +0100 +++ b/css/screen.css Tue Mar 15 14:58:31 2011 +0100 @@ -245,3 +245,19 @@ margin: 2em 2em 0.25em 0; } +#star a { + display: block; + overflow: hidden; + width: 16px; + height: 16px; + text-indent: 16px; + background: url('../img/star_off.png') no-repeat 50% 50%; + position: absolute; + top: 64px; + left: 3%; + margin-left: 17.5em; + margin-top: -0.2em; +} +#star a.unsubscribe { + background-image: url('../img/star_on.png'); +}
--- a/europython.py Mon Mar 14 17:21:35 2011 +0100 +++ b/europython.py Tue Mar 15 14:58:31 2011 +0100 @@ -68,5 +68,36 @@ } del _ + def subscribeLink(self, page): + """ Return subscribe/unsubscribe link to valid users + + @rtype: unicode + @return: subscribe or unsubscribe link + """ + if not ((self.cfg.mail_enabled or + self.cfg.jabber_enabled) and self.request.user.valid): + return '' + + _ = self.request.getText + if self.request.user.isSubscribedTo([page.page_name]): + action, text = 'unsubscribe', _("Unsubscribe") + else: + action, text = 'subscribe', _("Subscribe") + if action in self.request.cfg.actions_excluded: + return '' + return page.link_to(self.request, text=text, + querystr={'action': action}, + css_class='nbsubscribe %s' % action, + rel='nofollow') + + def wikipanel(self, d): + """ Create wiki panel """ + _ = self.request.getText + html = [ + u'<div id="star">', self.subscribeLink(d['page']), '</div>', + u'<div class="sidepanel">', self.navibar(d), u'</div>', + ] + return u'\n'.join(html) + def execute(request): return Theme(request)
