1
0
Fork 0
forked from github/pelican
This commit is contained in:
Meir Kriheli 2012-04-28 00:52:45 +03:00
commit b73d984ec9
11 changed files with 81 additions and 33 deletions

View file

@ -1,8 +1,10 @@
*Foire aux questions (FAQ)*
Foire aux questions (FAQ)
#########################
Voici un résumé des questions fréquemment posées pour pelican.
*Est-il obligatoire d'avoir un fichier de configuration ?*
Est-il obligatoire d'avoir un fichier de configuration ?
========================================================
Non. Les fichiers de configuration sont juste un moyen facile de configurer
pelican. Pour les opérations de base, il est possible de spécifier des
@ -11,17 +13,20 @@ en invoquant pelican avec la ligne de commande (voir pelican --help pour
plus
d'informations à ce sujet)
*Je crée mon propre thème, comment utiliser pygments?*
Je crée mon propre thème, comment utiliser pygments?
====================================================
Pygment ajoute quelques classes au contenu généré, de sorte qua colorisation
de votre thème se fait grâce à un fichier css. Vous pouvez jeter un oeil à
celui proposé par`sur le site du projet <http://pygments.org/demo/15101/>`_
*Comment puis-je créer mon propre thèm*
Comment puis-je créer mon propre thèm
=====================================
Vueillez vous référer à :ref:`theming-pelican-fr`.
*Comment puis-je aider?*
Comment puis-je aider?
======================
Vous avez plusieurs options pour aider. Tout d'abord, vous pouvez utiliser
le

View file

@ -19,6 +19,22 @@ The conversion from HTML to reStructuredText relies on `pandoc
written with Markdown syntax, they will not be converted (as Pelican also
supports Markdown).
Dependencies
""""""""""""
``pelican-import`` has two dependencies not required by the rest of pelican:
- BeautifulSoup
- pandoc
BeatifulSoup can be installed like any other Python package::
$ pip install BeautifulSoup
For pandoc, install a package for your operating system from the
`pandoc site <http://johnmacfarlane.net/pandoc/installing.html>`_.
Usage
"""""
@ -26,8 +42,8 @@ Usage
| [--dir-cat]
| input
Optional arguments:
"""""""""""""""""""
Optional arguments
""""""""""""""""""
-h, --help show this help message and exit
--wpfile Wordpress XML export

View file

@ -52,10 +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.
`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`.
@ -147,6 +147,8 @@ Setting name (default value) what does it do?
`TAG_SAVE_AS` ('tag/{name}.html') The location to save the tag page.
================================================ =====================================================
Note: when any of `*_SAVE_AS` is set to False, files will not be created.
Timezone
--------
@ -366,8 +368,7 @@ By default, two themes are available. You can specify them using the `-t` option
You can define your own theme too, and specify its placement in the same
manner. (Be sure to specify the full absolute path to it.)
Here is `a guide on how to create your theme
<http://pelican.notmyidea.org/en/latest/themes.html>`_
Here is :doc:`a guide on how to create your theme <themes>`
You can find a list of themes at http://github.com/ametaireau/pelican-themes.

View file

@ -61,8 +61,9 @@ class Pelican(object):
def _handle_deprecation(self):
if self.settings.get('CLEAN_URLS', False):
logger.warning('Found deprecated `CLEAN_URLS` in settings. Modifing'
' the following settings for the same behaviour.')
logger.warning('Found deprecated `CLEAN_URLS` in settings.'
' Modifying the following settings for the'
' same behaviour.')
self.settings['ARTICLE_URL'] = '{slug}/'
self.settings['ARTICLE_LANG_URL'] = '{slug}-{lang}/'
@ -75,7 +76,7 @@ class Pelican(object):
if self.settings.get('ARTICLE_PERMALINK_STRUCTURE', False):
logger.warning('Found deprecated `ARTICLE_PERMALINK_STRUCTURE` in'
' settings. Modifing the following settings for'
' settings. Modifying the following settings for'
' the same behaviour.')
structure = self.settings['ARTICLE_PERMALINK_STRUCTURE']

View file

@ -63,7 +63,7 @@ class Page(object):
self.in_default_lang = (self.lang == default_lang)
# create the slug if not existing, fro mthe title
# create the slug if not existing, from the title
if not hasattr(self, 'slug') and hasattr(self, 'title'):
self.slug = slugify(self.title)
@ -135,7 +135,7 @@ class Page(object):
def _get_summary(self):
"""Returns the summary of an article, based on the summary metadata
if it is set, else troncate the content."""
if it is set, else truncate the content."""
if hasattr(self, '_summary'):
return self._summary
else:
@ -183,7 +183,12 @@ class URLWrapper(object):
def _from_settings(self, key):
setting = "%s_%s" % (self.__class__.__name__.upper(), key)
return unicode(self.settings[setting]).format(**self.as_dict())
value = self.settings[setting]
if not isinstance(value, (str, unicode)):
logger.warning(u'%s is set to %s' % (setting, value))
return value
else:
return unicode(value).format(**self.as_dict())
url = property(functools.partial(_from_settings, key='URL'))
save_as = property(functools.partial(_from_settings, key='SAVE_AS'))

View file

@ -352,7 +352,7 @@ class PagesGenerator(Generator):
class StaticGenerator(Generator):
"""copy static paths (what you want to cpy, like images, medias etc.
"""copy static paths (what you want to copy, like images, medias etc.
to output"""
def _copy_paths(self, paths, source, destination, output_path,

View file

@ -132,7 +132,7 @@ def configure_settings(settings, default_settings=None, filename=None):
if ('SITEURL' in settings):
# If SITEURL has a trailing slash, remove it and provide a warning
siteurl = settings['SITEURL']
if (siteurl[len(siteurl) - 1:] == '/'):
if (siteurl.endswith('/')):
settings['SITEURL'] = siteurl[:-1]
logger.warn("Removed extraneous trailing slash from SITEURL.")
# If SITEURL is defined but FEED_DOMAIN isn't, set FEED_DOMAIN = SITEURL

View file

@ -35,7 +35,7 @@
{% endfor %}
{% endif %}
{% for cat, null in categories %}
<li {% if cat == category %}class="active"{% endif %}><a href="{{ SITEURL }}/category/{{ cat }}.html">{{ cat }}</a></li>
<li {% if cat == category %}class="active"{% endif %}><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat }}</a></li>
{% endfor %}
</ul></nav>
</header><!-- /#banner -->

View file

@ -13,7 +13,12 @@ from pelican.utils import slugify
def wp2fields(xml):
"""Opens a wordpress XML file, and yield pelican fields"""
from BeautifulSoup import BeautifulStoneSoup
try:
from BeautifulSoup import BeautifulStoneSoup
except ImportError:
error = ('Missing dependency '
'"BeautifulSoup" required to import Wordpress XML files.')
sys.exit(error)
xmlfile = open(xml, encoding='utf-8').read()
soup = BeautifulStoneSoup(xmlfile)
@ -40,7 +45,13 @@ def wp2fields(xml):
def dc2fields(file):
"""Opens a Dotclear export file, and yield pelican fields"""
from BeautifulSoup import BeautifulStoneSoup
try:
from BeautifulSoup import BeautifulStoneSoup
except ImportError:
error = ('Missing dependency '
'"BeautifulSoup" required to import Dotclear files.')
sys.exit(error)
in_cat = False
in_post = False
@ -213,9 +224,12 @@ def fields2pelican(fields, out_markup, output_path, dircat=False):
html_filename = os.path.join(output_path, filename+'.html')
with open(html_filename, 'w', encoding='utf-8') as fp:
# Replace simple newlines with <br />+newline so that the HTML file
# represents the original post more accurately
content = content.replace("\n", "<br />\n")
# Replace newlines with paragraphs wrapped with <p> so
# HTML is valid before conversion
paragraphs = content.split('\n\n')
paragraphs = [u'<p>{}</p>'.format(p) for p in paragraphs]
new_content = ''.join(paragraphs)
fp.write(content)
cmd = 'pandoc --normalize --reference-links --from=html --to={0} -o "{1}" "{2}"'.format(

View file

@ -202,16 +202,16 @@ def main():
print('''Welcome to pelican-quickstart v{v}.
This script will help you creating a new Pelican based website.
This script will help you create a new Pelican-based website.
Please answer the following questions so this script can generate the files needed by Pelican.
'''.format(v=__version__))
CONF['basedir'] = os.path.abspath(ask('Where do you want to create your new Web site ?', answer=str, default=args.path))
CONF['sitename'] = ask('How will you call your Web site ?', answer=str, default=args.title)
CONF['sitename'] = ask('What will be the title of this Web site ?', answer=str, default=args.title)
CONF['author'] = ask('Who will be the author of this Web site ?', answer=str, default=args.author)
CONF['lang'] = ask('What will be the default language of this Web site ?', str, args.lang or CONF['lang'], 2)
CONF['lang'] = ask('What will be the default language of this Web site ?', str, args.lang or CONF['lang'], 2)
CONF['with_pagination'] = ask('Do you want to enable article pagination ?', bool, bool(CONF['default_pagination']))
@ -226,12 +226,12 @@ Please answer the following questions so this script can generate the files need
if ask('Do you want to upload your website using FTP ?', answer=bool, default=False):
CONF['ftp_host'] = ask('What is the hostname of your FTP server ?', str, CONF['ftp_host'])
CONF['ftp_user'] = ask('What is your username on this server ?', str, CONF['ftp_user'])
CONF['ftp_traget_dir'] = ask('Where do you want to put your website on this server ?', str, CONF['ftp_target_dir'])
CONF['ftp_target_dir'] = ask('Where do you want to put your website on this server ?', str, CONF['ftp_target_dir'])
if ask('Do you want to upload your website using SSH ?', answer=bool, default=False):
CONF['ssh_host'] = ask('What is the hostname of your SSH server ?', str, CONF['ssh_host'])
CONF['ssh_user'] = ask('What is your username on this server ?', str, CONF['ssh_user'])
CONF['ssh_traget_dir'] = ask('Where do you want to put your website on this server ?', str, CONF['ssh_target_dir'])
CONF['ssh_target_dir'] = ask('Where do you want to put your website on this server ?', str, CONF['ssh_target_dir'])
if ask('Do you want to upload your website using Dropbox ?', answer=bool, default=False):
CONF['dropbox_dir'] = ask('Where is your Dropbox directory ?', str, CONF['dropbox_dir'])

View file

@ -36,7 +36,7 @@ class Writer(object):
feed.add_item(
title=item.title,
link='%s%s' % (self.site_url, item.url),
link='%s/%s' % (self.site_url, item.url),
unique_id='tag:%s,%s:%s' % (self.site_url.replace('http://', ''),
item.date.date(), item.url),
description=item.content,
@ -99,6 +99,12 @@ class Writer(object):
:param **kwargs: additional variables to pass to the templates
"""
if name is False:
return
elif not name:
# other stuff, just return for now
return
def _write_file(template, localcontext, output_path, name):
"""Render the template write the file."""
old_locale = locale.setlocale(locale.LC_ALL)