jekyll-theme-paperwiki 0.1.16 → 0.1.18

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: 1896b6de7d51495d6bdf12f3cc9aac56bb2573fcf80ce429725fee3593762b91
4
- data.tar.gz: 18e1e6d0a06dffaff1f3ab69f29464186573086d0ade1df15cea4b45085cf568
3
+ metadata.gz: b16cb2fa02d1728ccf3bd09ecb7638fa42c0a0243e93a84c91ab4a383416f4c0
4
+ data.tar.gz: b5dde0f6bbb1021bba6b9644a47a3d8a55f2a92e2b18a72c3a6f78ea6036c6af
5
5
  SHA512:
6
- metadata.gz: 894e88cf0db6b281bd2ab322009df722df6859da06b9e6471c8088ebb80e4e500ef58b6ea6bc78e8a0d3d5eac35c92a5f22147de733c255e00fb9e17f42b1947
7
- data.tar.gz: daa223a3bea9974c308e1fa6c726fee01e64d494586f827ef30d58c7d964ce8c24c0a523acb4969bc4cb5e1054d0eb397c2f8970ed2f1ef9ede4b63e910672de
6
+ metadata.gz: f4688f18aeb4133788850b20ae6c6a63f9d46694cc7f6ed74b5ca36d179fa4fc8017088118048971f16d4fa71434d3621c08fee169a187895672c18523728bcb
7
+ data.tar.gz: 5ac735c63413c3a22606e40dfd46d58286c25a61109a0193dd84c4dc09c9dae1420bba6959b1879059d02c3456fb06be7a9a5ae6567a4a87bff2847fe5b36570
data/README.md CHANGED
@@ -1,38 +1,21 @@
1
1
  # jekyll-theme-paperwiki
2
2
 
3
- ![](/assets/images/homepage.png)
3
+ ![A screenshot of the PaperWiki homepage.](/assets/images/homepage.png)
4
4
 
5
5
  For storing your worldbuilding notes! The intent of this theme is to get all the code out of the way and to allow you to write Markdown articles; the best way to do that is to install the theme as a gem. However, if you want to tinker with the code, just download this repository.
6
6
 
