jekyll-zettel 0.4.3 → 0.6.0
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 +30 -0
- data/lib/jekyll/stubs/glosse.md +22 -0
- data/lib/jekyll/stubs/{index.md → zettel.md} +3 -1
- data/lib/jekyll/zettel/globals.rb +18 -0
- data/lib/jekyll/zettel/glosse.rb +22 -0
- data/lib/jekyll/zettel/version.rb +1 -1
- data/lib/jekyll/zettel/zettel.rb +28 -0
- data/lib/jekyll/zettel.rb +58 -1
- metadata +9 -4
- data/lib/jekyll/commands/zettel.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12c74e815bb55368376966e3efc0a84ef0635c0ee8d66cf02cded71b02c06f45
|
4
|
+
data.tar.gz: 24da14c57cb4a4105b5f6683613115635c67e96731e2936d893f39b0bbcdf1cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60e2815612ca85eae9dab3aa0c351e5086f2e221889884e14b3f1da70a953a8523c90064af774f6b9e18681fb3372b75fc479fbf09a2c9820c903e269459e833
|
7
|
+
data.tar.gz: 6c12f7259736d3ac70a07f207004a17558966fd9e6479829b7fceeffaf9b84f3254d74bdb5b6644602b965f3187da95ca28f1863c62906ca9320b3b51e288c35
|
@@ -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,30 @@
|
|
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
|
+
page_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
|
+
---
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
layout: glosse
|
3
|
+
#
|
4
|
+
# created_at: #{Time.now}
|
5
|
+
#
|
6
|
+
# Die ID der Glosse entspricht dem Namen des Unterverzeichnisses.
|
7
|
+
# Dieser Wert darf auf keinen Fall geändert werden!
|
8
|
+
#
|
9
|
+
glosse: #{args['slug']}
|
10
|
+
#
|
11
|
+
# Die Dokumentation aller Properties findest du unter
|
12
|
+
# https://jessas.org/projekt/dokumentation/glosse/#frontmatter
|
13
|
+
#
|
14
|
+
title: #{args['title']}
|
15
|
+
description:
|
16
|
+
author:
|
17
|
+
#
|
18
|
+
# Optionale Properties
|
19
|
+
#
|
20
|
+
# tags: []
|
21
|
+
# image:
|
22
|
+
---
|
@@ -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
|
-
zettel: #{uuid}
|
9
|
+
zettel: #{args['uuid']}
|
10
10
|
#
|
11
11
|
# Die Dokumentation aller Properties findest du unter
|
12
12
|
# https://jessas.org/projekt/dokumentation/zettel/#frontmatter
|
@@ -17,10 +17,12 @@ author:
|
|
17
17
|
#
|
18
18
|
# Optionale Properties
|
19
19
|
#
|
20
|
+
# akteure: []
|
20
21
|
# tags: []
|
21
22
|
# folgezettel: []
|
22
23
|
# image:
|
23
24
|
# via:
|
24
25
|
# text:
|
25
26
|
# href:
|
27
|
+
# annotation:
|
26
28
|
---
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Zettel
|
3
|
+
# Enrich site variables with some meta data
|
4
|
+
class Globals < Jekyll::Generator
|
5
|
+
|
6
|
+
priority :lowest
|
7
|
+
|
8
|
+
def generate(site)
|
9
|
+
site.data['url_page'] = {}
|
10
|
+
|
11
|
+
site.pages.each do |page|
|
12
|
+
site.data['url_page'][page.url] = page
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -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
|
@@ -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,12 +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 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 args_empty?(args)
|
80
|
+
return false unless args.empty?
|
81
|
+
|
82
|
+
Jekyll.logger.error Jekyll::Zettel::LOG_KEY, 'Missing argument slug'
|
83
|
+
Jekyll.logger.info Jekyll::Zettel::LOG_KEY, 'usage: jekyll scaffold --glosse <slug>'
|
84
|
+
true
|
85
|
+
end
|
32
86
|
end
|
33
87
|
end
|
34
88
|
|
35
|
-
require 'jekyll/
|
89
|
+
require 'jekyll/zettel/globals'
|
36
90
|
require 'jekyll/zettel/references'
|
37
91
|
require 'jekyll/zettel/reference'
|
38
92
|
require 'jekyll/zettel/timeline'
|
39
93
|
require 'jekyll/zettel/tags'
|
40
94
|
require 'jekyll/zettel/zettelkasten'
|
95
|
+
require 'jekyll/commands/scaffold'
|
96
|
+
require 'jekyll/zettel/glosse'
|
97
|
+
require 'jekyll/zettel/zettel'
|
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.0
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citeproc-ruby
|
@@ -105,14 +105,19 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
107
|
- jekyll-zettel.gemspec
|
108
|
-
- lib/jekyll/commands/
|
109
|
-
- lib/jekyll/stubs/
|
108
|
+
- lib/jekyll/commands/scaffold.rb
|
109
|
+
- lib/jekyll/stubs/blatt.md
|
110
|
+
- lib/jekyll/stubs/glosse.md
|
111
|
+
- lib/jekyll/stubs/zettel.md
|
110
112
|
- lib/jekyll/zettel.rb
|
113
|
+
- lib/jekyll/zettel/globals.rb
|
114
|
+
- lib/jekyll/zettel/glosse.rb
|
111
115
|
- lib/jekyll/zettel/reference.rb
|
112
116
|
- lib/jekyll/zettel/references.rb
|
113
117
|
- lib/jekyll/zettel/tags.rb
|
114
118
|
- lib/jekyll/zettel/timeline.rb
|
115
119
|
- lib/jekyll/zettel/version.rb
|
120
|
+
- lib/jekyll/zettel/zettel.rb
|
116
121
|
- lib/jekyll/zettel/zettelkasten.rb
|
117
122
|
homepage: https://michaelgerzabek.com/gems/jekyll-zettel
|
118
123
|
licenses:
|
@@ -1,47 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
module Commands
|
3
|
-
# Jekyll subcommand <zettel>
|
4
|
-
class Zettel < Command
|
5
|
-
class << self
|
6
|
-
|
7
|
-
def init_with_program(prog)
|
8
|
-
prog.command(:zettel) do |c|
|
9
|
-
c.syntax 'zettel'
|
10
|
-
c.description 'Creates a new Zettel within subdir zettel'
|
11
|
-
c.action do |_args, _options|
|
12
|
-
uuid = new_zettel
|
13
|
-
file = "zettel/#{uuid}/index.md"
|
14
|
-
new_page(uuid, file)
|
15
|
-
|
16
|
-
Jekyll.logger.info '✓', "Created new Zettel with UUID: `#{uuid}`"
|
17
|
-
system("code #{File.expand_path(file)}")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def new_zettel
|
23
|
-
uuid = SecureRandom.uuid
|
24
|
-
dir = "zettel/#{uuid}"
|
25
|
-
return new_zettel if File.directory?(dir)
|
26
|
-
|
27
|
-
FileUtils.mkdir_p(dir)
|
28
|
-
uuid
|
29
|
-
end
|
30
|
-
|
31
|
-
def new_page(uuid, file)
|
32
|
-
File.open(file, 'w') { |out|
|
33
|
-
out.write evaluate_template(uuid, 'index.md')
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
# rubocop:disable Style/EvalWithLocation, Security/Eval, Lint/UnusedMethodArgument
|
38
|
-
def evaluate_template(uuid, file)
|
39
|
-
template = File.read(File.expand_path("../stubs/#{file}", __dir__))
|
40
|
-
eval("\"#{template}\"")
|
41
|
-
end
|
42
|
-
# rubocop:enable Style/EvalWithLocation, Security/Eval, Lint/UnusedMethodArgument
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|