Module: Jekyll::Zettel
- Included in:
- Akteur, Blatt, Glosse, References, Tags, Zeitleiste, Zettel, Zettelkasten
- Defined in:
- lib/jekyll/zettel.rb,
lib/jekyll/zettel/tags.rb,
lib/jekyll/zettel/blatt.rb,
lib/jekyll/zettel/akteur.rb,
lib/jekyll/zettel/glosse.rb,
lib/jekyll/zettel/zettel.rb,
lib/jekyll/zettel/globals.rb,
lib/jekyll/zettel/version.rb,
lib/jekyll/zettel/timeline.rb,
lib/jekyll/zettel/reference.rb,
lib/jekyll/zettel/references.rb,
lib/jekyll/zettel/zeitleiste.rb,
lib/jekyll/zettel/zettelkasten.rb
Overview
Jekyll zettel to your service
Defined Under Namespace
Classes: Akteur, Blatt, Error, Globals, Glosse, Reference, References, Tags, Timeline, Zeitleiste, Zettel, Zettelkasten
Constant Summary collapse
- LOG_KEY =
'Zettel:'.freeze
- VERSION =
'0.7.2'.freeze
Instance Method Summary collapse
- #args_empty?(args) ⇒ Boolean
- #create_dir_defensively(infotype, slug, file) ⇒ Object
- #create_page(args, file, template) ⇒ Object
-
#create_slug(title) ⇒ Object
rubocop:enable Style/EvalWithLocation, Security/Eval, Lint/UnusedMethodArgument rubocop: disable Layout/FirstHashElementIndentation, Metrics/MethodLength.
-
#evaluate_template(args, template) ⇒ Object
rubocop:disable Style/EvalWithLocation, Security/Eval, Lint/UnusedMethodArgument.
- #write_catalog(object) ⇒ Object
Instance Method Details
#args_empty?(args) ⇒ Boolean
80 81 82 83 84 85 86 |
# File 'lib/jekyll/zettel.rb', line 80 def args_empty?(args) return false unless args.empty? Jekyll.logger.error LOG_KEY, 'Missing argument slug' Jekyll.logger.info LOG_KEY, 'usage: jekyll scaffold --glosse <slug>' true end |
#create_dir_defensively(infotype, slug, file) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/jekyll/zettel.rb', line 66 def create_dir_defensively(infotype, slug, file) dir = File.dirname(file) if File.directory?(dir) if File.exist?(file) Jekyll.logger.error LOG_KEY, "#{infotype} `#{slug}` already present" nil else dir end else FileUtils.mkdir_p(dir) end end |
#create_page(args, file, template) ⇒ Object
34 35 36 37 |
# File 'lib/jekyll/zettel.rb', line 34 def create_page(args, file, template) File.open(file, 'w') { |out| out.write evaluate_template(args, template) } # puts evaluate_template(args, template) end |
#create_slug(title) ⇒ Object
rubocop:enable Style/EvalWithLocation, Security/Eval, Lint/UnusedMethodArgument rubocop: disable Layout/FirstHashElementIndentation, Metrics/MethodLength
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/jekyll/zettel.rb', line 47 def create_slug(title) I18n.config.available_locales = :de I18n.locale = :de I18n.backend.store_translations(:de, i18n: { transliterate: { rule: { 'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue', 'ü' => 'ue', 'ö' => 'oe', 'ä' => 'ae', 'ß' => 'sz' } } }) Jekyll::Utils.slugify(title, mode: 'latin') end |
#evaluate_template(args, template) ⇒ Object
rubocop:disable Style/EvalWithLocation, Security/Eval, Lint/UnusedMethodArgument
40 41 42 43 |
# File 'lib/jekyll/zettel.rb', line 40 def evaluate_template(args, template) string = File.read(File.("../stubs/#{template}", __FILE__)) eval("\"#{string}\"") end |
#write_catalog(object) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jekyll/zettel.rb', line 18 def write_catalog(object) Jekyll.logger.debug LOG_KEY, "Created references in `#{@site.in_dest_dir('.objects', "#{object}.json")}`" page = Jekyll::PageWithoutAFile.new(@site, @site.source, '.objects', "#{object}.json").tap do |file| file.content = JSON.pretty_generate(@site.data[object.to_s]) file.data.merge!( 'layout' => nil, 'sitemap' => false, ) file.output end @site.pages << page end |