Skip to content

Commit 67c3386

Browse files
committed
Make the homepage offline workable
This makes it possible to zip the generated _site and put it anywhere, even inside a subdirectory It uses relativize_url filter and includes the Lato font.
1 parent 18400ff commit 67c3386

39 files changed

+159
-51
lines changed

_includes/footer.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="col-md-8">
66
<ul class="list-inline">
77
<li>
8-
<a class="page-scroll" href="{{ "/#home" | relative_url }}">Home</a>
8+
<a class="page-scroll" href="{{ "/#home" | relativize_url }}">Home</a>
99
</li>
1010
<li class="footer-menu-divider">&sdot;</li>
1111
<li>
@@ -17,23 +17,23 @@
1717
</li>
1818
<li class="footer-menu-divider">&sdot;</li>
1919
<li>
20-
<a class="page-scroll" href="{{ "/#about" | relative_url }}">About</a>
20+
<a class="page-scroll" href="{{ "/#about" | relativize_url }}">About</a>
2121
</li>
2222
<li class="footer-menu-divider">&sdot;</li>
2323
<li>
24-
<a class="page-scroll" href="{{ "/#news" | relative_url }}">News</a>
24+
<a class="page-scroll" href="{{ "/#news" | relativize_url }}">News</a>
2525
</li>
2626
<li class="footer-menu-divider">&sdot;</li>
2727
<li>
28-
<a class="page-scroll" href="{{ "/#support" | relative_url }}">Support</a>
28+
<a class="page-scroll" href="{{ "/#support" | relativize_url }}">Support</a>
2929
</li>
3030
<li class="footer-menu-divider">&sdot;</li>
3131
<li>
32-
<a class="page-scroll" href="{{ "/#downloads" | relative_url }}">Downloads</a>
32+
<a class="page-scroll" href="{{ "/#downloads" | relativize_url }}">Downloads</a>
3333
</li>
3434
<li class="footer-menu-divider">&sdot;</li>
3535
<li>
36-
<a class="page-scroll" href="{{ "/#plugins" | relative_url }}">Plugins</a>
36+
<a class="page-scroll" href="{{ "/#plugins" | relativize_url }}">Plugins</a>
3737
</li>
3838
</ul>
3939
<p class="copyright text-muted small">{{ site.copyright }}</p>

_includes/head.html

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,13 @@
1010
<title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
1111

1212
<!-- Bootstrap Core CSS -->
13-
<link href="{{ "/css/bootstrap.min.css" | relative_url }}" rel="stylesheet">
13+
<link href="{{ "/css/bootstrap.min.css" | relativize_url }}" rel="stylesheet">
1414

1515
<!-- Custom CSS -->
16-
<link href="{{ "/css/landing-page.css" | relative_url }}" rel="stylesheet">
17-
<link href="{{ "/css/syntax.css" | relative_url }}" rel="stylesheet">
16+
<link href="{{ "/css/landing-page.css" | relativize_url }}" rel="stylesheet">
17+
<link href="{{ "/css/syntax.css" | relativize_url }}" rel="stylesheet">
1818

1919
<!-- Custom Fonts -->
20-
<link href="{{ "/font-awesome-4.1.0/css/font-awesome.min.css" | relative_url }}" rel="stylesheet" type="text/css">
21-
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
22-
23-
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
24-
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
25-
<!--[if lt IE 9]>
26-
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
27-
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
28-
<![endif]-->
29-
20+
<link href="{{ "/font-awesome-4.1.0/css/font-awesome.min.css" | relativize_url }}" rel="stylesheet" type="text/css">
21+
<link href="{{ "/css/font-lato.css" | relativize_url }}" rel="stylesheet" type="text/css">
3022
</head>

_includes/header.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<span class="icon-bar"></span>
1010
<span class="icon-bar"></span>
1111
</button>
12-
<a class="navbar-brand page-scroll" href="{{ "/#home" | relative_url }}"><i class="fa fa-home" aria-hidden="true"></i> PMD Source Code Analyzer</a>
12+
<a class="navbar-brand page-scroll" href="{{ "/#home" | relativize_url }}"><i class="fa fa-home" aria-hidden="true"></i> PMD Source Code Analyzer</a>
1313
</div>
1414
<!-- Collect the nav links, forms, and other content for toggling -->
1515
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
@@ -21,19 +21,19 @@
2121
<a href="https://github.com/pmd/pmd/issues">Bugs</a>
2222
</li>
2323
<li>
24-
<a class="page-scroll" href="{{ "/#about" | relative_url }}">About</a>
24+
<a class="page-scroll" href="{{ "/#about" | relativize_url }}">About</a>
2525
</li>
2626
<li>
27-
<a class="page-scroll" href="{{ "/#news" | relative_url }}">News</a>
27+
<a class="page-scroll" href="{{ "/#news" | relativize_url }}">News</a>
2828
</li>
2929
<li>
30-
<a class="page-scroll" href="{{ "/#downloads" | relative_url }}">Downloads</a>
30+
<a class="page-scroll" href="{{ "/#downloads" | relativize_url }}">Downloads</a>
3131
</li>
3232
<li>
33-
<a class="page-scroll" href="{{ "/#support" | relative_url }}">Support</a>
33+
<a class="page-scroll" href="{{ "/#support" | relativize_url }}">Support</a>
3434
</li>
3535
<li>
36-
<a class="page-scroll" href="{{ "/#plugins" | relative_url }}">Plugins</a>
36+
<a class="page-scroll" href="{{ "/#plugins" | relativize_url }}">Plugins</a>
3737
</li>
3838
</ul>
3939
</div>

