mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
commit
b2092fe0e7
4 changed files with 24 additions and 7 deletions
|
|
@ -2,6 +2,9 @@
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
import time
|
||||||
|
import calendar
|
||||||
|
import pytz
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from codecs import open as _open
|
from codecs import open as _open
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
|
@ -222,3 +225,13 @@ def files_changed(path, extensions):
|
||||||
LAST_MTIME = mtime
|
LAST_MTIME = mtime
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def set_date_tzinfo(d, tz_name=None):
|
||||||
|
""" Date without tzinfo shoudbe utc.
|
||||||
|
This function set the right tz to date that aren't utc and don't have tzinfo
|
||||||
|
"""
|
||||||
|
if tz_name is not None:
|
||||||
|
tz = pytz.timezone(tz_name)
|
||||||
|
return tz.localize(d)
|
||||||
|
else:
|
||||||
|
return d
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ from functools import partial
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
from feedgenerator import Atom1Feed, Rss201rev2Feed
|
from feedgenerator import Atom1Feed, Rss201rev2Feed
|
||||||
from pelican.utils import get_relative_path
|
from pelican.utils import get_relative_path, set_date_tzinfo
|
||||||
from pelican.paginator import Paginator
|
from pelican.paginator import Paginator
|
||||||
from pelican.log import *
|
from pelican.log import *
|
||||||
|
|
||||||
|
|
@ -37,7 +37,8 @@ class Writer(object):
|
||||||
description=item.content,
|
description=item.content,
|
||||||
categories=item.tags if hasattr(item, 'tags') else None,
|
categories=item.tags if hasattr(item, 'tags') else None,
|
||||||
author_name=getattr(item, 'author', 'John Doe'),
|
author_name=getattr(item, 'author', 'John Doe'),
|
||||||
pubdate=item.date)
|
pubdate=set_date_tzinfo(item.date,
|
||||||
|
self.settings.get('TIMEZONE', None)))
|
||||||
|
|
||||||
def write_feed(self, elements, context, filename=None, feed_type='atom'):
|
def write_feed(self, elements, context, filename=None, feed_type='atom'):
|
||||||
"""Generate a feed with the list of articles provided
|
"""Generate a feed with the list of articles provided
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -4,7 +4,7 @@ import sys
|
||||||
|
|
||||||
VERSION = "2.7.2" # find a better way to do so.
|
VERSION = "2.7.2" # find a better way to do so.
|
||||||
|
|
||||||
requires = ['feedgenerator', 'jinja2', 'pygments', 'docutils']
|
requires = ['feedgenerator', 'jinja2', 'pygments', 'docutils', 'pytz']
|
||||||
if sys.version_info < (2,7):
|
if sys.version_info < (2,7):
|
||||||
requires.append('argparse')
|
requires.append('argparse')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ TEMPLATES={
|
||||||
PELICAN=$pelican
|
PELICAN=$pelican
|
||||||
PELICANOPTS=$pelicanopts
|
PELICANOPTS=$pelicanopts
|
||||||
|
|
||||||
BASEDIR=$basedir
|
BASEDIR=$$(PWD)
|
||||||
INPUTDIR=$$(BASEDIR)/src
|
INPUTDIR=$$(BASEDIR)/src
|
||||||
OUTPUTDIR=$$(BASEDIR)/output
|
OUTPUTDIR=$$(BASEDIR)/output
|
||||||
CONFFILE=$$(BASEDIR)/pelican.conf.py
|
CONFFILE=$$(BASEDIR)/pelican.conf.py
|
||||||
|
|
@ -36,20 +36,21 @@ help:
|
||||||
\t@echo ' '
|
\t@echo ' '
|
||||||
|
|
||||||
|
|
||||||
html: $$(OUTPUTDIR)/index.html
|
html: clean $$(OUTPUTDIR)/index.html
|
||||||
\t@echo 'Done'
|
\t@echo 'Done'
|
||||||
|
|
||||||
$$(OUTPUTDIR)/%.html:
|
$$(OUTPUTDIR)/%.html:
|
||||||
\t$$(PELICAN) $$(INPUTDIR) -o $$(OUTPUTDIR) -s $$(CONFFILE)
|
\t$$(PELICAN) $$(INPUTDIR) -o $$(OUTPUTDIR) -s $$(CONFFILE)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
\trm -r $$(OUTPUTDIR)/*
|
\trm -fr $$(OUTPUTDIR)
|
||||||
|
\tmkdir $$(OUTPUTDIR)
|
||||||
|
|
||||||
dropbox_upload: $$(OUTPUTDIR)/index.html
|
dropbox_upload: $$(OUTPUTDIR)/index.html
|
||||||
\tcp -r $$(OUTPUTDIR)/* $$(DROPBOX_DIR)
|
\tcp -r $$(OUTPUTDIR)/* $$(DROPBOX_DIR)
|
||||||
|
|
||||||
ssh_upload: $$(OUTPUTDIR)/index.html
|
ssh_upload: $$(OUTPUTDIR)/index.html
|
||||||
\tscp -rv $$(OUTPUTDIR)/* $$(SSH_USER)@$$(SSH_HOST)/$$(SSH_TARGET_DIR)
|
\tscp -r $$(OUTPUTDIR)/* $$(SSH_USER)@$$(SSH_HOST):$$(SSH_TARGET_DIR)
|
||||||
|
|
||||||
ftp_upload: $$(OUTPUTDIR)/index.html
|
ftp_upload: $$(OUTPUTDIR)/index.html
|
||||||
\tlftp ftp://$$(FTP_USER)@$$(FTP_HOST) -e "mirror -R $$(OUTPUT_DIR)/* $$(FTP_TARGET_DIR) ; quit"
|
\tlftp ftp://$$(FTP_USER)@$$(FTP_HOST) -e "mirror -R $$(OUTPUT_DIR)/* $$(FTP_TARGET_DIR) ; quit"
|
||||||
|
|
@ -64,6 +65,8 @@ AUTHOR = u"$author"
|
||||||
SITENAME = u"$sitename"
|
SITENAME = u"$sitename"
|
||||||
SITEURL = '/'
|
SITEURL = '/'
|
||||||
|
|
||||||
|
TIMEZONE = 'Europe/Paris'
|
||||||
|
|
||||||
DEFAULT_LANG='$lang'
|
DEFAULT_LANG='$lang'
|
||||||
|
|
||||||
# Blogroll
|
# Blogroll
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue