Skip to content

Commit 533ae65

Browse files
committed
refactored to use a more reusable website generator
1 parent 09e19fe commit 533ae65

28 files changed

+500
-2676
lines changed

_config.yml

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,78 @@
1+
# Build settings
12
markdown: rdiscount
23
highlighter: pygments
34

45
relative_permalinks: false
56

7+
###############
8+
# Site settings
9+
###############
10+
title: VisualDiffer
11+
keywords: "mac,apple,osx,apps,development,macosx,diff,differ,visual,compare,search,regular expression"
12+
favicon: img/favicon.ico
13+
14+
# Show the popup about cookies
15+
cookiesdirective: true
16+
17+
common_links:
18+
- title: Official site
19+
link: &official_link http://visualdiffer.com/
20+
- title: Wiki
21+
link: &wiki_link http://wiki.visualdiffer.com/
22+
- title: Bug report, features request
23+
link: &bugs_link http://bugs.visualdiffer.com/
24+
- title: Mac App Store Page
25+
link: &mas_link "http://itunes.apple.com/us/app/visualdiffer/id412386481?mt=12&ls=1"
26+
- title: Twitter
27+
link: &twitter_link https://twitter.com/visualdiffer
28+
- title: GitHub
29+
link: &github_link https://github.com/visualdiffer
30+
31+
header:
32+
title: VisualDiffer
33+
subtitle: Wiki
34+
# must be 128x128
35+
logo_image: img/logo.png
36+
37+
# Set 'provider' to false to turn analytics off globally
38+
analytics:
39+
provider: google
40+
google:
41+
tracking_id: 'UA-257181-9'
42+
43+
navigation_links:
44+
- title: Support
45+
link: *bugs_link
46+
- title: Products
47+
submenus:
48+
- title: VisualDiffer
49+
link: *official_link
50+
- title: VisualGrep
51+
link: http://visualgrep.com
52+
- title: Clipboard Plain
53+
link: https://itunes.apple.com/us/app/clipboardplain/id528607880?mt=12
54+
55+
social_links:
56+
- label: Twitter
57+
link: *twitter_link
58+
icon_class: fa-twitter
59+
- label: GitHub
60+
link: *github_link
61+
icon_class: fa-github
62+
63+
######################
64+
# Application specific
65+
######################
66+
667
minItemsToShowToc: 2
768

869
# Needed only when generate Apple Help
970
showToggleButton: true
1071

11-
exclude: ['mas', '*.sh', 'params.json']
72+
exclude: ['mas', '*.sh', 'params.json']
73+
74+
toc:
75+
# Set 'type' to false to turn toc generation off globally
76+
# Supported types: 'js' or 'plugin'
77+
type: js
78+

_includes/analytics.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% case site.analytics.provider %}
2+
{% when 'google' %}
3+
<script>
4+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
6+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
7+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
8+
9+
ga('create', '{{ site.analytics.google.tracking_id }}', 'auto');
10+
ga('send', 'pageview');
11+
12+
</script>
13+
{% endcase %}

_includes/content.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<header>
2+
<h2>{{ page.title }}</h2>
3+
</header>
4+
<div class="row">
5+
<div class="12u">
6+
7+
<!-- Text -->
8+
<section class="box">
9+
{% case site.toc.type %}
10+
{% when 'plugin' %}
11+
{{ content | toc_generate }}
12+
{% when 'js' %}
13+
<div id="toc-container"></div>
14+
{{ content }}
15+
{% else %}
16+
{{ content }}
17+
{% endcase %}
18+
</section>
19+
20+
</div>
21+
</div>

_includes/cookiesdirective.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{% if site.cookiesdirective != null and site.cookiesdirective %}
2+
<script src="js/jquery.cookiesdirective.js"></script>
3+
<script type="text/javascript">
4+
$(function(){
5+
$.cookiesDirective({
6+
privacyPolicyUri: 'ternaryopPrivacyPolicy.html',
7+
explicitConsent: false,
8+
position : 'bottom',
9+
scriptWrapper: function(){},
10+
cookieScripts: 'Google Analytics',
11+
backgroundColor: '#444',
12+
message: 'We use third party cookies to ensure that we give you the best experience on our website. Such third party cookies may track your use of this website. If you continue without changing your settings, we\'ll assume that you are happy to receive all cookies',
13+
linkColor: '#ffffff',
14+
showPrivacyPolicyLink: false
15+
});
16+
});
17+
</script>
18+
{% endif %}

_includes/footer.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<footer id="footer">
2+
<ul class="icons">
3+
{% for l in site.social_links %}
4+
<li><a href="{{l.link}}" class="icon {{l.icon_class}}"><span class="label">{{l.label}}</span></a></li>
5+
{% endfor %}
6+
</ul>
7+
<ul class="copyright">
8+
<li>&copy; {{site.title}}. All rights reserved.</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
9+
</ul>
10+
</footer>

_includes/header.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<header id="header" class="skel-layers-fixed">
2+
<h1><span class="image header"><img src="{{ site.header.logo_image }}"/></span><a href="index.html">{{ site.header.title }}</a> {{ site.header.subtitle }}</h1>
3+
<nav id="nav">
4+
<ul>
5+
{% for i in site.navigation_links %}
6+
{% if i.link %}
7+
<li><a href="{{ i.link }}">{{ i.title }}</a></li>
8+
{% else if i.submenus %}
9+
<li><a href="" class="icon fa-angle-down">{{ i.title }}</a>
10+
<ul>
11+
{% for sub in i.submenus %}
12+
<li><a href="{{ sub.link }}">{{ sub.title }}</a></li>
13+
{% endfor %}
14+
</ul>
15+
</li>
16+
{% endif %}
17+
{% endfor %}
18+
</ul>
19+
</nav>
20+
</header>

_includes/scripts.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script src="js/jquery.cookie.js"></script>
2+
{% case site.toc.type %}
3+
{% when 'plugin' %}
4+
<script src="js/jquery.tocLight.js"></script>
5+
<script type="text/javascript">
6+
$(function() {
7+
$.toc.clickHideButton({saveShowStatus:true});
8+
});
9+
</script>
10+
{% when 'js' %}
11+
{% if page.noToc == null || page.noToc == false %}
12+
<script src="js/jquery.toc.js"></script>
13+
<script type="text/javascript">
14+
$(function() {
15+
$('#main').toc({
16+
{% if site.minItemsToShowToc != null %}
17+
minItemsToShowToc: {{ site.minItemsToShowToc }},
18+
{% endif %}
19+
renderIn: '#toc-container'
20+
});
21+
});
22+
</script>
23+
{% endif %}
24+
{% endcase %}
25+

_includes/stylesheets.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<link rel="stylesheet" type="text/css" media="screen" href="css/wiki/vd.css"/>
2+
<link rel="stylesheet" type="text/css" media="screen" href="css/wiki/toc.css"/>

_layouts/default.html

Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
-->
77
<html>
88
<head>
9-
<title>VisualDiffer - {{ page.title }}</title>
9+
<title>{{ site.title }}{% if page.title %} - {% endif %}{{ page.title }}</title>
1010
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
11-
<meta name="description" content="VisualDiffer : " />
12-
<meta name="keywords" content="macosx, osx, apple, diff, differ, visual, compare, search, regular expression" />
13-
<link rel="shortcut icon" href="img/ternaryop/vd/favicon.ico" type="image/x-icon"/>
14-
<link rel="icon" href="img/ternaryop/vd/favicon.ico" type="image/x-icon"/>
11+
<meta name="description" content="{% if page.description %}{{ page.description }}{% else if page.subtitle %}{{ page.subtitle }}{% else if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}" >
12+
<meta name="keywords" content="{{ site.keywords }}" />
13+
<link rel="shortcut icon" href="{{ site.favicon }}" type="image/x-icon"/>
14+
<link rel="icon" href="{{ site.favicon }}" type="image/x-icon"/>
1515
<!--[if lte IE 8]><script src="css/ie/html5shiv.js"></script><![endif]-->
1616
<script src="js/jquery.min.js"></script>
1717
<script src="js/jquery.dropotron.min.js"></script>
@@ -27,77 +27,24 @@
2727
<link rel="stylesheet" href="css/top-extras.css" />
2828
<!--[if lte IE 8]><link rel="stylesheet" href="css/ie/v8.css" /><![endif]-->
2929

30-
<script src="js/jquery.cookie.js"></script>
31-
<script src="js/jquery.tocLight.js"></script>
30+
{% include stylesheets.html %}
31+
{% include scripts.html %}
32+
{% include cookiesdirective.html %}
3233

33-
<link rel="stylesheet" type="text/css" media="screen" href="css/wiki/vd.css"/>
34-
<link rel="stylesheet" type="text/css" media="screen" href="css/wiki/toc.css"/>
35-
36-
<script type="text/javascript">
37-
$(function() {
38-
$.toc.clickHideButton({saveShowStatus:true});
39-
});
40-
</script>
41-
42-
<script>
43-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
44-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
45-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
46-
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
47-
48-
ga('create', 'UA-257181-9', 'auto');
49-
ga('send', 'pageview');
50-
51-
</script>
34+
{% include analytics.html %}
5235

5336
</head>
5437
<body>
5538

5639
<!-- Header -->
57-
<header id="header" class="skel-layers-fixed">
58-
<h1><span class="image header"><img src="img/ternaryop/vd/logo.png"/></span><a href="index.html">VisualDiffer</a> Wiki</h1>
59-
<nav id="nav">
60-
<ul>
61-
<li><a href="http://visualdiffer.com/mantis/my_view_page.php">Support</a></li>
62-
<li><a href="" class="icon fa-angle-down">Products</a>
63-
<ul>
64-
<li><a href="http://visualdiffer.com">VisualDiffer</a></li>
65-
<li><a href="http://visualgrep.com">VisualGrep</a></li>
66-
<li><a href="https://itunes.apple.com/us/app/clipboardplain/id528607880?mt=12">Clipboard Plain</a></li>
67-
</ul>
68-
</li>
69-
</ul>
70-
</nav>
71-
</header>
40+
{% include header.html %}
7241

