jekyll-dictionaries 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.idea/workspace.xml +40 -20
- data/README.md +38 -83
- data/_includes/.DS_Store +0 -0
- data/_includes/dictionaries/accordion.html +16 -0
- data/_includes/dictionaries/collectionItem.html +4 -0
- data/_includes/dictionaries/collectionName.html +2 -0
- data/_includes/dictionaries/head.html +37 -0
- data/_includes/dictionaries/list.html +13 -0
- data/_includes/dictionaries/multiple/collection.html +24 -0
- data/_includes/dictionaries/multiple/container.html +13 -0
- data/_includes/dictionaries/single/collection.html +20 -0
- data/_includes/dictionaries/single/container.html +13 -0
- data/_layouts/dictionary.html +63 -0
- data/_layouts/dictionary_api.json +3 -0
- data/jekyll-dictionaries.gemspec +2 -1
- data/lib/jekyll-dictionaries/generator.rb +30 -50
- data/lib/jekyll-dictionaries/generators/dictionaries.rb +62 -0
- data/lib/jekyll-dictionaries/generators/theme.rb +61 -0
- data/lib/jekyll-dictionaries/pages/dictionary.rb +53 -0
- data/lib/jekyll-dictionaries/pages/dictionary_api.rb +12 -0
- data/lib/jekyll-dictionaries/version.rb +1 -1
- data/lib/jekyll-dictionaries.rb +0 -3
- metadata +34 -5
- data/lib/jekyll-dictionaries/dictionary_api_page.rb +0 -10
- data/lib/jekyll-dictionaries/dictionary_page.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ae6fbb1a2c9e99134e6a3c2efa23a802b6b23b9a2990f3cb24de390d86e3b2a
|
4
|
+
data.tar.gz: daec5bcd991748fbcc89e55bc74f1c86998ad3d8d68ef3a11c4de77a792dcb7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7ccbf3eb1883c6286a4059eaa019cb6975480e57eaeedd351cd8e23a2d1f9505b2a8cf500e733249d31085ada93d076997d8934934fc45e7b86942f5efedbc6
|
7
|
+
data.tar.gz: b9ad86763fa24cfc53ee6abfc77f0d052a2927db263b8a4e5f99fa9034a10ce6a26b55da14c6f988887face3cab1cd9c1f9be73e1d2ac3b8204e4610e8f7b931
|
data/.DS_Store
CHANGED
Binary file
|
data/.idea/workspace.xml
CHANGED
@@ -5,7 +5,25 @@
|
|
5
5
|
</component>
|
6
6
|
<component name="ChangeListManager">
|
7
7
|
<list default="true" id="a0de0db4-04ba-4a6e-9544-85d905789a03" name="Changes" comment="">
|
8
|
+
<change afterPath="$PROJECT_DIR$/lib/jekyll-dictionaries/generators/dictionaries.rb" afterDir="false" />
|
9
|
+
<change afterPath="$PROJECT_DIR$/lib/jekyll-dictionaries/generators/theme.rb" afterDir="false" />
|
10
|
+
<change afterPath="$PROJECT_DIR$/lib/jekyll-dictionaries/pages/dictionary.rb" afterDir="false" />
|
11
|
+
<change afterPath="$PROJECT_DIR$/lib/jekyll-dictionaries/pages/dictionary_api.rb" afterDir="false" />
|
12
|
+
<change afterPath="$PROJECT_DIR$/spec/fixtures/jekyll/_includes/head.html" afterDir="false" />
|
8
13
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
14
|
+
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
15
|
+
<change beforePath="$PROJECT_DIR$/jekyll-dictionaries.gemspec" beforeDir="false" afterPath="$PROJECT_DIR$/jekyll-dictionaries.gemspec" afterDir="false" />
|
16
|
+
<change beforePath="$PROJECT_DIR$/lib/jekyll-dictionaries.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/jekyll-dictionaries.rb" afterDir="false" />
|
17
|
+
<change beforePath="$PROJECT_DIR$/lib/jekyll-dictionaries/dictionary_api_page.rb" beforeDir="false" />
|
18
|
+
<change beforePath="$PROJECT_DIR$/lib/jekyll-dictionaries/dictionary_page.rb" beforeDir="false" />
|
19
|
+
<change beforePath="$PROJECT_DIR$/lib/jekyll-dictionaries/generator.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/jekyll-dictionaries/generator.rb" afterDir="false" />
|
20
|
+
<change beforePath="$PROJECT_DIR$/spec/fixtures/jekyll/_config.yml" beforeDir="false" afterPath="$PROJECT_DIR$/spec/fixtures/jekyll/_config.yml" afterDir="false" />
|
21
|
+
<change beforePath="$PROJECT_DIR$/spec/fixtures/jekyll/_layouts/dictionary.html" beforeDir="false" />
|
22
|
+
<change beforePath="$PROJECT_DIR$/spec/fixtures/jekyll/_layouts/dictionary_api.json" beforeDir="false" />
|
23
|
+
<change beforePath="$PROJECT_DIR$/spec/fixtures/snapshots/api/multiple.json" beforeDir="false" afterPath="$PROJECT_DIR$/spec/fixtures/snapshots/api/multiple.json" afterDir="false" />
|
24
|
+
<change beforePath="$PROJECT_DIR$/spec/fixtures/snapshots/api/single.json" beforeDir="false" afterPath="$PROJECT_DIR$/spec/fixtures/snapshots/api/single.json" afterDir="false" />
|
25
|
+
<change beforePath="$PROJECT_DIR$/spec/fixtures/snapshots/pages/multiple.html" beforeDir="false" afterPath="$PROJECT_DIR$/spec/fixtures/snapshots/pages/multiple.html" afterDir="false" />
|
26
|
+
<change beforePath="$PROJECT_DIR$/spec/fixtures/snapshots/pages/single.html" beforeDir="false" afterPath="$PROJECT_DIR$/spec/fixtures/snapshots/pages/single.html" afterDir="false" />
|
9
27
|
</list>
|
10
28
|
<option name="SHOW_DIALOG" value="false" />
|
11
29
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
@@ -23,35 +41,37 @@
|
|
23
41
|
<option name="hideEmptyMiddlePackages" value="true" />
|
24
42
|
<option name="showLibraryContents" value="true" />
|
25
43
|
</component>
|
26
|
-
<component name="PropertiesComponent"
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
44
|
+
<component name="PropertiesComponent"><![CDATA[{
|
45
|
+
"keyToString": {
|
46
|
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
47
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
48
|
+
"WebServerToolWindowFactoryState": "false",
|
49
|
+
"last_opened_file_path": "/Users/s.ginkov/Work/Hinkou Labs/jekyll-dictionaries/spec/fixtures/snapshots/pages",
|
50
|
+
"node.js.detected.package.eslint": "true",
|
51
|
+
"node.js.detected.package.tslint": "true",
|
52
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
53
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
54
|
+
"nodejs_package_manager_path": "npm",
|
55
|
+
"ruby.rails.projectView.checked": "true",
|
56
|
+
"ruby.structure.view.model.defaults.configured": "true",
|
57
|
+
"settings.editor.selected.configurable": "org.jetbrains.plugins.ruby.settings.RubyActiveModuleSdkConfigurable",
|
58
|
+
"vue.rearranger.settings.migration": "true"
|
41
59
|
}
|
42
|
-
}
|
60
|
+
}]]></component>
|
43
61
|
<component name="RecentsManager">
|
44
62
|
<key name="CopyFile.RECENT_KEYS">
|
63
|
+
<recent name="$PROJECT_DIR$/spec/fixtures/snapshots/pages" />
|
64
|
+
<recent name="$PROJECT_DIR$/spec/fixtures/snapshots/api" />
|
45
65
|
<recent name="$PROJECT_DIR$/spec/fixtures/jekyll" />
|
46
66
|
<recent name="$PROJECT_DIR$" />
|
47
67
|
<recent name="$PROJECT_DIR$/.idea" />
|
48
68
|
</key>
|
49
69
|
<key name="MoveFile.RECENT_KEYS">
|
70
|
+
<recent name="$PROJECT_DIR$/lib/jekyll-dictionaries/pages" />
|
71
|
+
<recent name="$PROJECT_DIR$/lib/jekyll-dictionaries/generators" />
|
72
|
+
<recent name="$PROJECT_DIR$/_includes/dictionary" />
|
50
73
|
<recent name="$PROJECT_DIR$/" />
|
51
74
|
<recent name="$PROJECT_DIR$/spec/fixtures/snapshots/pages" />
|
52
|
-
<recent name="$PROJECT_DIR$/spec/fixtures/jekyll" />
|
53
|
-
<recent name="$PROJECT_DIR$" />
|
54
|
-
<recent name="$PROJECT_DIR$/spec/fixtures/snapshots/api" />
|
55
75
|
</key>
|
56
76
|
</component>
|
57
77
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
@@ -65,7 +85,7 @@
|
|
65
85
|
<updated>1696301317963</updated>
|
66
86
|
<workItem from="1696301319406" duration="9538000" />
|
67
87
|
<workItem from="1696310885150" duration="15107000" />
|
68
|
-
<workItem from="1696338033417" duration="
|
88
|
+
<workItem from="1696338033417" duration="29066000" />
|
69
89
|
</task>
|
70
90
|
<servers />
|
71
91
|
</component>
|
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# Jekyll Dictionaries Plugin
|
2
2
|
|
3
|
+
[![Continuous Integration](https://github.com/hinkoulabs/jekyll-dictionaries/actions/workflows/ruby.yml/badge.svg)](https://github.com/hinkoulabs/jekyll-dictionaries/actions/workflows/ruby.yml) [![Gem Version](https://badge.fury.io/rb/jekyll-dictionaries.svg)](https://badge.fury.io/rb/jekyll-dictionaries)
|
4
|
+
|
5
|
+
|
3
6
|
Welcome to the Jekyll Dictionaries Plugin project! This open-source project allows you to create and share JSON dictionaries that can be accessed via a public API for language learning in mobile applications.
|
4
7
|
|
5
8
|
## Table of Contents
|
6
9
|
|
10
|
+
- [Intro](#intro)
|
7
11
|
- [Installation](#installation)
|
8
|
-
- [Usage](#usage)
|
9
12
|
- [Dictionaries Structure](#dictionaries-structure)
|
10
13
|
- [Dictionary Types](#dictionary-types)
|
11
14
|
- [1. Single Translation Dictionary](#1-single-translation-dictionary)
|
@@ -17,105 +20,49 @@ Welcome to the Jekyll Dictionaries Plugin project! This open-source project allo
|
|
17
20
|
- [Dictionary Types Examples](#dictionary-types-examples)
|
18
21
|
- [1. Single Translation Dictionary Example](#1-single-translation-dictionary-example)
|
19
22
|
- [2. Multiple Translations Dictionary Example](#2-multiple-translations-dictionary-example)
|
23
|
+
- [Push New Version Commands](#push-new-version-commands)
|
20
24
|
- [License](#license)
|
21
25
|
|
26
|
+
## Intro
|
27
|
+
|
28
|
+
The plugin will automatically generate dictionary and dictionary api pages for all dictionaries located into folder `_data/dictionaries` of jekyll project.
|
29
|
+
|
22
30
|
## Installation
|
23
31
|
|
24
|
-
Add this line to your site's Gemfile:
|
32
|
+
1. Add this line to your site's Gemfile:
|
25
33
|
|
26
34
|
```ruby
|
27
35
|
gem 'jekyll-dictionaries'
|
28
36
|
```
|
29
37
|
|
30
|
-
|
31
|
-
|
32
|
-
**_layouts/dictionary_api.json:**
|
38
|
+
2. Include `dictionary/head.html` into default layout to add custom styles of the plugin (the plugin styles are added as inline css styles and it might be updated if it's needed):
|
33
39
|
|
34
|
-
```
|
35
|
-
|
36
|
-
|
37
|
-
{%
|
40
|
+
```html
|
41
|
+
<head>
|
42
|
+
...
|
43
|
+
{% include dictionaries/head.html %}
|
44
|
+
</head>
|
38
45
|
```
|
39
46
|
|
40
|
-
|
41
|
-
|
42
|
-
```
|
43
|
-
|
44
|
-
layout: page
|
45
|
-
---
|
46
|
-
|
47
|
-
<h1>Info</h1>
|
48
|
-
<table>
|
49
|
-
<tbody>
|
50
|
-
<tr>
|
51
|
-
<th>Name</th>
|
52
|
-
<td>{{ page.content.name }}</td>
|
53
|
-
</tr>
|
54
|
-
<tr>
|
55
|
-
<th>Version</th>
|
56
|
-
<td>{{ page.content.version }}</td>
|
57
|
-
</tr>
|
58
|
-
<tr>
|
59
|
-
<th>Learning</th>
|
60
|
-
<td>{{ page.content.learning }}</td>
|
61
|
-
</tr>
|
62
|
-
|
63
|
-
<tr>
|
64
|
-
<th>Translation Type</th>
|
65
|
-
<td>{{ page.content.translationType }}</td>
|
66
|
-
</tr>
|
67
|
-
|
68
|
-
{% if page.content.translationType == 'multiple' %}
|
69
|
-
|
70
|
-
<tr>
|
71
|
-
<th>Translations</th>
|
72
|
-
<td>{{ page.content.translations | join: ', ' }}</td>
|
73
|
-
</tr>
|
74
|
-
{% endif %}
|
75
|
-
|
76
|
-
{% assign apiPage = page.related_page %}
|
77
|
-
|
78
|
-
{% if apiPage %}
|
79
|
-
|
80
|
-
<tr>
|
81
|
-
<th> <a href="{{ apiPage.url | relative_url }}" target="_blank">API LINK</a> </th>
|
82
|
-
<td>
|
83
|
-
<button onclick="copyToClipboard('{{ apiPage.url | absolute_url }}')">Copy to Clipboard</button>
|
84
|
-
</td>
|
85
|
-
</tr>
|
86
|
-
{% endif %}
|
87
|
-
|
88
|
-
|
89
|
-
</tbody>
|
90
|
-
</table>
|
91
|
-
|
92
|
-
<script>
|
93
|
-
function copyToClipboard(text) {
|
94
|
-
// Copy the text inside the text field
|
95
|
-
navigator.clipboard.writeText(text);
|
96
|
-
}
|
97
|
-
</script>
|
47
|
+
3. Include `dictionaries/list.html` into index page to show a list of available dictionaries:
|
48
|
+
|
49
|
+
```html
|
50
|
+
{% include dictionaries/list.html %}
|
98
51
|
```
|
99
52
|
|
100
|
-
|
53
|
+
4. (OPTIONAL) Also it's possible to change layout and permalink of dictionary pages on site's `_config.yml`:
|
101
54
|
|
102
55
|
```yml
|
103
|
-
plugins:
|
104
|
-
- jekyll-dictionaries
|
105
|
-
|
106
56
|
dictionaries:
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
57
|
+
pages:
|
58
|
+
dictionary:
|
59
|
+
layout: dictionary
|
60
|
+
permalink: dictionaries/:name
|
61
|
+
dictionary_api:
|
62
|
+
layout: dictionary_api
|
63
|
+
permalink: api/dictionaries/:name.json
|
113
64
|
```
|
114
65
|
|
115
|
-
## Usage
|
116
|
-
|
117
|
-
The plugin will automatically generate dictionary and dictionary api pages for all dictionaries located into folder `_data/dictionaries` of jekyll project.
|
118
|
-
|
119
66
|
## Dictionaries Structure
|
120
67
|
|
121
68
|
The dictionaries in this project have a specific structure that consists of the following components:
|
@@ -332,7 +279,7 @@ _data/dictionaries/single/unit1/numbers.json
|
|
332
279
|
The plugin will generate JSON API **/api/dictionaries/single.json**
|
333
280
|
|
334
281
|
```json
|
335
|
-
{"
|
282
|
+
{"docUrl":"http://example.org/dictionaries/single","version":"1.0.0","name":"Basic (One Language)","translationType":"single","learning":"es","data":[{"name":"Greetings","type":"collection","data":[{"learning":"¡Hola!","primary":"Hello!"}]},{"type":"folder","name":"unit1","data":[{"name":"numbers","type":"collection","data":[{"primary":"one","learning":"uno"},{"primary":"two","learning":"dos"},{"primary":"three","learning":"tres"},{"primary":"four","learning":"cuatro"},{"primary":"five","learning":"cinco"},{"primary":"six","elearnings":"seis"},{"primary":"seven","learning":"siete"},{"primary":"eight","learning":"ocho"},{"primary":"nine","learning":"nueve"},{"primary":"ten","learning":"diez"}]}]}]}
|
336
283
|
```
|
337
284
|
|
338
285
|
### 2. Multiple Translations Dictionary Example
|
@@ -473,11 +420,19 @@ _data/dictionaries/multiple/unit1/numbers.json
|
|
473
420
|
The plugin will generate JSON API **/api/dictionaries/multiple.json**
|
474
421
|
|
475
422
|
```json
|
476
|
-
{"
|
423
|
+
{"docUrl":"http://example.org/dictionaries/multiple","version":"1.0.0","name":"Basic (Multiple Languages)","translationType":"multiple","learning":"es","translations":["en","ru","de","fr","pt"],"data":[{"name":"Greetings","type":"collection","data":[{"learning":"¡Hola!","en":"Hello!","ru":"Привет!","de":"Hallo!","fr":"Bonjour!","pt":"Olá!"}]},{"type":"folder","name":"Unit 1","data":[{"name":"numbers","type":"collection","data":[{"learning":"uno","en":"one","ru":"один","de":"eins","fr":"un","pt":"um"},{"learning":"dos","en":"two","ru":"два","de":"zwei","fr":"deux","pt":"dois"},{"learning":"tres","en":"three","ru":"три","de":"drei","fr":"trois","pt":"três"},{"learning":"cuatro","en":"four","ru":"четыре","de":"vier","fr":"quatre","pt":"quatro"},{"learning":"cinco","en":"five","ru":"пять","de":"fünf","fr":"cinq","pt":"cinco"},{"learning":"seis","en":"six","ru":"шесть","de":"sechs","fr":"six","pt":"seis"},{"learning":"siete","en":"seven","ru":"семь","de":"sieben","fr":"sept","pt":"sete"},{"learning":"ocho","en":"eight","ru":"восемь","de":"acht","fr":"huit","pt":"oito"},{"learning":"nueve","en":"nine","ru":"девять","de":"neun","fr":"neuf","pt":"nove"},{"learning":"diez","en":"ten","ru":"десять","de":"zehn","fr":"dix","pt":"dez"}]}]}]}
|
477
424
|
```
|
478
425
|
|
479
426
|
As you can see collection `greetings` and folder `un1` have names that are defined by property `name`.
|
480
427
|
|
428
|
+
## Push New Version Commands
|
429
|
+
|
430
|
+
```bash
|
431
|
+
gem bump
|
432
|
+
gem build jekyll-dictionaries.gemspec
|
433
|
+
gem push jekyll-dictionaries-1.0.2.gem
|
434
|
+
```
|
435
|
+
|
481
436
|
## License
|
482
437
|
|
483
438
|
This project is licensed under the MIT License.
|
data/_includes/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<script>
|
2
|
+
var acc = document.getElementsByClassName("accordion");
|
3
|
+
var i;
|
4
|
+
|
5
|
+
for (i = 0; i < acc.length; i++) {
|
6
|
+
acc[i].addEventListener("click", function () {
|
7
|
+
this.classList.toggle("active");
|
8
|
+
var panel = this.nextElementSibling;
|
9
|
+
if (panel.style.display === "block") {
|
10
|
+
panel.style.display = "none";
|
11
|
+
} else {
|
12
|
+
panel.style.display = "block";
|
13
|
+
}
|
14
|
+
});
|
15
|
+
}
|
16
|
+
</script>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" integrity="sha512-z3gLpd7yknf1YoNbCzqRKc4qyor8gaKU1qmn+CShxbuBusANI9QpRohGBreCFkKxLhei6S9CQXFEbbKuqLg0DA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
2
|
+
|
3
|
+
<style>
|
4
|
+
.accordion {
|
5
|
+
background-color: #eee;
|
6
|
+
color: #444;
|
7
|
+
cursor: pointer;
|
8
|
+
padding: 18px;
|
9
|
+
width: 100%;
|
10
|
+
border: none;
|
11
|
+
text-align: left;
|
12
|
+
outline: none;
|
13
|
+
font-size: 15px;
|
14
|
+
transition: 0.4s;
|
15
|
+
margin: 5px 0;
|
16
|
+
}
|
17
|
+
.accordion.active, .accordion:hover {
|
18
|
+
background-color: #ccc;
|
19
|
+
}
|
20
|
+
.accordion-panel {
|
21
|
+
padding: 5px;
|
22
|
+
padding-right: 0;
|
23
|
+
padding-left: 0;
|
24
|
+
display: none;
|
25
|
+
background-color: white;
|
26
|
+
overflow: hidden;
|
27
|
+
}
|
28
|
+
.accordion-panel.folder-container {
|
29
|
+
padding-left: 10px;
|
30
|
+
}
|
31
|
+
.accordion-icon {
|
32
|
+
margin-right: 10px;
|
33
|
+
}
|
34
|
+
.dictionary-list .list-header {
|
35
|
+
margin-bottom: 20px;
|
36
|
+
}
|
37
|
+
</style>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="dictionary-list">
|
2
|
+
<h2 class="list-header">Dictionary APIs</h2>
|
3
|
+
{% assign dictPages = site.pages | where_exp: "item", "item.scope == 'dictionary'" %}
|
4
|
+
{% if dictPages.size > 0 %}
|
5
|
+
<ul>
|
6
|
+
{% for page in dictPages %}
|
7
|
+
<li>
|
8
|
+
<a href="{{ page.url | relative_url }}" target="blank">{{ page.name | escape }}</a>
|
9
|
+
</li>
|
10
|
+
{% endfor %}
|
11
|
+
</ul>
|
12
|
+
{% endif %}
|
13
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<table>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Learning</th>
|
5
|
+
{% for translation in include.translations %}
|
6
|
+
<th>{{ translation }}</th>
|
7
|
+
{% endfor %}
|
8
|
+
</tr>
|
9
|
+
</thead>
|
10
|
+
<tbody>
|
11
|
+
{% for item in include.items %}
|
12
|
+
<tr>
|
13
|
+
<td>
|
14
|
+
{% include dictionaries/collectionItem.html value=item.learning note=item.notes.learning %}
|
15
|
+
</td>
|
16
|
+
{% for translation in include.translations %}
|
17
|
+
{% assign value = item[translation] %}
|
18
|
+
{% assign note = item.notes[translation] %}
|
19
|
+
<td>{% include dictionaries/collectionItem.html value=value note=note %}</td>
|
20
|
+
{% endfor %}
|
21
|
+
</tr>
|
22
|
+
{% endfor %}
|
23
|
+
</tbody>
|
24
|
+
</table>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{% for item in include.items %}
|
2
|
+
|
3
|
+
{% include dictionaries/collectionName.html item=item %}
|
4
|
+
|
5
|
+
<div class="accordion-panel {{ item.type }}-container">
|
6
|
+
{% case item.type %}
|
7
|
+
{% when "folder" %}
|
8
|
+
{% include dictionaries/multiple/container.html items=item.data translations=include.translations %}
|
9
|
+
{% when "collection" %}
|
10
|
+
{% include dictionaries/multiple/collection.html items=item.data translations=include.translations %}
|
11
|
+
{% endcase %}
|
12
|
+
</div>
|
13
|
+
{% endfor %}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<table>
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<th>Learning</th>
|
5
|
+
<th>Primary</th>
|
6
|
+
</tr>
|
7
|
+
</thead>
|
8
|
+
<tbody>
|
9
|
+
{% for item in include.items %}
|
10
|
+
<tr>
|
11
|
+
<td>
|
12
|
+
{% include dictionaries/collectionItem.html value=item.learning note=item.notes.learning %}
|
13
|
+
</td>
|
14
|
+
<td>
|
15
|
+
{% include dictionaries/collectionItem.html value=item.primary note=item.notes.primary %}
|
16
|
+
</td>
|
17
|
+
</tr>
|
18
|
+
{% endfor %}
|
19
|
+
</tbody>
|
20
|
+
</table>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{% for item in include.items %}
|
2
|
+
|
3
|
+
{% include dictionaries/collectionName.html item=item %}
|
4
|
+
|
5
|
+
<div class="accordion-panel {{ item.type }}-container">
|
6
|
+
{% case item.type %}
|
7
|
+
{% when "folder" %}
|
8
|
+
{% include dictionaries/single/container.html items=item.data %}
|
9
|
+
{% when "collection" %}
|
10
|
+
{% include dictionaries/single/collection.html items=item.data %}
|
11
|
+
{% endcase %}
|
12
|
+
</div>
|
13
|
+
{% endfor %}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
---
|
2
|
+
layout: page
|
3
|
+
---
|
4
|
+
|
5
|
+
<h1>Info</h1>
|
6
|
+
<table>
|
7
|
+
<tbody>
|
8
|
+
<tr>
|
9
|
+
<th>Name</th>
|
10
|
+
<td>{{ page.content.name }}</td>
|
11
|
+
</tr>
|
12
|
+
<tr>
|
13
|
+
<th>Version</th>
|
14
|
+
<td>{{ page.content.version }}</td>
|
15
|
+
</tr>
|
16
|
+
<tr>
|
17
|
+
<th>Learning</th>
|
18
|
+
<td>{{ page.content.learning }}</td>
|
19
|
+
</tr>
|
20
|
+
|
21
|
+
<tr>
|
22
|
+
<th>Translation Type</th>
|
23
|
+
<td>{{ page.content.translationType }}</td>
|
24
|
+
</tr>
|
25
|
+
|
26
|
+
{% if page.content.translationType == 'multiple' %}
|
27
|
+
|
28
|
+
<tr>
|
29
|
+
<th>Translations</th>
|
30
|
+
<td>{{ page.content.translations | join: ', ' }}</td>
|
31
|
+
</tr>
|
32
|
+
{% endif %}
|
33
|
+
|
34
|
+
{% assign apiPage = page.related_page %}
|
35
|
+
|
36
|
+
{% if apiPage %}
|
37
|
+
|
38
|
+
<tr>
|
39
|
+
<th> <a href="{{ apiPage.url | relative_url }}" target="_blank">API LINK</a> </th>
|
40
|
+
<td>
|
41
|
+
<button onclick="copyToClipboard('{{ apiPage.url | absolute_url }}')">Copy to Clipboard</button>
|
42
|
+
</td>
|
43
|
+
</tr>
|
44
|
+
{% endif %}
|
45
|
+
|
46
|
+
|
47
|
+
</tbody>
|
48
|
+
</table>
|
49
|
+
|
50
|
+
{% if page.content.translationType == 'single' %}
|
51
|
+
{% include dictionaries/single/container.html items=page.content.data prefix='dict-level' %}
|
52
|
+
{% else %}
|
53
|
+
{% include dictionaries/multiple/container.html items=page.content.data translations=page.content.translations prefix='dict-level' %}
|
54
|
+
{% endif %}
|
55
|
+
|
56
|
+
{% include dictionaries/accordion.html %}
|
57
|
+
|
58
|
+
<script>
|
59
|
+
function copyToClipboard(text) {
|
60
|
+
// Copy the text inside the text field
|
61
|
+
navigator.clipboard.writeText(text);
|
62
|
+
}
|
63
|
+
</script>
|
data/jekyll-dictionaries.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["hinkoulabs"]
|
9
9
|
spec.email = ["siarhei.hinkou@hinkoulabs.com"]
|
10
10
|
|
11
|
-
spec.summary = "A Jekyll plugin to generate JSON dictionaries for language learning applications"
|
11
|
+
spec.summary = "A Jekyll theme plugin to generate JSON dictionaries for language learning applications"
|
12
12
|
spec.homepage = "https://github.com/hinkoulabs/jekyll-dictionaries"
|
13
13
|
spec.license = "MIT"
|
14
14
|
spec.required_ruby_version = ">= 2.6.0"
|
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
31
|
spec.add_development_dependency 'rspec'
|
32
|
+
spec.add_development_dependency 'minima', '~> 2.5'
|
32
33
|
end
|
@@ -1,73 +1,53 @@
|
|
1
|
-
require_relative '
|
2
|
-
require_relative '
|
1
|
+
require_relative 'pages/dictionary'
|
2
|
+
require_relative 'pages/dictionary_api'
|
3
|
+
|
4
|
+
require_relative 'generators/dictionaries'
|
5
|
+
require_relative 'generators/theme'
|
3
6
|
|
4
7
|
module JekyllDictionaries
|
5
8
|
class Generator < Jekyll::Generator
|
6
|
-
|
9
|
+
CONFIG = {
|
10
|
+
'pages' => {
|
11
|
+
'dictionary' => {
|
12
|
+
'layout' => 'dictionary',
|
13
|
+
'permalink' => 'dictionaries/:name'
|
14
|
+
},
|
15
|
+
'dictionary_api' => {
|
16
|
+
'layout' => 'dictionary_api',
|
17
|
+
'permalink' => 'api/dictionaries/:name.json'
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
7
21
|
|
8
22
|
safe true
|
9
23
|
|
10
24
|
def generate(site)
|
11
25
|
@site = site
|
12
|
-
dicts = site.data['dictionaries'].inject([]) do |memo, (k, v)|
|
13
|
-
# dictionary start with _
|
14
|
-
m = k.match(DICT_REGEX)
|
15
|
-
if m
|
16
|
-
dict = v.merge(data: [])
|
17
|
-
|
18
|
-
name = m[1]
|
19
|
-
|
20
|
-
folder = site.data['dictionaries'][name]
|
21
|
-
|
22
|
-
if (folder)
|
23
|
-
dict[:data] = build_collections(folder)
|
24
|
-
end
|
25
26
|
|
26
|
-
|
27
|
-
end
|
28
|
-
memo
|
29
|
-
end
|
30
|
-
|
31
|
-
dicts.each do |dict|
|
32
|
-
api_page = DictionaryApiPage.new(site, dict, config)
|
33
|
-
doc_page = DictionaryPage.new(site, dict, config)
|
27
|
+
Generators::Theme.new(site).generate
|
34
28
|
|
35
|
-
|
36
|
-
doc_page.related_page = api_page
|
29
|
+
dictionaries = Generators::Dictionaries.new(site).generate
|
37
30
|
|
38
|
-
|
39
|
-
|
31
|
+
dictionaries.each do |dictionary|
|
32
|
+
build_dictionary_pages(dictionary)
|
40
33
|
end
|
41
34
|
end
|
42
35
|
|
43
36
|
protected
|
44
37
|
|
45
38
|
def config
|
46
|
-
@config ||= @site.config["dictionaries"] || {}
|
39
|
+
@config ||= Jekyll::Utils.deep_merge_hashes(CONFIG, @site.config["dictionaries"] || {})
|
47
40
|
end
|
48
41
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
# collection is detected
|
53
|
-
if (v['type'] == 'collection')
|
54
|
-
# set k as title if title is missing
|
55
|
-
memo << { name: v['name'] || k }.merge(v)
|
56
|
-
else
|
57
|
-
metadata = v['_metadata']
|
58
|
-
# folder is detected
|
59
|
-
memo
|
60
|
-
folder = {
|
61
|
-
type: 'folder',
|
62
|
-
name: metadata ? metadata['name'] : k,
|
63
|
-
data: build_collections(v.select { |kk, _| kk != '_metadata' })
|
64
|
-
}
|
65
|
-
memo << folder
|
66
|
-
end
|
67
|
-
end
|
42
|
+
def build_dictionary_pages(dictionary)
|
43
|
+
api_page = Pages::DictionaryApi.new(@site, dictionary, config['pages']['dictionary_api'])
|
44
|
+
doc_page = Pages::Dictionary.new(@site, dictionary, config['pages']['dictionary'])
|
68
45
|
|
69
|
-
|
70
|
-
|
46
|
+
api_page.related_page = doc_page
|
47
|
+
doc_page.related_page = api_page
|
48
|
+
|
49
|
+
@site.pages << api_page
|
50
|
+
@site.pages << doc_page
|
71
51
|
end
|
72
52
|
end
|
73
53
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module JekyllDictionaries
|
2
|
+
module Generators
|
3
|
+
class Dictionaries
|
4
|
+
DICT_REGEX = /^_(.*)/
|
5
|
+
|
6
|
+
def initialize(site)
|
7
|
+
@site = site
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate
|
11
|
+
build_dictionaries_from_data
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def build_dictionaries_from_data
|
17
|
+
@site.data['dictionaries'].inject([]) do |memo, (k, v)|
|
18
|
+
# dictionary start with _
|
19
|
+
m = k.match(DICT_REGEX)
|
20
|
+
if m
|
21
|
+
dict = v.merge('data' => [])
|
22
|
+
|
23
|
+
name = m[1]
|
24
|
+
|
25
|
+
folder = @site.data['dictionaries'][name]
|
26
|
+
|
27
|
+
if (folder)
|
28
|
+
dict['data'] = build_collections(folder)
|
29
|
+
end
|
30
|
+
|
31
|
+
memo << OpenStruct.new(filename: name, content: dict)
|
32
|
+
end
|
33
|
+
memo
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_collections(folder_content)
|
38
|
+
folder_content.inject([]) do |memo, (k, v)|
|
39
|
+
if v.is_a?(Hash)
|
40
|
+
# collection is detected
|
41
|
+
if (v['type'] == 'collection')
|
42
|
+
# set k as title if title is missing
|
43
|
+
memo << { 'name' => v['name'] || k }.merge(v)
|
44
|
+
else
|
45
|
+
metadata = v['_metadata']
|
46
|
+
# folder is detected
|
47
|
+
memo
|
48
|
+
folder = {
|
49
|
+
'type' => 'folder',
|
50
|
+
'name' => metadata ? metadata['name'] : k,
|
51
|
+
'data' => build_collections(v.select { |kk, _| kk != '_metadata' })
|
52
|
+
}
|
53
|
+
memo << folder
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
memo
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
3
|
+
module JekyllDictionaries
|
4
|
+
module Generators
|
5
|
+
class Theme
|
6
|
+
attr_reader :site, :theme
|
7
|
+
def initialize(site)
|
8
|
+
@site = site
|
9
|
+
end
|
10
|
+
|
11
|
+
def generate
|
12
|
+
add_includes
|
13
|
+
add_layouts
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def theme
|
19
|
+
@theme ||= Jekyll::Theme.new("jekyll-dictionaries")
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_includes
|
23
|
+
@site.includes_load_paths << theme.includes_path
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_layouts
|
27
|
+
layouts_path = theme.layouts_path
|
28
|
+
wrap_custom_theme do
|
29
|
+
entries_in(layouts_path).each do |layout_file|
|
30
|
+
@site.layouts[theme_file_name(layout_file)] ||= Jekyll::Layout.new(@site, layouts_path, layout_file)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def wrap_custom_theme
|
36
|
+
site_theme = @site.theme
|
37
|
+
@site.theme = theme
|
38
|
+
yield
|
39
|
+
@site.theme = site_theme
|
40
|
+
end
|
41
|
+
|
42
|
+
def entries_in(dir)
|
43
|
+
entries = []
|
44
|
+
within(dir) do
|
45
|
+
entries = Jekyll::EntryFilter.new(@site).filter(Dir["**/*.*"])
|
46
|
+
end
|
47
|
+
entries
|
48
|
+
end
|
49
|
+
|
50
|
+
def within(directory)
|
51
|
+
return unless File.exist?(directory)
|
52
|
+
|
53
|
+
Dir.chdir(directory) { yield }
|
54
|
+
end
|
55
|
+
|
56
|
+
def theme_file_name(file)
|
57
|
+
file.split(".")[0..-2].join(".")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module JekyllDictionaries
|
2
|
+
module Pages
|
3
|
+
class Dictionary < Jekyll::Page
|
4
|
+
attr_accessor :type
|
5
|
+
attr_reader :related_page
|
6
|
+
|
7
|
+
def initialize(site, dic, default_opts)
|
8
|
+
@site = site # the current site instance.
|
9
|
+
@base = site.source # path to the source directory.
|
10
|
+
@dir = dic.filename # the directory the page will reside in.
|
11
|
+
|
12
|
+
add_scope_data
|
13
|
+
|
14
|
+
# All pages have the same filename, so define attributes straight away.
|
15
|
+
@basename = dic.filename # filename without the extension.
|
16
|
+
@name = dic.content['name'] || dic.filename # basically @basename + @ext.
|
17
|
+
|
18
|
+
# Initialize data hash with a key pointing to all posts under current category.
|
19
|
+
# This allows accessing the list in a template via `page.linked_docs`.
|
20
|
+
@data = {
|
21
|
+
'content' => dic.content,
|
22
|
+
'scope' => @type
|
23
|
+
}
|
24
|
+
|
25
|
+
# Look up front matter defaults scoped to type `dictionary`, if given key
|
26
|
+
# doesn't exist in the `data` hash.
|
27
|
+
data.default_proc = proc do |_, key|
|
28
|
+
(default_opts || {})[key]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def related_page=(page)
|
33
|
+
@related_page = page
|
34
|
+
@data['related_page'] = @related_page
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_scope_data
|
38
|
+
@type = :dictionary
|
39
|
+
@ext = '.html'
|
40
|
+
end
|
41
|
+
|
42
|
+
# Placeholders that are used in constructing page URL.
|
43
|
+
def url_placeholders
|
44
|
+
{
|
45
|
+
:path => @dir,
|
46
|
+
:name => @dir,
|
47
|
+
:basename => basename,
|
48
|
+
:output_ext => output_ext,
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/jekyll-dictionaries.rb
CHANGED
@@ -4,9 +4,6 @@ require "jekyll"
|
|
4
4
|
require "jekyll-dictionaries/generator"
|
5
5
|
|
6
6
|
module JekyllDictionaries
|
7
|
-
autoload :DictionaryPage, "jekyll-dictionaries/dictionary_page.rb"
|
8
|
-
autoload :DictionaryApiPage, "jekyll-dictionaries/dictionary_api_page.rb"
|
9
|
-
|
10
7
|
def self.root
|
11
8
|
File.dirname __dir__
|
12
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-dictionaries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hinkoulabs
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minima
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.5'
|
27
41
|
description:
|
28
42
|
email:
|
29
43
|
- siarhei.hinkou@hinkoulabs.com
|
@@ -44,11 +58,25 @@ files:
|
|
44
58
|
- LICENSE.txt
|
45
59
|
- README.md
|
46
60
|
- Rakefile
|
61
|
+
- _includes/.DS_Store
|
62
|
+
- _includes/dictionaries/accordion.html
|
63
|
+
- _includes/dictionaries/collectionItem.html
|
64
|
+
- _includes/dictionaries/collectionName.html
|
65
|
+
- _includes/dictionaries/head.html
|
66
|
+
- _includes/dictionaries/list.html
|
67
|
+
- _includes/dictionaries/multiple/collection.html
|
68
|
+
- _includes/dictionaries/multiple/container.html
|
69
|
+
- _includes/dictionaries/single/collection.html
|
70
|
+
- _includes/dictionaries/single/container.html
|
71
|
+
- _layouts/dictionary.html
|
72
|
+
- _layouts/dictionary_api.json
|
47
73
|
- jekyll-dictionaries.gemspec
|
48
74
|
- lib/jekyll-dictionaries.rb
|
49
|
-
- lib/jekyll-dictionaries/dictionary_api_page.rb
|
50
|
-
- lib/jekyll-dictionaries/dictionary_page.rb
|
51
75
|
- lib/jekyll-dictionaries/generator.rb
|
76
|
+
- lib/jekyll-dictionaries/generators/dictionaries.rb
|
77
|
+
- lib/jekyll-dictionaries/generators/theme.rb
|
78
|
+
- lib/jekyll-dictionaries/pages/dictionary.rb
|
79
|
+
- lib/jekyll-dictionaries/pages/dictionary_api.rb
|
52
80
|
- lib/jekyll-dictionaries/version.rb
|
53
81
|
homepage: https://github.com/hinkoulabs/jekyll-dictionaries
|
54
82
|
licenses:
|
@@ -73,5 +101,6 @@ requirements: []
|
|
73
101
|
rubygems_version: 3.2.32
|
74
102
|
signing_key:
|
75
103
|
specification_version: 4
|
76
|
-
summary: A Jekyll plugin to generate JSON dictionaries for language learning
|
104
|
+
summary: A Jekyll theme plugin to generate JSON dictionaries for language learning
|
105
|
+
applications
|
77
106
|
test_files: []
|
@@ -1,51 +0,0 @@
|
|
1
|
-
module JekyllDictionaries
|
2
|
-
class DictionaryPage < Jekyll::Page
|
3
|
-
attr_accessor :type
|
4
|
-
attr_reader :related_page
|
5
|
-
|
6
|
-
def initialize(site, dic, default_opts)
|
7
|
-
@site = site # the current site instance.
|
8
|
-
@base = site.source # path to the source directory.
|
9
|
-
@dir = dic.filename # the directory the page will reside in.
|
10
|
-
|
11
|
-
add_scope_data
|
12
|
-
|
13
|
-
# All pages have the same filename, so define attributes straight away.
|
14
|
-
@basename = dic.filename # filename without the extension.
|
15
|
-
@name = dic.content['name'] || dic.filename # basically @basename + @ext.
|
16
|
-
|
17
|
-
# Initialize data hash with a key pointing to all posts under current category.
|
18
|
-
# This allows accessing the list in a template via `page.linked_docs`.
|
19
|
-
@data = {
|
20
|
-
'content' => dic.content,
|
21
|
-
'scope' => @type
|
22
|
-
}
|
23
|
-
|
24
|
-
# Look up front matter defaults scoped to type `dictionary`, if given key
|
25
|
-
# doesn't exist in the `data` hash.
|
26
|
-
data.default_proc = proc do |_, key|
|
27
|
-
(default_opts[@type.to_s] || {})[key]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def related_page=(page)
|
32
|
-
@related_page = page
|
33
|
-
@data['related_page'] = @related_page
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_scope_data
|
37
|
-
@type = :dictionary
|
38
|
-
@ext = '.html'
|
39
|
-
end
|
40
|
-
|
41
|
-
# Placeholders that are used in constructing page URL.
|
42
|
-
def url_placeholders
|
43
|
-
{
|
44
|
-
:path => @dir,
|
45
|
-
:name => @dir,
|
46
|
-
:basename => basename,
|
47
|
-
:output_ext => output_ext,
|
48
|
-
}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|