Skip to content

Commit f687294

Browse files
committed
pelican: updates for python3.x and pelican 4.11.x
1 parent e79e6c9 commit f687294

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

filters.py

-7
This file was deleted.

gitoyen.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env python
1+
#!/usr/bin/env python
22
# coding: utf8
33

44
import click
@@ -12,15 +12,16 @@
1212
import mimetypes
1313
import subprocess
1414

15-
import SimpleHTTPServer
16-
import SocketServer
15+
import http.server
16+
import socketserver
1717

1818
PELICAN_CONF = 'pelicanconf.py'
1919
OUTPUT = 'output'
2020
CONTENT = 'content'
2121
BLOG = 'content/blog'
2222
THEME = './theme'
2323

24+
2425
class Config(object):
2526
def __init__(self):
2627
self.settings = path.Path(PELICAN_CONF)
@@ -65,7 +66,7 @@ def __call__(self, env, start_response):
6566

6667
if not path.exists():
6768
return self._not_found(start_response)
68-
if path.isfile():
69+
if path.is_file():
6970
return self._serve_file(path, start_response)
7071
if path_index.exists():
7172
return self._serve_file(path_index, start_response)
@@ -125,8 +126,8 @@ def serve(ctx, config, no_debug, no_lr, port):
125126
inner_build()
126127
if no_lr:
127128
with config.output:
128-
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
129-
httpd = SocketServer.TCPServer(('', port), Handler)
129+
Handler = http.server.BaseHTTPRequestHandler
130+
httpd = socketserver.TCPServer(('', port), Handler)
130131

131132
click.echo('serving at port %d' % port)
132133
httpd.serve_forever()

pelicanconf.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*- #
33
from __future__ import unicode_literals
4+
import jinja2
5+
6+
7+
@jinja2.pass_context
8+
def is_active(ctx, page):
9+
return (ctx.get('output_file') == page.save_as or
10+
'blog' in ctx.get('output_file') and page.slug == 'blog')
411

5-
import filters
612

713
AUTHOR = u'gitoyen'
814
SITENAME = u'Gitoyen'
@@ -29,7 +35,7 @@
2935
TWITTER_USERNAME = 'gitoyen'
3036

3137

32-
JINJA_FILTERS = {'is_active': filters.is_active}
38+
JINJA_FILTERS = {'is_active': is_active}
3339

3440
THEME = './theme'
3541

@@ -44,7 +50,6 @@
4450

4551
INDEX_SAVE_AS = 'blog.html'
4652
PLUGIN_PATHS = ['plugins']
47-
PLUGINS = ['pelican-toc']
4853

4954
STATIC_PATHS = ['images', 'extra/favicon.ico', 'upload' ]
5055

@@ -53,7 +58,7 @@
5358
'TOC_RUN': 'true'
5459
}
5560

56-
MD_EXTENSIONS = ['attr_list', 'codehilite(css_class=highlight)', 'extra']
61+
#MD_EXTENSIONS = ['attr_list', 'codehilite(css_class=highlight)', 'extra']
5762
# Uncomment following line if you want document-relative URLs when developing
5863
# RELATIVE_URLS = True
5964

0 commit comments

Comments
 (0)