colinta / StrangeCase

It's yet another static site generator. Have you seen jekyll? hyde? Yup. Like those.
http://colinta.com/projects/StrangeCase.html
Other
49 stars 7 forks source link

why the newly published post doesn't appear in the foremost of the homepage? #52

Closed luckypoem closed 10 years ago

luckypoem commented 10 years ago

hi. the post http://sc.brite.biz.st/blogs/2014_06_15_0840_jingle_bell.html the newest post, why the newly published post doesn't appear in the foremost of the homepage while appear in the hindermost of the site? the whole site's posts are completely arranged reversible to the publishing time. how to let posts arranged as per the publishing time??(that is : the newest post is in the foremost of the site,the oldest post is in the hindermost of the site) tks a lot.

another issue: as3:~/StrangeCase-site/strange_case/tests# git clone https://github.com/colinta/colinta.com colinta.com-site as3:~/StrangeCase-site/strange_case/tests# cd colinta.com-site as3:~/StrangeCase-site/strange_case/tests/colinta.com-site# ls config.yaml fabfile.py includes layouts site as3:~/StrangeCase-site/strange_case/tests/colinta.com-site# scase inflect is required.

pip install inflect as3:~/StrangeCase-site/strange_case/tests/colinta.com-site# pip install inflect as3:~/StrangeCase-site/strange_case/tests/colinta.com-site# ls config.yaml fabfile.py includes layouts site as3:~/StrangeCase-site/strange_case/tests/colinta.com-site# scase Traceback (most recent call last): File "/usr/local/bin/scase", line 9, in load_entry_point('StrangeCase==4.6.3', 'console_scripts', 'scase')() File "/usr/local/lib/python2.7/site-packages/strange_case/main.py", line 187, in run strange_case(CONFIG) File "/usr/local/lib/python2.7/site-packages/strange_case/init.py", line 154, in strange_case root_node.generate() File "/usr/local/lib/python2.7/site-packages/strange_case/nodes/root_folder.py", line 37, in generate child.generate(self) File "/usr/local/lib/python2.7/site-packages/strange_case/nodes/folder.py", line 22, in generate super(FolderNode, self).generate(site) File "/usr/local/lib/python2.7/site-packages/strange_case/nodes/node.py", line 38, in generate child.generate(site) File "/usr/local/lib/python2.7/site-packages/strange_case/nodes/file.py", line 20, in generate self.generate_file(site, self.source_path, target_path) File "/usr/local/lib/python2.7/site-packages/strange_case/nodes/jinja.py", line 12, in generate_file content = self.render(site) File "/usr/local/lib/python2.7/site-packages/strange_case/nodes/jinja.py", line 26, in render return template.render(self.config, my=self, site=site) File "/usr/local/lib/python2.7/site-packages/strange_case/support/jinja.py", line 42, in render ret = super(StrangeCaseTemplate, self).render(_args, *_kwargs) File "/usr/local/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render return self.environment.handle_exception(exc_info, True) File "/usr/local/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception reraise(exc_type, exc_value, tb) File "/root/StrangeCase-site/strange_case/tests/colinta.com-site/site/blogs/2012_11_06_the_great_gatsby.j2", line 6, in top-level template code {% from 'includes/photos.j2' import photos %} File "/root/StrangeCase-site/strange_case/tests/colinta.com-site/layouts/post.j2", line 2, in top-level template code {% from 'includes/nextprev.j2' import nextprev %} File "/root/StrangeCase-site/strange_case/tests/colinta.com-site/layouts/base.j2", line 94, in top-level template code {% block main %} File "/root/StrangeCase-site/strange_case/tests/colinta.com-site/layouts/post.j2", line 26, in block "main" {%- block content %}{% endblock %} File "/root/StrangeCase-site/strange_case/tests/colinta.com-site/site/blogs/2012_11_06_the_great_gatsby.j2", line 9, in block "content" {% block content %}{% markdown %} File "/usr/local/lib/python2.7/site-packages/strange_case/extensions/misaka.py", line 90, in markdown return markdown(caller()) File "/root/StrangeCase-site/strange_case/tests/colinta.com-site/site/blogs/2012_11_06_the_great_gatsby.j2", line 16, in template {{ photos(site.static.image.thewedding) }} File "/root/StrangeCase-site/strange_case/tests/colinta.com-site/includes/photos.j2", line 3, in template {% for image in photos %} TypeError: 'NoneType' object is not iterable as3:~/StrangeCase-site/strange_case/tests/colinta.com-site#

how to fix the TypeError: 'NoneType' object is not iterable? tks

colinta commented 10 years ago

Hey there! The reason the files are in ascending order is just because that's how they get sorted by Python. There's a | reverse filter in Jinja, though, or you can grab the most recent with posts[-1].

The NoneType error is because there's no folder site/static/image/thewedding/. Just delete that part, it should compile.

luckypoem commented 10 years ago

hi. u said "There's a | reverse filter in Jinja, though, or you can grab the most recent with posts[-1]." could u pls explain how to operate concretely? modify which files? how to modify? tks a lot!

colinta commented 10 years ago
<!-- most recent blog -->
<a href="{{ site.blogs[-1].url }}">{{ site.blogs[-1].title }}</a>

<!-- blog pages -->
<ol>
{% for blog in site.blogs|reverse %}
  <li><span>{{ blog.created_at | date }}</span> &rsaquo; <a href="{{ blog.url }}">{{ blog.title }}</a></li>
{% endfor %}
</ol>

Also, the pagination extension supports a reverse option, too. https://github.com/colinta/StrangeCase/blob/master/strange_case/extensions/paginated.py