_includes/home.html

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
<section id="home">
22
<!-- Header -->
3-
<div class="intro-header">
3+
<div class="intro-header">
44

5-
<div class="container">
5+
<div class="container">
66

7-
<div class="row">
7+
<div class="row">
88
<div class="col-lg-3">
99
<img src="img/pmd_logo.png" alt="PMD - Don't shoot the messenger">
1010
</div>
11-
<div class="col-lg-9">
12-
<div class="intro-message">
13-
<h1>{{ page.title }}</h1>
14-
<h3>{{ page.subTitle }}</h3>
15-
<hr class="intro-divider">
16-
<ul class="list-inline">
17-
<li><a href="https://github.com/pmd/pmd/releases/download/pmd_releases%2F{{ site.pmd.latestVersion }}/pmd-bin-{{ site.pmd.latestVersion }}.zip" class="btn btn-default btn-lg"><i class="fa fa-download"></i> Download</a></li>
18-
<li><a href="https://pmd.github.io/latest/" class="btn btn-default btn-lg"><i class="fa fa-book"></i> Documentation</a></li>
19-
</ul>
11+
<div class="col-lg-9">
12+
<div class="intro-message">
13+
<h1>{{ page.title }}</h1>
14+
<h3>{{ page.subTitle }}</h3>
15+
<hr class="intro-divider">
16+
<ul class="list-inline">
17+
<li><a href="https://github.com/pmd/pmd/releases/download/pmd_releases%2F{{ site.pmd.latestVersion }}/pmd-bin-{{ site.pmd.latestVersion }}.zip" class="btn btn-default btn-lg"><i class="fa fa-download"></i> Download</a></li>
18+
<li><a href="https://pmd.github.io/latest/" class="btn btn-default btn-lg"><i class="fa fa-book"></i> Documentation</a></li>
19+
</ul>
2020
<hr class="intro-divider">
2121
Latest Version: {{ site.pmd.latestVersion }} ({{ site.pmd.latestVersionDate }})<br/>
2222
<a href="https://pmd.github.io/pmd-{{ site.pmd.latestVersion }}/pmd_release_notes.html">Release Notes</a> |
2323
<a href="https://github.com/pmd/pmd">Source</a>
2424

25-
</div>
26-
</div>
27-
</div>
28-
</div>
29-
<!-- /.container -->
25+
</div>
26+
</div>
27+
</div>
28+
</div>
29+
<!-- /.container -->
3030

31-
</div>
32-
<!-- /.intro-header -->
31+
</div>
32+
<!-- /.intro-header -->
3333
</section>

_includes/js.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!-- jQuery Version 1.11.0 -->
2-
<script src="{{ "/js/jquery-1.11.0.js" | relative_url }}"></script>
2+
<script src="{{ "/js/jquery-1.11.0.js" | relativize_url }}"></script>
33

44
<!-- Plugin JavaScript -->
5-
<script src="{{ "/js/jquery.easing.min.js" | relative_url }}"></script>
5+
<script src="{{ "/js/jquery.easing.min.js" | relativize_url }}"></script>
66

77
<!-- Bootstrap Core JavaScript -->
8-
<script src="{{ "/js/bootstrap.min.js" | relative_url }}"></script>
8+
<script src="{{ "/js/bootstrap.min.js" | relativize_url }}"></script>
99

1010
<!-- Custom Theme JavaScript -->
11-
<script src="{{ "/js/landing-page.js" | relative_url }}"></script>
11+
<script src="{{ "/js/landing-page.js" | relativize_url }}"></script>

_includes/news.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ <h2 class="text-center">News</h2>
88

99
<ul class="text-left">
1010
{% for post in site.posts limit:5 %}
11-
<li><a href="{{ post.url | relative_url }}">{{ post.date | date_to_string }}: {{ post.title }}</a></li>
11+
<li><a href="{{ post.url | relativize_url }}">{{ post.date | date_to_string }}: {{ post.title }}</a></li>
1212
{% endfor %}
1313
</ul>
1414

15-
<a href="{{ "news/" | relative_url }}">All news</a>
15+
<a href="{{ "/news/" | relativize_url }}">All news</a>
1616
</div>
1717
</div>
1818
</section>

_layouts/news.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h2>News</h2>
1414

