Browse Source

Made notemeta.yaml configurable

main
Lakshmi Vyasarajan 14 years ago
parent
commit
b6bff2abab
2 changed files with 13 additions and 7 deletions
  1. +7
    -3
      hyde/ext/plugins/meta.py
  2. +6
    -4
      hyde/tests/ext/test_meta.py

+ 7
- 3
hyde/ext/plugins/meta.py View File

@@ -59,6 +59,9 @@ class MetaPlugin(Plugin):
config = self.site.config
metadata = config.meta if hasattr(config, 'meta') else {}
self.site.meta = Metadata(metadata)
self.nodemeta = 'nodemeta.yaml'
if hasattr(self.site.meta, 'nodemeta'):
self.nodemeta = self.site.meta.nodemeta
for node in self.site.content.walk():
self.__read_node__(node)
for resource in node.resources:
@@ -110,9 +113,10 @@ class MetaPlugin(Plugin):

def __read_node__(self, node):
"""
Look for nodemeta.yaml. Load and assign it to the node.
Look for nodemeta.yaml (or configured name). Load and assign it
to the node.
"""
nodemeta = node.get_resource('nodemeta.yaml')
nodemeta = node.get_resource(self.nodemeta)
parent_meta = node.parent.meta if node.parent else self.site.meta
if nodemeta:
nodemeta.is_processable = False
@@ -127,7 +131,7 @@ class MetaPlugin(Plugin):

def begin_node(self, node):
"""
Look for nodemeta.yaml. Load and assign it to the node.
Read node meta data.
"""
self.__read_node__(node)



+ 6
- 4
hyde/tests/ext/test_meta.py View File

@@ -182,13 +182,14 @@ title: Even nicer title

page_d = {'title': 'An even nicer title'}

blog_d = {'author': 'Lakshmi'}
blog_d = {'author': 'Laks'}

content_d = {'title': 'A nice title',
'author': 'Lakshmi Vyas'}

site_d = {'author': 'Lakshmi',
'twitter': 'lakshmivyas'}
'twitter': 'lakshmivyas',
'nodemeta': 'meta.yaml'}
text = """
---
title: %(title)s
@@ -208,7 +209,7 @@ title: %(title)s
about2.write(text % page_d)
content_meta = File(TEST_SITE.child('content/nodemeta.yaml'))
content_meta.write(yaml.dump(content_d))
content_meta = File(TEST_SITE.child('content/blog/nodemeta.yaml'))
content_meta = File(TEST_SITE.child('content/blog/meta.yaml'))
content_meta.write(yaml.dump(blog_d))
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.meta.MetaPlugin']
@@ -231,4 +232,5 @@ title: %(title)s
text = target.read_all()
q = PyQuery(text)
for k, v in expected.items():
assert v in q("span." + k).text()
if k != 'nodemeta':
assert v in q("span." + k).text()

Loading…
Cancel
Save