diff --git a/README.rst b/README.rst index 06a6007..0a5daff 100644 --- a/README.rst +++ b/README.rst @@ -134,8 +134,8 @@ A brief list of features them in the templates. 3. Organization: The sorter, grouper and tagger plugins provide rich meta-data driven organizational capabilities to hyde sites. -4. Publishing: Hyde sites can be published to variety of targets including: - github pages, Amazon S3 & SFTP. +4. Publishing: Hyde sites can be published to variety of targets including + github pages, Amazon S3 & SFTP. Links ----- diff --git a/hyde/model.py b/hyde/model.py index fc51b38..5066c87 100644 --- a/hyde/model.py +++ b/hyde/model.py @@ -150,7 +150,7 @@ class Config(Expando): base_url="/", not_found='404.html', plugins = [], - ignore = [ "*~", "*.bak" ] + ignore = [ "*~", "*.bak", ".hg", ".git", ".svn"] ) self.config_file = config_file self.config_dict = config_dict diff --git a/hyde/site.py b/hyde/site.py index 6d46487..c6d7bcc 100644 --- a/hyde/site.py +++ b/hyde/site.py @@ -351,16 +351,24 @@ class RootNode(Node): 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 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 def visit_file(afile): - for pattern in self.site.config.ignore: - if fnmatch.fnmatch(afile.name, pattern): - return - self.add_resource(afile) + if dont_ignore(afile.name): + self.add_resource(afile) class Site(object): """ diff --git a/hyde/tests/test_model.py b/hyde/tests/test_model.py index 795290d..8ad5057 100644 --- a/hyde/tests/test_model.py +++ b/hyde/tests/test_model.py @@ -111,7 +111,7 @@ class TestConfig(object): assert hasattr(c, 'plugins') assert len(c.plugins) == 0 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.not_found == '404.html' diff --git a/hyde/tests/test_site.py b/hyde/tests/test_site.py index 181d697..276ca8b 100644 --- a/hyde/tests/test_site.py +++ b/hyde/tests/test_site.py @@ -236,13 +236,32 @@ class TestSiteWithConfig(object): assert resource.full_url == "/media/" + path 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() path = 'apple-touch-icon.png' resource = s.content.resource_from_relative_path(path) assert resource 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') resource = s.content.resource_from_relative_path(path) 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