jekyll-zettel 0.5.3 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll/commands/scaffold.rb +51 -0
- data/lib/jekyll/stubs/blatt.md +35 -0
- data/lib/jekyll/stubs/glosse.md +8 -2
- data/lib/jekyll/stubs/zettel.md +6 -1
- data/lib/jekyll/zettel/glosse.rb +22 -0
- data/lib/jekyll/zettel/references.rb +1 -1
- data/lib/jekyll/zettel/tags.rb +1 -1
- data/lib/jekyll/zettel/version.rb +1 -1
- data/lib/jekyll/zettel/zettel.rb +28 -0
- data/lib/jekyll/zettel/zettelkasten.rb +1 -1
- data/lib/jekyll/zettel.rb +59 -3
- metadata +6 -3
- data/lib/jekyll/commands/zettel.rb +0 -110
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51a5c32e36a7b3917ba21eb4962a0778185d661ea7696e4f091814cf77e3227b
|
4
|
+
data.tar.gz: 57fd94df848c4efcbd98a575ff2c1bf9ee0267b4d087d078ff46aeb8d0cc21c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91bc3e64237d83ac01516fc1dbc639bc4bff1346adee7d139c428fc39b357c9f73b36c7f4ba636d4bb9b78c6aca06dff906af9b07355f2f8ffb2510091e1153d
|
7
|
+
data.tar.gz: e5fff6f734ce34f308d673a9861492f5c04d97824e47bde23503b57b1d571a6d3f7af5f89bc11ac3bd66c24a1421ecc4dbd4e918297e18d025d922a3b3b0b706
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Commands
|
3
|
+
# Jekyll subcommand <scaffold>
|
4
|
+
class Scaffold < Command
|
5
|
+
class << self
|
6
|
+
|
7
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
8
|
+
def init_with_program(prog)
|
9
|
+
prog.command(:scaffold) do |c|
|
10
|
+
c.syntax 'scaffold <option> [arg]'
|
11
|
+
c.description 'Create new infotype scaffold'
|
12
|
+
c.option 'akteur', '-a', '--akteur', 'scaffold a new Akteur; arg <full name> required'
|
13
|
+
c.option 'blatt', '-b', '--blatt', 'scaffold a new Arbeitsblatt; arg <title> required'
|
14
|
+
c.option 'glosse', '-g', '--glosse', 'scaffold a new Glosse; arg <title> required'
|
15
|
+
c.option 'zeitleiste', '-e', '--zeitleiste', 'scaffold a new Zeitleiste; arg <title> required'
|
16
|
+
c.option 'zettel', '-z', '--zettel', 'scaffold a new Zettel'
|
17
|
+
c.action do |args, options|
|
18
|
+
|
19
|
+
if options.empty?
|
20
|
+
Jekyll.logger.error Jekyll::Zettel::LOG_KEY, 'Missing infotype, use: jekyll scaffold <option> [arg]'
|
21
|
+
else
|
22
|
+
infotype = options.keys[0].capitalize
|
23
|
+
name = "Jekyll::Zettel::#{infotype}"
|
24
|
+
if class_exists?(name)
|
25
|
+
clazz = name.split('::').inject(Object) do |o, c|
|
26
|
+
o.const_get c
|
27
|
+
end
|
28
|
+
|
29
|
+
file = clazz.new.scaffold(args)
|
30
|
+
system("code #{File.expand_path(file)}") unless file.nil?
|
31
|
+
# puts file
|
32
|
+
else
|
33
|
+
Jekyll.logger.error Jekyll::Zettel::LOG_KEY, "Infotype `#{infotype}` not yet implemented"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
41
|
+
def class_exists?(clazz)
|
42
|
+
klass = Module.const_get(clazz)
|
43
|
+
klass.is_a?(Class)
|
44
|
+
rescue NameError
|
45
|
+
false
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
# created_at: #{Time.now}
|
3
|
+
#
|
4
|
+
# Never ever change the id of your page!
|
5
|
+
# Changing the id has manifold side effects. Most of them unwanted.
|
6
|
+
# If you want to move or rename the page do it within the realms of
|
7
|
+
# this project.
|
8
|
+
#
|
9
|
+
id: #{args['id']}
|
10
|
+
#
|
11
|
+
#
|
12
|
+
# Be careful in changing the layout of this page.
|
13
|
+
# Additional meta data may be required.
|
14
|
+
#
|
15
|
+
layout: page
|
16
|
+
#
|
17
|
+
#
|
18
|
+
# The following front-matter attributes are mandatory
|
19
|
+
#
|
20
|
+
title:
|
21
|
+
description:
|
22
|
+
#
|
23
|
+
#
|
24
|
+
# These front-matter attributes are optional, but support a nice
|
25
|
+
# look-and-feel. If you want to use them just delete the hash
|
26
|
+
# character at the beginning of the corresponding lines.
|
27
|
+
#
|
28
|
+
# kicker:
|
29
|
+
# image:
|
30
|
+
---
|
31
|
+
|
32
|
+
|
33
|
+
<!-- Fußnoten -->
|
34
|
+
|
35
|
+
<!-- Links -->
|
data/lib/jekyll/stubs/glosse.md
CHANGED
@@ -6,12 +6,13 @@ layout: glosse
|
|
6
6
|
# Die ID der Glosse entspricht dem Namen des Unterverzeichnisses.
|
7
7
|
# Dieser Wert darf auf keinen Fall geändert werden!
|
8
8
|
#
|
9
|
-
|
9
|
+
id: #{args['slug']}
|
10
|
+
tag: #{args['title']}
|
10
11
|
#
|
11
12
|
# Die Dokumentation aller Properties findest du unter
|
12
13
|
# https://jessas.org/projekt/dokumentation/glosse/#frontmatter
|
13
14
|
#
|
14
|
-
title:
|
15
|
+
title:
|
15
16
|
description:
|
16
17
|
author:
|
17
18
|
#
|
@@ -20,3 +21,8 @@ author:
|
|
20
21
|
# tags: []
|
21
22
|
# image:
|
22
23
|
---
|
24
|
+
|
25
|
+
|
26
|
+
<!-- Fußnoten -->
|
27
|
+
|
28
|
+
<!-- Links -->
|
data/lib/jekyll/stubs/zettel.md
CHANGED
@@ -6,7 +6,7 @@ layout: zettel
|
|
6
6
|
# Die UUID des Zettels entspricht dem Namen des Unterverzeichnisses.
|
7
7
|
# Dieser Wert darf auf keinen Fall geändert werden!
|
8
8
|
#
|
9
|
-
|
9
|
+
id: #{args['uuid']}
|
10
10
|
#
|
11
11
|
# Die Dokumentation aller Properties findest du unter
|
12
12
|
# https://jessas.org/projekt/dokumentation/zettel/#frontmatter
|
@@ -26,3 +26,8 @@ author:
|
|
26
26
|
# href:
|
27
27
|
# annotation:
|
28
28
|
---
|
29
|
+
|
30
|
+
|
31
|
+
<!-- Fußnoten -->
|
32
|
+
|
33
|
+
<!-- Links -->
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Zettel
|
3
|
+
# Scaffolder for infotype Glosse
|
4
|
+
class Glosse
|
5
|
+
|
6
|
+
include Jekyll::Zettel
|
7
|
+
|
8
|
+
def scaffold(args)
|
9
|
+
return nil if args_empty?(args)
|
10
|
+
|
11
|
+
slug = create_slug(args.first)
|
12
|
+
file = "glosse/#{slug}/index.md"
|
13
|
+
return file if create_dir_defensively('Glosse', slug, file).nil?
|
14
|
+
|
15
|
+
create_page({ 'slug' => slug, 'title' => args.first }, file, 'glosse.md')
|
16
|
+
|
17
|
+
Jekyll.logger.info '✓', "Created glosse with slug `#{slug}`"
|
18
|
+
file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/jekyll/zettel/tags.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Zettel
|
3
|
+
# Scaffolder for infotype Zettel
|
4
|
+
class Zettel
|
5
|
+
|
6
|
+
include Jekyll::Zettel
|
7
|
+
|
8
|
+
def scaffold(_args)
|
9
|
+
uuid = create_uuid
|
10
|
+
file = "zettel/#{uuid}/index.md"
|
11
|
+
create_page({ 'uuid' => uuid }, file, 'zettel.md')
|
12
|
+
|
13
|
+
Jekyll.logger.info '✓', "Created new Zettel with UUID `#{uuid}`"
|
14
|
+
file
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_uuid
|
18
|
+
uuid = SecureRandom.uuid
|
19
|
+
dir = "zettel/#{uuid}"
|
20
|
+
return create_uuid if File.directory?(dir)
|
21
|
+
|
22
|
+
FileUtils.mkdir_p(dir)
|
23
|
+
uuid
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/jekyll/zettel.rb
CHANGED
@@ -29,13 +29,69 @@ module Jekyll
|
|
29
29
|
|
30
30
|
@site.pages << page
|
31
31
|
end
|
32
|
+
|
33
|
+
def create_page(args, file, template)
|
34
|
+
File.open(file, 'w') { |out| out.write evaluate_template(args, template) }
|
35
|
+
# puts evaluate_template(args, template)
|
36
|
+
end
|
37
|
+
|
38
|
+
# rubocop:disable Style/EvalWithLocation, Security/Eval, Lint/UnusedMethodArgument
|
39
|
+
def evaluate_template(args, template)
|
40
|
+
string = File.read(File.expand_path("../stubs/#{template}", __FILE__))
|
41
|
+
eval("\"#{string}\"")
|
42
|
+
end
|
43
|
+
|
44
|
+
# rubocop:enable Style/EvalWithLocation, Security/Eval, Lint/UnusedMethodArgument
|
45
|
+
# rubocop: disable Layout/FirstHashElementIndentation, Metrics/MethodLength
|
46
|
+
def create_slug(title)
|
47
|
+
I18n.config.available_locales = :de
|
48
|
+
I18n.locale = :de
|
49
|
+
I18n.backend.store_translations(:de, i18n: {
|
50
|
+
transliterate: {
|
51
|
+
rule: {
|
52
|
+
'Ä' => 'Ae',
|
53
|
+
'Ö' => 'Oe',
|
54
|
+
'Ü' => 'Ue',
|
55
|
+
'ü' => 'ue',
|
56
|
+
'ö' => 'oe',
|
57
|
+
'ä' => 'ae',
|
58
|
+
'ß' => 'sz'
|
59
|
+
}
|
60
|
+
}
|
61
|
+
})
|
62
|
+
Jekyll::Utils.slugify(title, mode: 'latin')
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_dir_defensively(infotype, slug, file)
|
66
|
+
dir = File.dirname(file)
|
67
|
+
if File.directory?(dir)
|
68
|
+
if File.exist?(file)
|
69
|
+
Jekyll.logger.error LOG_KEY, "#{infotype} `#{slug}` already present"
|
70
|
+
nil
|
71
|
+
else
|
72
|
+
dir
|
73
|
+
end
|
74
|
+
else
|
75
|
+
FileUtils.mkdir_p(dir)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def args_empty?(args)
|
80
|
+
return false unless args.empty?
|
81
|
+
|
82
|
+
Jekyll.logger.error LOG_KEY, 'Missing argument slug'
|
83
|
+
Jekyll.logger.info LOG_KEY, 'usage: jekyll scaffold --glosse <slug>'
|
84
|
+
true
|
85
|
+
end
|
32
86
|
end
|
33
87
|
end
|
34
88
|
|
35
|
-
require 'jekyll/commands/
|
89
|
+
require 'jekyll/commands/scaffold'
|
36
90
|
require 'jekyll/zettel/globals'
|
37
|
-
require 'jekyll/zettel/
|
91
|
+
require 'jekyll/zettel/glosse'
|
38
92
|
require 'jekyll/zettel/reference'
|
39
|
-
require 'jekyll/zettel/
|
93
|
+
require 'jekyll/zettel/references'
|
40
94
|
require 'jekyll/zettel/tags'
|
95
|
+
require 'jekyll/zettel/timeline'
|
96
|
+
require 'jekyll/zettel/zettel'
|
41
97
|
require 'jekyll/zettel/zettelkasten'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-zettel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Gerzabek
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citeproc-ruby
|
@@ -105,16 +105,19 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
107
|
- jekyll-zettel.gemspec
|
108
|
-
- lib/jekyll/commands/
|
108
|
+
- lib/jekyll/commands/scaffold.rb
|
109
|
+
- lib/jekyll/stubs/blatt.md
|
109
110
|
- lib/jekyll/stubs/glosse.md
|
110
111
|
- lib/jekyll/stubs/zettel.md
|
111
112
|
- lib/jekyll/zettel.rb
|
112
113
|
- lib/jekyll/zettel/globals.rb
|
114
|
+
- lib/jekyll/zettel/glosse.rb
|
113
115
|
- lib/jekyll/zettel/reference.rb
|
114
116
|
- lib/jekyll/zettel/references.rb
|
115
117
|
- lib/jekyll/zettel/tags.rb
|
116
118
|
- lib/jekyll/zettel/timeline.rb
|
117
119
|
- lib/jekyll/zettel/version.rb
|
120
|
+
- lib/jekyll/zettel/zettel.rb
|
118
121
|
- lib/jekyll/zettel/zettelkasten.rb
|
119
122
|
homepage: https://michaelgerzabek.com/gems/jekyll-zettel
|
120
123
|
licenses:
|
@@ -1,110 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
module Commands
|
3
|
-
# Jekyll subcommand <zettel>
|
4
|
-
class Zettel < Command
|
5
|
-
class << self
|
6
|
-
|
7
|
-
# rubocop:disable Metrics/MethodLength
|
8
|
-
def init_with_program(prog)
|
9
|
-
prog.command(:zettel) do |c|
|
10
|
-
c.syntax 'zettel'
|
11
|
-
c.description 'Creates a new Infotype'
|
12
|
-
c.action do |args, _options|
|
13
|
-
|
14
|
-
infotype = args[0] || 'zettel'
|
15
|
-
|
16
|
-
if respond_to?("new_#{infotype}")
|
17
|
-
|
18
|
-
file = public_send("new_#{infotype}", args)
|
19
|
-
system("code #{File.expand_path(file)}") unless file.nil?
|
20
|
-
|
21
|
-
else
|
22
|
-
Jekyll.logger.error Jekyll::Zettel::LOG_KEY, "Invalid infotype #{infotype}"
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def new_glosse(args)
|
30
|
-
if args[1].nil?
|
31
|
-
Jekyll.logger.error Jekyll::Zettel::LOG_KEY, 'Missing argument slug'
|
32
|
-
Jekyll.logger.info Jekyll::Zettel::LOG_KEY, 'usage: jekyll zettel glosse <slug>'
|
33
|
-
nil
|
34
|
-
else
|
35
|
-
slug = create_slug(args[1])
|
36
|
-
file = "glosse/#{slug}/index.md"
|
37
|
-
return file if create_dir_defensively('Glosse', slug, file).nil?
|
38
|
-
|
39
|
-
create_page({ 'slug' => slug, 'title' => args[1] }, file, 'glosse.md')
|
40
|
-
|
41
|
-
Jekyll.logger.info '✓', "Created glosse with slug `#{slug}`"
|
42
|
-
file
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def create_slug(title)
|
47
|
-
I18n.config.available_locales = :de
|
48
|
-
I18n.locale = :de
|
49
|
-
I18n.backend.store_translations(:de, i18n: {
|
50
|
-
transliterate: {
|
51
|
-
rule: {
|
52
|
-
'Ä' => 'Ae',
|
53
|
-
'Ö' => 'Oe',
|
54
|
-
'Ü' => 'Ue',
|
55
|
-
'ü' => 'ue',
|
56
|
-
'ö' => 'oe',
|
57
|
-
'ä' => 'ae',
|
58
|
-
'ß' => 'sz'
|
59
|
-
}
|
60
|
-
}
|
61
|
-
})
|
62
|
-
Jekyll::Utils.slugify(title, mode: 'latin')
|
63
|
-
end
|
64
|
-
|
65
|
-
def create_dir_defensively(infotype, slug, file)
|
66
|
-
dir = File.dirname(file)
|
67
|
-
if File.directory?(dir)
|
68
|
-
if File.exist?(file)
|
69
|
-
Jekyll.logger.error Jekyll::Zettel::LOG_KEY, "#{infotype} `#{slug}` already present"
|
70
|
-
nil
|
71
|
-
else
|
72
|
-
dir
|
73
|
-
end
|
74
|
-
else
|
75
|
-
FileUtils.mkdir_p(dir)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def new_zettel(_args)
|
80
|
-
uuid = create_uuid
|
81
|
-
file = "zettel/#{uuid}/index.md"
|
82
|
-
create_page({ 'uuid' => uuid }, file, 'zettel.md')
|
83
|
-
|
84
|
-
Jekyll.logger.info '✓', "Created new Zettel with UUID `#{uuid}`"
|
85
|
-
file
|
86
|
-
end
|
87
|
-
|
88
|
-
def create_uuid
|
89
|
-
uuid = SecureRandom.uuid
|
90
|
-
dir = "zettel/#{uuid}"
|
91
|
-
return create_uuid if File.directory?(dir)
|
92
|
-
|
93
|
-
FileUtils.mkdir_p(dir)
|
94
|
-
uuid
|
95
|
-
end
|
96
|
-
|
97
|
-
def create_page(args, file, template)
|
98
|
-
File.open(file, 'w') { |out| out.write evaluate_template(args, template) }
|
99
|
-
end
|
100
|
-
|
101
|
-
# rubocop:disable Style/EvalWithLocation, Security/Eval, Lint/UnusedMethodArgument
|
102
|
-
def evaluate_template(args, template)
|
103
|
-
string = File.read(File.expand_path("../stubs/#{template}", __dir__))
|
104
|
-
eval("\"#{string}\"")
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|