mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
merge win-encoding
This commit is contained in:
commit
dd299d272b
56 changed files with 1031 additions and 375 deletions
|
|
@ -184,6 +184,8 @@ def build_header(title, date, author, categories, tags):
|
|||
header = '%s\n%s\n' % (title, '#' * len(title))
|
||||
if date:
|
||||
header += ':date: %s\n' % date
|
||||
if author:
|
||||
header += ':author: %s\n' % author
|
||||
if categories:
|
||||
header += ':category: %s\n' % ', '.join(categories)
|
||||
if tags:
|
||||
|
|
@ -196,6 +198,8 @@ def build_markdown_header(title, date, author, categories, tags):
|
|||
header = 'Title: %s\n' % title
|
||||
if date:
|
||||
header += 'Date: %s\n' % date
|
||||
if author:
|
||||
header += 'Author: %s\n' % author
|
||||
if categories:
|
||||
header += 'Category: %s\n' % ', '.join(categories)
|
||||
if tags:
|
||||
|
|
@ -216,7 +220,7 @@ def fields2pelican(fields, out_markup, output_path, dircat=False, strip_raw=Fals
|
|||
filename = os.path.basename(filename)
|
||||
|
||||
# option to put files in directories with categories names
|
||||
if dircat and (len(categories) == 1):
|
||||
if dircat and (len(categories) > 0):
|
||||
catname = slugify(categories[0])
|
||||
out_filename = os.path.join(output_path, catname, filename+ext)
|
||||
if not os.path.isdir(os.path.join(output_path, catname)):
|
||||
|
|
|
|||
|
|
@ -9,13 +9,12 @@ import codecs
|
|||
|
||||
from pelican import __version__
|
||||
|
||||
_TEMPLATES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), \
|
||||
_TEMPLATES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
|
||||
"templates")
|
||||
|
||||
|
||||
CONF = {
|
||||
'pelican' : 'pelican',
|
||||
'pelicanopts' : '',
|
||||
'pelican': 'pelican',
|
||||
'pelicanopts': '',
|
||||
'basedir': '.',
|
||||
'ftp_host': 'localhost',
|
||||
'ftp_user': 'anonymous',
|
||||
|
|
@ -24,8 +23,8 @@ CONF = {
|
|||
'ssh_port': 22,
|
||||
'ssh_user': 'root',
|
||||
'ssh_target_dir': '/var/www',
|
||||
'dropbox_dir' : '~/Dropbox/Public/',
|
||||
'default_pagination' : 10,
|
||||
'dropbox_dir': '~/Dropbox/Public/',
|
||||
'default_pagination': 10,
|
||||
'siteurl': '',
|
||||
'lang': 'en'
|
||||
}
|
||||
|
|
@ -77,7 +76,7 @@ def ask(question, answer=str, default=None, l=None):
|
|||
if l and len(r) != l:
|
||||
print('You must enter a {0} letters long string'.format(l))
|
||||
else:
|
||||
break
|
||||
break
|
||||
|
||||
return r
|
||||
|
||||
|
|
@ -148,14 +147,16 @@ def main():
|
|||
|
||||
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__))
|
||||
|
||||
project = os.path.join(os.environ.get('VIRTUAL_ENV', '.'), '.project')
|
||||
if os.path.isfile(project):
|
||||
CONF['basedir'] = open(project, 'r').read().rstrip("\n")
|
||||
print('Using project associated with current virtual environment. Will save to:\n%s\n' % CONF['basedir'])
|
||||
print('Using project associated with current virtual environment.'
|
||||
'Will save to:\n%s\n' % CONF['basedir'])
|
||||
else:
|
||||
CONF['basedir'] = os.path.abspath(ask('Where do you want to create your new web site?', answer=str, default=args.path))
|
||||
|
||||
|
|
@ -201,9 +202,13 @@ Please answer the following questions so this script can generate the files need
|
|||
|
||||
try:
|
||||
with codecs.open(os.path.join(CONF['basedir'], 'pelicanconf.py'), 'w', 'utf-8') as fd:
|
||||
conf_python = dict()
|
||||
for key, value in CONF.iteritems():
|
||||
conf_python[key] = repr(value)
|
||||
|
||||
for line in get_template('pelicanconf.py'):
|
||||
template = string.Template(line)
|
||||
fd.write(template.safe_substitute(CONF))
|
||||
fd.write(template.safe_substitute(conf_python))
|
||||
fd.close()
|
||||
except OSError, e:
|
||||
print('Error: {0}'.format(e))
|
||||
|
|
@ -228,11 +233,16 @@ Please answer the following questions so this script can generate the files need
|
|||
print('Error: {0}'.format(e))
|
||||
|
||||
if develop:
|
||||
conf_shell = dict()
|
||||
for key, value in CONF.iteritems():
|
||||
if isinstance(value, basestring) and ' ' in value:
|
||||
value = '"' + value.replace('"', '\\"') + '"'
|
||||
conf_shell[key] = value
|
||||
try:
|
||||
with codecs.open(os.path.join(CONF['basedir'], 'develop_server.sh'), 'w', 'utf-8') as fd:
|
||||
for line in get_template('develop_server.sh'):
|
||||
template = string.Template(line)
|
||||
fd.write(template.safe_substitute(CONF))
|
||||
fd.write(template.safe_substitute(conf_shell))
|
||||
fd.close()
|
||||
os.chmod((os.path.join(CONF['basedir'], 'develop_server.sh')), 0755)
|
||||
except OSError, e:
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ ssh_upload: publish
|
|||
scp -P $$(SSH_PORT) -r $$(OUTPUTDIR)/* $$(SSH_USER)@$$(SSH_HOST):$$(SSH_TARGET_DIR)
|
||||
|
||||
rsync_upload: publish
|
||||
rsync -e "ssh -p $(SSH_PORT)" -P -rvz --delete $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
|
||||
rsync -e "ssh -p $(SSH_PORT)" -P -rvz --delete $(OUTPUTDIR) $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
|
||||
|
||||
dropbox_upload: publish
|
||||
cp -r $$(OUTPUTDIR)/* $$(DROPBOX_DIR)
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*- #
|
||||
|
||||
AUTHOR = u"$author"
|
||||
SITENAME = u"$sitename"
|
||||
AUTHOR = $author
|
||||
SITENAME = $sitename
|
||||
SITEURL = ''
|
||||
|
||||
TIMEZONE = 'Europe/Paris'
|
||||
|
||||
DEFAULT_LANG = '$lang'
|
||||
DEFAULT_LANG = $lang
|
||||
|
||||
# Blogroll
|
||||
LINKS = (('Pelican', 'http://docs.notmyidea.org/alexis/pelican/'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue