-
Notifications
You must be signed in to change notification settings - Fork 0
/
guan-yu-pelican-zhu-ti-gum-bugde-chu-li.html
312 lines (261 loc) · 21.7 KB
/
guan-yu-pelican-zhu-ti-gum-bugde-chu-li.html
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="CatsAction" />
<meta property="og:type" content="article" />
<meta name="twitter:card" content="summary">
<meta name="keywords" content="pelican, blog, jinjia2, html, python, " />
<meta property="og:title" content="关于pelican 主题gum bug的处理"/>
<meta property="og:url" content="./guan-yu-pelican-zhu-ti-gum-bugde-chu-li.html" />
<meta property="og:description" content="最近在用pelican搭建个人静态博客时,在安装主题时,发现官方提供的主题gum不能正常渲染出tags和pages,下面简单记录处理过程。想了解pelican的安装,可以查看我的pelican安装与部署 1:安装pelican主题 下面以安装gum为例 git clone https://github.com/getpelican/pelican-themes.git cp -r ~/pelican-themes/gum /you-blog-directory 接下来在配置文件pelicanconf.py中指定主题theme = gum。其实可以不用把主题复制到你的博客目录,你只需在theme后指定主题所在目录,让pelican正确解析到就行。不过为了修改和git版本跟踪,这里把它复制到博客目录。 2:gum主题tags和pages的渲染问题。 找到gum模板文件sidebar.html。发现它把pages写成PAGES了,导致侧边栏Pages总未展示。官方主题有好几个都有这个问题,我估计是仿照一个主题写的缘故。 <h4>Tags</h4> {% if tags %} <ul class="blank"> {% for tag …" />
<meta property="og:site_name" content="CatsAction's blog" />
<meta property="og:article:author" content="CatsAction" />
<meta property="og:article:published_time" content="2015-01-05T00:00:00+08:00" />
<meta property="og:article:modified_time" content="2017-04-10T18:11:00+08:00" />
<meta name="twitter:title" content="关于pelican 主题gum bug的处理">
<meta name="twitter:description" content="最近在用pelican搭建个人静态博客时,在安装主题时,发现官方提供的主题gum不能正常渲染出tags和pages,下面简单记录处理过程。想了解pelican的安装,可以查看我的pelican安装与部署 1:安装pelican主题 下面以安装gum为例 git clone https://github.com/getpelican/pelican-themes.git cp -r ~/pelican-themes/gum /you-blog-directory 接下来在配置文件pelicanconf.py中指定主题theme = gum。其实可以不用把主题复制到你的博客目录,你只需在theme后指定主题所在目录,让pelican正确解析到就行。不过为了修改和git版本跟踪,这里把它复制到博客目录。 2:gum主题tags和pages的渲染问题。 找到gum模板文件sidebar.html。发现它把pages写成PAGES了,导致侧边栏Pages总未展示。官方主题有好几个都有这个问题,我估计是仿照一个主题写的缘故。 <h4>Tags</h4> {% if tags %} <ul class="blank"> {% for tag …">
<title>关于pelican 主题gum bug的处理 ·
CatsAction's blog
</title>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="./theme/image/logo.ico" />
<link rel="stylesheet" type="text/css" href="./theme/css/elegant.prod.css" media="screen">
<link rel="stylesheet" type="text/css" href="./theme/css/custom.css" media="screen">
</head>
<body>
<div id="content">
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="./"><span class=site-name>CatsAction's blog</span></a>
<div class="nav-collapse collapse">
<ul class="nav pull-right top-menu">
<li >
<a href=
.
>Home</a>
</li>
<li ><a href="./categories.html">Categories</a></li>
<li ><a href="./tags.html">Tags</a></li>
<li ><a href="./archives.html">Archives</a></li>
<li><form class="navbar-search" action="./search.html" onsubmit="return validateForm(this.elements['q'].value);"> <input type="text" class="search-query" placeholder="Search" name="q" id="tipue_search_input"></form></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span1"></div>
<div class="span10">
<article itemscope>
<div class="row-fluid">
<header class="page-header span10 offset2">
<h1>
<a href="./guan-yu-pelican-zhu-ti-gum-bugde-chu-li.html">
关于pelican 主题gum bug的处理
</a>
</h1>
</header>
</div>
<div class="row-fluid">
<div class="span8 offset2 article-content">
<p>最近在用pelican搭建个人静态博客时,在安装主题时,发现官方提供的主题gum不能正常渲染出tags和pages,下面简单记录处理过程。想了解pelican的安装,可以查看我的<a href="./pelicanan-zhuang-yu-bu-shu.html">pelican安装与部署</a></p>
<h4>1:安装pelican主题</h4>
<p>下面以安装gum为例</p>
<div class="highlight"><pre><span></span>git clone https://github.com/getpelican/pelican-themes.git
cp -r ~/pelican-themes/gum /you-blog-directory
</pre></div>
<p>接下来在配置文件pelicanconf.py中指定主题<code>theme = gum</code>。其实可以不用把主题复制到你的博客目录,你只需在theme后指定主题所在目录,让pelican正确解析到就行。不过为了修改和git版本跟踪,这里把它复制到博客目录。</p>
<h4>2:gum主题tags和pages的渲染问题。</h4>
<p>找到gum模板文件sidebar.html。发现它把pages写成PAGES了,导致侧边栏Pages总未展示。官方主题有好几个都有这个问题,我估计是仿照一个主题写的缘故。</p>
<div class="highlight"><pre><span></span><span class="nt"><h4></span>Tags<span class="nt"></h4></span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">tags</span> <span class="cp">%}</span>
<span class="nt"><ul</span> <span class="na">class=</span><span class="s">"blank"</span><span class="nt">></span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">tag</span> <span class="k">in</span> <span class="nv">tag_cloud</span> <span class="cp">%}</span>
<span class="nt"><li</span> <span class="na">class=</span><span class="s">"tag-</span><span class="cp">{{</span> <span class="nv">tag.1</span> <span class="cp">}}</span><span class="s">"</span><span class="nt">><a</span> <span class="na">href=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">SITEURL</span> <span class="cp">}}</span><span class="s">/</span><span class="cp">{{</span> <span class="nv">tag.0.url</span> <span class="cp">}}</span><span class="s">"</span><span class="nt">></span><span class="cp">{{</span> <span class="nv">tag.0</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt"></a></li></span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="nt"></ul></span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
</pre></div>
<p>上面是gum对于tags的渲染,需要修改成如下</p>
<div class="highlight"><pre><span></span><span class="nt"><a</span> <span class="na">href=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">SITEURL</span> <span class="cp">}}</span><span class="s">/tags.html"</span><span class="nt">><h4></span>Tags<span class="nt"></h4></a></span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">tags</span> <span class="cp">%}</span>
<span class="nt"><ul</span> <span class="na">class=</span><span class="s">"blank"</span><span class="nt">></span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">tag</span><span class="o">,</span> <span class="kp">_</span> <span class="k">in</span> <span class="nv">tags</span> <span class="cp">%}</span>
<span class="nt"><li</span> <span class="na">class=</span><span class="s">"tag-</span><span class="cp">{{</span> <span class="nv">tag</span> <span class="cp">}}</span><span class="s">"</span><span class="nt">><a</span> <span class="na">href=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">SITEURL</span> <span class="cp">}}</span><span class="s">/</span><span class="cp">{{</span> <span class="nv">tag.url</span> <span class="cp">}}</span><span class="s">"</span><span class="nt">></span><span class="cp">{{</span> <span class="nv">tag</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span><span class="nt"></a></li></span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="nt"></ul></span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span>
</pre></div>
<p>至于为何修改成这样,请参考官方文档<a href="http://docs.getpelican.com/en/stable/themes.html">Creating themes</a></p>
<h4>3: 对tags和categories界面展示的优化</h4>
<p>tags.html和categories.html模板展示博客的tags列表和分类列表。gum原来的模板并未展示每个tag或category对应的文章,于是我做了如下修改</p>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">extends</span> <span class="s2">"base.html"</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">block</span> <span class="nv">title</span> <span class="cp">%}{{</span> <span class="nv">SITENAME</span> <span class="cp">}}</span> - Tags<span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">block</span> <span class="nv">content</span> <span class="cp">%}</span>
<span class="nt"><h4><i</span> <span class="na">class=</span><span class="s">"icon-tags icon-large"</span><span class="nt">></i></span>Tags for <span class="cp">{{</span> <span class="nv">SITENAME</span> <span class="cp">}}</span><span class="nt"></h4></span>
<span class="nt"><ul></span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">tag</span><span class="o">,</span> <span class="nv">articles</span> <span class="k">in</span> <span class="nv">tags</span> <span class="cp">%}</span>
<span class="nt"><li</span> <span class="na">class=</span><span class="s">"tag-</span><span class="cp">{{</span> <span class="nv">tag</span> <span class="cp">}}</span><span class="s">"</span><span class="nt">></span>
<span class="nt"><a</span> <span class="na">href=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">SITEURL</span> <span class="cp">}}</span><span class="s">/</span><span class="cp">{{</span> <span class="nv">tag.url</span> <span class="cp">}}</span><span class="s">"</span><span class="nt">></span>
<span class="nt"><i</span> <span class="na">class=</span><span class="s">"icon-tag icon-large"</span><span class="nt">></i></span><span class="cp">{{</span> <span class="nv">tag</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span>
<span class="nt"></a></span>
<span class="nt"><ul></span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">article</span> <span class="k">in</span> <span class="nv">articles</span> <span class="cp">%}</span>
<span class="nt"><li><a</span> <span class="na">href=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">SITEURL</span> <span class="cp">}}</span><span class="s">/</span><span class="cp">{{</span> <span class="nv">article.url</span> <span class="cp">}}</span><span class="s">"</span><span class="nt">></span><span class="cp">{{</span> <span class="nv">article.title</span> <span class="cp">}}</span><span class="nt"></a></li></span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="nt"></ul></span>
<span class="nt"></li></span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="nt"></ul></span>
<span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span>
</pre></div>
<p>gum主题原来的模板</p>
<div class="highlight"><pre><span></span><span class="cp">{%</span> <span class="k">extends</span> <span class="s2">"base.html"</span> <span class="cp">%}</span>
<span class="cp">{%</span> <span class="k">block</span> <span class="nv">content</span> <span class="cp">%}</span>
<span class="nt"><ul></span>
<span class="nt"><li</span> <span class="na">class=</span><span class="s">"nav-header"</span><span class="nt">><h4><i</span> <span class="na">class=</span><span class="s">"icon-tags icon-large"</span><span class="nt">></i></span>Tags<span class="nt"></h4></li></span>
<span class="cp">{%</span> <span class="k">for</span> <span class="nv">tag</span> <span class="k">in</span> <span class="nv">tag_cloud</span> <span class="cp">%}</span>
<span class="nt"><li</span> <span class="na">class=</span><span class="s">"tag-</span><span class="cp">{{</span> <span class="nv">tag.1</span> <span class="cp">}}</span><span class="s">"</span><span class="nt">></span>
<span class="nt"><a</span> <span class="na">href=</span><span class="s">"</span><span class="cp">{{</span> <span class="nv">SITEURL</span> <span class="cp">}}</span><span class="s">/</span><span class="cp">{{</span> <span class="nv">tag.0.url</span> <span class="cp">}}</span><span class="s">"</span><span class="nt">></span>
<span class="nt"><i</span> <span class="na">class=</span><span class="s">"icon-tag icon-large"</span><span class="nt">></i></span><span class="cp">{{</span> <span class="nv">tag.0</span><span class="o">|</span><span class="nf">e</span> <span class="cp">}}</span>
<span class="nt"></a></span>
<span class="nt"></li></span>
<span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span>
<span class="nt"></ul></span>
<span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span>
</pre></div>
<p>categories.html我就不粘贴代码了,思路都一样。并且原模板对于categories.html也没有bug。</p>
<p>由于附图不方便文章布局,对于上面修改后的页面效果,可以自行修改预览。</p>
<hr />
<aside>
<nav>
<ul class="articles-timeline">
<li class="previous-article">« <a href="./pelicanan-zhuang-yu-bu-shu.html"
title="Previous: pelican安装与部署">pelican安装与部署</a></li>
<li class="next-article"><a href="./guan-yu-sublime-text3shi-yong-zhong-de-yi-xie-ji-lu.html"
title="Next: 关于sublime text3使用中的一些记录">关于sublime text3使用中的一些记录</a> »</li>
</ul>
</nav>
</aside>
</div>
<section id="article-sidebar" class="span2">
<h4>Published</h4>
<time itemprop="dateCreated" datetime="2015-01-05T00:00:00+08:00"> 1
5, 2015</time>
<!--<h4>Last Updated</h4>
<time datetime="2017-04-10T18:11:00+08:00"> 4 10, 2017</time>
-->
<h4>Category</h4>
<a class="category-link"
href="./categories.html#python-ref">python</a>
<h4>Tags</h4>
<ul class="list-of-tags tags-in-article">
<li><a href="./tags.html#blog-ref">blog
<span>2</span>
</a></li>
<li><a href="./tags.html#html-ref">html
<span>1</span>
</a></li>
<li><a href="./tags.html#jinjia2-ref">jinjia2
<span>1</span>
</a></li>
<li><a href="./tags.html#pelican-ref">pelican
<span>2</span>
</a></li>
</ul>
<h4>Stay in Touch</h4>
<div id="sidebar-social-link">
<a href="mailto:[email protected]" title="My Email Address" target="_blank" rel="nofollow noopener noreferrer">
<svg xmlns="http://www.w3.org/2000/svg" aria-label="Mail" role="img" viewBox="0 0 512 512"><rect width="512" height="512" rx="15%" fill="#328cff"/><path d="m250 186c-46 0-69 35-69 74 0 44 29 72 68 72 43 0 73-32 73-75 0-44-34-71-72-71zm-1-37c30 0 57 13 77 33 0-22 35-22 35 1v150c-1 10 10 16 16 9 25-25 54-128-14-187-64-56-149-47-195-15-48 33-79 107-49 175 33 76 126 99 182 76 28-12 41 26 12 39-45 19-168 17-225-82-38-68-36-185 67-248 78-46 182-33 244 32 66 69 62 197-2 246-28 23-71 1-71-32v-11c-20 20-47 32-77 32-57 0-108-51-108-108 0-58 51-110 108-110" fill="#fff"/></svg>
</a>
<a href="https://github.com/boyaziqi" title="catsaction Github Repository" target="_blank" rel="nofollow noopener noreferrer">
<svg xmlns="http://www.w3.org/2000/svg" aria-label="GitHub" role="img" viewBox="0 0 512 512"><rect width="512" height="512" rx="15%" fill="#1B1817"/><path fill="#fff" d="M335 499c14 0 12 17 12 17H165s-2-17 12-17c13 0 16-6 16-12l-1-50c-71 16-86-28-86-28-12-30-28-37-28-37-24-16 1-16 1-16 26 2 40 26 40 26 22 39 59 28 74 22 2-17 9-28 16-35-57-6-116-28-116-126 0-28 10-51 26-69-3-6-11-32 3-67 0 0 21-7 70 26 42-12 86-12 128 0 49-33 70-26 70-26 14 35 6 61 3 67 16 18 26 41 26 69 0 98-60 120-117 126 10 8 18 24 18 48l-1 70c0 6 3 12 16 12z"/></svg>
</a>
<a href="https://www.linkedin.com/feed/" title="My LinkedIn" target="_blank" rel="nofollow noopener noreferrer">
<svg xmlns="http://www.w3.org/2000/svg" aria-label="LinkedIn" role="img" viewBox="0 0 512 512" fill="#fff"><rect width="512" height="512" rx="15%" fill="#0077b5"/><circle cx="142" cy="138" r="37"/><path stroke="#fff" stroke-width="66" d="M244 194v198M142 194v198"/><path d="M276 282c0-20 13-40 36-40 24 0 33 18 33 45v105h66V279c0-61-32-89-76-89-34 0-51 19-59 32"/></svg>
</a>
</div>
<h4>Friendship Links</h4>
<ul class="list-of-tags tags-in-article">
<li>
<a href="https://leetcode-cn.com/" title="力扣中国站点" target="_blank" rel="nofollow noopener noreferrer">
LeetCode
</a>
</li>
<li>
<a href="https://coolshell.cn/about" title="陈皓酷壳" target="_blank" rel="nofollow noopener noreferrer">
CoolShell
</a>
</li>
<li>
<a href="https://yikun.github.io/" title="姜毅坤博客" target="_blank" rel="nofollow noopener noreferrer">
Yikun
</a>
</li>
<li>
<a href="https://www.nowcoder.com/" title="牛客网" target="_blank" rel="nofollow noopener noreferrer">
牛客网
</a>
</li>
</ul>
</section>
</div>
</article>
</div>
<div class="span1"></div>
</div>
</div>
</div>
<footer>
<div>
<span class="site-name">CatsAction's blog</span> - It's a wonderful world
</div>
<div id="fpowered">
Powered by: <a href="http://getpelican.com/" title="Pelican Home Page" target="_blank" rel="nofollow noopener noreferrer">Pelican</a>
Theme: <a href="https://elegant.oncrashreboot.com/" title="Theme Elegant Home Page" target="_blank" rel="nofollow noopener noreferrer">Elegant</a>
</div>
</footer> <script src="//code.jquery.com/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script>
function validateForm(query)
{
return (query.length > 0);
}
</script>
<script>
(function () {
if (window.location.hash.match(/^#comment-\d+$/)) {
$('#comment_thread').collapse('show');
}
})();
window.onhashchange=function(){
if (window.location.hash.match(/^#comment-\d+$/))
window.location.reload(true);
}
$('#comment_thread').on('shown', function () {
var link = document.getElementById('comment-accordion-toggle');
var old_innerHTML = link.innerHTML;
$(link).fadeOut(200, function() {
$(this).text('Click here to hide comments').fadeIn(200);
});
$('#comment_thread').on('hidden', function () {
$(link).fadeOut(200, function() {
$(this).text(old_innerHTML).fadeIn(200);
});
})
})
</script>
</body>
<!-- Theme: Elegant built for Pelican
License : MIT -->
</html>