mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge branch 'hacks' of https://github.com/RonnyPfannschmidt/pelican
This commit is contained in:
commit
b7daed2ce3
4 changed files with 21 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
from pelican.generators import (ArticlesGenerator, PagesGenerator,
|
from pelican.generators import (ArticlesGenerator, PagesGenerator,
|
||||||
StaticGenerator, PdfGenerator)
|
StaticGenerator, PdfGenerator)
|
||||||
|
|
@ -140,6 +141,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
if files_changed(pelican.path, pelican.markup):
|
if files_changed(pelican.path, pelican.markup):
|
||||||
pelican.run()
|
pelican.run()
|
||||||
|
time.sleep(.5) # sleep to avoid cpu load
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
from logging import *
|
from logging import CRITICAL, ERROR, WARN, INFO, DEBUG
|
||||||
|
from logging import critical, error, info, warning, warn, debug
|
||||||
|
from logging import Formatter, getLogger, StreamHandler
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ try:
|
||||||
from docutils import core
|
from docutils import core
|
||||||
|
|
||||||
# import the directives to have pygments support
|
# import the directives to have pygments support
|
||||||
import rstdirectives
|
from pelican import rstdirectives
|
||||||
except ImportError:
|
except ImportError:
|
||||||
core = False
|
core = False
|
||||||
try:
|
try:
|
||||||
|
|
@ -11,15 +11,14 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
Markdown = False
|
Markdown = False
|
||||||
import re
|
import re
|
||||||
import string
|
|
||||||
|
|
||||||
from pelican.utils import get_date, open
|
from pelican.utils import get_date, open
|
||||||
|
|
||||||
|
|
||||||
_METADATAS_PROCESSORS = {
|
_METADATAS_PROCESSORS = {
|
||||||
'tags': lambda x: map(string.strip, x.split(',')),
|
'tags': lambda x: map(unicode.strip, x.split(',')),
|
||||||
'date': lambda x: get_date(x),
|
'date': lambda x: get_date(x),
|
||||||
'status': string.strip,
|
'status': unicode.strip,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -46,7 +45,9 @@ class RstReader(Reader):
|
||||||
metadatas = self._parse_metadata(text)
|
metadatas = self._parse_metadata(text)
|
||||||
extra_params = {'input_encoding': 'unicode',
|
extra_params = {'input_encoding': 'unicode',
|
||||||
'initial_header_level': '2'}
|
'initial_header_level': '2'}
|
||||||
rendered_content = core.publish_parts(text, writer_name='html',
|
rendered_content = core.publish_parts(text,
|
||||||
|
source_path=filename,
|
||||||
|
writer_name='html',
|
||||||
settings_overrides=extra_params)
|
settings_overrides=extra_params)
|
||||||
title = rendered_content.get('title')
|
title = rendered_content.get('title')
|
||||||
content = rendered_content.get('body')
|
content = rendered_content.get('body')
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ from datetime import datetime
|
||||||
from codecs import open as _open
|
from codecs import open as _open
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from pelican.log import *
|
from pelican.log import warning, info
|
||||||
|
|
||||||
|
|
||||||
def get_date(string):
|
def get_date(string):
|
||||||
|
|
@ -62,7 +62,7 @@ def clean_output_dir(path):
|
||||||
|
|
||||||
# remove all the existing content from the output folder
|
# remove all the existing content from the output folder
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(path)
|
pass # WEEEEE dont kill
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -164,9 +164,13 @@ def process_translations(content_list):
|
||||||
len_ = len(default_lang_items)
|
len_ = len(default_lang_items)
|
||||||
if len_ > 1:
|
if len_ > 1:
|
||||||
warning(u'there are %s variants of "%s"' % (len_, slug))
|
warning(u'there are %s variants of "%s"' % (len_, slug))
|
||||||
|
for x in default_lang_items:
|
||||||
|
warning(' %s' % x.filename)
|
||||||
elif len_ == 0:
|
elif len_ == 0:
|
||||||
default_lang_items = items[:1]
|
default_lang_items = items[:1]
|
||||||
|
|
||||||
|
if not slug:
|
||||||
|
warning('empty slug for %r' %( default_lang_items[0].filename,))
|
||||||
index.extend(default_lang_items)
|
index.extend(default_lang_items)
|
||||||
translations.extend(filter(
|
translations.extend(filter(
|
||||||
lambda x: x not in default_lang_items,
|
lambda x: x not in default_lang_items,
|
||||||
|
|
@ -188,9 +192,10 @@ def files_changed(path, extensions):
|
||||||
|
|
||||||
def file_times(path):
|
def file_times(path):
|
||||||
"""Return the last time files have been modified"""
|
"""Return the last time files have been modified"""
|
||||||
for top_level in os.listdir(path):
|
for root, dirs, files in os.walk(path):
|
||||||
for root, dirs, files in os.walk(top_level):
|
dirs[:] = [x for x in dirs if x[0] != '.']
|
||||||
for file in filter(with_extension, files):
|
for file in files:
|
||||||
|
if any(file.endswith(ext) for ext in extensions):
|
||||||
yield os.stat(os.path.join(root, file)).st_mtime
|
yield os.stat(os.path.join(root, file)).st_mtime
|
||||||
|
|
||||||
global LAST_MTIME
|
global LAST_MTIME
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue