Browse Source

Added tag archives to basic template

main
Lakshmi Vyasarajan 14 years ago
parent
commit
9ca8d70e37
8 changed files with 84 additions and 10 deletions
  1. +5
    -1
      hyde/ext/plugins/tagger.py
  2. +2
    -2
      hyde/generator.py
  3. +34
    -2
      hyde/layouts/basic/content/media/css/site.css
  4. +3
    -1
      hyde/layouts/basic/layout/blog.j2
  5. +1
    -1
      hyde/layouts/basic/layout/macros.j2
  6. +28
    -0
      hyde/layouts/basic/layout/tagged_posts.j2
  7. +10
    -2
      hyde/layouts/basic/site.yaml
  8. +1
    -1
      hyde/tests/sites/test_tagger/site.yaml

+ 5
- 1
hyde/ext/plugins/tagger.py View File

@@ -130,11 +130,15 @@ class TaggerPlugin(Plugin):
text = "{%% extends \"%s\" %%}" % template

for tag, resources in self.site.tagger.tags.to_dict().iteritems():
archive_text = self.template.render(text, dict(
context = {}
context.update(self.site.context)
context.update(dict(
site=self.site,
node=source,
tag=tag,
walker=getattr(source,
"walk_resources_tagged_with_%s" % tag)
))
archive_text = self.template.render(text, context)
archive_file = File(target.child("%s.%s" % (tag, extension)))
archive_file.write(archive_text)

+ 2
- 2
hyde/generator.py View File

@@ -43,9 +43,9 @@ class Generator(object):
"""
# TODO: update metadata and other resource
# specific properties here.
self.__context__.update(resource=resource)
self.__context__.update(resource=resource, node=resource.node)
yield self.__context__
self.__context__.update(resource=None)
self.__context__.update(resource=None, node=None)

def context_for_path(self, path):
resource = self.site.resource_from_path(path)


+ 34
- 2
hyde/layouts/basic/content/media/css/site.css View File

@@ -42,8 +42,9 @@ table {
}

a {
color: #666;
color: #37e;
text-decoration: underline;
text-shadow: 0px 2px 0px #fff;
}

a:hover{
@@ -317,10 +318,12 @@ ul.tags li a{
text-decoration: none;
}

h1.tag:before,
ul.tags li a:before{
content: '\00AB';
}

h1.tag:after,
ul.tags li a:after{
content: '\00BB';
}
@@ -404,4 +407,33 @@ a.backlink:hover, a.prev:hover, a.next:hover{

#facebook_like{
margin-top: 1px;
}
}

.archives ul.posts{
margin-top: 24px;
}

.archives li.post{
list-style-type: none;
border-bottom: 1px dotted #ccc;
padding: 12px 0;

}

.archives li.post time{
color: #999;
text-shadow: 0px 2px 0px #fff;
margin-right: 24px;
display:block;
float: left;
width: 120px;
}

.archives li.post a{
float: left;
}

.archives ul.tags{
float: right;
margin-bottom:0;
}

+ 3
- 1
hyde/layouts/basic/layout/blog.j2 View File

@@ -48,7 +48,9 @@
<ul class="tags clear">
{% for tag in resource.meta.tags %}
<li>
<a class="small">{{ tag }}</a>
<a class="small" href="{{ content_url('blog/tags/'~tag~'.html') }}">
{{ tag }}
</a>
</li>
{% endfor %}
</ul>


+ 1
- 1
hyde/layouts/basic/layout/macros.j2 View File

@@ -20,7 +20,7 @@
{% set active = (resource.url ==
site.content.resource_from_relative_path(item.url).url) -%}
{% else -%}
{% set active = (resource.node ==
{% set active = (node ==
site.content.node_from_relative_path(item.url)) -%}
{%- endif %}
{% set classes = ['button', 'white'] -%}


+ 28
- 0
hyde/layouts/basic/layout/tagged_posts.j2 View File

@@ -0,0 +1,28 @@
{% extends "base.j2" %}

{% block main %}
<section class="archives">
<h1 class="tag title">{{ tag }}</h1>
<ul class="posts clear">
{% for resource in walker() -%}
<li class="post clear">
<time datetime="{{ resource.meta.created.strftime('%Y-%m-%d') }}">
{{ resource.meta.created.strftime('%a, %d %b %Y') }}
</time>
<a href="{{ content_url(resource.url) }}">{{ resource.meta.title }}</a>
{% if resource.meta.tags %}
<ul class="tags">
{% for tag in resource.meta.tags %}
<li>
<a class="small" href="{{ content_url('blog/tags/'~tag~'.html') }}">
{{ tag }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{%- endfor %}
</ul>
</section>
{% endblock %}

+ 10
- 2
hyde/layouts/basic/site.yaml View File

@@ -6,7 +6,7 @@ plugins:
- hyde.ext.plugins.meta.MetaPlugin
- hyde.ext.plugins.auto_extend.AutoExtendPlugin
- hyde.ext.plugins.sorter.SorterPlugin
- hyde.ext.plugins.grouper.GrouperPlugin
- hyde.ext.plugins.tagger.TaggerPlugin
- hyde.ext.plugins.syntext.SyntextPlugin
- hyde.ext.plugins.textlinks.TextlinksPlugin
context:
@@ -47,4 +47,12 @@ sorter:
reverse: true
filters:
source.kind: html
meta.listable: true
meta.listable: true
tagger:
sorter: time
archives:
blog:
source: blog
target: blog/tags
template: tagged_posts.j2
archive_extension: html

+ 1
- 1
hyde/tests/sites/test_tagger/site.yaml View File

@@ -27,4 +27,4 @@ tagger:
template: tagged_posts.j2
source: blog
target: blog/tags
archive_extension: html
extension: html

Loading…
Cancel
Save