mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add support of multiple static paths and feed generation.
This commit is contained in:
parent
e585c83ac1
commit
75821fb644
9 changed files with 33 additions and 76 deletions
1
TODO
1
TODO
|
|
@ -1,2 +1 @@
|
||||||
* Add RSS generation
|
|
||||||
* package it !
|
* package it !
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ from functools import partial
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
from feedgenerator import Atom1Feed
|
||||||
|
|
||||||
import rstdirectives # import the directives to have pygments support
|
import rstdirectives # import the directives to have pygments support
|
||||||
|
|
||||||
|
|
@ -20,7 +21,9 @@ _DEFAULT_THEME =\
|
||||||
_DEFAULT_CONFIG = {'PATH': None,
|
_DEFAULT_CONFIG = {'PATH': None,
|
||||||
'THEME': _DEFAULT_THEME,
|
'THEME': _DEFAULT_THEME,
|
||||||
'OUTPUT_PATH': 'output/',
|
'OUTPUT_PATH': 'output/',
|
||||||
'MARKUP': 'rst'}
|
'MARKUP': 'rst',
|
||||||
|
'STATIC_PATHS': ['css', 'images'],
|
||||||
|
'FEED_FILENAME': 'atom.xml'}
|
||||||
|
|
||||||
def generate_output(path=None, theme=None, output_path=None, markup=None,
|
def generate_output(path=None, theme=None, output_path=None, markup=None,
|
||||||
settings=None):
|
settings=None):
|
||||||
|
|
@ -84,12 +87,31 @@ def generate_output(path=None, theme=None, output_path=None, markup=None,
|
||||||
generate('%s' % article.url,
|
generate('%s' % article.url,
|
||||||
templates['article'], context, article=article)
|
templates['article'], context, article=article)
|
||||||
|
|
||||||
# copy css path to output/css
|
# generate atom feed
|
||||||
try:
|
feed = Atom1Feed(
|
||||||
shutil.copytree(os.path.join(theme, 'css'),
|
title=context['BLOGNAME'],
|
||||||
os.path.join(output_path, 'css'))
|
link=context['BLOGURL'],
|
||||||
except OSError:
|
feed_url='%s/%s' % (context['BLOGURL'], context['FEED_FILENAME']),
|
||||||
pass
|
description=context['BLOGSUBTITLE'])
|
||||||
|
for article in articles:
|
||||||
|
feed.add_item(
|
||||||
|
title=article.title,
|
||||||
|
link='%s/%s' % (context['BLOGURL'], article.url),
|
||||||
|
description=article.content,
|
||||||
|
author_name=article.author,
|
||||||
|
pubdate=article.date)
|
||||||
|
|
||||||
|
fp = open(os.path.join(output_path, context['FEED_FILENAME']), 'w')
|
||||||
|
feed.write(fp, 'utf-8')
|
||||||
|
fp.close()
|
||||||
|
|
||||||
|
# copy static paths to output
|
||||||
|
for path in context['STATIC_PATHS']:
|
||||||
|
try:
|
||||||
|
shutil.copytree(os.path.join(theme, path),
|
||||||
|
os.path.join(output_path, path))
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def generate_file(path, name, template, context, **kwargs):
|
def generate_file(path, name, template, context, **kwargs):
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<title>{% block title %}{{ BLOGNAME }}{%endblock%}</title>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<link rel="stylesheet" href="css/main.css" type="text/css" />
|
|
||||||
|
|
||||||
<!--[if IE]>
|
|
||||||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
|
|
||||||
|
|
||||||
<!--[if lte IE 7]>
|
|
||||||
<link rel="stylesheet" type="text/css" media="all" href="css/ie.css"/>
|
|
||||||
<script src="js/IE8.js" type="text/javascript"></script><![endif]-->
|
|
||||||
|
|
||||||
<!--[if lt IE 7]>
|
|
||||||
<link rel="stylesheet" type="text/css" media="all" href="css/ie6.css"/><![endif]-->
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body id="index" class="home">
|
|
||||||
|
|
||||||
<header id="banner" class="body">
|
|
||||||
<h1><a href="#">{{ BLOGNAME }} <strong>{{ BLOGSUBTITLE }}</strong></a></h1>
|
|
||||||
<nav><ul>
|
|
||||||
<li class="active"><a href="{{ BLOGURL }}">blog</a></li>
|
|
||||||
{% for title, link in MENUITEMS %}
|
|
||||||
<li><a href="{{ link }}">{{ title }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul></nav>
|
|
||||||
</header><!-- /#banner -->
|
|
||||||
{% block content %}
|
|
||||||
{% endblock %}
|
|
||||||
<section id="extras" class="body">
|
|
||||||
{% if BLOGROLL %}
|
|
||||||
<div class="blogroll">
|
|
||||||
<h2>blogroll</h2>
|
|
||||||
<ul>
|
|
||||||
{% for name, link in BLOGROLL %}
|
|
||||||
<li><a href="{{ link }}">{{ name }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div><!-- /.blogroll -->
|
|
||||||
{% endif %}
|
|
||||||
{% if SOCIAL %}
|
|
||||||
<div class="social">
|
|
||||||
<h2>social</h2>
|
|
||||||
<ul>
|
|
||||||
<li><a href="{{ FEEDURL }}" rel="alternate">rss</a></li>
|
|
||||||
{% for name, link in SOCIAL %}
|
|
||||||
<li><a href="{{ link }}">{{ name }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
</div><!-- /.social -->
|
|
||||||
{% endif %}
|
|
||||||
</section><!-- /#extras -->
|
|
||||||
|
|
||||||
<footer id="contentinfo" class="body">
|
|
||||||
<address id="about" class="vcard body">
|
|
||||||
Proudly powered by <a href="#">pelican</a>, which takes great advantages of <a href="http://python.org">python</a>.
|
|
||||||
</address><!-- /#about -->
|
|
||||||
|
|
||||||
<p>The theme is by<a href="http://smashingmagazine.com">Smashing Magazine</a>, thanks!</p>
|
|
||||||
</footer><!-- /#contentinfo -->
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -281,7 +281,7 @@ img.left, figure.left {float: right; margin: 0 0 2em 2em;}
|
||||||
.social a[href*='digg.com'] {background-image: url('../images/icons/digg.png');}
|
.social a[href*='digg.com'] {background-image: url('../images/icons/digg.png');}
|
||||||
.social a[href*='facebook.com'] {background-image: url('../images/icons/facebook.png');}
|
.social a[href*='facebook.com'] {background-image: url('../images/icons/facebook.png');}
|
||||||
.social a[href*='last.fm'], .social a[href*='lastfm.'] {background-image: url('../images/icons/lastfm.png');}
|
.social a[href*='last.fm'], .social a[href*='lastfm.'] {background-image: url('../images/icons/lastfm.png');}
|
||||||
.social a[href*='/feed/'] {background-image: url('../images/icons/rss.png');}
|
.social a[href*='atom.xml'] {background-image: url('../images/icons/rss.png');}
|
||||||
.social a[href*='twitter.com'] {background-image: url('../images/icons/twitter.png');}
|
.social a[href*='twitter.com'] {background-image: url('../images/icons/twitter.png');}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
BIN
samples/themes/notmyidea/images/icons/delicious.png
Normal file
BIN
samples/themes/notmyidea/images/icons/delicious.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 963 B |
BIN
samples/themes/notmyidea/images/icons/lastfm.png
Normal file
BIN
samples/themes/notmyidea/images/icons/lastfm.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 980 B |
BIN
samples/themes/notmyidea/images/icons/rss.png
Normal file
BIN
samples/themes/notmyidea/images/icons/rss.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 896 B |
BIN
samples/themes/notmyidea/images/icons/twitter.png
Normal file
BIN
samples/themes/notmyidea/images/icons/twitter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 835 B |
|
|
@ -4,6 +4,8 @@
|
||||||
<title>{% block title %}{{ BLOGNAME }}{%endblock%}</title>
|
<title>{% block title %}{{ BLOGNAME }}{%endblock%}</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="stylesheet" href="css/main.css" type="text/css" />
|
<link rel="stylesheet" href="css/main.css" type="text/css" />
|
||||||
|
<link href="atom.xml" type="application/atom+xml" rel="alternate" title="{{ BLOGNAME }} ATOM Feed" />
|
||||||
|
|
||||||
|
|
||||||
<!--[if IE]>
|
<!--[if IE]>
|
||||||
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
|
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
|
||||||
|
|
@ -45,7 +47,7 @@
|
||||||
<div class="social">
|
<div class="social">
|
||||||
<h2>social</h2>
|
<h2>social</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="{{ FEEDURL }}" rel="alternate">rss</a></li>
|
<li><a href="atom.xml" rel="alternate">atom feed</a></li>
|
||||||
{% for name, link in SOCIAL %}
|
{% for name, link in SOCIAL %}
|
||||||
<li><a href="{{ link }}">{{ name }}</a></li>
|
<li><a href="{{ link }}">{{ name }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue