mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge branch 'master' of https://github.com/ametaireau/pelican into fix-sort-categories
This commit is contained in:
commit
a72567fa36
11 changed files with 70 additions and 32 deletions
|
|
@ -1,8 +1,10 @@
|
||||||
*Foire aux questions (FAQ)*
|
Foire aux questions (FAQ)
|
||||||
|
#########################
|
||||||
|
|
||||||
Voici un résumé des questions fréquemment posées pour pelican.
|
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
|
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
|
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
|
plus
|
||||||
d'informations à ce sujet)
|
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
|
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 à
|
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/>`_
|
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`.
|
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
|
Vous avez plusieurs options pour aider. Tout d'abord, vous pouvez utiliser
|
||||||
le
|
le
|
||||||
|
|
|
||||||
|
|
@ -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
|
written with Markdown syntax, they will not be converted (as Pelican also
|
||||||
supports Markdown).
|
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
|
Usage
|
||||||
"""""
|
"""""
|
||||||
|
|
||||||
|
|
@ -26,8 +42,8 @@ Usage
|
||||||
| [--dir-cat]
|
| [--dir-cat]
|
||||||
| input
|
| input
|
||||||
|
|
||||||
Optional arguments:
|
Optional arguments
|
||||||
"""""""""""""""""""
|
""""""""""""""""""
|
||||||
|
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--wpfile Wordpress XML export
|
--wpfile Wordpress XML export
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,10 @@ Setting name (default value) What does it do?
|
||||||
supported extensions.
|
supported extensions.
|
||||||
`OUTPUT_PATH` (``'output/'``) Where to output the generated files.
|
`OUTPUT_PATH` (``'output/'``) Where to output the generated files.
|
||||||
`PATH` (``None``) Path to look at for input files.
|
`PATH` (``None``) Path to look at for input files.
|
||||||
`PAGE_DIR' (``'pages'``) Directory to look at for pages.
|
`PAGE_DIR` (``'pages'``) Directory to look at for pages.
|
||||||
`PAGE_EXCLUDES' (``()``) A list of directories to exclude when looking for pages.
|
`PAGE_EXCLUDES` (``()``) A list of directories to exclude when looking for pages.
|
||||||
`ARTICLE_DIR' (``''``) Directory to look at for articles.
|
`ARTICLE_DIR` (``''``) Directory to look at for articles.
|
||||||
`ARTICLE_EXCLUDES': (``('pages',)``) A list of directories to exclude when looking 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
|
`PDF_GENERATOR` (``False``) Set to True if you want to have PDF versions
|
||||||
of your documents. You will need to install
|
of your documents. You will need to install
|
||||||
`rst2pdf`.
|
`rst2pdf`.
|
||||||
|
|
@ -361,8 +361,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
|
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.)
|
manner. (Be sure to specify the full absolute path to it.)
|
||||||
|
|
||||||
Here is `a guide on how to create your theme
|
Here is :doc:`a guide on how to create your theme <themes>`
|
||||||
<http://pelican.notmyidea.org/en/latest/themes.html>`_
|
|
||||||
|
|
||||||
You can find a list of themes at http://github.com/ametaireau/pelican-themes.
|
You can find a list of themes at http://github.com/ametaireau/pelican-themes.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,9 @@ class Pelican(object):
|
||||||
def _handle_deprecation(self):
|
def _handle_deprecation(self):
|
||||||
|
|
||||||
if self.settings.get('CLEAN_URLS', False):
|
if self.settings.get('CLEAN_URLS', False):
|
||||||
logger.warning('Found deprecated `CLEAN_URLS` in settings. Modifing'
|
logger.warning('Found deprecated `CLEAN_URLS` in settings.'
|
||||||
' the following settings for the same behaviour.')
|
' Modifying the following settings for the'
|
||||||
|
' same behaviour.')
|
||||||
|
|
||||||
self.settings['ARTICLE_URL'] = '{slug}/'
|
self.settings['ARTICLE_URL'] = '{slug}/'
|
||||||
self.settings['ARTICLE_LANG_URL'] = '{slug}-{lang}/'
|
self.settings['ARTICLE_LANG_URL'] = '{slug}-{lang}/'
|
||||||
|
|
@ -75,7 +76,7 @@ class Pelican(object):
|
||||||
|
|
||||||
if self.settings.get('ARTICLE_PERMALINK_STRUCTURE', False):
|
if self.settings.get('ARTICLE_PERMALINK_STRUCTURE', False):
|
||||||
logger.warning('Found deprecated `ARTICLE_PERMALINK_STRUCTURE` in'
|
logger.warning('Found deprecated `ARTICLE_PERMALINK_STRUCTURE` in'
|
||||||
' settings. Modifing the following settings for'
|
' settings. Modifying the following settings for'
|
||||||
' the same behaviour.')
|
' the same behaviour.')
|
||||||
|
|
||||||
structure = self.settings['ARTICLE_PERMALINK_STRUCTURE']
|
structure = self.settings['ARTICLE_PERMALINK_STRUCTURE']
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class Page(object):
|
||||||
|
|
||||||
self.in_default_lang = (self.lang == default_lang)
|
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'):
|
if not hasattr(self, 'slug') and hasattr(self, 'title'):
|
||||||
self.slug = slugify(self.title)
|
self.slug = slugify(self.title)
|
||||||
|
|
||||||
|
|
@ -135,7 +135,7 @@ class Page(object):
|
||||||
|
|
||||||
def _get_summary(self):
|
def _get_summary(self):
|
||||||
"""Returns the summary of an article, based on the summary metadata
|
"""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'):
|
if hasattr(self, '_summary'):
|
||||||
return self._summary
|
return self._summary
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,7 @@ class PagesGenerator(Generator):
|
||||||
|
|
||||||
|
|
||||||
class StaticGenerator(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"""
|
to output"""
|
||||||
|
|
||||||
def _copy_paths(self, paths, source, destination, output_path,
|
def _copy_paths(self, paths, source, destination, output_path,
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ def configure_settings(settings, default_settings=None, filename=None):
|
||||||
if ('SITEURL' in settings):
|
if ('SITEURL' in settings):
|
||||||
# If SITEURL has a trailing slash, remove it and provide a warning
|
# If SITEURL has a trailing slash, remove it and provide a warning
|
||||||
siteurl = settings['SITEURL']
|
siteurl = settings['SITEURL']
|
||||||
if (siteurl[len(siteurl) - 1:] == '/'):
|
if (siteurl.endswith('/')):
|
||||||
settings['SITEURL'] = siteurl[:-1]
|
settings['SITEURL'] = siteurl[:-1]
|
||||||
logger.warn("Removed extraneous trailing slash from SITEURL.")
|
logger.warn("Removed extraneous trailing slash from SITEURL.")
|
||||||
# If SITEURL is defined but FEED_DOMAIN isn't, set FEED_DOMAIN = SITEURL
|
# If SITEURL is defined but FEED_DOMAIN isn't, set FEED_DOMAIN = SITEURL
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for cat, null in categories %}
|
{% 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 %}
|
{% endfor %}
|
||||||
</ul></nav>
|
</ul></nav>
|
||||||
</header><!-- /#banner -->
|
</header><!-- /#banner -->
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,12 @@ from pelican.utils import slugify
|
||||||
|
|
||||||
def wp2fields(xml):
|
def wp2fields(xml):
|
||||||
"""Opens a wordpress XML file, and yield pelican fields"""
|
"""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()
|
xmlfile = open(xml, encoding='utf-8').read()
|
||||||
soup = BeautifulStoneSoup(xmlfile)
|
soup = BeautifulStoneSoup(xmlfile)
|
||||||
|
|
@ -40,7 +45,13 @@ def wp2fields(xml):
|
||||||
|
|
||||||
def dc2fields(file):
|
def dc2fields(file):
|
||||||
"""Opens a Dotclear export file, and yield pelican fields"""
|
"""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_cat = False
|
||||||
in_post = 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')
|
html_filename = os.path.join(output_path, filename+'.html')
|
||||||
|
|
||||||
with open(html_filename, 'w', encoding='utf-8') as fp:
|
with open(html_filename, 'w', encoding='utf-8') as fp:
|
||||||
# Replace simple newlines with <br />+newline so that the HTML file
|
# Replace newlines with paragraphs wrapped with <p> so
|
||||||
# represents the original post more accurately
|
# HTML is valid before conversion
|
||||||
content = content.replace("\n", "<br />\n")
|
paragraphs = content.split('\n\n')
|
||||||
|
paragraphs = [u'<p>{}</p>'.format(p) for p in paragraphs]
|
||||||
|
new_content = ''.join(paragraphs)
|
||||||
|
|
||||||
fp.write(content)
|
fp.write(content)
|
||||||
|
|
||||||
cmd = 'pandoc --normalize --reference-links --from=html --to={0} -o "{1}" "{2}"'.format(
|
cmd = 'pandoc --normalize --reference-links --from=html --to={0} -o "{1}" "{2}"'.format(
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,9 @@ clean:
|
||||||
dropbox_upload: $$(OUTPUTDIR)/index.html
|
dropbox_upload: $$(OUTPUTDIR)/index.html
|
||||||
\tcp -r $$(OUTPUTDIR)/* $$(DROPBOX_DIR)
|
\tcp -r $$(OUTPUTDIR)/* $$(DROPBOX_DIR)
|
||||||
|
|
||||||
|
rsync_upload: $$(OUTPUTDIR)/index.html
|
||||||
|
\trsync --delete -rvz -e ssh $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
|
||||||
|
|
||||||
ssh_upload: $$(OUTPUTDIR)/index.html
|
ssh_upload: $$(OUTPUTDIR)/index.html
|
||||||
\tscp -r $$(OUTPUTDIR)/* $$(SSH_USER)@$$(SSH_HOST):$$(SSH_TARGET_DIR)
|
\tscp -r $$(OUTPUTDIR)/* $$(SSH_USER)@$$(SSH_HOST):$$(SSH_TARGET_DIR)
|
||||||
|
|
||||||
|
|
@ -199,16 +202,16 @@ def main():
|
||||||
|
|
||||||
print('''Welcome to pelican-quickstart v{v}.
|
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.
|
Please answer the following questions so this script can generate the files needed by Pelican.
|
||||||
|
|
||||||
'''.format(v=__version__))
|
'''.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['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['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']))
|
CONF['with_pagination'] = ask('Do you want to enable article pagination ?', bool, bool(CONF['default_pagination']))
|
||||||
|
|
||||||
|
|
@ -223,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):
|
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_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_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):
|
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_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_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):
|
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'])
|
CONF['dropbox_dir'] = ask('Where is your Dropbox directory ?', str, CONF['dropbox_dir'])
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class Writer(object):
|
||||||
|
|
||||||
feed.add_item(
|
feed.add_item(
|
||||||
title=item.title,
|
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://', ''),
|
unique_id='tag:%s,%s:%s' % (self.site_url.replace('http://', ''),
|
||||||
item.date.date(), item.url),
|
item.date.date(), item.url),
|
||||||
description=item.content,
|
description=item.content,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue