1 |
commit: 563f4c60d694a0ce2e053a88fdf11f1f88e63dcd |
2 |
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jan 28 19:40:51 2020 +0000 |
4 |
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Feb 3 00:01:19 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=563f4c60 |
7 |
|
8 |
Support offline browsing. |
9 |
|
10 |
Pass an "offline" flag to devbook.xsl, which disables loading of |
11 |
external assets and loads a simple CSS instead. This will replace |
12 |
the fragile patching in the app-doc/devmanual ebuild. |
13 |
|
14 |
offline.css was originally contributed (as fallback.css) |
15 |
by Lucas Ramage in bug 617724. |
16 |
|
17 |
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org> |
18 |
|
19 |
Makefile | 5 ++++- |
20 |
devbook.xsl | 55 +++++++++++++++++++++++++++++++++++++------------------ |
21 |
offline.css | 19 +++++++++++++++++++ |
22 |
3 files changed, 60 insertions(+), 19 deletions(-) |
23 |
|
24 |
diff --git a/Makefile b/Makefile |
25 |
index 3fb4c52..ef2c735 100644 |
26 |
--- a/Makefile |
27 |
+++ b/Makefile |
28 |
@@ -7,6 +7,9 @@ HTMLS := $(subst text.xml,index.html,$(XMLS)) |
29 |
ECLASS_HTMLS := $(wildcard eclass-reference/*/index.html) |
30 |
IMAGES := $(patsubst %.svg,%.png,$(SVGS)) |
31 |
|
32 |
+# Nonzero value disables external assets for offline browsing. |
33 |
+OFFLINE = 0 |
34 |
+ |
35 |
all: prereq validate build documents.js |
36 |
|
37 |
prereq: |
38 |
@@ -49,7 +52,7 @@ documents.js: bin/build_search_documents.py $(XMLS) |
39 |
# |
40 |
.SECONDEXPANSION: |
41 |
%.html: $$(dir $$@)text.xml devbook.xsl xsl/*.xsl $$(subst text.xml,index.html,$$(wildcard $$(dir $$@)*/text.xml)) |
42 |
- xsltproc devbook.xsl $< > $@ |
43 |
+ xsltproc --param offline "$(OFFLINE)" devbook.xsl $< > $@ |
44 |
|
45 |
validate: prereq |
46 |
@xmllint --noout --dtdvalid devbook.dtd $(XMLS) \ |
47 |
|
48 |
diff --git a/devbook.xsl b/devbook.xsl |
49 |
index 3ff6502..faf9796 100644 |
50 |
--- a/devbook.xsl |
51 |
+++ b/devbook.xsl |
52 |
@@ -14,6 +14,10 @@ |
53 |
|
54 |
<xsl:output method="html" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/> |
55 |
|
56 |
+<!-- When true, disable external assets for offline browsing. |
57 |
+ The parameter can be passed with "xsltproc -\-param offline 1". --> |
58 |
+<xsl:param name="offline" select="0"/> |
59 |
+ |
60 |
<xsl:variable name="newline"> |
61 |
<xsl:text> |
62 |
</xsl:text> |
63 |
@@ -451,13 +455,21 @@ |
64 |
<title><xsl:value-of select="/guide/chapter[1]/title"/> – Gentoo Development Guide</title> |
65 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
66 |
<meta name="description" content="The Gentoo Devmanual is a technical manual which covers topics such as writing ebuilds and eclasses, and policies that developers should be abiding by." /> |
67 |
- <link href="https://assets.gentoo.org/tyrian/bootstrap.min.css" rel="stylesheet" media="screen" /> |
68 |
- <link href="https://assets.gentoo.org/tyrian/tyrian.min.css" rel="stylesheet" media="screen" /> |
69 |
+ <xsl:choose> |
70 |
+ <xsl:when test="$offline"> |
71 |
+ <link rel="stylesheet" href="{$relative_path_depth_recursion}offline.css" type="text/css" /> |
72 |
+ </xsl:when> |
73 |
+ <xsl:otherwise> |
74 |
+ <link href="https://assets.gentoo.org/tyrian/bootstrap.min.css" rel="stylesheet" media="screen" /> |
75 |
+ <link href="https://assets.gentoo.org/tyrian/tyrian.min.css" rel="stylesheet" media="screen" /> |
76 |
+ </xsl:otherwise> |
77 |
+ </xsl:choose> |
78 |
<link rel="stylesheet" href="{$relative_path_depth_recursion}devmanual.css" type="text/css" /> |
79 |
<link rel="icon" href="https://www.gentoo.org/favicon.ico" type="image/x-icon" /> |
80 |
</head> |
81 |
<body> |
82 |
<header> |
83 |
+ <xsl:if test="not($offline)"> |
84 |
<div class="site-title"> |
85 |
<div class="container"> |
86 |
<div class="row"> |
87 |
@@ -561,6 +573,7 @@ |
88 |
</div> |
89 |
</div> |
90 |
</div> |
91 |
+ </xsl:if> |
92 |
<div class="container"> |
93 |
<div class="row"> |
94 |
<div class="col-md010"> |
95 |
@@ -581,20 +594,24 @@ |
96 |
</main> |
97 |
<footer> |
98 |
<div class="container"> |
99 |
- <div class="row"> |
100 |
- <div class="col-xs-12 col-md-offset-2 col-md-7"> |
101 |
- </div> |
102 |
- <div class="col-xs-12 col-md-3"> |
103 |
- <h3 class="footerhead">Questions or comments?</h3> |
104 |
- Please feel free to <a href="https://www.gentoo.org/inside-gentoo/contact/">contact us</a>. |
105 |
+ <xsl:if test="not($offline)"> |
106 |
+ <div class="row"> |
107 |
+ <div class="col-xs-12 col-md-offset-2 col-md-7"> |
108 |
+ </div> |
109 |
+ <div class="col-xs-12 col-md-3"> |
110 |
+ <h3 class="footerhead">Questions or comments?</h3> |
111 |
+ Please feel free to <a href="https://www.gentoo.org/inside-gentoo/contact/">contact us</a>. |
112 |
+ </div> |
113 |
</div> |
114 |
- </div> |
115 |
+ </xsl:if> |
116 |
<div class="row"> |
117 |
<div class="col-xs-2 col-sm-3 col-md-2"> |
118 |
- <ul class="footerlinks three-icons"> |
119 |
- <li><a href="https://twitter.com/gentoo" title="@Gentoo on Twitter"><span class="fa fa-twitter fa-fw"></span></a></li> |
120 |
- <li><a href="https://www.facebook.com/gentoo.org" title="Gentoo on Facebook"><span class="fa fa-facebook fa-fw"></span></a></li> |
121 |
- </ul> |
122 |
+ <xsl:if test="not($offline)"> |
123 |
+ <ul class="footerlinks three-icons"> |
124 |
+ <li><a href="https://twitter.com/gentoo" title="@Gentoo on Twitter"><span class="fa fa-twitter fa-fw"></span></a></li> |
125 |
+ <li><a href="https://www.facebook.com/gentoo.org" title="Gentoo on Facebook"><span class="fa fa-facebook fa-fw"></span></a></li> |
126 |
+ </ul> |
127 |
+ </xsl:if> |
128 |
</div> |
129 |
<div class="col-xs-10 col-sm-9 col-md-10"> |
130 |
<strong>Copyright (C) 2001-2020 Gentoo Authors</strong><br /> |
131 |
@@ -608,11 +625,13 @@ |
132 |
</div> |
133 |
</div> |
134 |
</footer> |
135 |
- <script src="https://assets.gentoo.org/tyrian/jquery.min.js"></script> |
136 |
- <script src="https://assets.gentoo.org/tyrian/bootstrap.min.js"></script> |
137 |
- <script src="https://assets.gentoo.org/lunr/lunr.min.js"></script> |
138 |
- <script><xsl:text>var documentsSrc = "</xsl:text><xsl:value-of select="$relative_path_depth_recursion"/><xsl:text>documents.js"</xsl:text></script> |
139 |
- <script src="{$relative_path_depth_recursion}search.js"></script> |
140 |
+ <xsl:if test="not($offline)"> |
141 |
+ <script src="https://assets.gentoo.org/tyrian/jquery.min.js"></script> |
142 |
+ <script src="https://assets.gentoo.org/tyrian/bootstrap.min.js"></script> |
143 |
+ <script src="https://assets.gentoo.org/lunr/lunr.min.js"></script> |
144 |
+ <script><xsl:text>var documentsSrc = "</xsl:text><xsl:value-of select="$relative_path_depth_recursion"/><xsl:text>documents.js"</xsl:text></script> |
145 |
+ <script src="{$relative_path_depth_recursion}search.js"></script> |
146 |
+ </xsl:if> |
147 |
</body> |
148 |
</html> |
149 |
</xsl:template> |
150 |
|
151 |
diff --git a/offline.css b/offline.css |
152 |
new file mode 100644 |
153 |
index 0000000..42f94e9 |
154 |
--- /dev/null |
155 |
+++ b/offline.css |
156 |
@@ -0,0 +1,19 @@ |
157 |
+body { |
158 |
+ margin: 40px auto; |
159 |
+ max-width: 650px; |
160 |
+ line-height: 1.6; |
161 |
+ font-size: 18px; |
162 |
+ color: #454545; |
163 |
+ background-color: #fafafa; |
164 |
+ padding: 0 10px; |
165 |
+} |
166 |
+ |
167 |
+header, footer { |
168 |
+ padding: 0.75em 1em; |
169 |
+ margin: 0; |
170 |
+ background-color: #e1e1e1; |
171 |
+} |
172 |
+ |
173 |
+h1, h2, h3, h4, h5, h6 { |
174 |
+ line-height: 1.2; |
175 |
+} |