* Ignores .hg, .svn, .git by default * Additional nodes can be ignored by adding to site.config.ignoremain
@@ -134,8 +134,8 @@ A brief list of features | |||||
them in the templates. | them in the templates. | ||||
3. Organization: The sorter, grouper and tagger plugins provide rich | 3. Organization: The sorter, grouper and tagger plugins provide rich | ||||
meta-data driven organizational capabilities to hyde sites. | meta-data driven organizational capabilities to hyde sites. | ||||
4. Publishing: Hyde sites can be published to variety of targets including: | 4. Publishing: Hyde sites can be published to variety of targets including | ||||
github pages, Amazon S3 & SFTP. | github pages, Amazon S3 & SFTP. | ||||
Links | Links | ||||
----- | ----- | ||||
@@ -150,7 +150,7 @@ class Config(Expando): | |||||
base_url="/", | base_url="/", | ||||
not_found='404.html', | not_found='404.html', | ||||
plugins = [], | plugins = [], | ||||
ignore = [ "*~", "*.bak" ] | ignore = [ "*~", "*.bak", ".hg", ".git", ".svn"] | ||||
) | ) | ||||
self.config_file = config_file | self.config_file = config_file | ||||
self.config_dict = config_dict | self.config_dict = config_dict | ||||
@@ -351,16 +351,24 @@ class RootNode(Node): | |||||
with self.source_folder.walker as walker: | with self.source_folder.walker as walker: | ||||
def dont_ignore(name): | |||||
for pattern in self.site.config.ignore: | |||||
if fnmatch.fnmatch(name, pattern): | |||||
return False | |||||
return True | |||||
@walker.folder_visitor | @walker.folder_visitor | ||||
def visit_folder(folder): | def visit_folder(folder): | ||||
self.add_node(folder) | if dont_ignore(folder.name): | ||||
self.add_node(folder) | |||||
else: | |||||
logger.debug("Ignoring node: %s" % folder.name) | |||||
return False | |||||
@walker.file_visitor | @walker.file_visitor | ||||
def visit_file(afile): | def visit_file(afile): | ||||
for pattern in self.site.config.ignore: | if dont_ignore(afile.name): | ||||
if fnmatch.fnmatch(afile.name, pattern): | self.add_resource(afile) | ||||
return | |||||
self.add_resource(afile) | |||||
class Site(object): | class Site(object): | ||||
""" | """ | ||||
@@ -111,7 +111,7 @@ class TestConfig(object): | |||||
assert hasattr(c, 'plugins') | assert hasattr(c, 'plugins') | ||||
assert len(c.plugins) == 0 | assert len(c.plugins) == 0 | ||||
assert hasattr(c, 'ignore') | assert hasattr(c, 'ignore') | ||||
assert c.ignore == ["*~", "*.bak"] | assert c.ignore == ["*~", "*.bak", ".hg", ".git", ".svn"] | ||||
assert c.deploy_root_path == TEST_SITE.child_folder('deploy') | assert c.deploy_root_path == TEST_SITE.child_folder('deploy') | ||||
assert c.not_found == '404.html' | assert c.not_found == '404.html' | ||||
@@ -236,13 +236,32 @@ class TestSiteWithConfig(object): | |||||
assert resource.full_url == "/media/" + path | assert resource.full_url == "/media/" + path | ||||
def test_config_ignore(self): | def test_config_ignore(self): | ||||
s = Site(self.SITE_PATH, config=self.config) | c = Config(self.SITE_PATH, config_dict=self.config.to_dict()) | ||||
s = Site(self.SITE_PATH, config=c) | |||||
s.load() | s.load() | ||||
path = 'apple-touch-icon.png' | path = 'apple-touch-icon.png' | ||||
resource = s.content.resource_from_relative_path(path) | resource = s.content.resource_from_relative_path(path) | ||||
assert resource | assert resource | ||||
assert resource.full_url == "/" + path | assert resource.full_url == "/" + path | ||||
s = Site(self.SITE_PATH, config=self.config) | s = Site(self.SITE_PATH, config=c) | ||||
s.config.ignore.append('*.png') | s.config.ignore.append('*.png') | ||||
resource = s.content.resource_from_relative_path(path) | resource = s.content.resource_from_relative_path(path) | ||||
assert not resource | assert not resource | ||||
def test_config_ignore_nodes(self): | |||||
c = Config(self.SITE_PATH, config_dict=self.config.to_dict()) | |||||
git = self.SITE_PATH.child_folder('.git') | |||||
git.make() | |||||
s = Site(self.SITE_PATH, config=c) | |||||
s.load() | |||||
git_node = s.content.node_from_relative_path('.git') | |||||
assert not git_node | |||||
blog_node = s.content.node_from_relative_path('blog') | |||||
assert blog_node | |||||
assert blog_node.full_url == "/blog" | |||||
s = Site(self.SITE_PATH, config=c) | |||||
s.config.ignore.append('blog') | |||||
blog_node = s.content.node_from_relative_path('blog') | |||||
assert not blog_node | |||||
git_node = s.content.node_from_relative_path('.git') | |||||
assert not git_node |