jekyll-rtd-theme 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23a52d768800e6af7ea1d5c4c35a91cee56046bade55174bcc0eb4d31e9ed676
4
- data.tar.gz: 3d005a4cb29f27c512492cccfcdc9da428303af00df3f2ba5a7f3bc3a22e5c07
3
+ metadata.gz: 0fe2af4a55863950ce67d80e629b1b91e87a7381598baf0a39e66d8d577e48b3
4
+ data.tar.gz: d7735dedfcf430ab8cbb1d6f4708aa2ae036d4faff449cc8af18b9e4b5d3e4f2
5
5
  SHA512:
6
- metadata.gz: 022acda52128c5ced54cb84635fd067ff26ed77c99a8bc4e50762ba40d3769104d739e82ad08f56958b802f8eed716407c7d1e094cdcec75c7e3c264791cf0a8
7
- data.tar.gz: 68f91d2be6fb03d1c00b2d29c84acd297c4539478a6b1622fbf69dee85a71b91d8ea1326d98e1687b6676621bba2027e2e858602bb24f8333eaaa0a6bc7815c5
6
+ metadata.gz: cd1194ed2522bb51043228ca16f92cc44fb79eb4cb5e12806a6f655b2d04a264cc57efa0382ade4e08887dd6729e8ff0f3e23e9979a173b5abe20935f7662067
7
+ data.tar.gz: ef92a03c1da2d455219a4f65f3a89d352ecbc4379fe3e24882f14381bb6e5c8d53687a60c0b90370476f63f2761ef6b80622f9fd805601c95409f181a967752a
@@ -6,3 +6,13 @@
6
6
  </a>
7
7
  </dd>
8
8
  </dl>
