Commits

Gael Pasgrimaud committed 8d2d73d

improve blog template

  • Participants
  • Parent commits 6bccf62

Comments (0)

Files changed (3)

rstctl/__init__.py

             parser.parse_args(['-h'])
     elif options.template:
             name = options.template
-            title = ' '.join(args)
-            template.template(name, title)
+            kwargs = dict(lang='en', tags='python')
+            kwargs.update(dict([v.split('=') for v in args if '=' in v]))
+            title = ' '.join([v for v in args if '=' not in v])
+            template.template(name, title, **kwargs)
             return
     else:
         filename = args[0]
 ## -*- coding: utf-8 -*-
 <% from datetime import datetime %>\
-${'='*len(title)}
-${title}
-${'='*len(title)}
+${'='*(len(title)+5)}
+${title.capitalize()}
+${'='*(len(title)+5)}
 
 :Author: gawel
 :Date: ${datetime.now().strftime('%d/%m/%Y %H:%M')}
 :Id: ${filename}
-:Tags: python; 
-:Lang: fr
+:Tags: ${';'.join([t for t in tags.split()])} 
+:Lang: ${lang}
 
 
 .. Links

rstctl/template.py

 def normalize(title):
     filename = urllib.quote_plus(title)
     for i, o in (('%E8', 'e'), ('%E9', 'e'),
-                 ('%20', '_'), ('+', '_')
+                 ('%20', '_'), ('+', '_'),
+                 ('-', '_'),
                 ):
         filename = filename.replace(i, o)
     return filename