picodocs 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fd29692d9bf0fa2c25f823caac4abf5b3088f8903c6c2dcb1093331967a2225e
4
+ data.tar.gz: 45dbea1df6177e7da88811f0595289e78bb265147be5f7937eb2221912a986d6
5
+ SHA512:
6
+ metadata.gz: 59a171c7033d1b8b8856d84911c712022302707de3b351fa224957699ec86100c18bb8b1b0ecf531e553d806e0bdcc52e162d03a3f4c67dc9bed78b663c02d41
7
+ data.tar.gz: 43e5f1c595044480194b3319b676c5aa59bc15586498633595eefecad16d805ed9e185e5cef8e0698576f3ab149ff2af350665e08ce81984d0ddb2c291353094
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Alexander Heimbuch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # Picodocs Theme
2
+
3
+ Simple documentation theme for Jekyll featuring [Picocss framework](https://picocss.com/), [PrismJS syntax highlighter](http://prismjs.com/) and [LunrJS search](https://lunrjs.com/).
4
+
5
+ One of the core features is a full text client side search and full responsiveness. It has zero dependencies with other gems and should be easily build with Github.
6
+
7
+ ## Picodocs
8
+
9
+ Add this line to your Jekyll site's `Gemfile`:
10
+
11
+ ```ruby
12
+ gem "picodocs"
13
+ ```
14
+
15
+ Adapt your Jekyll site config `_config.yml`:
16
+
17
+ ```yaml
18
+ title: My Docs Page Title
19
+ description: MY description
20
+ url: "https://base/url/site"
21
+ theme: picodocs
22
+
23
+ markdown: kramdown
24
+ kramdown:
25
+ syntax_highlighter_opts:
26
+ disable : true
27
+
28
+ exclude:
29
+ - Gemfile
30
+ - Gemfile.lock
31
+ - README.md
32
+ ```
33
+
34
+ And then execute:
35
+
36
+ $ bundle
37
+
38
+ Or install it yourself as:
39
+
40
+ $ gem install picodocs
41
+
42
+
43
+ ## Usage
44
+
45
+ ### Github Pages
46
+
47
+ You can use this theme by simply adding `remote_theme: alexander-heimbuch/picodocs` to your `_config.yml` (Thanks to @kogli for the hint).
48
+
49
+ ### Available Themes
50
+
51
+ This theme is made for _pages_ only and doesn't support _posts_ by default. So the only available layouts are `default` and `page`.
52
+
53
+ ### Navigation
54
+
55
+ The navigation supports especially only one level. If you need deep nested structures you propably should use a larger documentation system like [GitBook](https://www.gitbook.com/).
56
+
57
+ Not every page by default is part of the navigation. If you want to add a page to the navigation you have to add the `navigation` attribute with a desired `index`:
58
+
59
+ ```
60
+ ---
61
+ layout: page
62
+ title: Navigation
63
+ navigation: 2
64
+ ---
65
+ ```
66
+
67
+ The navigation `index` is starting with 1 representing the first item.
68
+
69
+
70
+ ## Development
71
+
72
+ To set up your environment to develop this theme, run `bundle install`.
73
+
74
+ Your theme is setup just like a normal Jekyll site! To test your theme, run `bundle exec jekyll serve` and open your browser at `http://localhost:4000`. This starts a Jekyll server using your theme. Add pages, documents, data, etc. like normal to test your theme's contents. As you make modifications to your theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal.
75
+
76
+ When your theme is released, only the files in `_layouts`, `_includes`, and `_sass` tracked with Git will be released.
77
+
78
+ ## License
79
+
80
+ The theme is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
81
+
@@ -0,0 +1,13 @@
1
+ <head>
2
+ <meta charset="utf-8">
3
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+
6
+ <title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
7
+ <meta name="description" content="{{ page.excerpt | default: site.description | strip_html | normalize_whitespace | truncate: 160 | escape }}">
8
+
9
+ <link rel="icon" href="{{ "/assets/images/favicon.ico" | relative_url }}">
10
+ <link rel="canonical" href="{{ page.url | replace:'index.html','' | absolute_url }}">
11
+
12
+ {% include styles.html %}
13
+ </head>
@@ -0,0 +1,16 @@
1
+ {% capture html %}
2
+ <nav>
3
+ <ul class="navigation" id="navigation">
4
+ {% assign entries = site.pages | sort: "navigation" %}
5
+ {% for entry in entries %}
6
+ {% if entry.navigation %}
7
+ <li>
8
+ <a class="{% if page.url == entry.url entry.url %}active{% endif %}" href="{{ entry.url | relative_url }}">
9
+ {{ entry.title }}
10
+ </a>
11
+ </li>
12
+ {% endif %}
13
+ {% endfor %}
14
+ </ul>
15
+ </nav>
16
+ {% endcapture %}{{ html | strip_newlines | replace:' ','' | replace:' ','' | replace:' ',' ' }}
@@ -0,0 +1,8 @@
1
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/lunr.js/2.3.9/lunr.min.js" integrity="sha512-4xUl/d6D6THrAnXAwGajXkoWaeMNwEKK4iNfq5DotEbLPAfk6FSxSP3ydNxqDgCw1c/0Z1Jg6L8h2j+++9BZmg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
2
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/prism.min.js" integrity="sha512-UOoJElONeUNzQbbKQbjldDf9MwOHqxNz49NNJJ1d90yp+X9edsHyJoAs6O4K19CZGaIdjI5ohK+O2y5lBTW6uQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
3
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/components/prism-yaml.min.js" integrity="sha512-epBuSQcDNi/0lmCXr7cGjqWcfnzXe4m/GdIFFNDcQ7v/JF4H8I+l4wmVQiYO6NkLGSDo3LR7HaUfUL/5sjWtXg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
4
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/components/prism-markdown.min.js" integrity="sha512-4lQBgtc3AKPFSyFxc8Uaq6rz3VHwrSOdQxXtkJN9cS81ErTSoNSBxLDzWNYwwYryuvQpseKWiOmZdArMroqnLw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
5
+
6
+ <script src="{{ "/assets/js/database.js" | relative_url }}"></script>
7
+ <script src="{{ "/assets/js/search.js" | relative_url }}"></script>
8
+ <script src="{{ "/assets/js/mobile-navigation.js" | relative_url }}"></script>
@@ -0,0 +1 @@
1
+ <nav><ul id="search-results" class="navigation"></ul></nav>
@@ -0,0 +1 @@
1
+ <input type="text" class="search-input" id="search-input" placeholder="Type to search" />
@@ -0,0 +1,11 @@
1
+ <aside class="sidebar" id="sidebar">
2
+ <div class="sidebar-mobile">
3
+ <img src="{{ "/assets/images/menu.svg" | relative_url }}" class="menu-icon" id="menu" />
4
+ <img src="{{ "/assets/images/close.svg" | relative_url }}" class="close-icon" id="close" />
5
+ </div>
6
+ {% include search.html %}
7
+ <div class="sidebar-main">
8
+ {% include navigation.html %}
9
+ {% include search-results.html %}
10
+ </div>
11
+ </aside>
@@ -0,0 +1,3 @@
1
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/picocss/1.5.6/pico.min.css" integrity="sha512-shNO98xEjcnLN2zXfvCsoL6HoFTMkFgvg2h9bQE5V2U//e3cIZRWtJ/u7Wae5Fzcu4+hYYwYhjJSa8Eg0+GhIA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
2
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/themes/prism-tomorrow.min.css" integrity="sha512-kSwGoyIkfz4+hMo5jkJngSByil9jxJPKbweYec/UgS+S1EgE45qm4Gea7Ks2oxQ7qiYyyZRn66A9df2lMtjIsw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
3
+ <link rel="stylesheet" href="{{ "/assets/css/docs.css" | relative_url }}">
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html lang="{{ page.lang | default: site.lang | default: "en" }}">
3
+ {% include head.html %}
4
+ <body>
5
+ <div class="wrapper">
6
+ {% include sidebar.html %}
7
+ <main class="content">
8
+ <div class="inner">
9
+ {{ content }}
10
+ </div>
11
+ </main>
12
+ </div>
13
+ {% include scripts.html %}
14
+ </body>
15
+ </html>
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ {{ content }}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * VARIABLES
3
+ */
4
+
5
+ $base-height: 1em;
6
+ $content-width: 800px;
7
+ $sidebar-width: 300px;
8
+ $mobile-width: 745px;
9
+ $min-width: 360px;
10
+ $header-height: 50px;
11
+
12
+ $link-color: #008cff;
13
+
14
+ $sidebar-border: 1px solid rgba(0,0,0,0.07);
15
+ $sidebar-color: #364149;
16
+
17
+ $navigation-background: #fafafa;
18
+ $navigation-link-color: #008cff;
19
+
20
+ $content-color: #333;
21
+
@@ -0,0 +1,161 @@
1
+ ---
2
+ ---
3
+ @import "variables";
4
+
5
+
6
+ html,
7
+ body {
8
+ margin: 0;
9
+ height: 100%;
10
+ max-height: 100%;
11
+ overflow: hidden;
12
+ min-width: $min-width;
13
+ }
14
+
15
+ .wrapper {
16
+ height: 100%;
17
+ width: 100%;
18
+ max-height: 100%;
19
+ min-height: 100%;
20
+ display: flex;
21
+ overflow: hidden;
22
+ }
23
+
24
+ // Sidebar
25
+ .sidebar {
26
+ display: block;
27
+ width: 20%;
28
+ max-width: $sidebar-width;
29
+ padding: 0;
30
+ border-right: 1px solid var(--muted-border-color);
31
+ height: 100%;
32
+ overflow: hidden;
33
+
34
+ .sidebar-main {
35
+ height: 100%;
36
+ padding: 0 $base-height;
37
+ }
38
+
39
+ .sidebar-mobile {
40
+ display: none;
41
+ height: $header-height;
42
+ padding: 0 $base-height;
43
+ text-align: right;
44
+
45
+ .close-icon,
46
+ .menu-icon {
47
+ width: 18px;
48
+ cursor: pointer;
49
+ height: auto;
50
+ display: none;
51
+ }
52
+ }
53
+ }
54
+
55
+ .search-input {
56
+ border: 0;
57
+ border-bottom: 1px solid var(--muted-border-color);
58
+ font-size: 16px;
59
+ }
60
+
61
+ .navigation {
62
+ display: block;
63
+ width: 100%;
64
+ margin: 0;
65
+ padding: 0;
66
+ list-style: none;
67
+
68
+ li {
69
+ margin: 0;
70
+ padding: 10px 15px;
71
+ }
72
+
73
+ a {
74
+ display: block;
75
+ white-space: nowrap;
76
+ overflow: hidden;
77
+ text-overflow: ellipsis;
78
+ color: var(--secondary);
79
+ font-weight: var(--font-weight);
80
+ font-size: 16px;
81
+
82
+
83
+ &.active {
84
+ color: var(--primary);
85
+ }
86
+ }
87
+ }
88
+
89
+ // Content
90
+ .content {
91
+ display: flex;
92
+ justify-content: center;
93
+ min-height: 100%;
94
+ height: 100%;
95
+ width: 100%;
96
+ overflow-y: auto;
97
+ color: $content-color;
98
+ line-height: 1.7;
99
+ word-wrap: break-word;
100
+ }
101
+
102
+ .inner {
103
+ width: 100%;
104
+ max-width: $content-width;
105
+ padding: $base-height ($base-height * 2) ($base-height * 3) $base-height;
106
+
107
+ &::after {
108
+ content: "";
109
+ display: block;
110
+ height: $base-height * 2;
111
+ }
112
+ }
113
+
114
+ .section {
115
+ margin-bottom: $base-height;
116
+ }
117
+
118
+ pre[class*="language-"] {
119
+ background: var(--code-background-color);
120
+ }
121
+
122
+ /**
123
+ * Mobile
124
+ */
125
+ @media (max-width: $mobile-width) {
126
+ .wrapper {
127
+ flex-direction: column;
128
+ }
129
+
130
+ .sidebar {
131
+ width: 100%;
132
+ max-width: 100%;
133
+ border-right: none;
134
+ height: $header-height;
135
+
136
+ .sidebar-mobile {
137
+ display: flex;
138
+
139
+ .menu-icon {
140
+ display: inline;
141
+ }
142
+ }
143
+
144
+ &.opened {
145
+ overflow: visible;
146
+ height: auto;
147
+ border-bottom: $sidebar-border;
148
+ }
149
+ }
150
+
151
+ .content {
152
+ width: 100%;
153
+ margin-top: 0;
154
+ height: calc(100% - #{$header-height});
155
+ min-height: calc(100% - #{$header-height});
156
+ }
157
+
158
+ .inner {
159
+ padding: $base-height;
160
+ }
161
+ }
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
2
+ <path fill="#888" d="M24 20.188l-8.315-8.209 8.2-8.282-3.697-3.697-8.212 8.318-8.31-8.203-3.666 3.666 8.321 8.24-8.206 8.313 3.666 3.666 8.237-8.318 8.285 8.203z"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
2
+ <path fill="#888" d="M24 6h-24v-4h24v4zm0 4h-24v4h24v-4zm0 8h-24v4h24v-4z"/>
3
+ </svg>
@@ -0,0 +1,18 @@
1
+ ---
2
+ ---
3
+
4
+ window.database = {
5
+ {% for page in site.pages %}
6
+ {% if page.layout != 'page' %}
7
+ {% continue %}
8
+ {% endif %}
9
+ "{{ page.url | slugify }}": {
10
+ "title": "{{ page.title | xml_escape }}",
11
+ "category": "{{ page.category | xml_escape }}",
12
+ "content": {{ page.content | strip_html | strip_newlines | jsonify }},
13
+ "url": "{{ page.url | xml_escape }}",
14
+ "href": "{{ site.baseurl }}{{ page.url | xml_escape }}"
15
+ }
16
+ {% unless forloop.last %},{% endunless %}
17
+ {% endfor %}
18
+ };
@@ -0,0 +1,15 @@
1
+ const menuIcon = document.getElementById("menu");
2
+ const closeIcon = document.getElementById("close");
3
+ const sidebar = document.getElementById("sidebar");
4
+
5
+ menuIcon.addEventListener("click", () => {
6
+ sidebar.classList.add("opened");
7
+ menuIcon.style.display = "none";
8
+ closeIcon.style.display = "block";
9
+ });
10
+
11
+ closeIcon.addEventListener("click", () => {
12
+ sidebar.classList.remove("opened");
13
+ menuIcon.style.display = "block";
14
+ closeIcon.style.display = "none";
15
+ });
@@ -0,0 +1,117 @@
1
+ const resultsContainer = document.getElementById("search-results");
2
+ const navigationContainer = document.getElementById("navigation");
3
+ const nothingFound = document.createElement("li");
4
+ nothingFound.innerText = "Nothing found.";
5
+ const searchQuery = document.getElementById("search-input");
6
+
7
+ database = window.database || {};
8
+
9
+ function createSearchStore(data) {
10
+ return window.lunr(function () {
11
+ this.field("id");
12
+ this.field("title", { boost: 10 });
13
+ this.field("category");
14
+ this.field("content");
15
+
16
+ Object.keys(data).forEach((key) => {
17
+ this.add({
18
+ id: key,
19
+ title: data[key].title,
20
+ category: data[key].category,
21
+ content: data[key].content,
22
+ });
23
+ });
24
+ });
25
+ }
26
+
27
+ function resultEntry(result) {
28
+ const searchEntry = document.createElement("li");
29
+ const searchLink = document.createElement("a");
30
+
31
+ const categoryPath = result.url.split("/");
32
+ categoryPath.shift();
33
+ categoryPath.pop();
34
+
35
+ searchEntry.appendChild(searchLink);
36
+
37
+ searchLink.setAttribute("href", result.href);
38
+
39
+ searchLink.innerText = result.title;
40
+
41
+ return searchEntry;
42
+ }
43
+
44
+ function displayResults(results) {
45
+ resultsContainer.innerHTML = "";
46
+
47
+ if (results.length > 0) {
48
+ results.map(function (entry) {
49
+ resultsContainer.appendChild(resultEntry(entry));
50
+ });
51
+ } else {
52
+ resultsContainer.appendChild(nothingFound);
53
+ }
54
+
55
+ navigationContainer.style.display = "none";
56
+ resultsContainer.style.display = "block";
57
+ }
58
+
59
+ function hideResults() {
60
+ resultsContainer.style.display = "none";
61
+ navigationContainer.style.display = "block";
62
+ }
63
+
64
+ function searchStore(store, data) {
65
+ return (term) => store.search(term).map((result) => data[result.ref]);
66
+ }
67
+
68
+ function queryChange(display, hide, search) {
69
+ return (event) => {
70
+ var value = event.srcElement.value;
71
+
72
+ if (value.length === 0) {
73
+ hide();
74
+ }
75
+
76
+ if (value.length > 2) {
77
+ display(search(value));
78
+ }
79
+ };
80
+ }
81
+
82
+ function keyboardControls(hide) {
83
+ return function (event) {
84
+ switch (event.keyCode) {
85
+ case 27:
86
+ hide();
87
+ break;
88
+ }
89
+ };
90
+ }
91
+
92
+ function getQueryVariable(variable) {
93
+ const query = window.location.search.substring(1);
94
+ const vars = query.split("&");
95
+
96
+ for (let i = 0; i < vars.length; i++) {
97
+ const pair = vars[i].split("=");
98
+
99
+ if (pair[0] === variable) {
100
+ return decodeURIComponent(pair[1].replace(/\+/g, "%20"));
101
+ }
102
+ }
103
+ }
104
+
105
+ const search = searchStore(createSearchStore(database), database);
106
+ const searchTerm = getQueryVariable("query");
107
+
108
+ if (searchTerm) {
109
+ displayResults(search(searchTerm));
110
+ searchQuery.attr("value", searchTerm);
111
+ }
112
+
113
+ searchQuery.addEventListener(
114
+ "input",
115
+ queryChange(displayResults, hideResults, search)
116
+ );
117
+ document.addEventListener("keyup", keyboardControls(hideResults));
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: picodocs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.5
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Heimbuch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - github@heimbu.ch
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE.md
49
+ - README.md
50
+ - _includes/head.html
51
+ - _includes/navigation.html
52
+ - _includes/scripts.html
53
+ - _includes/search-results.html
54
+ - _includes/search.html
55
+ - _includes/sidebar.html
56
+ - _includes/styles.html
57
+ - _layouts/default.html
58
+ - _layouts/page.html
59
+ - _sass/variables.scss
60
+ - assets/css/docs.scss
61
+ - assets/images/close.svg
62
+ - assets/images/menu.svg
63
+ - assets/js/database.js
64
+ - assets/js/mobile-navigation.js
65
+ - assets/js/search.js
66
+ homepage: https://github.com/alexander-heimbuch/picodocs
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubygems_version: 3.0.3.1
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Minimal Jekyll documentation theme based on Picocss and Prism
89
+ test_files: []