jekyll-zettel 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/commands/scaffold.rb +51 -0
- data/lib/jekyll/stubs/blatt.md +30 -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 +57 -1
- 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: 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
|
+
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,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 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/commands/zettel'
|
36
89
|
require 'jekyll/zettel/globals'
|
37
90
|
require 'jekyll/zettel/references'
|
38
91
|
require 'jekyll/zettel/reference'
|
39
92
|
require 'jekyll/zettel/timeline'
|
40
93
|
require 'jekyll/zettel/tags'
|
41
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,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
|