From 0ca9997e107f67fc4e8eebd0511809e254b11f58 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Tue, 6 Mar 2012 00:29:56 +0100 Subject: [PATCH 1/2] paths for finding articles and pages are now parametrable --- pelican/generators.py | 10 ++++++---- pelican/settings.py | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pelican/generators.py b/pelican/generators.py index 6ba12cf4..ac2cd865 100644 --- a/pelican/generators.py +++ b/pelican/generators.py @@ -211,10 +211,10 @@ class ArticlesGenerator(Generator): def generate_context(self): """change the context""" - # return the list of files to use - files = self.get_files(self.path, exclude=['pages', ]) all_articles = [] - for f in files: + for f in self.get_files( + os.path.join(self.path, self.settings['ARTICLE_DIR']), + exclude=self.settings['ARTICLE_EXCLUDES']): try: content, metadata = read_file(f, settings=self.settings) except Exception, e: @@ -316,7 +316,9 @@ class PagesGenerator(Generator): def generate_context(self): all_pages = [] - for f in self.get_files(os.sep.join((self.path, 'pages'))): + for f in self.get_files( + os.path.join(self.path, self.settings['PAGE_DIR']), + exclude=self.settings['PAGE_EXCLUDES']): try: content, metadata = read_file(f) except Exception, e: diff --git a/pelican/settings.py b/pelican/settings.py index 6ed76f46..1b31582f 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -8,6 +8,10 @@ from pelican import log DEFAULT_THEME = os.sep.join([os.path.dirname(os.path.abspath(__file__)), "themes/notmyidea"]) _DEFAULT_CONFIG = {'PATH': None, + 'ARTICLE_DIR': '', + 'ARTICLE_EXCLUDES': ('pages',), + 'PAGE_DIR': 'pages', + 'PAGE_EXCLUDES': (), 'THEME': DEFAULT_THEME, 'OUTPUT_PATH': 'output/', 'MARKUP': ('rst', 'md'), From aef7418bdf2094b8e6edc5b2e6300bf8a60bb851 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Tue, 6 Mar 2012 00:45:22 +0100 Subject: [PATCH 2/2] add docs for new page/article paths settings --- docs/settings.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/settings.rst b/docs/settings.rst index 69e2adc8..31183be3 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -52,6 +52,10 @@ Setting name (default value) What does it do? supported extensions. `OUTPUT_PATH` (``'output/'``) Where to output the generated files. `PATH` (``None``) Path to look at for input files. +`PAGE_DIR' (``'pages'``) Directory to look at for pages. +`PAGE_EXCLUDES' (``()``) A list of directories to exclude when looking for pages. +`ARTICLE_DIR' (``''``) Directory to look at for articles. +`ARTICLE_EXCLUDES': (``('pages',)``) A list of directories to exclude when looking for articles. `PDF_GENERATOR` (``False``) Set to True if you want to have PDF versions of your documents. You will need to install `rst2pdf`.