7342
<!-- Main -->
7443
<section id="main" class="container">
75-
<header>
76-
<h2>{{ page.title }}</h2>
77-
<!-- <p></p> -->
78-
</header>
79-
<div class="row">
80-
<div class="12u">
81-
82-
<!-- Text -->
83-
<section class="box">
84-
{{ content | toc_generate }}
85-
</section>
86-
87-
</div>
88-
</div>
44+
{% include content.html %}
8945
</section>
9046

9147
<!-- Footer -->
92-
<footer id="footer">
93-
<ul class="icons">
94-
<li><a href="http://www.twitter.com/visualdiffer" class="icon fa-twitter"><span class="label">Twitter</span></a></li>
95-
<li><a href="https://github.com/visualdiffer" class="icon fa-github"><span class="label">GitHub</span></a></li>
96-
</ul>
97-
<ul class="copyright">
98-
<li>&copy; VisualDiffer. All rights reserved.</li><li>Design: <a href="http://html5up.net">HTML5 UP</a></li>
99-
</ul>
100-
</footer>
101-
48+
{% include footer.html %}
10249
</body>
10350
</html>

_plugins/tocGenerator.rb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ module TOCGenerator
1111
def toc_generate(html)
1212
# No Toc can be specified on every single page
1313
# For example the index page has no table of contents
14-
no_toc = @context.environments.first["page"]["noToc"] || false;
15-
16-
return html if no_toc
14+
return html if (@context.environments.first["page"]["noToc"] || false)
1715

1816
config = @context.registers[:site].config
1917

@@ -53,11 +51,11 @@ def toc_generate(html)
5351
ct = tag.xpath("count(following-sibling::#{toc_top_tag})")
5452
sects = tag.xpath("following-sibling::#{toc_sec_tag}[count(following-sibling::#{toc_top_tag})=#{ct}]")
5553

56-
level_html = '';
57-
inner_section = 0;
54+
level_html = ''
55+
inner_section = 0
5856

59-
sects.map.each do |sect|
60-
inner_section += 1;
57+
sects.each do |sect|
58+
inner_section += 1
6159
anchor_id = [
6260
anchor_prefix, toc_level, '-', toc_section, '-',
6361
inner_section
@@ -75,18 +73,18 @@ def toc_generate(html)
7573

7674
level_html = '<ul>' + level_html + '</ul>' if level_html.length > 0
7775

78-
anchor_id = anchor_prefix + toc_level.to_s + '-' + toc_section.to_s;
76+
anchor_id = anchor_prefix + toc_level.to_s + '-' + toc_section.to_s
7977
tag['id'] = "#{anchor_id}"
8078

8179
toc_html += create_level_html(anchor_id,
8280
toc_level,
8381
toc_section,
8482
item_number,
8583
tag.text,
86-
level_html);
84+
level_html)
8785

88-
toc_section += 1 + inner_section;
89-
item_number += 1;
86+
toc_section += 1 + inner_section
87+
item_number += 1
9088
end
9189

9290
# for convenience item_number starts from 1
@@ -95,22 +93,22 @@ def toc_generate(html)
9593

9694
return html unless toc_html.length > 0
9795

98-
hide_html = '';
96+
hide_html = ''
9997
hide_html = HIDE_HTML.gsub('%1', hide_label) if (show_toggle_button)
10098

10199
if min_items_to_show_toc <= toc_index_count
102100
replaced_toggle_html = TOGGLE_HTML
103101
.gsub('%1', contents_label)
104-
.gsub('%2', hide_html);
102+
.gsub('%2', hide_html)
105103

106104
toc_table = TOC_CONTAINER_HTML
107105
.gsub('%1', replaced_toggle_html)
108-
.gsub('%2', toc_html);
106+
.gsub('%2', toc_html)
109107

110108
doc.css('body').children.before(toc_table)
111109
end
112110

113-
doc.to_xhtml
111+
doc.css('body').children.to_xhtml
114112
end
115113

116114
private
@@ -120,7 +118,7 @@ def create_level_html(anchor_id, toc_level, toc_section, tocNumber, tocText, toc
120118
.gsub('%1', anchor_id.to_s)
121119
.gsub('%2', tocNumber.to_s)
122120
.gsub('%3', tocText)
123-
.gsub('%4', tocInner ? tocInner : '');
121+
.gsub('%4', tocInner ? tocInner : '')
124122
'<li class="toc_level-%1 toc_section-%2">%3</li>'
125123
.gsub('%1', toc_level.to_s)
126124
.gsub('%2', toc_section.to_s)

0 commit comments

Comments
 (0)