Skip to content

Commit 54b2bec

Browse files
committedMay 17, 2017
pkgindex_compiler: support for theme INI files
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent c1a23b7 commit 54b2bec

File tree

2 files changed

+40
-24
lines changed

2 files changed

+40
-24
lines changed
 

‎v7/pkgindex_compiler/pkgindex_compiler.plugin

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ MinVersion = 7.8.1+
88

99
[Documentation]
1010
Author = Chris Warrick, Roberto Alsina
11-
Version = 0.2.2
11+
Version = 0.3.0
1212
Website = https://plugins.getnikola.com/
1313
Description = Compile pages in package indexes

‎v7/pkgindex_compiler/pkgindex_compiler.py

+39-23
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,13 @@ def parse_theme_info(post, pkg_dir, config):
154154
data['previewimage_thumbnail'] = '/' + demo_dir + '.thumbnail.png'
155155
data['demo_link'] = '/' + demo_dir + '/demo/'
156156
conf_sample = os.path.join(pkg_dir, 'conf.py.sample')
157+
ini = os.path.join(pkg_dir, theme + '.theme')
157158
engine = os.path.join(pkg_dir, 'engine')
158159
parent = os.path.join(pkg_dir, 'parent')
159160

161+
data['chain'] = utils.get_theme_chain(theme, [os.path.dirname(pkg_dir), 'themes'])
162+
data['chain'] = [os.path.basename(i) for i in reversed(data['chain'])]
163+
160164
if os.path.exists(conf_sample):
161165
post.add_dependency(conf_sample)
162166
with io.open(conf_sample, 'r', encoding='utf-8') as f:
@@ -166,30 +170,42 @@ def parse_theme_info(post, pkg_dir, config):
166170
else:
167171
data['confpy'] = None
168172

169-
if os.path.exists(engine):
170-
post.add_dependency(engine)
171-
with io.open(engine, 'r', encoding='utf-8') as f:
172-
data['engine'] = f.read().strip()
173-
else:
174-
data['engine'] = 'mako'
175-
176-
if os.path.exists(parent):
177-
post.add_dependency(parent)
178-
with io.open(parent, 'r', encoding='utf-8') as f:
179-
data['parent'] = f.read().strip()
180-
elif theme == 'base':
181-
pass
173+
if os.path.exists(ini):
174+
post.add_dependency(ini)
175+
c = configparser.ConfigParser()
176+
c.read(ini)
177+
data['parent'] = c.get('Theme', 'parent', fallback=None)
178+
data['engine'] = c.get('Theme', 'engine', fallback='mako')
179+
data['bootswatch'] = c.getboolean('Nikola', 'bootswatch', fallback=False)
180+
data['tags'] = 'theme,' + data['engine']
181+
theme_tags = c.get('Theme', 'tags', fallback='')
182+
if theme_tags:
183+
data['tags'] += ',' + theme_tags
184+
185+
if data['parent'] is None and theme != 'base':
186+
raise ValueError("Theme {0} has no parent.".format(theme))
182187
else:
183-
raise ValueError("Theme {0} has no parent.".format(theme))
184-
185-
data['chain'] = utils.get_theme_chain(theme, [os.path.dirname(pkg_dir), 'themes'])
186-
data['chain'] = [os.path.basename(i) for i in reversed(data['chain'])]
187-
data['bootswatch'] = (('bootstrap' in data['chain'] or
188-
'bootstrap-jinja' in data['chain'] or
189-
'bootstrap3-jinja' in data['chain'] or
190-
'bootstrap3' in data['chain']) and
191-
'bootstrap3-gradients' not in data['chain'])
192-
data['tags'] = 'theme,' + data['engine']
188+
if os.path.exists(engine):
189+
post.add_dependency(engine)
190+
with io.open(engine, 'r', encoding='utf-8') as f:
191+
data['engine'] = f.read().strip()
192+
else:
193+
data['engine'] = 'mako'
194+
195+
if os.path.exists(parent):
196+
post.add_dependency(parent)
197+
with io.open(parent, 'r', encoding='utf-8') as f:
198+
data['parent'] = f.read().strip()
199+
elif theme == 'base':
200+
pass
201+
else:
202+
raise ValueError("Theme {0} has no parent.".format(theme))
203+
data['bootswatch'] = (('bootstrap' in data['chain'] or
204+
'bootstrap-jinja' in data['chain'] or
205+
'bootstrap3-jinja' in data['chain'] or
206+
'bootstrap3' in data['chain']) and
207+
'bootstrap3-gradients' not in data['chain'])
208+
data['tags'] = 'theme,' + data['engine']
193209

194210
return data
195211

0 commit comments

Comments
 (0)
Please sign in to comment.