Merge branch 'devel'

This commit is contained in:
Ahmet Bakan 2015-04-14 21:25:31 -07:00
commit 61c03d38d1
5 changed files with 20 additions and 36 deletions

View file

@ -63,31 +63,6 @@ subparser.set_defaults(func=lambda ns: ablog_start())
subparser.set_defaults(subparser=subparser)
if 0:
def ablog_post(subparser, **kwargs):
conf = read_conf(find_confdir(subparser))
filename = kwargs['filename']
title = kwargs['title']
date_format = getattr(conf, 'post_date_format', '%b %d, %Y')
# add template here and create file
print('{} is ready to be edited.'.format(filename))
subparser = ablog_commands.add_parser('post',
help='post ')
subparser.add_argument('filename', help='filename')
subparser.add_argument('-t', '--title', dest='title', type=str,
help='post title')
subparser.set_defaults(func=lambda ns: ablog_post(**ns.__dict__))
subparser.set_defaults(subparser=subparser)
def ablog_build(subparser, **kwargs):
@ -236,7 +211,7 @@ def ablog_post(subparser, **kwargs):
POST_TEMPLATE =u'''
%(title)s
====================
%(equal)s
.. post:: %(date)s
:tags:
@ -244,8 +219,6 @@ def ablog_post(subparser, **kwargs):
'''
blog_root = find_confdir(subparser)
from datetime import date
from os import path
@ -253,10 +226,16 @@ def ablog_post(subparser, **kwargs):
today = date.today()
title = kwargs['title']
filename = kwargs['filename']
if not filename.lower().endswith('.rst'):
filename += '.rst'
today = today.strftime("%b %d, %Y")
if not title:
title = filename[:-4].replace('-', ' ').title()
pars = {'date': today,
'title': title
'title': title,
'equal': '=' * len(title)
}
if path.isfile(filename):
@ -272,17 +251,14 @@ def ablog_post(subparser, **kwargs):
subparser = ablog_commands.add_parser('post',
help='create a blank post',)
subparser.add_argument('-t', dest='title', type=str,
default='New Post',
help='post title; default is `New Post`')
help='post title; default is formed from filename')
subparser.add_argument(dest='filename', type=str,
help='filename, e.g. my-nth-post.rst')
help='filename, e.g. my-nth-post (.rst appended)')
subparser.set_defaults(func=lambda ns: ablog_post(**ns.__dict__))
subparser.set_defaults(subparser=subparser)

View file

@ -125,6 +125,7 @@ class PostListDirective(Directive):
'date': lambda a: a.strip(),
'sort': directives.flag,
'excerpts': directives.flag,
'list-style': lambda a: a.strip(),
}
def run(self):
@ -146,6 +147,7 @@ class PostListDirective(Directive):
node['sort'] = 'sort' in self.options
node['excerpts'] = 'excerpts' in self.options
node['image'] = 'image' in self.options
node['list-style'] = self.options.get('list-style', 'disc')
return [node]
@ -378,6 +380,7 @@ def process_postlist(app, doctree, docname):
excerpts = node.attributes['excerpts']
date_format = node.attributes['date'] or _(blog.post_date_format_short)
bl = nodes.bullet_list()
bl.attributes['classes'].append('post-list-style-' + node['list-style'])
for post in posts:
bli = nodes.list_item()
bl.append(bli)

View file

@ -13,6 +13,9 @@
<style type="text/css">
ul.ablog-archive {list-style: none; overflow: auto; margin-left: 0px}
ul.ablog-archive li {float: left; margin-right: 5px; font-size: 80%}
ul.post-list-style-disc {list-style-type: disc;}
ul.post-list-style-none {list-style-type: none;}
ul.post-list-style-circle {list-style-type: circle;}
</style>
{% endblock %}

View file

@ -146,11 +146,11 @@ Finally, ``ablog post`` will make a new post template file.
usage: ablog post [-h] [-t TITLE] filename
positional arguments:
filename filename, e.g. my-nth-post.rst
filename filename, e.g. my-nth-post (.rst appended)
optional arguments:
-h, --help show this help message and exit
-t TITLE post title; default is `New Post
-t TITLE post title; default is formed from filename
Clean Files
-----------

View file

@ -140,6 +140,7 @@ A list of posts can be displayed in any page using the following directive:
:tags: tips
:date: %A, %B %d, %Y
:format: {title} by {author} on {date}
:list-style: circle
:excerpts:
:sort:
@ -158,6 +159,7 @@ A list of posts can be displayed in any page using the following directive:
:tags: tips
:date: %A, %B %d, %Y
:format: {title} by {author} on {date}
:list-style: circle
:excerpts:
:sort: