# HG changeset patch # User Arne Babenhauserheide # Date 1242102618 -7200 # Node ID 4a8b12498bdf6c7fb50bf490adcb323771fd08e6 # Parent fc5a9f3e54792edcdb1a1252323a2b783a5fb66c Added the tag "mercurial_tricks_advanced", so we can distinguish between basic tricks (no extensions required) and advanced tricks (including history rewriting, mq and similar). diff -r fc5a9f3e5479 -r 4a8b12498bdf hgscm/apps/www/templatetags/extras.py --- a/hgscm/apps/www/templatetags/extras.py Tue May 12 06:20:17 2009 +0200 +++ b/hgscm/apps/www/templatetags/extras.py Tue May 12 06:30:18 2009 +0200 @@ -11,12 +11,26 @@ self._filename = self._random() def _random(self): - file = random.choice(os.listdir(settings.MERCURIAL_TRICKS)) - return os.path.join(settings.MERCURIAL_TRICKS, file) + p = random.choice(os.listdir(settings.MERCURIAL_TRICKS)) + return os.path.join(settings.MERCURIAL_TRICKS, p) def render(self, context): f = open(self._filename) - result = "

Tricks

" + f.read() + "

" + result = "

Basic Tricks

" + f.read() + "

" + f.close() + return result + +class MercurialTricksAdvancedNode(template.Node): + def __init__(self): + self._filename = self._random() + + def _random(self): + p = random.choice(os.listdir(settings.MERCURIAL_TRICKS_ADVANCED)) + return os.path.join(settings.MERCURIAL_TRICKS_ADVANCED, p) + + def render(self, context): + f = open(self._filename) + result = "

Advanced Tricks

" + f.read() + "

" f.close() return result @@ -40,9 +54,13 @@ def do_mercurial_tricks (parser, token): return MercurialTricksNode() +def do_mercurial_tricks_advanced (parser, token): + return MercurialTricksAdvancedNode() + def do_download_button(parser, token): extended = len(token.split_contents()) > 1 return DownloadButtonNode(extended) register.tag('mercurial_tricks', do_mercurial_tricks) +register.tag('mercurial_tricks_advanced', do_mercurial_tricks_advanced) register.tag('download_button', do_download_button) diff -r fc5a9f3e5479 -r 4a8b12498bdf hgscm/settings.py --- a/hgscm/settings.py Tue May 12 06:20:17 2009 +0200 +++ b/hgscm/settings.py Tue May 12 06:30:18 2009 +0200 @@ -69,6 +69,8 @@ MERCURIAL_TRICKS = os.path.join(BASE_DIR, "templates/tricks") +MERCURIAL_TRICKS_ADVANCED = os.path.join(BASE_DIR, "templates/tricks_advanced") + TEMPLATE_DIRS = ( os.path.join(BASE_DIR, "templates"), )