7
7
  For the easiest starting point, I have uploaded a [sample site](https://github.com/pomeloshark/paperwiki-example) that you can download with everything preconfigured, so if you're unfamiliar with Jekyll you can bypass all the setup and get right to it. See that repo for instructions.
8
8
 
9
- I've tried to adhere to accessible and easy to read design principles while retaining the look and layout of a classic wiki that we're all familiar with - I've aped some elements of Wikipedia's organizational system and layout while trying to make it as clean and user friendly as possible.
10
-
11
- This theme is not mobile friendly, as I personally do absolutely no work on mobile and thus my development skills are lacking. I stuck in a couple CSS breakpoints, so it'll be mostly legible on a medium-sized tablet, but don't expect great results on a phone. There is also no dark mode or other alternate colour scheme, but please feel free to fork this project and add whatever functionality you're looking for.
12
-
13
9
  This theme is not really intended for blogging, but you could add in the functionality easily enough by creating a `_posts` collection and setting a default post layout in the config file, as there is a dedicated `post` layout, as well as a `blog.md` which will list all of your blog posts on one page. If you have no need for it you can delete this file.
14
10
 
15
11
 
16
12
 
17
- ## Usage
18
-
19
- In case you're unfamiliar with it, a basic Jekyll site includes the following:
20
- + The `_includes` folder contains snippets of HTML that are frequently reused on pages throughout the website. This saves us from having to copy and paste the HTML on multiple pages, and we only have to edit it in one file in order to change every instance of it.
21
- + The `_layouts` folder contains the formatting for different types of pages, meaning that instead of formatting each page individually we can just specify which layout template to use.
22
- + The `_sass` folder contains all the styling for the site, written in SCSS.
23
- + The `_site` folder contains everything that Jekyll outputs when it builds the site. Don't edit anything in this folder, as it will be rewritten the next time you serve the site.
24
- + The `assets` folder contains things like fonts, images, and Javascript files. It also contains a `.scss` file importing all of your SCSS so that Jekyll can convert it to regular CSS.
25
-
26
- This theme comes with all of these prepackaged, so most of what you have to do is edit the `_config.yaml` file. The theme has some default config set already, but you can override these in your own config file if you wish. You can also add any of the above folders to your own project with includes, layouts, or SCSS to override the theme's files. For example, you will want to add your own `assets` folder to store your own images, including one titled `favicon.png` in order to override the placeholder one i've included.
27
-
28
-
29
-
30
13
  ## Installation
31
14
 
32
15
  [Install Jekyll](https://jekyllrb.com/docs/). If you're using the example site linked above, you can skip ahead to the [using the wiki](#using-the-wiki) section. Otherwise, create a new site by running the following in your terminal:
33
16
 
34
17
  ```
35
- $ jekyll new MYSITENAME
18
+ jekyll new SITE_NAME_HERE
36
19
  ```
37
20
 
38
21
  This will give you a very bare bones Jekyll site, with an index page, a folder for blog posts, a config file, and a Gemfile. You'll have to do a little setup to make it usable with this theme. Here's what the directory should look like:
@@ -90,26 +73,7 @@ Navigate to your localhost and...you will see an empty page. This is because the
90
73
  layout: launchpad
91
74
  ```
92
75
 
93
- This will show you the default wiki homepage. The three links - explore, contents, and random page - link to pages that are included with the theme, and consist of pregenerated content based on the wiki articles you've written. Now you can start adding articles in your `_wiki` folder.
94
-
95
-
96
-
97
- ### Using the wiki
98
-
99
- All of your wiki pages should be written in Markdown, and you must begin each `.md` file like so:
100
-
101
- ```
102
- ---
103
- ---
104
- ```
105
-
106
- Between these two lines is where you include *front matter*, such as specifying the layout or the permalink to the page. However, you can leave the front matter blank - wiki pages have layouts and permalinks set by default in the theme's config file, and you only need to specify them if you want to override the defaults. You also do not need to specify a title for the page, as it is automatically taken from the filename. All you absolutely need is the two triple-dashed lines, as Jekyll needs it to know that the front matter is there in order to output the page.
107
-
108
- Caveats:
109
- - If the site won't build due to an error with the random page, make sure you have more than one wiki article for it to draw from
110
- - You may need to specify a permalink and a title if you want to use certain characters that are not allowed in filenames -- say, some IPA characters. Otherwise just title your articles "Article title.md", with spaces, not underscores or hyphens, and the default settings will take care of the rest.
111
-
112
- If you're unfamiliar with Markdown, see [here](https://www.markdownguide.org/).
76
+ This will show you the default wiki homepage. The three links - explore, contents, and random page - link to pages that are included with the theme, and consist of pregenerated content based on the wiki articles you've written. Now you can start adding articles in your `_wiki` folder. See my [guide](https://pomeloshark.github.io/jekyll) for further details.
113
77
 
114
78
 
115
79
 
@@ -0,0 +1,25 @@
1
+ <script type="text/javascript">
2
+
3
+ var urls=[];
4
+
5
+ {% for doc in docs -%}
6
+ urls.push("{{ doc.url | absolute_url }}");
7
+ {% endfor -%}
8
+
9
+ var url = urls[Math.floor(Math.random()*urls.length)];
10
+
11
+ var link = document.createElement('link');
12
+ link.setAttribute('rel', 'canonical');
13
+ link.setAttribute('href', url);
14
+ document.head.appendChild(link);
15
+
16
+ if (typeof IE_fix != "undefined") {
17
+ document.write("Redirecting...");
18
+ var referLink = document.createElement("a");
19
+ referLink.href = url;
20
+ document.body.appendChild(referLink);
21
+ referLink.click();
22
+ } else {
23
+ window.location.replace(url);
24
+ }
25
+ </script>
@@ -0,0 +1,25 @@
1
+ ---
2
+ layout: entry
3
+ ---
4
+
5
+ <article class="entry entry_grammar">
6
+
7
+ <h1>
8
+ {{ page.name | remove: ".md" }}
9
+ </h1>
10
+
11
+ {% if site.entry_tags_top %}
12
+ <section class="entry-tags entry-tags_top">
13
+ {% include entry_tags.html %}
14
+ </section>
15
+ {% endif %}
16
+
17
+ {{ content }}
18
+
19
+ {% if site.entry_tags_top == false %}
20
+ <section class="entry-tags entry-tags_bottom">
21
+ {% include entry_tags.html %}
22
+ </section>
23
+ {% endif %}
24
+
25
+ </article>
data/_layouts/random.html CHANGED
@@ -5,39 +5,10 @@
5
5
  layout: page
6
6
  ---
7
7
 
8
- {%- assign docs = site.posts -%}
8
+ {%- assign docs = site.documents -%}
9
9
 
10
- {%- if site.random_redirect.pages == true -%}
11
- {%- assign pages = site.documents | where_exp:"page","page.url != '/random/'" -%}
12
- {%- assign docs = docs | concat: pages -%}
10
+ {%- if site.random_redirect.posts == true -%}
11
+ {%- assign docs = docs | concat: site.posts -%}
13
12
  {%- endif -%}
14
13
 
15
- {%- if site.random_redirect.documents == true -%}
16
- {%- assign docs = docs | concat: site.documents | uniq -%}
17
- {%- endif -%}
18
-
19
- <script type="text/javascript">
20
-
21
- var urls=[];
22
-
23
- {% for doc in docs -%}
24
- urls.push("{{ doc.url | absolute_url }}");
25
- {% endfor -%}
26
-
27
- var url = urls[Math.floor(Math.random()*urls.length)];
28
-
29
- var link = document.createElement('link');
30
- link.setAttribute('rel', 'canonical');
31
- link.setAttribute('href', url);
32
- document.head.appendChild(link);
33
-
34
- if (typeof IE_fix != "undefined") {
35
- document.write("Redirecting...");
36
- var referLink = document.createElement("a");
37
- referLink.href = url;
38
- document.body.appendChild(referLink);
39
- referLink.click();
40
- } else {
41
- window.location.replace(url);
42
- }
43
- </script>
14
+ {% include random_redirect.html %}
@@ -0,0 +1,12 @@
1
+ ---
2
+ # Jekyll page that redirects to a random page, post or document
3
+ # https://github.com/jekylltools/jekyll-random-redirect
4
+ # v1.6
5
+ layout: page
6
+ ---
7
+
8
+ {% assign project = page.project %}
9
+
10
+ {%- assign docs = site.documents | where_exp: "page","page.collection == project" -%}
11
+
12
+ {% include random_redirect.html %}
@@ -0,0 +1,16 @@
1
+ ---
2
+ layout: search
3
+ ---
4
+
5
+ {% assign project = page.project %}
6
+
7
+ {%- assign docs = site.documents | where_exp: "page","page.collection == project" -%}
8
+
9
+ <script>
10
+ window.pages = {
11
+ {% for page in docs %}
12
+ {% include search_results.html %}
13
+ {% unless forloop.last %},{% endunless %}
14
+ {% endfor %}
15
+ };
16
+ </script>
@@ -0,0 +1,27 @@
1
+ ---
2
+ layout: entry
3
+ ---
4
+
5
+ <article class="entry entry_work">
6
+
7
+ <h1>
8
+ {{ page.name | remove: ".md" }}
9
+ </h1>
10
+
11
+ {% if site.entry_tags_top %}
12
+ <section class="entry-tags entry-tags_top">
13
+ {% include entry_tags.html %}
14
+ </section>
15
+ {% endif %}
16
+
17
+ {{ content }}
18
+
19
+ {% if site.entry_tags_top == false %}
20
+ <section class="entry-tags entry-tags_bottom">
21
+ {% include entry_tags.html %}
22
+ </section>
23
+ {% endif %}
24
+
25
+ </article>
26
+
27
+ {% include wiki_sidebar.html %}
@@ -5,14 +5,23 @@
5
5
 
6
6
  .interlinear_gloss {
7
7
  border-collapse: collapse;
8
+ border: 0;
8
9
  margin-left: 3%;
9
10
  margin-top: 0;
10
11
  margin-bottom: 1.75rem;
12
+ tr {
13
+ border: 0;
14
+ }
15
+ tr:nth-child(even) {
16
+ background-color: transparent;
17
+ }
11
18
  td {
12
- padding: 0 0 0 1em;
19
+ padding: 0.5em;
20
+ border: 0;
13
21
  }
14
22
  td:first-child {
15
- border-left: 4px solid $color-pistachio;
23
+ border-left: 0.5em solid $color-pistachio;
24
+ padding-left: 1em;
16
25
  }
17
26
  }
18
27
 
@@ -14,7 +14,10 @@
14
14
  margin-left: 0;
15
15
  }
16
16
 
17
- .search_result {}
17
+ .search_result {
18
+ text-decoration: none;
19
+ font-weight: bold;
20
+ }
18
21
 
19
22
  .search_result-details {
20
23
  margin-bottom: 0;
@@ -26,3 +29,10 @@
26
29
  .search_result-preview {
27
30
  margin-bottom: 1.75rem;
28
31
  }
32
+
33
+ .search_result-highlight {
34
+ padding: 0.2em 0.3em;
35
+
36
+ background-color: $color-peach;
37
+ border-radius: $border_radius-inline;
38
+ }
@@ -0,0 +1,162 @@
1
+ import * as lunr from "lunr";
2
+
3
+ /*!
4
+ * lunr.unicodeNormalizer
5
+ * by Chris Van <cvan>, 2014
6
+ * Extension for lunr.js <http://lunrjs.com/>
7
+ * Includes code from https://github.com/dodo/node-slug/blob/master/slug.js
8
+ */
9
+
10
+ const charmap: {[inchar: string]: string} = {
11
+ // Latin & IPA
12
+ 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ā': 'A', 'Ȧ': 'A', 'Ä': 'A',
13
+ 'Å': 'A', 'Ǎ': 'A', 'Ą': 'A', 'Ạ': 'A', 'Æ': 'AE', 'Ḃ': 'B', 'Ḅ': 'B',
14
+ 'Ç': 'C', 'Ć': 'C', 'Ĉ': 'C', 'Č': 'C', 'Ċ': 'C', 'Ḋ': 'D', 'Ḍ': 'D',
15
+ 'Ḏ': 'D', 'Ď': 'D', 'Ð': 'D', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ẽ': 'E',
16
+ 'Ē': 'E', 'Ė': 'E', 'Ë': 'E', 'Ě': 'E', 'Ẹ': 'E', 'Ę': 'E', 'Ǵ': 'G',
17
+ 'Ĝ': 'G', 'Ġ': 'G', 'Ǧ': 'G', 'Ĥ': 'H', 'Ȟ': 'H', 'Ḥ': 'H', 'Ì': 'I',
18
+ 'Í': 'I', 'Î': 'I', 'Ĩ': 'I', 'Ī': 'I', 'İ': 'I', 'Ï': 'I', 'Ǐ': 'I',
19
+ 'Ị': 'I', 'Į': 'I', 'Ḱ': 'K', 'Ǩ': 'K', 'Ḵ': 'K', 'Ḳ': 'K', 'Ĺ': 'L',
20
+ 'Ḻ': 'L', 'Ḷ': 'L', 'Ḿ': 'M', 'Ṁ': 'M', 'Ṃ': 'M', 'Ǹ': 'N', 'Ń': 'N',
21
+ 'Ñ': 'N', 'Ṅ': 'N', 'Ň': 'N', 'Ŋ': 'N', 'Ɲ': 'N', 'Ṇ': 'N', 'Ò': 'O',
22
+ 'Ó': 'O', 'Ô': 'O', 'Õ': 'O', 'Ō': 'O', 'Ȯ': 'O', 'Ö': 'O', 'Ő': 'O',
23
+ 'Ǫ': 'O', 'Ọ': 'O', 'Ɔ': 'O', 'Ø': 'O', 'Ŕ': 'R', 'Ṙ': 'R', 'Ř': 'R',
24
+ 'Ṛ': 'R', 'Ś': 'S', 'Ŝ': 'S', 'Ṡ': 'S', 'Ṣ': 'S', 'Ș': 'S', 'Ş': 'S',
25
+ 'Ṭ': 'T', 'Ț': 'T', 'Ţ': 'T', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', 'Ũ': 'U',
26
+ 'Ū': 'U', 'Ü': 'U', 'Ű': 'U', 'Ǔ': 'U', 'Ụ': 'U', 'Ṳ': 'U', 'Ų': 'U',
27
+ 'Ẁ': 'W', 'Ẃ': 'W', 'Ŵ': 'W', 'Ẉ': 'W', 'Ỳ': 'Y', 'Ý': 'Y', 'Ŷ': 'Y',
28
+ 'Ỹ': 'Y', 'Ȳ': 'Y', 'Ẏ': 'Y', 'Ÿ': 'Y', 'Ź': 'Z', 'Ẑ': 'Z', 'Ż': 'Z',
29
+ 'Ž': 'Z', 'Ẓ': 'Z', 'Ẕ': 'Z', 'Þ': 'TH', 'ß': 'ss',
30
+ 'à': 'a', 'á': 'a', 'â': 'a', 'ã': 'a', 'ā': 'a', 'ȧ': 'a', 'ä': 'a',
31
+ 'å': 'a', 'ǎ': 'a', 'ą': 'a', 'ạ': 'a', 'ɑ': 'a', 'ɐ': 'a', 'ɒ': 'a',
32
+ 'æ': 'ae',
33
+ 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', 'ì': 'i', 'í': 'i',
34
+ 'î': 'i', 'ï': 'i', 'ð': 'd', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o',
35
+ 'õ': 'o', 'ö': 'o', 'ő': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u',
36
+ 'ü': 'u', 'ű': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y', 'ẞ': 'SS',
37
+
38
+ // Greek
39
+ 'Α': 'A', 'Β': 'B', 'Γ': 'G', 'Δ': 'D', 'Ε': 'E', 'Ζ': 'Z', 'Η': 'H',
40
+ 'Θ': '8', 'Ι': 'I', 'Κ': 'K', 'Λ': 'L', 'Μ': 'M', 'Ν': 'N', 'Ξ': '3',
41
+ 'Ο': 'O', 'Π': 'P', 'Ρ': 'R', 'Σ': 'S', 'Τ': 'T', 'Υ': 'Y', 'Φ': 'F',
42
+ 'Χ': 'X', 'Ψ': 'PS', 'Ω': 'W',
43
+ 'Ά': 'A', 'Έ': 'E', 'Ί': 'I', 'Ό': 'O', 'Ύ': 'Y', 'Ή': 'H', 'Ώ': 'W',
44
+ 'Ϊ': 'I', 'Ϋ': 'Y',
45
+ 'α': 'a', 'β': 'b', 'γ': 'g', 'δ': 'd', 'ε': 'e', 'ζ': 'z', 'η': 'h',
46
+ 'θ': '8', 'ι': 'i', 'κ': 'k', 'λ': 'l', 'μ': 'm', 'ν': 'n', 'ξ': '3',
47
+ 'ο': 'o', 'π': 'p', 'ρ': 'r', 'σ': 's', 'τ': 't', 'υ': 'y', 'φ': 'f',
48
+ 'χ': 'x', 'ψ': 'ps', 'ω': 'w',
49
+ 'ά': 'a', 'έ': 'e', 'ί': 'i', 'ό': 'o', 'ύ': 'y', 'ή': 'h', 'ώ': 'w',
50
+ 'ς': 's', 'ϊ': 'i', 'ΰ': 'y', 'ϋ': 'y', 'ΐ': 'i',
51
+
52
+ // Turkish
53
+ 'Ş': 'S', 'İ': 'I', 'Ğ': 'G',
54
+ 'ş': 's', 'ı': 'i', 'ğ': 'g',
55
+
56
+ // Russian
57
+ 'А': 'A', 'Б': 'B', 'В': 'V', 'Г': 'G', 'Д': 'D', 'Е': 'E', 'Ё': 'Yo',
58
+ 'Ж': 'Zh', 'З': 'Z', 'И': 'I', 'Й': 'J', 'К': 'K', 'Л': 'L', 'М': 'M',
59
+ 'Н': 'N', 'О': 'O', 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T', 'У': 'U',
60
+ 'Ф': 'F', 'Х': 'H', 'Ц': 'C', 'Ч': 'Ch', 'Ш': 'Sh', 'Щ': 'Sh', 'Ъ': 'U',
61
+ 'Ы': 'Y', 'Ь': '', 'Э': 'E', 'Ю': 'Yu', 'Я': 'Ya',
62
+ 'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo',
63
+ 'ж': 'zh', 'з': 'z', 'и': 'i', 'й': 'j', 'к': 'k', 'л': 'l', 'м': 'm',
64
+ 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
65
+ 'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'ch', 'ш': 'sh', 'щ': 'sh', 'ъ': 'u',
66
+ 'ы': 'y', 'ь': '', 'э': 'e', 'ю': 'yu', 'я': 'ya',
67
+
68
+ // Ukranian
69
+ 'Є': 'Ye', 'І': 'I', 'Ї': 'Yi', 'Ґ': 'G',
70
+ 'є': 'ye', 'і': 'i', 'ї': 'yi', 'ґ': 'g',
71
+
72
+ // Czech
73
+ 'Č': 'C', 'Ď': 'D', 'Ě': 'E', 'Ň': 'N', 'Ř': 'R', 'Š': 'S', 'Ť': 'T',
74
+ 'Ů': 'U', 'Ž': 'Z',
75
+ 'č': 'c', 'ď': 'd', 'ě': 'e', 'ň': 'n', 'ř': 'r', 'š': 's', 'ť': 't',
76
+ 'ů': 'u', 'ž': 'z',
77
+
78
+ // Polish
79
+ 'Ą': 'A', 'Ć': 'C', 'Ę': 'e', 'Ł': 'L', 'Ń': 'N', 'Ś': 'S', 'Ź': 'Z',
80
+ 'Ż': 'Z',
81
+ 'ą': 'a', 'ć': 'c', 'ę': 'e', 'ł': 'l', 'ń': 'n', 'ś': 's', 'ź': 'z',
82
+ 'ż': 'z',
83
+
84
+ // Latvian
85
+ 'Ā': 'A', 'Ē': 'E', 'Ģ': 'G', 'Ī': 'i', 'Ķ': 'k', 'Ļ': 'L', 'Ņ': 'N',
86
+ 'Ū': 'u',
87
+ 'ā': 'a', 'ē': 'e', 'ģ': 'g', 'ī': 'i', 'ķ': 'k', 'ļ': 'l', 'ņ': 'n',
88
+ 'ū': 'u',
89
+
90
+ // Currency
91
+ '€': 'euro', '₢': 'cruzeiro', '₣': 'french franc', '£': 'pound',
92
+ '₤': 'lira', '₥': 'mill', '₦': 'naira', '₧': 'peseta', '₨': 'rupee',
93
+ '₩': 'won', '₪': 'new shequel', '₫': 'dong', '₭': 'kip', '₮': 'tugrik',
94
+ '₯': 'drachma', '₰': 'penny', '₱': 'peso', '₲': 'guarani',
95
+ '₳': 'austral', '₴': 'hryvnia', '₵': 'cedi', '¢': 'cent', '¥': 'yen',
96
+ '元': 'yuan', '円': 'yen', '﷼': 'rial', '₠': 'ecu', '¤': 'currency',
97
+ '฿': 'baht', "$": 'dollar', '₹': 'indian rupee',
98
+
99
+ // Symbols
100
+ '©': '(c)', 'œ': 'oe', 'Œ': 'OE', '∑': 'sum', '®': '(r)', '†': '+',
101
+ '“': '"', '”': '"', '‘': "'", '’': "'", '∂': 'd', 'ƒ': 'f', '™': 'tm',
102
+ '℠': 'sm', '…': '...', '˚': 'o', 'º': 'o', 'ª': 'a', '•': '*',
103
+ '∆': 'delta', '∞': 'infinity', '♥': 'love', '&': 'and', '|': 'or',
104
+ '<': 'less', '>': 'greater'
105
+ };
106
+ const charmapPattern = Object.keys(charmap).map(function(char) {
107
+ // Update this with every normalized character that is also a unicode
108
+ // operator.
109
+ return char.replace(/[\|\$]/g, '\\$&'); // `$&` -> returns matched text
110
+ }).join('|');
111
+ const charmapRegExp = new RegExp('(' + charmapPattern + ')', 'g');
112
+
113
+ function unicodeFolder(str: string) {
114
+ return str.replace(charmapRegExp, function(char: string) {
115
+ return charmap[char];
116
+ });
117
+ }
118
+
119
+ export default function patchLunr(lunrmod: any) {
120
+ var tokenizer = function(obj: any, metadata: any) {
121
+ if (!arguments.length || obj === null || obj === undefined) return [];
122
+ if (Array.isArray(obj)) {
123
+ return obj.map(function(t) {
124
+ return new lunrmod.Token(
125
+ unicodeFolder(lunrmod.utils.asString(t)).toLowerCase(),
126
+ lunrmod.utils.clone(metadata))
127
+ });
128
+ }
129
+ var str = obj.toString(), len = str.length, tokens = []
130
+
131
+ for (var sliceEnd = 0, sliceStart = 0; sliceEnd <= len; sliceEnd++) {
132
+ var char = str.charAt(sliceEnd),
133
+ sliceLength = sliceEnd - sliceStart
134
+
135
+ if ((char.match(lunrmod.tokenizer.separator) || sliceEnd == len)) {
136
+
137
+ if (sliceLength > 0) {
138
+ var tokenMetadata = lunrmod.utils.clone(metadata) || {}
139
+ tokenMetadata["position"] = [sliceStart, sliceLength]
140
+ tokenMetadata["index"] = tokens.length
141
+
142
+ tokens.push(
143
+ new lunrmod.Token (
144
+ unicodeFolder(str.slice(sliceStart, sliceEnd)).toLowerCase(),
145
+ tokenMetadata
146
+ )
147
+ )
148
+ }
149
+
150
+ sliceStart = sliceEnd + 1
151
+ }
152
+ }
153
+
154
+ return tokens
155
+ }
156
+
157
+ for (const attr in lunrmod.tokenizer){
158
+ // @ts-ignore
159
+ tokenizer[attr] = lunrmod.tokenizer[attr];
160
+ }
161
+ lunrmod.tokenizer = tokenizer;
162
+ }
data/assets/js/search.js CHANGED
@@ -1,17 +1,26 @@
1
- // Yoinked in its entirety from https://davidwalsh.name/adding-search-to-your-site-with-javascript
1
+ // Yoinked in its entirety from https://davidwalsh.name/adding-search-to-your-site-with-javascript and https://trackjs.com/blog/site-search-with-javascript-part-2/
2
2
 
3
+ //var lunr = require("lunr")
4
+ //require("lunr.unicodeNormalizer")(lunr)
5
+
6
+ // Build the search index
3
7
  var searchIndex = lunr(function() {
4
- // define searchable fields for each page
8
+ // this.use("lunr.unicodeNormalizer")
9
+ // Define searchable fields for each page
5
10
  this.ref("id");
6
- this.field("title", { boost: 10 });
7
- this.field("content");
8
- this.field("portal");
9
- this.field("categories");
10
- for (var key in window.pages) {
11
+ this.field("title", { boost: 100 }); // Boost the importance of the title field, prioritizing title matches
12
+ this.field("content", { boost: 50 });
13
+ this.field("portal", { boost: 10 });
14
+ this.field("categories", { boost: 10 });
15
+ this.field("tags", { boost: 10 });
16
+ for (var key in window.pages) { // Loop through all pages to add their data to the search index
11
17
  this.add({
12
18
  "id": key,
13
19
  "title": pages[key].title,
14
- "content": pages[key].content
20
+ "content": pages[key].content,
21
+ "portal": pages[key].portal,
22
+ "categories": pages[key].categories,
23
+ "tags": pages[key].tags
15
24
  });
16
25
  }
17
26
  });
@@ -30,21 +39,44 @@ function getQueryVariable(variable) {
30
39
  }
31
40
 
32
41
  var searchTerm = getQueryVariable("q");
33
- // creation of searchIndex from earlier example
34
- var results = searchIndex.search(searchTerm);
42
+ // Create index of search term matches
43
+ var results = searchIndex.search(searchTerm + "*"); // Wildcard by default
35
44
  var resultPages = results.map(function (match) {
36
45
  return pages[match.ref];
37
46
  });
38
47
 
39
48
 
40
49
 
50
+ // Text highlighting
51
+ function formatContent(content, searchTerm) {
52
+ var termIdx = content.toLowerCase().indexOf(searchTerm.toLowerCase());
53
+ if (termIdx >= 0) {
54
+ var startIdx = Math.max(0, termIdx - 140);
55
+ var endIdx = Math.min(content.length, termIdx + searchTerm.length + 140);
56
+ var trimmedContent = (startIdx === 0) ? "" : "&hellip;";
57
+ trimmedContent += content.substring(startIdx, endIdx);
58
+ trimmedContent += (endIdx >= content.length) ? "" : "&hellip;"
59
+
60
+ var highlightedContent = trimmedContent.replace(new RegExp(searchTerm, "ig"), function matcher(match) {
61
+ return "<mark class='search_result-highlight'>" + match + "</mark>";
62
+ });
63
+
64
+ return highlightedContent;
65
+ }
66
+ else {
67
+ var emptyTrimmedString = content.substr(0, 280);
68
+ emptyTrimmedString += (content.length < 280) ? "" : "&hellip;";
69
+ return emptyTrimmedString;
70
+ }
71
+ }
72
+
73
+
41
74
 
42
- // resultPages from previous example
43
75
  resultsString = "";
44
- resultPages.forEach(function (r) {
76
+ resultPages.forEach(function (r) { // Format the output on the search results page
45
77
  resultsString += "<dt class='search_result'>";
46
- resultsString += "<a href='" + r.url + "'>" + r.title + "</a>";
78
+ resultsString += "<a class='search_result' href='" + r.url + "'>" + r.title + "</a>";
47
79
  resultsString += "<span class='search_result-details'>" + r.portal + " ⋅ " + r.categories + "</span></dt>"
48
- resultsString += "<dd class='search_result-preview'>" + r.content.substring(0, 200) + "..." + "</dd>";
80
+ resultsString += "<dd class='search_result-preview'>" + formatContent(r.content, searchTerm) + "" + "</dd>";
49
81
  });
50
82
  document.querySelector("#search-results").innerHTML = resultsString;
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-paperwiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - pomeloshark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-04 00:00:00.000000000 Z
11
+ date: 2023-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.3'
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.3'
26
+ version: '0'
27
27
  description:
28
28
  email:
29
29
  executables: []
@@ -39,20 +39,25 @@ files:
39
39
  - _includes/global_footer.html
40
40
  - _includes/global_head.html
41
41
  - _includes/global_header.html
42
+ - _includes/random_redirect.html
42
43
  - _includes/search_results.html
43
44
  - _includes/wiki_sidebar.html
44
45
  - _layouts/collections.html
45
46
  - _layouts/default.html
46
47
  - _layouts/entry.html
48
+ - _layouts/grammar.html
47
49
  - _layouts/launchpad.html
48
50
  - _layouts/page.html
49
51
  - _layouts/portal.html
50
52
  - _layouts/post.html
51
53
  - _layouts/random.html
54
+ - _layouts/random_collection.html
52
55
  - _layouts/reference_desk.html
53
56
  - _layouts/search.html
57
+ - _layouts/search_collection.html
54
58
  - _layouts/search_global.html
55
59
  - _layouts/wiki.html
60
+ - _layouts/work.html
56
61
  - _sass/partials/_base.scss
57
62
  - _sass/partials/_blog.scss
58
63
  - _sass/partials/_collections.scss
@@ -68,7 +73,6 @@ files:
68
73
  - _sass/variables/_fonts.scss
69
74
  - _sass/variables/_media-queries.scss
70
75
  - _sass/variables/_misc.scss
71
- - assets/.DS_Store
72
76
  - assets/css/css.scss
73
77
  - assets/fonts/Inter/.DS_Store
74
78
  - assets/fonts/Inter/Inter-Bold.otf
@@ -100,7 +104,6 @@ files:
100
104
  - assets/fonts/RemixIcon/remixicon.css
101
105
  - assets/fonts/RemixIcon/remixicon.eot
102
106
  - assets/fonts/RemixIcon/remixicon.glyph.json
103
- - assets/fonts/RemixIcon/remixicon.less
104
107
  - assets/fonts/RemixIcon/remixicon.svg
105
108
  - assets/fonts/RemixIcon/remixicon.symbol.svg
106
109
  - assets/fonts/RemixIcon/remixicon.ttf
@@ -2380,6 +2383,7 @@ files:
2380
2383
  - assets/images/favicon.png
2381
2384
  - assets/images/homepage.png
2382
2385
  - assets/js/lunr.js
2386
+ - assets/js/lunr.unicodeNormalizer.ts
2383
2387
  - assets/js/search.js
2384
2388
  - assets/js/toc.js
2385
2389
  homepage: https://github.com/pomeloshark/jekyll-theme-paperwiki
@@ -2404,5 +2408,5 @@ requirements: []
2404
2408
  rubygems_version: 3.2.15
2405
2409
  signing_key:
2406
2410
  specification_version: 4
2407
- summary: A theme meant for use as a personal wiki.
2411
+ summary: A Jekyll theme meant for use as a personal wiki.
2408
2412
  test_files: []
data/assets/.DS_Store DELETED
Binary file