diff --git a/pelican/settings.py b/pelican/settings.py index 1b32395c..125d0bb0 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -55,6 +55,13 @@ def read_settings(filename): if key.isupper(): context[key] = tempdict[key] + # Make the paths relative to the settings file + for path in ['PATH', 'OUTPUT_PATH']: + if path in context: + if context[path] is not None and not os.path.isabs(context[path]): + # FIXME: + context[path] = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(filename), context[path]))) + # if locales is not a list, make it one locales = context['LOCALE'] @@ -74,11 +81,5 @@ def read_settings(filename): else: log.warn("LOCALE option doesn't contain a correct value") - # Make the paths relative to the settings file - for path in ['PATH', 'OUTPUT_PATH']: - if path in context: - if context[path] is not None and not os.path.isabs(context[path]): - context[path] = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(filename), context[path]))) - # set the locale return context diff --git a/tests/content/article_with_metadata.rst b/tests/content/article_with_metadata.rst new file mode 100644 index 00000000..3410885e --- /dev/null +++ b/tests/content/article_with_metadata.rst @@ -0,0 +1,11 @@ + +This is a super article ! +######################### + +:tags: foo, bar, foobar +:date: 2010-12-02 10:14 +:category: yeah +:author: Alexis Métaireau +:summary: + Multi-line metadata should be supported + as well as **inline markup**. diff --git a/tests/default_conf.py b/tests/default_conf.py new file mode 100755 index 00000000..2796d561 --- /dev/null +++ b/tests/default_conf.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +AUTHOR = u'Alexis Métaireau' +SITENAME = u"Alexis' log" +SITEURL = 'http://blog.notmyidea.org' + +GITHUB_URL = 'http://github.com/ametaireau/' +DISQUS_SITENAME = "blog-notmyidea" +PDF_GENERATOR = False +REVERSE_CATEGORY_ORDER = True +LOCALE = "" +DEFAULT_PAGINATION = 2 + +FEED_RSS = 'feeds/all.rss.xml' +CATEGORY_FEED_RSS = 'feeds/%s.rss.xml' + +LINKS = (('Biologeek', 'http://biologeek.org'), + ('Filyb', "http://filyb.info/"), + ('Libert-fr', "http://www.libert-fr.com"), + ('N1k0', "http://prendreuncafe.com/blog/"), + (u'Tarek Ziadé', "http://ziade.org/blog"), + ('Zubin Mithra', "http://zubin71.wordpress.com/"),) + +SOCIAL = (('twitter', 'http://twitter.com/ametaireau'), + ('lastfm', 'http://lastfm.com/user/akounet'), + ('github', 'http://github.com/ametaireau'),) + +# global metadata to all the contents +DEFAULT_METADATA = (('yeah', 'it is'),) + +# static paths will be copied under the same name +STATIC_PATHS = ["pictures",] + +# A list of files to copy from the source to the destination +FILES_TO_COPY = (('extra/robots.txt', 'robots.txt'),) + +# foobar will not be used, because it's not in caps. All configuration keys +# have to be in caps +foobar = "barbaz" diff --git a/tests/test_readers.py b/tests/test_readers.py index 5a255209..bf7504fb 100644 --- a/tests/test_readers.py +++ b/tests/test_readers.py @@ -5,7 +5,7 @@ import datetime from pelican import readers CUR_DIR = os.path.dirname(__file__) -CONTENT_PATH = os.path.join(CUR_DIR, '..', '..', 'samples', 'content') +CONTENT_PATH = os.path.join(CUR_DIR, 'content') def _filename(*args): return os.path.join(CONTENT_PATH, *args) @@ -13,9 +13,9 @@ def _filename(*args): class RstReaderTest(unittest2.TestCase): - def test_metadata(self): + def test_article_with_metadata(self): reader = readers.RstReader() - content, metadata = reader.read(_filename('super_article.rst')) + content, metadata = reader.read(_filename('article_with_metadata.rst')) expected = { 'category': 'yeah', 'author': u'Alexis Métaireau', diff --git a/tests/test_settings.py b/tests/test_settings.py index 39680a9f..8391e8c6 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -4,12 +4,11 @@ import os from pelican.settings import read_settings, _DEFAULT_CONFIG SETTINGS = os.sep.join([os.path.dirname(os.path.abspath(__file__)), - "../../samples/pelican.conf.py"]) + "default_conf.py"]) class SettingsTest(TestCase): - - def test_read_settings(self): + def test_read_settings_from_file(self): # providing a file, it should read it, replace the default values and append # new values to the settings, if any settings = read_settings(SETTINGS)