9
+
10
+ <script>
11
+ $(document).ready(function() {
12
+ let analytics = new URL("https://rundocs-analytics.glitch.me/collect?v={{ version }}&lang={{ lang }}");
13
+ analytics.searchParams.append("user_lang", navigator.language);
14
+ analytics.searchParams.append("host", location.host);
15
+ analytics.searchParams.append("platform", navigator.platform);
16
+ $.getJSON(analytics.toString(), (data) => $("#counter").html(data.count));
17
+ });
18
+ </script>
@@ -1,39 +1,75 @@
1
1
  $(document).ready(function() {
2
- let analytics = new URL("https://rundocs-analytics.glitch.me/collect?v={{ version }}&lang={{ lang }}");
3
- let highlight = new URL(location.href).searchParams.get("highlight");
4
- let current = $(".wy-menu-vertical").find(`[href="${location.pathname}"]`);
2
+ function set(name, value) {
3
+ return localStorage.setItem(name, value);
4
+ }
5
5
 
6
- /* directory toc */
7
- if (current.length > 0) {
8
- current.closest("li.toctree-l1").parent().addClass("current");
9
- current.closest("li.toctree-l1").addClass("current");
10
- current.closest("li.toctree-l2").addClass("current");
11
- current.closest("li.toctree-l3").addClass("current");
12
- current.closest("li.toctree-l4").addClass("current");
13
- current.closest("li.toctree-l5").addClass("current");
14
- current[0].scrollIntoView();
6
+ function get(name) {
7
+ return localStorage.getItem(name) || false;
15
8
  }
16
- /* content toc */
17
- $(".wy-menu-vertical li.current").append(function() {
18
- let level = parseInt($(this).attr("class").match(/toctree-l(\d+)/)[1]) + 1;
19
- let toc = ["<ul>"];
20
- let sort = parseInt(this.dataset.sort);
9
+
10
+ /* anchors */
11
+ anchors.add();
12
+
13
+ /* generate content TOC (id from anchors) */
14
+ $(".wy-menu-vertical li.current").append('<ul class="content-toc"></ul>').html(function() {
15
+ let level = parseInt(this.dataset.level);
16
+ let temp = 0;
17
+ let stack = [$(this).find(".content-toc")];
21
18
 
22
19
  $(".document").find("h2,h3,h4,h5,h6").each(function() {
23
- toc.push(`<li class="toctree-l${level}"><a class="reference internal" href="#${this.id}">${$(this).text()}</a></li>`);
20
+ let anchor = $("<a/>").addClass("reference internal").text($(this).text()).attr("href", `#${this.id}`);
21
+ let tagLevel = parseInt(this.tagName.slice(1)) - 1;
22
+
23
+ if (tagLevel > temp) {
24
+ let parent = stack[0].children("li:last")[0];
25
+ if (parent) {
26
+ stack.unshift($("<ul/>").appendTo(parent));
27
+ }
28
+ } else {
29
+ stack.splice(0, Math.min(temp - tagLevel, Math.max(stack.length - 1, 0)));
30
+ }
31
+ temp = tagLevel;
32
+
33
+ $("<li/>").addClass(`toctree-l${level + tagLevel}`).append(anchor).appendTo(stack[0]);
24
34
  });
25
- toc.push("</ul>");
26
- /* return is apend */
27
- if (toc.length == 2) {
28
- return "";
29
- } else {
30
- return toc.join("");
35
+ /* if TOC is empty remove ul */
36
+ if (!stack[0].html()) {
37
+ stack[0].remove();
31
38
  }
32
39
  });
40
+
41
+ /* display current file in TOC */
42
+ let link = $(".wy-menu-vertical").find(`[href="${location.pathname}"]`);
43
+ if (link.length > 0) {
44
+ link.closest("li.toctree-l1").parent().addClass("current");
45
+ link.closest("li.toctree-l1").addClass("current");
46
+ link.closest("li.toctree-l2").addClass("current");
47
+ link.closest("li.toctree-l3").addClass("current");
48
+ link.closest("li.toctree-l4").addClass("current");
49
+ link.closest("li.toctree-l5").addClass("current");
50
+ }
51
+
52
+ /* restore sidebar scroll within 10 minutes */
53
+ let scroll = get("scroll");
54
+ let scrollTime = get("scrollTime");
55
+ let scrollHost = get("scrollHost");
56
+
57
+ if (scroll && scrollTime && scrollHost) {
58
+ if (scrollHost == location.host && (Date.now() - scrollTime < 6e5)) {
59
+ $(".wy-side-scroll").scrollTop(scroll);
60
+ }
61
+ }
62
+ $(".wy-side-scroll").scroll(function() {
63
+ set("scroll", this.scrollTop);
64
+ set("scrollTime", Date.now());
65
+ set("scrollHost", location.host);
66
+ });
67
+
33
68
  /* native nav */
34
69
  SphinxRtdTheme.Navigation.enable(true);
35
70
 
36
71
  /* search highlight */
72
+ let highlight = new URL(location.href).searchParams.get("highlight");
37
73
  if (highlight) {
38
74
  $(".section").find("*").each(function() {
39
75
  try {
@@ -41,7 +77,7 @@ $(document).ready(function() {
41
77
  $(this).addClass("highlighted-box");
42
78
  }
43
79
  } catch (e) {
44
- feedback(["highlight", e.message]);
80
+ debug(e.message);
45
81
  }
46
82
  });
47
83
  $(".section").find(".highlighted-box").each(function() {
@@ -50,16 +86,9 @@ $(document).ready(function() {
50
86
  }
51
87
  });
52
88
  }
89
+
53
90
  /* admonition */
54
91
  $(".admonition-title").each(function() {
55
92
  $(this).html(ui.admonition[$(this).attr("ui")]);
56
93
  });
57
- /* anchors */
58
- anchors.add();
59
-
60
- /* analytics */
61
- analytics.searchParams.append("user_lang", navigator.language);
62
- analytics.searchParams.append("host", location.host);
63
- analytics.searchParams.append("platform", navigator.platform);
64
- $.getJSON(analytics.toString(), (data) => $("#counter").html(data.count));
65
- });
94
+ });
@@ -13,7 +13,7 @@ function search(data) {
13
13
  $(".search").empty();
14
14
  $(".search-summary").html(i18n[lang].search_results_not_found);
15
15
  $("#search-results h2").html(i18n[lang].search_results);
16
- return feedback(["search", e.message]);
16
+ return debug(e.message);
17
17
  }
18
18
 
19
19
  function slice(content, min, max) {
@@ -32,7 +32,7 @@ function search(data) {
32
32
  }
33
33
  }
34
34
  } catch (e) {
35
- feedback(["search", e.message]);
35
+ debug(e.message);
36
36
  }
37
37
  try {
38
38
  if (page.content) {
@@ -40,7 +40,7 @@ function search(data) {
40
40
  content = page.content.match(regexp);
41
41
  }
42
42
  } catch (e) {
43
- feedback(["search", e.message]);
43
+ debug(e.message);
44
44
  }
45
45
  if (title || content) {
46
46
  let result = [`<a href="${ui.baseurl}${page.url}?highlight=${text}">${page.title}</a>`];
@@ -72,5 +72,5 @@ function search(data) {
72
72
  }
73
73
 
74
74
  $(document).ready(function() {
75
- $.ajax(`${ui.baseurl}/pages.json`).done(search).fail((xhr, message) => feedback(["search", message]));
75
+ $.ajax(`${ui.baseurl}/pages.json`).done(search).fail((xhr, message) => debug(message));
76
76
  });
@@ -0,0 +1,33 @@
1
+ self.addEventListener("activate", function(event) {
2
+ let cacheWhitelist = ["rundocs-{{ version }}"];
3
+
4
+ event.waitUntil(
5
+ caches.keys().then(function(keyList) {
6
+ return Promise.all(keyList.map(function(key) {
7
+ if (cacheWhitelist.indexOf(key) === -1) {
8
+ return caches.delete(key);
9
+ }
10
+ }));
11
+ })
12
+ );
13
+ });
14
+
15
+ self.addEventListener("fetch", function(e) {
16
+ if (/^https:\/\/cdn\.jsdelivr\.net\/gh\/rundocs\/jekyll-rtd-theme@.+/.exec(e.request.url)) {
17
+ e.respondWith(
18
+ caches.match(e.request).then(function(resp) {
19
+ if (resp !== undefined) {
20
+ return resp;
21
+ } else {
22
+ return fetch(e.request, { cache: "no-store" }).then(function(resp) {
23
+ let clone = resp.clone();
24
+ caches.open("rundocs-{{ version }}").then(function(cache) {
25
+ cache.put(e.request, clone);
26
+ });
27
+ return resp;
28
+ }).catch(console.log);
29
+ }
30
+ })
31
+ );
32
+ }
33
+ });
@@ -24,7 +24,7 @@
24
24
  {%- assign level = level | minus: 1 -%}
25
25
  {%- endif -%}
26
26
 
27
- <li class="toctree-l{{ level }} {{ current }}" data-sort="{{ item.sort }}">
27
+ <li class="toctree-l{{ level }} {{ current }}" data-sort="{{ item.sort }}" data-level="{{ level }}">
28
28
  <a class="reference internal {{ current }}" href="{{ item.url | relative_url }}">
29
29
  {%- if item.sort and site.show_sorted != false -%}
30
30
  {{ item.sort }}. {{ item.title | default: item.url }}
@@ -1,10 +1,10 @@
1
1
  {%- assign description = content | strip_html | split: " " | join: " " | escape | truncate: 150 -%}
2
- {%- assign version = "1.1.4" -%}
2
+ {%- assign version = "1.1.5" -%}
3
3
  {%- assign addons = "github, i18n, plugins, analytics" | split: ", " -%}
4
4
 
5
5
  {%- assign schema_date = page.date | default: site.time | date_to_xmlschema -%}
6
6
  {%- assign schema_modi = site.time | date_to_xmlschema -%}
7
- {%- assign schema_surl = page.url | absolute_url | replace: 'http://', 'https://' | xml_escape -%}
7
+ {%- assign schema_surl = page.url | absolute_url | xml_escape -%}
8
8
 
9
9
  {% comment %} scss {% endcomment %}
10
10
  {%- capture site_scss -%}
@@ -58,8 +58,8 @@
58
58
  {% comment %} content {% endcomment %}
59
59
  {%- assign content = content
60
60
  | replace: '’', "'"
61
- | replace: '<pre class="highlight"><code>', "<pre>"
62
- | replace: '<pre><code class=', "<pre class="
61
+ | replace: '<pre class="highlight"><code>', '<pre class="notranslate">'
62
+ | replace: '<pre><code class="', '<pre class="notranslate '
63
63
  | replace: "</code></pre>", "</pre>"
64
64
  | replace: '<code class="language-plaintext highlighter-rouge">', '<code class="literal">'
65
65
  | replace: "<table>", '<table class="docutils align-default">' -%}
@@ -10,9 +10,13 @@
10
10
  {%- capture current -%}
11
11
  {%- if page.url == item.url %}current{% endif -%}
12
12
  {%- endcapture %}
13
- <li class="toctree-l{{ level }} {{ current }}">
13
+ <li class="toctree-l{{ level }} {{ current }}" data-sort="{{ item.sort }}" data-level="{{ level }}">
14
14
  <a class="reference internal {{ current }}" href="{{ item.url | relative_url }}">
15
- {{ item.title | default: item.url }}
15
+ {%- if item.sort and site.show_sorted != false -%}
16
+ {{ item.sort }}. {{ item.title | default: item.url }}
17
+ {%- else -%}
18
+ {{ item.title | default: item.url }}
19
+ {%- endif -%}
16
20
  </a>
17
21
  </li>
18
22
  {%- endfor %}
@@ -28,13 +28,17 @@ layout: plugins/compress
28
28
  dataLayer.push(arguments);
29
29
  }
30
30
 
31
- function feedback(messages) {
32
- gtag("event", "exception", {
33
- "description": messages.join(":")
34
- });
31
+ function debug() {
32
+ console.debug.apply(console, arguments);
35
33
  }
36
34
 
37
35
  gtag("js", new Date());
36
+
37
+ if ("serviceWorker" in navigator) {
38
+ navigator.serviceWorker.register("{{ site.baseurl }}/sw.caches.js");
39
+ } else {
40
+ debug("Service Worker not supported!");
41
+ }
38
42
  </script>
39
43
  <!-- meta -->
40
44
  <meta name="description" content="{{ description }}">
@@ -85,8 +89,8 @@ layout: plugins/compress
85
89
  </script>
86
90
  <!-- link -->
87
91
  <link rel="canonical" href="{{ schema_surl }}">
88
- {% if prev %}<link rel="prev" href="{{ prev.url | absolute_url | replace: 'http://', 'https://' }}">{% endif %}
89
- {% if next %}<link rel="next" href="{{ next.url | absolute_url | replace: 'http://', 'https://' }}">{% endif %}
92
+ {% if prev %}<link rel="prev" href="{{ prev.url | absolute_url }}">{% endif %}
93
+ {% if next %}<link rel="next" href="{{ next.url | absolute_url }}">{% endif %}
90
94
  <!-- theme -->
91
95
  <link rel="stylesheet" href="{{ cdn }}/assets/css/theme.css">
92
96
  <link rel="stylesheet" href="{{ cdn }}/assets/css/rougify/{{ site.rougify | default: 'github' }}.css">
@@ -182,15 +186,18 @@ layout: plugins/compress
182
186
  <!-- script -->
183
187
  <script src="{{ cdn }}/assets/js/theme.js"></script>
184
188
  <script src="{{ cdn }}/assets/js/anchor.min.js"></script>
189
+
185
190
  {% comment %} mermaid {% endcomment %}
186
- {%- if content contains '<pre class="language-mermaid">' -%}
187
- {%- if site.mermaid.src -%}
188
- <script src="{{ site.mermaid.src }}"></script>
191
+ {%- if content contains '<pre class="notranslate language-mermaid">' -%}
192
+ {%- if site.mermaid.custom -%}
193
+ <script src="{{ site.mermaid.custom }}"></script>
189
194
  {%- else -%}
190
195
  <script src="{{ cdn }}/assets/js/mermaid.min.js"></script>
191
- {%- endif -%}
192
- <script>mermaid.initialize({startOnLoad: true});</script>
193
- {%- endif -%}
196
+ {%- endif %}
197
+ <script>
198
+ mermaid.initialize({% if site.mermaid.initialize %}{{ site.mermaid.initialize | jsonify }}{% else %}{}{% endif %});
199
+ </script>
200
+ {%- endif %}
194
201
  <script>
195
202
  {% include assets/common.js %}
196
203
  {% include assets/custom.js %} {{ site.script }}
@@ -8,7 +8,7 @@
8
8
  {%- assign admonitions = "note, tip, warning, danger" | split: ", " -%}
9
9
  {%- comment %} get pre code and type {% endcomment -%}
10
10
  {%- assign pre_blocks = child_blocks.first | replace_first: ">", "```<temp>```" | split: "```<temp>```" -%}
11
- {%- assign pre_type = pre_blocks.first | replace: '"', '' | replace: " class=language-", "" -%}
11
+ {%- assign pre_type = pre_blocks.first | replace: '"', '' | replace: " class=notranslate language-", "" -%}
12
12
 
13
13
  {%- if admonitions contains pre_type -%}
14
14
  <div class="admonition {{ pre_type }}">
@@ -6,4 +6,4 @@ permalink: /robots.txt
6
6
  User-agent: *
7
7
  Allow: /
8
8
 
9
- Sitemap: {{ "sitemap.xml" | absolute_url | replace: "http://", "https://" }}
9
+ Sitemap: {{ "sitemap.xml" | absolute_url }}
@@ -9,7 +9,7 @@ permalink: /sitemap.xml
9
9
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
10
10
  {%- for page in site_pages -%}
11
11
  <url>
12
- <loc>{{ page.url | absolute_url | replace: "http://", "https://" | xml_escape }}</loc>
12
+ <loc>{{ page.url | absolute_url | xml_escape }}</loc>
13
13
  <priority>{{ page.content | size | divided_by: 2048.0 | times: 10 | ceil | divided_by: 10.0 | at_least: 0.1 | at_most: 1.0 }}</priority>
14
14
  <lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
15
15
  </url>
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: plugins/compress
3
+ permalink: /sw.caches.js
4
+ ---
5
+
6
+ {%- include reset/defaults.liquid -%}
7
+
8
+ {%- include assets/sw.caches.js -%}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-rtd-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - saowang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-21 00:00:00.000000000 Z
11
+ date: 2020-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github-pages
@@ -43,6 +43,7 @@ files:
43
43
  - _includes/assets/custom.js
44
44
  - _includes/assets/custom.scss
45
45
  - _includes/assets/search.js
46
+ - _includes/assets/sw.caches.js
46
47
  - _includes/breadcrumbs.liquid
47
48
  - _includes/extend/list.liquid
48
49
  - _includes/extend/tabs.liquid
@@ -125,6 +126,7 @@ files:
125
126
  - assets/robots.liquid
126
127
  - assets/search.liquid
127
128
  - assets/sitemap.liquid
129
+ - assets/sw.caches.liquid
128
130
  homepage: https://github.com/rundocs/jekyll-rtd-theme
129
131
  licenses:
130
132
  - MIT