@@ -1,16 +1,22 @@ | |||
Version 0.8.4c8 | |||
=============== | |||
* Added support for loading modules from the site path. Thanks to | |||
@theomega for the idea (Issue #78 & #79) | |||
Version 0.8.4c7 | |||
=============== | |||
Thanks to @tcheneau | |||
* Added support for AsciiDoc. | |||
* Added support for AsciiDoc. | |||
Version 0.8.4c6 | |||
=============== | |||
Thanks to @gr3dman | |||
* Added paginator plugin and tests | |||
* Added paginator plugin and tests | |||
Version 0.8.4c5 | |||
=============== | |||
@@ -1,4 +1,4 @@ | |||
Version 0.8.4c7 | |||
Version 0.8.4c8 | |||
A brand new **hyde** | |||
==================== | |||
@@ -13,6 +13,7 @@ from hyde.util import getLoggerWithConsoleHandler | |||
import codecs | |||
import os | |||
import sys | |||
import yaml | |||
HYDE_LAYOUTS = "HYDE_LAYOUTS" | |||
@@ -61,6 +62,9 @@ class Engine(Application): | |||
import logging | |||
logger.setLevel(logging.DEBUG) | |||
sitepath = Folder(args.sitepath).fully_expanded_path | |||
return Folder(sitepath) | |||
@subcommand('create', help='Create a new hyde site.') | |||
@store('-l', '--layout', default='basic', help='Layout for the new site') | |||
@true('-f', '--force', default=False, dest='overwrite', | |||
@@ -70,8 +74,7 @@ class Engine(Application): | |||
The create command. Creates a new site from the template at the given | |||
sitepath. | |||
""" | |||
self.main(args) | |||
sitepath = Folder(Folder(args.sitepath).fully_expanded_path) | |||
sitepath = self.main(args) | |||
markers = ['content', 'layout', 'site.yaml'] | |||
exists = any((FS(sitepath.child(item)).exists for item in markers)) | |||
@@ -103,8 +106,8 @@ class Engine(Application): | |||
The generate command. Generates the site at the given | |||
deployment directory. | |||
""" | |||
self.main(args) | |||
site = self.make_site(args.sitepath, args.config, args.deploy) | |||
sitepath = self.main(args) | |||
site = self.make_site(sitepath, args.config, args.deploy) | |||
from hyde.generator import Generator | |||
gen = Generator(site) | |||
incremental = True | |||
@@ -130,8 +133,7 @@ class Engine(Application): | |||
deployment directory, address and port. Regenerates | |||
the entire site or specific files based on ths request. | |||
""" | |||
self.main(args) | |||
sitepath = Folder(Folder(args.sitepath).fully_expanded_path) | |||
sitepath = self.main(args) | |||
config_file = sitepath.child(args.config) | |||
site = self.make_site(args.sitepath, args.config, args.deploy) | |||
from hyde.server import HydeWebServer | |||
@@ -157,8 +159,8 @@ class Engine(Application): | |||
Publishes the site based on the configuration from the `target` | |||
parameter. | |||
""" | |||
self.main(args) | |||
site = self.make_site(args.sitepath, args.config) | |||
sitepath = self.main(args) | |||
site = self.make_site(sitepath, args.config) | |||
from hyde.publisher import Publisher | |||
publisher = Publisher.load_publisher(site, | |||
args.publisher, | |||
@@ -171,7 +173,6 @@ class Engine(Application): | |||
""" | |||
Creates a site object from the given sitepath and the config file. | |||
""" | |||
sitepath = Folder(Folder(sitepath).fully_expanded_path) | |||
config = Config(sitepath, config_file=config) | |||
if deploy: | |||
config.deploy_root = deploy | |||
@@ -591,18 +591,28 @@ class Folder(FS): | |||
dir_util.copy_tree(self.path, str(target)) | |||
return target | |||
def get_walker(self, pattern=None): | |||
""" | |||
Return a `FolderWalker` object with a set pattern. | |||
""" | |||
return FolderWalker(self, pattern) | |||
@property | |||
def walker(self, pattern=None): | |||
def walker(self): | |||
""" | |||
Return a `FolderWalker` object | |||
""" | |||
return FolderWalker(self) | |||
return FolderWalker(self, pattern) | |||
def get_lister(self, pattern=None): | |||
""" | |||
Return a `FolderLister` object with a set pattern. | |||
""" | |||
return FolderLister(self, pattern) | |||
@property | |||
def lister(self, pattern=None): | |||
def lister(self): | |||
""" | |||
Return a `FolderLister` object | |||
""" | |||
return FolderLister(self, pattern) | |||
return FolderLister(self) |
@@ -4,6 +4,7 @@ Parses & holds information about the site to be generated. | |||
""" | |||
import os | |||
import fnmatch | |||
import sys | |||
import urlparse | |||
from functools import wraps | |||
@@ -368,6 +369,10 @@ class Site(object): | |||
def __init__(self, sitepath=None, config=None): | |||
super(Site, self).__init__() | |||
self.sitepath = Folder(Folder(sitepath).fully_expanded_path) | |||
# Add sitepath to the list of module search paths so that | |||
# local plugins can be included. | |||
sys.path.insert(0, self.sitepath.fully_expanded_path) | |||
self.config = config if config else Config(self.sitepath) | |||
self.content = RootNode(self.config.content_root_path, self) | |||
self.plugins = [] | |||
@@ -4,7 +4,7 @@ Use nose | |||
`$ pip install nose` | |||
`$ nosetests` | |||
Code borrowed from rwbench.py from the jinja2 examples | |||
Some code borrowed from rwbench.py from the jinja2 examples | |||
""" | |||
from datetime import datetime | |||
from hyde.ext.templates.jinja import Jinja2Template | |||
@@ -33,7 +33,8 @@ class Article(object): | |||
self.title = generate_lorem_ipsum(1, False, 5, 10) | |||
self.user = choice(users) | |||
self.body = generate_lorem_ipsum() | |||
self.pub_date = datetime.utcfromtimestamp(randrange(10 ** 9, 2 * 10 ** 9)) | |||
self.pub_date = datetime.utcfromtimestamp( | |||
randrange(10 ** 9, 2 * 10 ** 9)) | |||
self.published = True | |||
def dateformat(x): | |||
@@ -10,6 +10,10 @@ from nose.tools import raises | |||
import os | |||
from hyde.exceptions import HydeException | |||
from hyde.fs import File, Folder | |||
from hyde.generator import Generator | |||
from hyde.site import Site | |||
def test_can_load_locals(): | |||
@@ -42,6 +46,29 @@ def test_can_load_module_without_dot(): | |||
assert abc['d'] == 'efg' | |||
assert abc['l'] == 'mno' | |||
def test_can_load_site_specific_plugins(): | |||
TEST_SITE = File(__file__).parent.child_folder('_test') | |||
TEST_SITE.make() | |||
TEST_SITE.parent.child_folder( | |||
'sites/test_jinja').copy_contents_to(TEST_SITE) | |||
TEST_SITE.parent.child_folder( | |||
'ssp').copy_contents_to(TEST_SITE) | |||
s = Site(TEST_SITE) | |||
gen = Generator(s) | |||
gen.generate_all() | |||
banner = """ | |||
<!-- | |||
This file was produced with infinite love, care & sweat. | |||
Please dont copy. If you have to, please drop me a note. | |||
--> | |||
""" | |||
with TEST_SITE.child_folder('deploy').get_walker('*.html') as walker: | |||
@walker.file_visitor | |||
def visit_file(f): | |||
text = f.read_all() | |||
assert text.strip().startswith(banner.strip()) | |||
@raises(HydeException) | |||
def test_exception_raised_for_invalid_module(): | |||
@@ -3,4 +3,4 @@ | |||
Handles hyde version | |||
TODO: Use fabric like versioning scheme | |||
""" | |||
__version__ = '0.8.4c2' | |||
__version__ = '0.8.4c8' |