From 4a8156e08a5e3ffe540f56ecb894b951dd9b7c84 Mon Sep 17 00:00:00 2001 From: Yehonal Date: Sun, 16 Dec 2018 15:54:48 +0100 Subject: Git-Wiki 2.0 --- .gitignore | 3 +- _config.yml.dist | 21 ++- _includes/drassil_comments/comments.html | 20 +++ _includes/drassil_sidebar/sidebar.html | 6 + _includes/gw_content/body.html | 5 + _includes/gw_content/content.html | 25 +++ _includes/gw_content/wrapper.html | 5 + _includes/gw_defines/defines.html | 5 + _includes/gw_footer/footer.html | 19 +++ _includes/gw_head/head.html | 13 ++ _includes/gw_head/meta.html | 12 ++ _includes/gw_head/scripts.html | 15 ++ _includes/gw_head/styles.html | 9 + _includes/gw_header/downloads.html | 5 + _includes/gw_header/header.html | 21 +++ _includes/gw_header/logo.html | 4 + _includes/gw_tail/tail.html | 34 ++++ _includes/gw_tools/page_actions.html | 14 ++ _includes/gw_tools/search_module.html | 25 +++ _includes/gw_tools/tools.html | 13 ++ _layouts/default.html | 146 ---------------- _layouts/git-wiki-default.html | 9 + _layouts/page.html | 5 - _sass/git-wiki-style.scss | 282 +++++++++++++++++++++++++++++++ _sass/style.scss | 282 ------------------------------- assets/css/git-wiki-style.scss | 4 + assets/css/style.scss | 4 - assets/js/red-links.js | 28 +++ assets/js/toc.js | 106 ++++++++++++ assets/js/wiki-features.js | 127 -------------- 30 files changed, 697 insertions(+), 570 deletions(-) create mode 100644 _includes/drassil_comments/comments.html create mode 100644 _includes/drassil_sidebar/sidebar.html create mode 100644 _includes/gw_content/body.html create mode 100644 _includes/gw_content/content.html create mode 100644 _includes/gw_content/wrapper.html create mode 100644 _includes/gw_defines/defines.html create mode 100644 _includes/gw_footer/footer.html create mode 100644 _includes/gw_head/head.html create mode 100644 _includes/gw_head/meta.html create mode 100644 _includes/gw_head/scripts.html create mode 100644 _includes/gw_head/styles.html create mode 100644 _includes/gw_header/downloads.html create mode 100644 _includes/gw_header/header.html create mode 100644 _includes/gw_header/logo.html create mode 100644 _includes/gw_tail/tail.html create mode 100644 _includes/gw_tools/page_actions.html create mode 100644 _includes/gw_tools/search_module.html create mode 100644 _includes/gw_tools/tools.html delete mode 100644 _layouts/default.html create mode 100644 _layouts/git-wiki-default.html delete mode 100644 _layouts/page.html create mode 100644 _sass/git-wiki-style.scss delete mode 100644 _sass/style.scss create mode 100644 assets/css/git-wiki-style.scss delete mode 100644 assets/css/style.scss create mode 100644 assets/js/red-links.js create mode 100644 assets/js/toc.js delete mode 100644 assets/js/wiki-features.js diff --git a/.gitignore b/.gitignore index c08f9ad..191b112 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -_site \ No newline at end of file +_site +Gemfile.lock \ No newline at end of file diff --git a/_config.yml.dist b/_config.yml.dist index 8a115bb..2e3fd39 100644 --- a/_config.yml.dist +++ b/_config.yml.dist @@ -8,11 +8,22 @@ theme: wiki_folder: wiki use_github_wiki: false use_prose_io: true -google_cse_token: -custom_head: false -custom_sidebar: false -custom_footer: false -gems: +google_cse_token: +defaults: + - + scope: + path: "" # an empty string here means all files in the project + values: + layout: "git-wiki-default" + - + scope: + path: "" + type: "pages" + values: + layout: "git-wiki-default" +sass: + style: compressed +plugins: - jekyll-sitemap - jekyll-mentions - jemoji diff --git a/_includes/drassil_comments/comments.html b/_includes/drassil_comments/comments.html new file mode 100644 index 0000000..bf4d761 --- /dev/null +++ b/_includes/drassil_comments/comments.html @@ -0,0 +1,20 @@ +
+ + \ No newline at end of file diff --git a/_includes/drassil_sidebar/sidebar.html b/_includes/drassil_sidebar/sidebar.html new file mode 100644 index 0000000..4b7a396 --- /dev/null +++ b/_includes/drassil_sidebar/sidebar.html @@ -0,0 +1,6 @@ +Menu: + + \ No newline at end of file diff --git a/_includes/gw_content/body.html b/_includes/gw_content/body.html new file mode 100644 index 0000000..5edfa9b --- /dev/null +++ b/_includes/gw_content/body.html @@ -0,0 +1,5 @@ + + {% include gw_content/wrapper.html %} + + {% include gw_tail/tail.html %} + \ No newline at end of file diff --git a/_includes/gw_content/content.html b/_includes/gw_content/content.html new file mode 100644 index 0000000..347f69d --- /dev/null +++ b/_includes/gw_content/content.html @@ -0,0 +1,25 @@ +
+ {% include gw_tools/tools.html %} + + {% if site.inc_before_toc %} + {% include {{ site.inc_before_toc }} %} + {% endif %} + +
+ + {% if site.inc_after_toc %} + {% include {{ site.inc_after_toc }} %} + {% endif %} + + {% if site.inc_before_content %} + {% include {{ site.inc_before_content }} %} + {% endif %} + +
+ {{ content }} +
+ + {% if site.inc_after_content %} + {% include {{ site.inc_after_content }} %} + {% endif %} +
\ No newline at end of file diff --git a/_includes/gw_content/wrapper.html b/_includes/gw_content/wrapper.html new file mode 100644 index 0000000..9fb0223 --- /dev/null +++ b/_includes/gw_content/wrapper.html @@ -0,0 +1,5 @@ +
+ {% include gw_header/header.html %} + {% include gw_content/content.html %} + {% include gw_footer/footer.html %} +
\ No newline at end of file diff --git a/_includes/gw_defines/defines.html b/_includes/gw_defines/defines.html new file mode 100644 index 0000000..d479d72 --- /dev/null +++ b/_includes/gw_defines/defines.html @@ -0,0 +1,5 @@ +{% assign version = "1.0.5" %} +{% capture lchar %}{{page.url | slice: -1, 1}}{% endcapture %} +{% capture url %} +{% if lchar == "/" %}{{page.url}}index.html{% else %}{{ page.url | default: 'index.html' }}{% endif%} +{% endcapture %} \ No newline at end of file diff --git a/_includes/gw_footer/footer.html b/_includes/gw_footer/footer.html new file mode 100644 index 0000000..7aed17c --- /dev/null +++ b/_includes/gw_footer/footer.html @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/_includes/gw_head/head.html b/_includes/gw_head/head.html new file mode 100644 index 0000000..cf82bd9 --- /dev/null +++ b/_includes/gw_head/head.html @@ -0,0 +1,13 @@ + + {% if site.inc_before_head %} + {% include {{ site.inc_before_head }} %} + {% endif %} + + {% include gw_head/meta.html %} + {% include gw_head/scripts.html %} + {% include gw_head/styles.html %} + + {% if site.inc_after_head %} + {% include {{ site.inc_after_head }} %} + {% endif %} + \ No newline at end of file diff --git a/_includes/gw_head/meta.html b/_includes/gw_head/meta.html new file mode 100644 index 0000000..141ab05 --- /dev/null +++ b/_includes/gw_head/meta.html @@ -0,0 +1,12 @@ +{% if site.inc_before_meta %} +{% include {{ site.inc_before_meta }} %} +{% endif %} + + + + +{{ site.title | default: site.github.repository_name }} by {{ site.github.owner_name }} + +{% if site.inc_after_meta %} +{% include {{ site.inc_after_meta }} %} +{% endif %} \ No newline at end of file diff --git a/_includes/gw_head/scripts.html b/_includes/gw_head/scripts.html new file mode 100644 index 0000000..65ee4ff --- /dev/null +++ b/_includes/gw_head/scripts.html @@ -0,0 +1,15 @@ +{% if site.inc_before_scripts %} +{% include {{ site.inc_before_scripts }} %} +{% endif %} + + + + + + +{% if site.inc_after_scripts %} +{% include {{ site.inc_after_scripts }} %} +{% endif %} \ No newline at end of file diff --git a/_includes/gw_head/styles.html b/_includes/gw_head/styles.html new file mode 100644 index 0000000..3bb7ecc --- /dev/null +++ b/_includes/gw_head/styles.html @@ -0,0 +1,9 @@ +{% if site.inc_before_styles %} +{% include {{ site.inc_before_styles }} %} +{% endif %} + + + +{% if site.inc_after_styles %} +{% include {{ site.inc_after_styles }} %} +{% endif %} \ No newline at end of file diff --git a/_includes/gw_header/downloads.html b/_includes/gw_header/downloads.html new file mode 100644 index 0000000..8f654f9 --- /dev/null +++ b/_includes/gw_header/downloads.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/_includes/gw_header/header.html b/_includes/gw_header/header.html new file mode 100644 index 0000000..1b0b74c --- /dev/null +++ b/_includes/gw_header/header.html @@ -0,0 +1,21 @@ +
+ {% if site.inc_before_header %} + {% include {{ site.inc_before_header }} %} + {% endif %} + + {% if site.show_downloads %} + {% include gw_header/logo.html %} + {% endif %} + + {% if site.github.is_user_page %} +

View My GitHub Profile

+ {% endif %} + + {% if site.show_downloads %} + {% include gw_header/downloads.html %} + {% endif %} + + {% if site.inc_after_header %} + {% include {{ site.inc_after_header }} %} + {% endif %} +
\ No newline at end of file diff --git a/_includes/gw_header/logo.html b/_includes/gw_header/logo.html new file mode 100644 index 0000000..a4a36c3 --- /dev/null +++ b/_includes/gw_header/logo.html @@ -0,0 +1,4 @@ + +

{{ site.title | default: site.github.repository_name }}

+
+

{{ site.description | default: site.github.project_tagline }}

\ No newline at end of file diff --git a/_includes/gw_tail/tail.html b/_includes/gw_tail/tail.html new file mode 100644 index 0000000..e86191c --- /dev/null +++ b/_includes/gw_tail/tail.html @@ -0,0 +1,34 @@ +{% if site.inc_before_tail %} +{% include {{ site.inc_before_tail }} %} +{% endif %} + + + +{% if site.google_analytics %} + +{% endif %} + + + +{% if site.inc_after_tail %} +{% include {{ site.inc_after_tail }} %} +{% endif %} \ No newline at end of file diff --git a/_includes/gw_tools/page_actions.html b/_includes/gw_tools/page_actions.html new file mode 100644 index 0000000..927b178 --- /dev/null +++ b/_includes/gw_tools/page_actions.html @@ -0,0 +1,14 @@ +{{page.relative_path}} +{% if site.use_github_wiki %} +Edit +History +Source +{% else %} +Edit +{% if site.use_prose_io %} +Edit + with Prose.io +{% endif %} +History +Source +{% endif %} \ No newline at end of file diff --git a/_includes/gw_tools/search_module.html b/_includes/gw_tools/search_module.html new file mode 100644 index 0000000..f79335a --- /dev/null +++ b/_includes/gw_tools/search_module.html @@ -0,0 +1,25 @@ +{% if site.google_cse_token %} + + +{% else %} +
+ + {% if site.use_github_wiki %} + + {% else %} + + + {% endif %} + +
+{% endif %} \ No newline at end of file diff --git a/_includes/gw_tools/tools.html b/_includes/gw_tools/tools.html new file mode 100644 index 0000000..c0b50f7 --- /dev/null +++ b/_includes/gw_tools/tools.html @@ -0,0 +1,13 @@ +
+ {% if site.inc_before_tools %} + {% include {{ site.inc_before_tools }} %} + {% endif %} + + {% include gw_tools/page_actions.html %} + + {% include gw_tools/search_module.html %} + + {% if site.inc_after_tools %} + {% include {{ site.inc_after_tools }} %} + {% endif %} +
\ No newline at end of file diff --git a/_layouts/default.html b/_layouts/default.html deleted file mode 100644 index 4f08612..0000000 --- a/_layouts/default.html +++ /dev/null @@ -1,146 +0,0 @@ - - - - {% assign version = "1.0.5" %} - {% capture lchar %}{{page.url | slice: -1, 1}}{% endcapture %} - {% capture url %}{% if lchar == "/" %}{{page.url}}index.html{% else %}{{ page.url | default: 'index.html' }}{% endif %}{% endcapture %} - - - {{ site.title | default: site.github.repository_name }} by {{ site.github.owner_name }} - - - - - - - {% if site.custom_head %} - {% include head.html %} - {% endif %} - - - - - -
-
- -

{{ site.title | default: site.github.repository_name }}

-
-

{{ site.description | default: site.github.project_tagline }}

- - {% if site.github.is_user_page %} -

View My GitHub Profile

- {% endif %} - - {% if site.show_downloads %} - - {% endif %} - - {% if site.custom_sidebar %} - {% include sidebar.html %} - {% endif %} - -
-
-
- {{page.relative_path}} - {% if site.use_github_wiki %} - Edit - History - Source - {% else %} - Edit - {% if site.use_prose_io %} - Edit with Prose.io - {% endif %} - History - Source - {% endif %} - - {% if site.google_cse_token %} - - - {% else %} -
- - {% if site.use_github_wiki %} - - {% else %} - - - {% endif %} - -
- {% endif %} -
- -
- -
- {{ content }} -
- - {% if site.comments %} - {% include comments.html %} - {% endif %} - -
- -
- - - - {% if site.google_analytics %} - - {% endif %} - - - - diff --git a/_layouts/git-wiki-default.html b/_layouts/git-wiki-default.html new file mode 100644 index 0000000..8bb038b --- /dev/null +++ b/_layouts/git-wiki-default.html @@ -0,0 +1,9 @@ +{% include gw_defines/defines.html %} + + + +{% include gw_head/head.html %} + +{% include gw_content/body.html %} + + \ No newline at end of file diff --git a/_layouts/page.html b/_layouts/page.html deleted file mode 100644 index 5e71126..0000000 --- a/_layouts/page.html +++ /dev/null @@ -1,5 +0,0 @@ ---- -layout: default ---- - -{{ content }} diff --git a/_sass/git-wiki-style.scss b/_sass/git-wiki-style.scss new file mode 100644 index 0000000..c40fd08 --- /dev/null +++ b/_sass/git-wiki-style.scss @@ -0,0 +1,282 @@ +@import "fonts"; +@import "rouge-github"; + +body { + background-color: #fff; + padding:50px; + font: 14px/1.5 "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; + color:#727272; + font-weight:400; +} + +h1, h2, h3, h4, h5, h6 { + color:#222; + margin:0 0 20px; +} + +p, ul, ol, table, pre, dl { + margin:0 0 20px; +} + +h1, h2, h3 { + line-height:1.1; +} + +h1 { + font-size:28px; +} + +h2 { + color:#393939; +} + +h3, h4, h5, h6 { + color:#494949; +} + +a { + color:#39c; + text-decoration:none; +} + +a:hover { + color:#069; +} + +a small { + font-size:11px; + color:#777; + margin-top:-0.3em; + display:block; +} + +a:hover small { + color:#777; +} + +.wrapper { + /*width:860px;*/ + margin:0 auto; +} + +blockquote { + border-left:1px solid #e5e5e5; + margin:0; + padding:0 0 0 20px; + font-style:italic; +} + +code, pre { + font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal, Consolas, Liberation Mono, DejaVu Sans Mono, Courier New, monospace; + color:#333; + font-size:12px; +} + +pre { + padding:8px 15px; + background: #f8f8f8; + border-radius:5px; + border:1px solid #e5e5e5; + overflow-x: auto; +} + +table { + width:100%; + border-collapse:collapse; +} + +th, td { + text-align:left; + padding:5px 10px; + border-bottom:1px solid #e5e5e5; +} + +dt { + color:#444; + font-weight:700; +} + +th { + color:#444; +} + +img { + max-width:100%; +} + +header { + width: 272px; + float: left; + position: fixed; + -webkit-font-smoothing: subpixel-antialiased; + overflow-y: auto; + overflow-x: auto; + max-height: 100%; +} + +header .downloads { + list-style:none; + height:40px; + padding:0; + background: #f4f4f4; + border-radius:5px; + border:1px solid #e0e0e0; + width:270px; +} + +header .downloads li { + width:89px; + float:left; + border-right:1px solid #e0e0e0; + height:40px; +} + +header .downloads li:first-child a { + border-radius:5px 0 0 5px; +} + +header .downloads li:last-child a { + border-radius:0 5px 5px 0; +} + +header .downloads a { + line-height:1; + font-size:11px; + color:#999; + display:block; + text-align:center; + padding-top:6px; + height:34px; +} + +header .downloads a:hover { + color:#999; +} + +header .downloads a:active { + background-color:#f0f0f0; +} + +strong { + color:#222; + font-weight:700; +} + +header .downloads li + li + li { + border-right:none; + width:89px; +} + +header .downloads a strong { + font-size:14px; + display:block; + color:#222; +} + +section { + /*width:500px; + float:right;*/ + padding-left: 320px; + padding-bottom:50px; +} + +small { + font-size:11px; +} + +hr { + border:0; + background:#e5e5e5; + height:1px; + margin:0 0 20px; +} + +footer { + padding-left: 320px; + float:left; + bottom:50px; + -webkit-font-smoothing:subpixel-antialiased; +} + +.tools-element { + border-left: aqua; + border-left-style: solid; + padding-left: 10px; + padding-right: 10px; +} + +@media print, screen and (max-width: 960px) { + + div.wrapper { + width:auto; + margin:0; + } + + header, section, footer { + float:none; + position:static; + width:auto; + } + + header { + padding-right:320px; + } + + section, footer { + border:1px solid #e5e5e5; + border-width:1px 0; + padding:20px 0; + margin:0 0 20px; + } + + header a small { + display:inline; + } + + header .downloads { + position:absolute; + right:50px; + top:52px; + } +} + + +@media print, screen and (max-width: 720px) { + body { + word-wrap:break-word; + } + + header { + padding:0; + } + + header .downloads, header p.view { + position:static; + } + + pre, code { + word-wrap:normal; + } +} + +@media print, screen and (max-width: 480px) { + body { + padding:15px; + } + + header .downloads { + width:99%; + } + + header li, header .downloads li + li + li { + width:33%; + } +} + +@media print { + body { + padding:0.4in; + font-size:12pt; + color:#444; + } +} diff --git a/_sass/style.scss b/_sass/style.scss deleted file mode 100644 index c40fd08..0000000 --- a/_sass/style.scss +++ /dev/null @@ -1,282 +0,0 @@ -@import "fonts"; -@import "rouge-github"; - -body { - background-color: #fff; - padding:50px; - font: 14px/1.5 "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; - color:#727272; - font-weight:400; -} - -h1, h2, h3, h4, h5, h6 { - color:#222; - margin:0 0 20px; -} - -p, ul, ol, table, pre, dl { - margin:0 0 20px; -} - -h1, h2, h3 { - line-height:1.1; -} - -h1 { - font-size:28px; -} - -h2 { - color:#393939; -} - -h3, h4, h5, h6 { - color:#494949; -} - -a { - color:#39c; - text-decoration:none; -} - -a:hover { - color:#069; -} - -a small { - font-size:11px; - color:#777; - margin-top:-0.3em; - display:block; -} - -a:hover small { - color:#777; -} - -.wrapper { - /*width:860px;*/ - margin:0 auto; -} - -blockquote { - border-left:1px solid #e5e5e5; - margin:0; - padding:0 0 0 20px; - font-style:italic; -} - -code, pre { - font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal, Consolas, Liberation Mono, DejaVu Sans Mono, Courier New, monospace; - color:#333; - font-size:12px; -} - -pre { - padding:8px 15px; - background: #f8f8f8; - border-radius:5px; - border:1px solid #e5e5e5; - overflow-x: auto; -} - -table { - width:100%; - border-collapse:collapse; -} - -th, td { - text-align:left; - padding:5px 10px; - border-bottom:1px solid #e5e5e5; -} - -dt { - color:#444; - font-weight:700; -} - -th { - color:#444; -} - -img { - max-width:100%; -} - -header { - width: 272px; - float: left; - position: fixed; - -webkit-font-smoothing: subpixel-antialiased; - overflow-y: auto; - overflow-x: auto; - max-height: 100%; -} - -header .downloads { - list-style:none; - height:40px; - padding:0; - background: #f4f4f4; - border-radius:5px; - border:1px solid #e0e0e0; - width:270px; -} - -header .downloads li { - width:89px; - float:left; - border-right:1px solid #e0e0e0; - height:40px; -} - -header .downloads li:first-child a { - border-radius:5px 0 0 5px; -} - -header .downloads li:last-child a { - border-radius:0 5px 5px 0; -} - -header .downloads a { - line-height:1; - font-size:11px; - color:#999; - display:block; - text-align:center; - padding-top:6px; - height:34px; -} - -header .downloads a:hover { - color:#999; -} - -header .downloads a:active { - background-color:#f0f0f0; -} - -strong { - color:#222; - font-weight:700; -} - -header .downloads li + li + li { - border-right:none; - width:89px; -} - -header .downloads a strong { - font-size:14px; - display:block; - color:#222; -} - -section { - /*width:500px; - float:right;*/ - padding-left: 320px; - padding-bottom:50px; -} - -small { - font-size:11px; -} - -hr { - border:0; - background:#e5e5e5; - height:1px; - margin:0 0 20px; -} - -footer { - padding-left: 320px; - float:left; - bottom:50px; - -webkit-font-smoothing:subpixel-antialiased; -} - -.tools-element { - border-left: aqua; - border-left-style: solid; - padding-left: 10px; - padding-right: 10px; -} - -@media print, screen and (max-width: 960px) { - - div.wrapper { - width:auto; - margin:0; - } - - header, section, footer { - float:none; - position:static; - width:auto; - } - - header { - padding-right:320px; - } - - section, footer { - border:1px solid #e5e5e5; - border-width:1px 0; - padding:20px 0; - margin:0 0 20px; - } - - header a small { - display:inline; - } - - header .downloads { - position:absolute; - right:50px; - top:52px; - } -} - - -@media print, screen and (max-width: 720px) { - body { - word-wrap:break-word; - } - - header { - padding:0; - } - - header .downloads, header p.view { - position:static; - } - - pre, code { - word-wrap:normal; - } -} - -@media print, screen and (max-width: 480px) { - body { - padding:15px; - } - - header .downloads { - width:99%; - } - - header li, header .downloads li + li + li { - width:33%; - } -} - -@media print { - body { - padding:0.4in; - font-size:12pt; - color:#444; - } -} diff --git a/assets/css/git-wiki-style.scss b/assets/css/git-wiki-style.scss new file mode 100644 index 0000000..34e537a --- /dev/null +++ b/assets/css/git-wiki-style.scss @@ -0,0 +1,4 @@ +--- +--- + +@import "git-wiki-style.scss"; diff --git a/assets/css/style.scss b/assets/css/style.scss deleted file mode 100644 index 72a6aed..0000000 --- a/assets/css/style.scss +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -@import "style.scss"; diff --git a/assets/js/red-links.js b/assets/js/red-links.js new file mode 100644 index 0000000..446db02 --- /dev/null +++ b/assets/js/red-links.js @@ -0,0 +1,28 @@ + +(function ($) { + // + // RED LINK FEATURE (Hacky) + // TODO: filter external links + $.fn.redLinks = function () { + $('a').each(function () { + // avoid red link for external urls + if (this.hostname != window.location.hostname) + return; + + var that = this; + $.ajax({ + type: 'HEAD', + url: this.href, + success: function () { + + }, + error: function (xhr, ajaxOptions, thrownError) { + if (xhr.status == 404) { + $(that).css('color', 'red'); + } + } + }); + }); + }; + +})(jQuery); diff --git a/assets/js/toc.js b/assets/js/toc.js new file mode 100644 index 0000000..d8fcf33 --- /dev/null +++ b/assets/js/toc.js @@ -0,0 +1,106 @@ + +// https://github.com/ghiculescu/jekyll-table-of-contents +(function ($) { + $.fn.toc = function (options) { + var defaults = { + noBackToTopLinks: false, + title: 'Jump to...', + minimumHeaders: 3, + headers: 'h1, h2, h3, h4, h5, h6', + listType: 'ol', // values: [ol|ul] + showEffect: 'show', // values: [show|slideDown|fadeIn|none] + showSpeed: 'slow', // set to 0 to deactivate effect + classes: { + list: '', + item: '' + } + }, + settings = $.extend(defaults, options); + + function fixedEncodeURIComponent(str) { + return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { + return '%' + c.charCodeAt(0).toString(16); + }); + } + + function createLink(header) { + var innerText = (header.textContent === undefined) ? header.innerText : header.textContent; + return "" + innerText + ""; + } + + var headers = $(settings.headers).filter(function () { + // get all headers with an ID + var previousSiblingName = $(this).prev().attr("name"); + if (!this.id && previousSiblingName) { + this.id = $(this).attr("id", previousSiblingName.replace(/\./g, "-")); + } + + // Yehonal + if (!this.id) { + this.id = $(this).text().replace(/\W/g, '_'); + } + + return this.id; + }), output = $(this); + if (!headers.length || headers.length < settings.minimumHeaders || !output.length) { + $(this).hide(); + return; + } + + if (0 === settings.showSpeed) { + settings.showEffect = 'none'; + } + + var render = { + show: function () { output.hide().html(html).show(settings.showSpeed); }, + slideDown: function () { output.hide().html(html).slideDown(settings.showSpeed); }, + fadeIn: function () { output.hide().html(html).fadeIn(settings.showSpeed); }, + none: function () { output.html(html); } + }; + + var get_level = function (ele) { return parseInt(ele.nodeName.replace("H", ""), 10); }; + var highest_level = headers.map(function (_, ele) { return get_level(ele); }).get().sort()[0]; + var return_to_top = ' '; + + var level = get_level(headers[0]), + this_level, + html = settings.title + " <" + settings.listType + " class=\"" + settings.classes.list + "\">"; + headers.on('click', function () { + if (!settings.noBackToTopLinks) { + window.location.hash = this.id; + } + }) + .addClass('clickable-header') + .each(function (_, header) { + this_level = get_level(header); + if (!settings.noBackToTopLinks && this_level === highest_level) { + $(header).addClass('top-level-header').after(return_to_top); + } + if (this_level === level) // same level as before; same indenting + html += "
  • " + createLink(header); + else if (this_level <= level) { // higher level than before; end parent ol + for (var i = this_level; i < level; i++) { + html += "
  • " + } + html += "
  • " + createLink(header); + } + else if (this_level > level) { // lower level than before; expand the previous to contain a ol + for (i = this_level; i > level; i--) { + html += "<" + settings.listType + " class=\"" + settings.classes.list + "\">" + + "
  • " + } + html += createLink(header); + } + level = this_level; // update for the next one + }); + html += ""; + if (!settings.noBackToTopLinks) { + $(document).on('click', '.back-to-top', function () { + $(window).scrollTop(0); + window.location.hash = ''; + }); + } + + render[settings.showEffect](); + }; +})(jQuery); diff --git a/assets/js/wiki-features.js b/assets/js/wiki-features.js deleted file mode 100644 index 41e5216..0000000 --- a/assets/js/wiki-features.js +++ /dev/null @@ -1,127 +0,0 @@ - -// https://github.com/ghiculescu/jekyll-table-of-contents -(function($){ - $.fn.toc = function(options) { - var defaults = { - noBackToTopLinks: false, - title: 'Jump to...', - minimumHeaders: 3, - headers: 'h1, h2, h3, h4, h5, h6', - listType: 'ol', // values: [ol|ul] - showEffect: 'show', // values: [show|slideDown|fadeIn|none] - showSpeed: 'slow', // set to 0 to deactivate effect - classes: { list: '', - item: '' - } - }, - settings = $.extend(defaults, options); - - function fixedEncodeURIComponent (str) { - return encodeURIComponent(str).replace(/[!'()*]/g, function(c) { - return '%' + c.charCodeAt(0).toString(16); - }); - } - - function createLink (header) { - var innerText = (header.textContent === undefined) ? header.innerText : header.textContent; - return "" + innerText + ""; - } - - var headers = $(settings.headers).filter(function() { - // get all headers with an ID - var previousSiblingName = $(this).prev().attr( "name" ); - if (!this.id && previousSiblingName) { - this.id = $(this).attr( "id", previousSiblingName.replace(/\./g, "-") ); - } - - // Yehonal - if (!this.id) { - this.id = $(this).text().replace(/\W/g,'_'); - } - - return this.id; - }), output = $(this); - if (!headers.length || headers.length < settings.minimumHeaders || !output.length) { - $(this).hide(); - return; - } - - if (0 === settings.showSpeed) { - settings.showEffect = 'none'; - } - - var render = { - show: function() { output.hide().html(html).show(settings.showSpeed); }, - slideDown: function() { output.hide().html(html).slideDown(settings.showSpeed); }, - fadeIn: function() { output.hide().html(html).fadeIn(settings.showSpeed); }, - none: function() { output.html(html); } - }; - - var get_level = function(ele) { return parseInt(ele.nodeName.replace("H", ""), 10); }; - var highest_level = headers.map(function(_, ele) { return get_level(ele); }).get().sort()[0]; - var return_to_top = ' '; - - var level = get_level(headers[0]), - this_level, - html = settings.title + " <" +settings.listType + " class=\"" + settings.classes.list +"\">"; - headers.on('click', function() { - if (!settings.noBackToTopLinks) { - window.location.hash = this.id; - } - }) - .addClass('clickable-header') - .each(function(_, header) { - this_level = get_level(header); - if (!settings.noBackToTopLinks && this_level === highest_level) { - $(header).addClass('top-level-header').after(return_to_top); - } - if (this_level === level) // same level as before; same indenting - html += "
  • " + createLink(header); - else if (this_level <= level){ // higher level than before; end parent ol - for(var i = this_level; i < level; i++) { - html += "
  • " - } - html += "
  • " + createLink(header); - } - else if (this_level > level) { // lower level than before; expand the previous to contain a ol - for(i = this_level; i > level; i--) { - html += "<" + settings.listType + " class=\"" + settings.classes.list +"\">" + - "
  • " - } - html += createLink(header); - } - level = this_level; // update for the next one - }); - html += ""; - if (!settings.noBackToTopLinks) { - $(document).on('click', '.back-to-top', function() { - $(window).scrollTop(0); - window.location.hash = ''; - }); - } - - render[settings.showEffect](); - }; - - // - // RED LINK FEATURE (Hacky) - // TODO: filter external links - $.fn.redLinks = function () { - $('a').each(function () { - var that = this; - $.ajax({ - type: 'HEAD', - url: this.href, - success: function () { - - }, - error: function (xhr, ajaxOptions, thrownError) { - if (xhr.status == 404) { - $(that).css('color', 'red'); - } - } - }); - }); - }; - -})(jQuery); -- cgit