summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehonal <yehonal.azeroth@gmail.com>2020-01-12 19:26:36 +0100
committerYehonal <yehonal.azeroth@gmail.com>2020-01-12 19:26:36 +0100
commitee8613b3383f896aaf49fb693d20761c90bec0ec (patch)
treeced5c72dc4b61c68d2c5f8ec9f4b00c3367652de
parent33429ab077e1739bd616d637c3beed863c7d1cfc (diff)
parent865e801950d4062fcab0a9a2de0bce3b8b2e39e4 (diff)
downloadwiki-ee8613b3383f896aaf49fb693d20761c90bec0ec.tar.gz
wiki-ee8613b3383f896aaf49fb693d20761c90bec0ec.tar.bz2
wiki-ee8613b3383f896aaf49fb693d20761c90bec0ec.zip
Merge branch 'master' of https://github.com/Drassil/git-wiki-theme
-rw-r--r--_includes/git-wiki/components/copyrights/copyrights.html4
-rw-r--r--_includes/git-wiki/components/logo/logo.html2
-rw-r--r--_includes/git-wiki/components/toc/toc-lib.html33
-rw-r--r--_includes/git-wiki/components/toc/toc.html5
-rw-r--r--_includes/git-wiki/defines/defines.html2
-rw-r--r--_includes/git-wiki/sections/head/scripts.html2
-rw-r--r--_includes/git-wiki/sections/header/header.html2
-rw-r--r--_includes/git-wiki/sections/tail/tail.html12
-rw-r--r--assets/js/checkLinks.js (renamed from assets/js/red-links.js)22
-rw-r--r--wiki/main_page.md6
10 files changed, 64 insertions, 26 deletions
diff --git a/_includes/git-wiki/components/copyrights/copyrights.html b/_includes/git-wiki/components/copyrights/copyrights.html
index 8a2841e..dd15f9f 100644
--- a/_includes/git-wiki/components/copyrights/copyrights.html
+++ b/_includes/git-wiki/components/copyrights/copyrights.html
@@ -2,10 +2,10 @@
<div class="git-wiki-copyrights">
<p>This project is maintained by <a href="{{ site.github.owner_url }}">{{ site.github.owner_name }}</a></p>
{% endif %}
- <p><small>Hosted on GitHub Pages &mdash; Powered by <a href="https://github.com/Drassil/git-wiki">Git-Wiki v{{
+ <p><small>Hosted on GitHub Pages &mdash; Powered by <a href="https://github.com/Drassil/git-wiki-theme">Git-Wiki v{{
version }}</a> </p>
{% if site.github.is_project_page %}
<p class="view"><a href="{{ site.github.repository_url }}">View the Project on GitHub <small>{{ github_name }}</small></a></p>
</div>
-{% endif %} \ No newline at end of file
+{% endif %}
diff --git a/_includes/git-wiki/components/logo/logo.html b/_includes/git-wiki/components/logo/logo.html
index 375b06b..e7ad94a 100644
--- a/_includes/git-wiki/components/logo/logo.html
+++ b/_includes/git-wiki/components/logo/logo.html
@@ -1,5 +1,5 @@
<div class="git-wiki-main-logo">
- <a href="{{ '/' | relative_url }}"><img src="{{ site.logo_url }}">
+<a href="{{ '/' | relative_url }}"><img src="{{ site.logo_url | relative_url }}">
<h1>{{ site.title | default: site.github.repository_name | escape }}</h1>
</a>
<p>{{ site.description | default: site.github.project_tagline }}</p>
diff --git a/_includes/git-wiki/components/toc/toc-lib.html b/_includes/git-wiki/components/toc/toc-lib.html
index 4aa9c88..8851400 100644
--- a/_includes/git-wiki/components/toc/toc-lib.html
+++ b/_includes/git-wiki/components/toc/toc-lib.html
@@ -12,15 +12,17 @@
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
Optional Parameters:
- * sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC
- * class (string) : '' - a CSS class assigned to the TOC
- * id (string) : '' - an ID to assigned to the TOC
- * h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored
- * h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored
- * ordered (bool) : false - when set to true, an ordered list will be outputted instead of an unordered list
- * item_class (string) : '' - add custom class(es) for each list item; has support for '%level%' placeholder, which is the current heading level
- * baseurl (string) : '' - add a base url to the TOC links for when your TOC is on another page than the actual content
- * anchor_class (string) : '' - add custom class(es) for each anchor element
+ * title (string) : Contents: - title for the TOC
+ * minHeaders (int) : 1 - minimum number of headers required to show the TOC
+ * sanitize (bool) : false - when set to true, the headers will be stripped of any HTML in the TOC
+ * class (string) : '' - a CSS class assigned to the TOC
+ * id (string) : '' - an ID to assigned to the TOC
+ * h_min (int) : 1 - the minimum TOC header level to use; any header lower than this value will be ignored
+ * h_max (int) : 6 - the maximum TOC header level to use; any header greater than this value will be ignored
+ * ordered (bool) : false - when set to true, an ordered list will be outputted instead of an unordered list
+ * item_class (string) : '' - add custom class(es) for each list item; has support for '%level%' placeholder, which is the current heading level
+ * baseurl (string) : '' - add a base url to the TOC links for when your TOC is on another page than the actual content
+ * anchor_class (string) : '' - add custom class(es) for each anchor element
Output:
An ordered or unordered list representing the table of contents of a markdown block. This snippet will only
@@ -28,6 +30,8 @@
{% endcomment %}
{% capture my_toc %}{% endcapture %}
+ {% assign title = include.title | default: "Contents:" %}
+ {% assign minHeaders = include.minHeaders | default: 1 %}
{% assign orderedList = include.ordered | default: false %}
{% assign minHeader = include.h_min | default: 1 %}
{% assign maxHeader = include.h_max | default: 6 %}
@@ -36,6 +40,8 @@
{% capture listModifier %}{% if orderedList %}1.{% else %}-{% endif %}{% endcapture %}
+ {% assign hCount = 0 %}
+
{% for node in nodes %}
{% if node == "" %}
{% continue %}
@@ -79,6 +85,8 @@
{% capture listItemClass %}{:.{{ include.item_class | replace: '%level%', headerLevel }}}{% endcapture %}
{% endif %}
+ {% assign hCount = hCount | plus: 1 %}
+
{% capture heading_body %}{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}{% endcapture %}
{% capture my_toc %}{{ my_toc }}
{{ space }}{{ listModifier }} {{ listItemClass }} [{{ heading_body | replace: "|", "\|" }}]({% if include.baseurl %}{{ include.baseurl }}{% endif %}#{{ html_id }}){% if include.anchor_class %}{:.{{ include.anchor_class }}}{% endif %}{% endcapture %}
@@ -93,4 +101,9 @@
{% capture my_toc %}{: #{{ include.id }}}
{{ my_toc | lstrip }}{% endcapture %}
{% endif %}
-{% endcapture %}{% assign tocWorkspace = '' %}{{ my_toc | markdownify | strip }} \ No newline at end of file
+{% endcapture %}{% assign tocWorkspace = '' %}
+
+{% if hCount >= minHeaders %}
+ {{ title }}
+ {{ my_toc | markdownify | strip }}
+{% endif %} \ No newline at end of file
diff --git a/_includes/git-wiki/components/toc/toc.html b/_includes/git-wiki/components/toc/toc.html
index c354b42..7329f40 100644
--- a/_includes/git-wiki/components/toc/toc.html
+++ b/_includes/git-wiki/components/toc/toc.html
@@ -2,10 +2,7 @@
{% include {{ site.inc_before_toc }} %}
{% endif %}
-<div>
- <p>Contents:</p>
- {% include git-wiki/components/toc/toc-lib.html html=content sanitize=true class="inline_toc" id="git-wiki-toc" h_min=1 h_max=3 ordered=1 %}
-</div>
+{% include git-wiki/components/toc/toc-lib.html title="Contents:" minHeaders=1 html=content sanitize=true class="inline_toc" id="git-wiki-toc" h_min=1 h_max=3 ordered=1 %}
{% if site.inc_after_toc %}
{% include {{ site.inc_after_toc }} %}
diff --git a/_includes/git-wiki/defines/defines.html b/_includes/git-wiki/defines/defines.html
index a91df14..6400403 100644
--- a/_includes/git-wiki/defines/defines.html
+++ b/_includes/git-wiki/defines/defines.html
@@ -1,4 +1,4 @@
-{% assign version = "2.5.1" %}
+{% assign version = "2.5.3" %}
{% capture lchar %}{{page.url | slice: -1, 1}}{% endcapture %}
{% capture url %}
{% if lchar == "/" %}{{page.url}}index.html{% else %}{{ page.url | default: 'index.html' }}{% endif%}
diff --git a/_includes/git-wiki/sections/head/scripts.html b/_includes/git-wiki/sections/head/scripts.html
index 9cf23f3..9497626 100644
--- a/_includes/git-wiki/sections/head/scripts.html
+++ b/_includes/git-wiki/sections/head/scripts.html
@@ -4,7 +4,7 @@
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
-<script src="{{ '/assets/js/red-links.js' | relative_url }}"></script>
+<script src="{{ '/assets/js/checkLinks.js' | relative_url }}"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
diff --git a/_includes/git-wiki/sections/header/header.html b/_includes/git-wiki/sections/header/header.html
index 38ec85b..ffbea44 100644
--- a/_includes/git-wiki/sections/header/header.html
+++ b/_includes/git-wiki/sections/header/header.html
@@ -2,7 +2,7 @@
<button class="w3-button w3-teal" onclick="sidebar_toggle()">&#9776;</button>
<a href="{{ '/' | relative_url }}">
{% if site.logo_url %}
- <img src="{{ site.logo_url }}" width="20px">
+ <img src="{{ site.logo_url | relative_url }}" width="20px">
{% endif %}
{{ site.title | escape }}
</a>
diff --git a/_includes/git-wiki/sections/tail/tail.html b/_includes/git-wiki/sections/tail/tail.html
index 692867f..f5944c9 100644
--- a/_includes/git-wiki/sections/tail/tail.html
+++ b/_includes/git-wiki/sections/tail/tail.html
@@ -18,6 +18,18 @@
</script>
{% endif %}
+{% assign items = site.html_pages %}
+{% for page in items %}
+{% assign url = page.url | relative_url %}
+{% assign urls = urls | append: url | append: "," %}
+{% endfor %}
+
+<script type="text/javascript">
+ $(document).ready(function () {
+ $(document.body).checkLinks("{{ urls }}".split(","));
+ });
+</script>
+
{% if site.inc_after_tail %}
{% include {{ site.inc_after_tail }} %}
{% endif %}
diff --git a/assets/js/red-links.js b/assets/js/checkLinks.js
index 8c1d719..bd41fb6 100644
--- a/assets/js/red-links.js
+++ b/assets/js/checkLinks.js
@@ -1,8 +1,7 @@
(function ($) {
//
// RED LINK FEATURE (Hacky)
- // TODO: filter external links
- $.fn.redLinks = function () {
+ $.fn.checkLinks = function (staticPages) {
setTimeout(
function () {
$('a').each(function () {
@@ -13,12 +12,25 @@
return;
}
- var ext = this.href.split('.').pop().split(/\#|\?/)[0];
+ for (var k in staticPages) {
+ var page = staticPages[k];
+ var link = document.createElement("a");
+ link.href = page;
- // [Performance tip] pessimistic condition based on the fact that
+ if (this.href === link.href) {
+ return;
+ }
+ }
+
+ var ext = this.pathname.split('.').pop().split(/\#|\?/)[0];
+
+ // pessimistic condition based on the fact that
// markdown files are automatically converted in html
// if they are part of the wiki (the real check is right below)
- if (ext.toLowerCase() == "md" || ext.toLowerCase() == "markdown")
+ var lExt = ext && ext.toLowerCase();
+ var isRed = lExt == "md" || lExt == "markdown";
+
+ if (isRed)
$(this).css('color', 'red');
var that = this;
diff --git a/wiki/main_page.md b/wiki/main_page.md
index a1716a5..3191a47 100644
--- a/wiki/main_page.md
+++ b/wiki/main_page.md
@@ -4,4 +4,8 @@ redirect_from: "/"
This is a sample of main page. You can edit it to start your wiki.
-For documentation, installation guide and demo of [git-wiki-theme](git-wiki-theme.md) visit this [link](http://drassil.github.io/git-wiki/)
+For documentation, installation guide and demo of [git-wiki-theme](git-wiki-theme) visit this [link](http://drassil.github.io/git-wiki/)
+
+## acca1
+
+## acca2