Skip to content

Commit b0bcd25

Browse files
committed
indent <li>s, bring back some phpurple
1 parent dce2586 commit b0bcd25

File tree

4 files changed

+122
-2
lines changed

4 files changed

+122
-2
lines changed

_octopress/plugins/category_list.rb

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Tag Cloud for Octopress, modified by pf_miles, for use with utf-8 encoded blogs(all regexp added 'u' option).
2+
# modified by alswl, tag_cloud -> category_cloud
3+
# =======================
4+
#
5+
# Description:
6+
# ------------
7+
# Easy output tag cloud and category list.
8+
#
9+
# Syntax:
10+
# -------
11+
# {% tag_cloud [counter:true] %}
12+
# {% category_list [counter:true] %}
13+
#
14+
# Example:
15+
# --------
16+
# In some template files, you can add the following markups.
17+
#
18+
# ### source/_includes/custom/asides/tag_cloud.html ###
19+
#
20+
# <section>
21+
# <h1>Tag Cloud</h1>
22+
# <span id="tag-cloud">{% tag_cloud %}</span>
23+
# </section>
24+
#
25+
# ### source/_includes/custom/asides/category_list.html ###
26+
#
27+
# <section>
28+
# <h1>Categories</h1>
29+
# <ul id="category-list">{% category_list counter:true %}</ul>
30+
# </section>
31+
#
32+
# Notes:
33+
# ------
34+
# Be sure to insert above template files into `default_asides` array in `_config.yml`.
35+
# And also you can define styles for 'tag-cloud' or 'category-list' in a `.scss` file.
36+
# (ex: `sass/custom/_styles.scss`)
37+
#
38+
# Licence:
39+
# --------
40+
# Distributed under the [MIT License][MIT].
41+
#
42+
# [MIT]: http://www.opensource.org/licenses/mit-license.php
43+
#
44+
module Jekyll
45+
46+
class CategoryCloud < Liquid::Tag
47+
48+
def initialize(tag_name, markup, tokens)
49+
@opts = {}
50+
if markup.strip =~ /\s*counter:(\w+)/iu
51+
@opts['counter'] = ($1 == 'true')
52+
markup = markup.strip.sub(/counter:\w+/iu,'')
53+
end
54+
super
55+
end
56+
57+
def render(context)
58+
lists = {}
59+
max, min = 1, 1
60+
config = context.registers[:site].config
61+
category_dir = config['root'] + config['category_dir'] + '/'
62+
categories = context.registers[:site].categories
63+
categories.keys.sort_by{ |str| str.downcase }.each do |category|
64+
count = categories[category].count
65+
lists[category] = count
66+
max = count if count > max
67+
end
68+
69+
html = ''
70+
lists.each do | category, counter |
71+
url = category_dir + category.gsub(/_|\P{Word}/u, '-').gsub(/-{2,}/u, '-').downcase
72+
style = "font-size: #{100 + (60 * Float(counter)/max)}%"
73+
html << "<a href='#{url}' style='#{style}'>#{category}"
74+
if @opts['counter']
75+
html << "(#{categories[category].count})"
76+
end
77+
html << "</a> "
78+
end
79+
html
80+
end
81+
end
82+
83+
class CategoryList < Liquid::Tag
84+
85+
def initialize(tag_name, markup, tokens)
86+
@opts = {}
87+
if markup.strip =~ /\s*counter:(\w+)/iu
88+
@opts['counter'] = ($1 == 'true')
89+
markup = markup.strip.sub(/counter:\w+/iu,'')
90+
end
91+
super
92+
end
93+
94+
def render(context)
95+
html = ""
96+
config = context.registers[:site].config
97+
category_dir = config['root'] + config['category_dir'] + '/'
98+
categories = context.registers[:site].categories
99+
categories.keys.sort_by{ |str| str.downcase }.each do |category|
100+
url = category_dir + category.gsub(/_|\P{Word}/u, '-').gsub(/-{2,}/u, '-').downcase
101+
html << "<li><a href='#{url}'>#{category}"
102+
if @opts['counter']
103+
html << " (#{categories[category].count})"
104+
end
105+
html << "</a></li>"
106+
end
107+
html
108+
end
109+
end
110+
111+
end
112+
113+
Liquid::Template.register_tag('category_cloud', Jekyll::CategoryCloud)
114+
Liquid::Template.register_tag('category_list', Jekyll::CategoryList)

_octopress/sass/custom/_colors.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
/* If you want to tweak the Solarized colors you can do that here */
2020
//$base03: #002b36; //darkest blue
21+
$base03: #1C092E; //darkest purple
2122
//$base02: #073642; //dark blue
23+
$base02: #3D3263; //dark purple
2224
//$base01: #586e75; //darkest gray
2325
//$base00: #657b83; //dark gray
2426
//$base0: #839496; //medium gray

_octopress/sass/custom/_styles.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
// This File is imported last, and will override other styles in the cascade
2-
// Add styles here to make changes without digging in too much
2+
// Add styles here to make changes without digging in too much
3+
4+
ul, ol {
5+
margin-left: 18px;
6+
}

_octopress/sass/partials/_header.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ body > header {
3434
margin-left: -6px;
3535
}
3636
div#logoLeft, #logoRight{
37-
color: #1b88ff;
37+
color: $base02;
3838
font-family: "Courier New", Courier, monospace;
3939
font-weight: normal;
4040
font-size: 1.2em;

0 commit comments

Comments
 (0)