-
Notifications
You must be signed in to change notification settings - Fork 3
/
pelicanconf.py
200 lines (165 loc) · 5.43 KB
/
pelicanconf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json
import os
import jinja2
import expand_html_literal
CURR_DIR = os.path.abspath(os.path.dirname(__file__))
def get_path(*names):
return os.path.join(CURR_DIR, *names)
AUTHOR = "Danny Hermes"
SITENAME = "Bossy Lobster"
SITESUBTITLE = "A blog by Danny Hermes; musing on tech, mathematics, etc."
# Default is empty string unless building to publish.
SITEURL = ""
PATH = "content" # Directory containing posts.
# Times and dates
DEFAULT_DATE_FORMAT = "%b %d, %Y"
TIMEZONE = "US/Pacific"
DEFAULT_LANG = "en"
FORMATTED_FIELDS = ["title"]
# Set the article URL
ARTICLE_URL = "{date:%Y}/{date:%m}/{slug}.html"
ARTICLE_SAVE_AS = "{date:%Y}/{date:%m}/{slug}.html"
# Title menu options
ARCHIVES_SAVE_AS = "all-posts.html"
MENUITEMS = [
("All Posts", "/{}".format(ARCHIVES_SAVE_AS)),
("GitHub", "http://github.com/dhermes/"),
("Mathematics", "/mathematics"),
("Testimonials", "/testimonials"),
("About Me", "/about-me"),
]
# Archive customizations.
NEWEST_FIRST_ARCHIVES = True
HIDE_CATEGORIES_IN_ARCHIVE = True
ARCHIVE_TITLE = "All Posts"
# This assumes pelican>=3.3
STATIC_PATHS = [
# Folders.
"code",
"css",
"images",
"js",
# Files.
"favicon.ico",
"favicon.png",
]
# Theme and plugins
THEME = "pelican-octopress-theme/"
PLUGIN_PATHS = ["pelican-plugins"]
PLUGINS = [
"summary",
"simple_footnotes",
# These tags currently fail when building with Pelican 3.5.
# 'liquid_tags.include_code',
# 'liquid_tags.notebook',
]
# Some menu settings
DISPLAY_PAGES_ON_MENU = False
DISPLAY_CATEGORIES_ON_MENU = False
HIDE_TAGS_IN_SIDEBAR = True
HIDE_CATEGORIES_IN_SIDEBAR = True
# Markdown Extension
# See https://github.com/getpelican/pelican/issues/2091#issue-202323613
# and http://docs.getpelican.com/en/3.7.0/settings.html
MARKDOWN = {
"extensions": [
"markdown.extensions.codehilite",
"markdown.extensions.extra",
"markdown.extensions.meta",
expand_html_literal.ExpandLiteral(),
],
"extension_configs": {
"markdown.extensions.codehilite": {"css_class": "highlight"}
},
"output_format": "html5",
}
# Pagination
DEFAULT_PAGINATION = None
# Sharing
TWITTER_USER = "bossylobster"
GOOGLE_PLUS_USER = "DannyHermes"
GOOGLE_PLUS_ONE = True
GOOGLE_PLUS_HIDDEN = False
FACEBOOK_LIKE = False
TWITTER_TWEET_BUTTON = True
TWITTER_LATEST_TWEETS = True
TWITTER_FOLLOW_BUTTON = True
TWITTER_TWEET_COUNT = 3
TWITTER_SHOW_REPLIES = "false"
TWITTER_SHOW_FOLLOWER_COUNT = "true"
# Sidebar for the octopress theme, a relative path (to the root).
SIDEBAR_IMAGE = "images/bossy_lobster_350_alpha.png"
SECOND_SIDEBAR_IMAGE = "images/dhermes_headshot.jpg"
# Add extra header.
with open(get_path("extra_header.html"), "r") as file_obj:
EXTRA_HEADER = file_obj.read()
# NOTE: The liquid_tags.notebook plugin will also create an
# _nb_header.html file so we should add that if
# liquid_tags.notebook is to be used.
# Paths to ignore. These are custom files used to render actual
# posts. The `.template` files are Jinja2 templates.
IGNORE_FILES = ["*.template"]
# Adding Disqus comments to page.
DISQUS_SITENAME = "bossylobster"
# Put pages in root. This is strictly for the 404 page.
PAGE_URL = "{slug}.html"
PAGE_SAVE_AS = "{slug}.html"
# NOTE: This is not secure for actually serving requests, but
# is fine for static, trusted and known content.
# See http://stackoverflow.com/a/12340004/1068170.
def escapejs(val):
return json.dumps(str(val))
JINJA_FILTERS = {"escapejs": escapejs}
# Turn off feeds for translations, author, categories and tags.
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
CATEGORY_FEED_ATOM = None
CATEGORY_FEED_RSS = None
TAG_FEED_ATOM = None
TAG_FEED_RSS = None
TRANSLATION_FEED_ATOM = None
TRANSLATION_FEED_RSS = None
# Some feed settings can be optionally turned on.
FEED_DOMAIN = None
FEED_ALL_ATOM = None
FEED_ALL_RSS = None
FEED_ATOM = None
FEED_RSS = None
# If building to publish. This is essentially a `publishconf.py`.
if os.environ.get("PUBLISH") == "true":
# Required to turn on comments.
SITEURL = "https://blog.bossylobster.com"
# Add Google Analytics support.
GOOGLE_ANALYTICS = "UA-56716324-1"
# Add Google AdSense.
with open(get_path("google_adsense_code.html"), "r") as file_obj:
GOOGLE_ADSENSE_CODE = file_obj.read()
# RSS/Atom feeds
FEED_DOMAIN = SITEURL
FEED_ATOM = "feeds/atom.xml"
FEED_ALL_ATOM = "feeds/atom.all.xml"
FEED_RSS = "feeds/rss.xml"
FEED_ALL_RSS = "feeds/rss.all.xml"
# Search
with open(get_path("custom_search.html"), "r") as file_obj:
CUSTOM_SEARCH_TEMPLATE = file_obj.read()
CUSTOM_SEARCH = jinja2.Template(CUSTOM_SEARCH_TEMPLATE).render(SITEURL=SITEURL)
# Header
with open(get_path("custom_header.html"), "r") as file_obj:
CUSTOM_HEADER_TEMPLATE = jinja2.Template(file_obj.read())
# Remove local variables that aren't meant to be used in templates.
del CURR_DIR
del get_path
del file_obj
del CUSTOM_SEARCH_TEMPLATE