jekyll-zettel 0.5.0 → 0.6.1
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/stubs/glosse.md +22 -0
- data/lib/jekyll/stubs/{index.md → zettel.md} +1 -1
- data/lib/jekyll/zettel/globals.rb +3 -3
- 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 +60 -3
- metadata +8 -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: 2b04c909f6875c77d95d63e4870a2b4a9916249bb881bf602f709a9ff4aca381
|
4
|
+
data.tar.gz: e6edd7dc79d77bef7263be87e24b2c90af28ddfc0ae7270a70e63e9b1cc6fc72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb40a4449183978303653da1c54f8412ea4a3d7ec3664a7da420ea46b031fcfebf87a5bef7c40383337028bf5dc6f1a183a8d681888df4b30bbc2ab1c1a5dd0a
|
7
|
+
data.tar.gz: 6cdc3f9417565c49574eaf9cf3759192fa2fafebabe9551b00a33c14d2222179dcf73d41032d05cd5a17f97403b92e957be3303b58e3cdf78dc5ab68d42951d7
|
@@ -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
|
@@ -3,13 +3,13 @@ module Jekyll
|
|
3
3
|
# Enrich site variables with some meta data
|
4
4
|
class Globals < Jekyll::Generator
|
5
5
|
|
6
|
-
priority :
|
6
|
+
priority :lowest
|
7
7
|
|
8
8
|
def generate(site)
|
9
|
-
site.data['
|
9
|
+
site.data['url_page'] = {}
|
10
10
|
|
11
11
|
site.pages.each do |page|
|
12
|
-
site.data['
|
12
|
+
site.data['url_page'][page.url] = page
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -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,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 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/
|
36
|
-
require 'jekyll/zettel/
|
89
|
+
require 'jekyll/commands/scaffold'
|
90
|
+
require 'jekyll/zettel/globals'
|
91
|
+
require 'jekyll/zettel/glosse'
|
37
92
|
require 'jekyll/zettel/reference'
|
38
|
-
require 'jekyll/zettel/
|
93
|
+
require 'jekyll/zettel/references'
|
39
94
|
require 'jekyll/zettel/tags'
|
95
|
+
require 'jekyll/zettel/timeline'
|
96
|
+
require 'jekyll/zettel/zettel'
|
40
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.1
|
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,15 +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
|
111
113
|
- lib/jekyll/zettel/globals.rb
|
114
|
+
- lib/jekyll/zettel/glosse.rb
|
112
115
|
- lib/jekyll/zettel/reference.rb
|
113
116
|
- lib/jekyll/zettel/references.rb
|
114
117
|
- lib/jekyll/zettel/tags.rb
|
115
118
|
- lib/jekyll/zettel/timeline.rb
|
116
119
|
- lib/jekyll/zettel/version.rb
|
120
|
+
- lib/jekyll/zettel/zettel.rb
|
117
121
|
- lib/jekyll/zettel/zettelkasten.rb
|
118
122
|
homepage: https://michaelgerzabek.com/gems/jekyll-zettel
|
119
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
|