1515
<ul class="text-left">
1616
{% for post in site.posts %}
17-
<li><a href="{{ post.url | relative_url }}">{{ post.date | date_to_string }}: {{ post.title }}</a></li>
17+
<li><a href="{{ post.url | relativize_url }}">{{ post.date | date_to_string }}: {{ post.title }}</a></li>
1818
{% endfor %}
1919
</ul>
2020
</div>

_plugins/UrlRelativizer.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# See https://github.com/jekyll/jekyll/issues/6360#issuecomment-329275101
3+
#
4+
# Usage:
5+
# {{ "/css/style.css" | relativize_url }} will generate
6+
# "css/style.css" for pages in the root, and "../css/style.css"
7+
# for pages in immediate subdirectories.
8+
#
9+
10+
require 'pathname'
11+
12+
module Jekyll
13+
module UrlRelativizer
14+
def relativize_url(url)
15+
pageUrl = @context.registers[:page]["url"]
16+
pageDir = Pathname(pageUrl) #.parent
17+
#warn "relativize url=#{url} for pageurl=#{pageUrl} pagedir=#{pageDir}\n"
18+
Pathname(url).relative_path_from(pageDir).to_s
19+
end
20+
end
21+
end
22+
23+
Liquid::Template.register_filter(Jekyll::UrlRelativizer)

css/font-lato.css

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* https://fonts.google.com/specimen/Lato
3+
*/
4+
@font-face {
5+
font-family: 'Lato';
6+
src: url('../fonts/Lato-LightItalic.woff2') format('woff2'),
7+
url('../fonts/Lato-LightItalic.woff') format('woff'),
8+
url('../fonts/Lato-LightItalic.ttf') format('truetype');
9+
font-weight: 300;
10+
font-style: italic;
11+
}
12+
13+
@font-face {
14+
font-family: 'Lato';
15+
src: url('../fonts/Lato-Bold.woff2') format('woff2'),
16+
url('../fonts/Lato-Bold.woff') format('woff'),
17+
url('../fonts/Lato-Bold.ttf') format('truetype');
18+
font-weight: bold;
19+
font-style: normal;
20+
}
21+
22+
@font-face {
23+
font-family: 'Lato Hairline';
24+
src: url('../fonts/Lato-HairlineItalic.woff2') format('woff2'),
25+
url('../fonts/Lato-HairlineItalic.woff') format('woff'),
26+
url('../fonts/Lato-HairlineItalic.ttf') format('truetype');
27+
font-weight: 300;
28+
font-style: italic;
29+
}
30+
31+
@font-face {
32+
font-family: 'Lato';
33+
src: url('../fonts/Lato-BoldItalic.woff2') format('woff2'),
34+
url('../fonts/Lato-BoldItalic.woff') format('woff'),
35+
url('../fonts/Lato-BoldItalic.ttf') format('truetype');
36+
font-weight: bold;
37+
font-style: italic;
38+
}
39+
40+
@font-face {
41+
font-family: 'Lato';
42+
src: url('../fonts/Lato-Regular.woff2') format('woff2'),
43+
url('../fonts/Lato-Regular.woff') format('woff'),
44+
url('../fonts/Lato-Regular.ttf') format('truetype');
45+
font-weight: normal;
46+
font-style: normal;
47+
}
48+
49+
@font-face {
50+
font-family: 'Lato Hairline';
51+
src: url('../fonts/Lato-Hairline.woff2') format('woff2'),
52+
url('../fonts/Lato-Hairline.woff') format('woff'),
53+
url('../fonts/Lato-Hairline.ttf') format('truetype');
54+
font-weight: 300;
55+
font-style: normal;
56+
}
57+
58+
@font-face {
59+
font-family: 'Lato';
60+
src: url('../fonts/Lato-Black.woff2') format('woff2'),
61+
url('../fonts/Lato-Black.woff') format('woff'),
62+
url('../fonts/Lato-Black.ttf') format('truetype');
63+
font-weight: 900;
64+
font-style: normal;
65+
}
66+
67+
@font-face {
68+
font-family: 'Lato';
69+
src: url('../fonts/Lato-Italic.woff2') format('woff2'),
70+
url('../fonts/Lato-Italic.woff') format('woff'),
71+
url('../fonts/Lato-Italic.ttf') format('truetype');
72+
font-weight: normal;
73+
font-style: italic;
74+
}
75+
76+
@font-face {
77+
font-family: 'Lato';
78+
src: url('../fonts/Lato-Light.woff2') format('woff2'),
79+
url('../fonts/Lato-Light.woff') format('woff'),
80+
url('../fonts/Lato-Light.ttf') format('truetype');
81+
font-weight: 300;
82+
font-style: normal;
83+
}
84+
85+
@font-face {
86+
font-family: 'Lato';
87+
src: url('../fonts/Lato-BlackItalic.woff2') format('woff2'),
88+
url('../fonts/Lato-BlackItalic.woff') format('woff'),
89+
url('../fonts/Lato-BlackItalic.ttf') format('truetype');
90+
font-weight: 900;
91+
font-style: italic;
92+
}
93+

fonts/Lato-Black.ttf

70.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)