jekyll-kw-loremipsum 0.1.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 +7 -0
- data/README.md +86 -0
- data/lib/jekyll-kw-loremipsum/configuration.rb +36 -0
- data/lib/jekyll-kw-loremipsum/parser.rb +130 -0
- data/lib/jekyll-kw-loremipsum/version.rb +10 -0
- data/lib/jekyll-kw-loremipsum.rb +30 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8a4bd65e8a7b80c8fa8aa94224dc80433fd94958c12293d27928f4fa1526a11d
|
4
|
+
data.tar.gz: bbb2a32ffafb07df5ae3a33c8292c6929f6855d47406f777179512f181a8eeba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f3bc8b8a6f859fdb651d377159043667e98dc503732a814b10572809f861da7e5a7069be0a672cfe869ced4f1aa4b28aebaa4fdb224d52cb6c7d3383f4a6063d
|
7
|
+
data.tar.gz: 293c028d0fda76ff4674d6b5ef031f83bcf7c2e553c7557c61341f3730524bba30f429cb293c3669c6be1b2727c888deef7b32556a120d67f85468a82a656614
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# jekyll-kw-loremipsum
|
2
|
+
|
3
|
+

|
4
|
+

|
5
|
+

|
6
|
+
|
7
|
+
[](https://badge.fury.io/rb/jekyll-kw-loremipsum)
|
8
|
+
|
9
|
+
LoremIpsum is a [jekyll][Jekyll Website] plugin. The plugin can be used as a **tag** for jekyll. You can get some dummy text for your webpage, without copy & pasting the Lorem Ipsum words yourself.
|
10
|
+
|
11
|
+
- Use the tag `{% kw_lorem_ipsum 30w %}` to get 30 different words.
|
12
|
+
- Use the tag `{% kw_lorem_ipsum random 4p 7miw 12maw %}` to get 4 paragraphs between 7 and 12 words.
|
13
|
+
|
14
|
+
## 🚀 Installation
|
15
|
+
|
16
|
+
Add this section to your application's `Gemfile` inside the `jekyll_plugins` and execute `bundle install`
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
group :jekyll_plugins do
|
20
|
+
gem 'jekyll-kw-loremipsum'
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
Or install the dependency with `bundle` itself, you can use the option `--skip-install`, when `bundle install` will be called later
|
25
|
+
|
26
|
+
```sh
|
27
|
+
bundle add jekyll-kw-loremipsum --group jekyll_plugins
|
28
|
+
```
|
29
|
+
|
30
|
+
Then add the following to your site's `_config.yml` to activate the plugin, see also the [Configuration](#%EF%B8%8F-configuration) section to change the default configuration.
|
31
|
+
|
32
|
+
```yaml
|
33
|
+
plugins:
|
34
|
+
- jekyll-kw-loremipsum
|
35
|
+
```
|
36
|
+
|
37
|
+
> The Plug-In is tested with jekyll 3.8, 3.9, 4.0 and 4.1!
|
38
|
+
|
39
|
+
## 🔥 Usage
|
40
|
+
|
41
|
+
## ⏰ Changelog
|
42
|
+
|
43
|
+
* ...
|
44
|
+
* Build GitHub CI workflows
|
45
|
+
* Prepare CI-workflow with Appraisal `bundle exec appraisal generate`
|
46
|
+
* 0.0.2 Read the [NextSteps.md](NextSteps.md) and follow the introduction steps
|
47
|
+
* 0.0.1 Install [Visual Studio Extension - Folder Templates](https://marketplace.visualstudio.com/items?itemName=Huuums.vscode-fast-folder-structure), and run `NewJekyllPlugInAsRubyGem` to get the a skeleton project from template
|
48
|
+
* 0.0.0 Create project `jekyll-kw-loremipsum` from [template][GitHub jekyll-plugin-template]
|
49
|
+
|
50
|
+
## ⚙️ Configuration
|
51
|
+
|
52
|
+
Add `jekyll-kw-loremipsum` section to `_config.yml` configure the plugin globally. If you want to use defaults you can omit the config-section.
|
53
|
+
|
54
|
+
```yaml
|
55
|
+
jekyll-kw-loremipsum:
|
56
|
+
my_boolean: false
|
57
|
+
my_string: 'sha384'
|
58
|
+
my_number: 1.23
|
59
|
+
```
|
60
|
+
|
61
|
+
Configuration values, the `default` value is in **bold**
|
62
|
+
|
63
|
+
| Key | Description | Values (**default**) |
|
64
|
+
|-----|-------------|----------------------|
|
65
|
+
| my_boolean | A boolean value | **false**, true |
|
66
|
+
| my_string | A string | foo, **hello plugin**, bar |
|
67
|
+
| my_number | A (decimal) number | **0** |
|
68
|
+
|
69
|
+
## 📝 Notes / Hints
|
70
|
+
|
71
|
+
TODO: Add notes, hints and learnings
|
72
|
+
|
73
|
+
## 👋 Contribution
|
74
|
+
|
75
|
+
TODO: How to contribute, e.g. [CONTRIBUTING.md](CONTRIBUTING.md)
|
76
|
+
|
77
|
+
## 🏆 Kudos
|
78
|
+
|
79
|
+
TODO: Add big thanks and kudos persons / links / blogs
|
80
|
+
|
81
|
+
## ✅ Template
|
82
|
+
|
83
|
+
The project was created from the template [GitHub n13org/jekyll-plugin-template][GitHub jekyll-plugin-template]. We would ❤️ when you keep the reference. Thanks!
|
84
|
+
|
85
|
+
[GitHub jekyll-plugin-template]: https://github.com/n13org/jekyll-plugin-template
|
86
|
+
[Jekyll Website]: https://jekyllrb.com/
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module KargWare
|
5
|
+
module LoremIpsum
|
6
|
+
# LoremIpsum configuration class
|
7
|
+
class Configuration
|
8
|
+
attr_accessor :my_integer, :my_float, :my_boolean, :my_string
|
9
|
+
|
10
|
+
DEFAULT_CONFIG = {
|
11
|
+
'my_integer' => 1,
|
12
|
+
'my_float' => 2.4,
|
13
|
+
'my_boolean' => true,
|
14
|
+
'my_string' => 'foo bar'
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
def initialize(options)
|
18
|
+
options = generate_option_hash(options)
|
19
|
+
|
20
|
+
@my_integer = options['my_integer']
|
21
|
+
@my_float = options['my_float']
|
22
|
+
@my_boolean = options['my_boolean']
|
23
|
+
@my_string = options['my_string']
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def generate_option_hash(options)
|
29
|
+
DEFAULT_CONFIG.merge(options)
|
30
|
+
rescue TypeError
|
31
|
+
DEFAULT_CONFIG
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module KargWare
|
5
|
+
module LoremIpsum
|
6
|
+
# LoremIpsum parser class
|
7
|
+
class Parser
|
8
|
+
# https://loremipsum.de/downloads/original.txt
|
9
|
+
@@words_lorem_ipsum = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
|
10
|
+
# @@words_lorem_ipsum = "Lorem ipsum dolor sit amet, consetetur sadipscing"
|
11
|
+
|
12
|
+
@@arr_words_lorem_ipsum = nil
|
13
|
+
def self.arr_words_lorem_ipsum
|
14
|
+
if @@arr_words_lorem_ipsum == nil
|
15
|
+
@@arr_words_lorem_ipsum = @@words_lorem_ipsum.split(" ")
|
16
|
+
end
|
17
|
+
@@arr_words_lorem_ipsum
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.get_words(cnt, random=false)
|
21
|
+
if random
|
22
|
+
arr_part = self.arr_words_lorem_ipsum.sample(cnt)
|
23
|
+
else
|
24
|
+
arr_part = self.arr_words_lorem_ipsum.slice(0, cnt)
|
25
|
+
end
|
26
|
+
|
27
|
+
arr_part.join(" ").chomp(",")
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(config)
|
31
|
+
@config = config
|
32
|
+
|
33
|
+
match_parameters(@config)
|
34
|
+
end
|
35
|
+
|
36
|
+
def match_parameters(str)
|
37
|
+
# 1w == 1 word (default 40)
|
38
|
+
@words = 40
|
39
|
+
# 3p == 3 paragraphs (default -1)
|
40
|
+
# 7miw == 7 Min words in para (default 40)
|
41
|
+
# 15maw == 15 Max words in para (default 40)
|
42
|
+
@paras = -1
|
43
|
+
@minw = 40
|
44
|
+
@maxw = 40
|
45
|
+
# random == Should the words be random (or ordered) (default false)
|
46
|
+
@random = false
|
47
|
+
|
48
|
+
matched_words = str.strip.match(/\d+w/)
|
49
|
+
matched_paras = str.strip.match(/\d+p/)
|
50
|
+
matched_minw = str.strip.match(/\d+miw/)
|
51
|
+
matched_maxw = str.strip.match(/\d+maw/)
|
52
|
+
matched_random = str.strip.match(/random/)
|
53
|
+
|
54
|
+
# puts "Parser: W: %s P: %s MiW: %s MaW: %s Random: $s" % [matched_words, matched_paras, matched_minw, matched_maxw, matched_random]
|
55
|
+
|
56
|
+
@words = matched_words[0].strip.sub("w", "").to_i if matched_words
|
57
|
+
@paras = matched_paras[0].strip.sub("p", "").to_i if matched_paras
|
58
|
+
@minw = matched_minw[0].strip.sub("miw", "").to_i if matched_minw
|
59
|
+
@maxw = matched_maxw[0].strip.sub("maw", "").to_i if matched_maxw
|
60
|
+
@random = true if matched_random
|
61
|
+
end
|
62
|
+
|
63
|
+
def echo_config
|
64
|
+
puts "%s (%s) - W: %04d P: %04d MiW: %04d MaW: %04d" % [@paras == -1 ? "Words" : "Paras", @random, @words, @paras, @minw, @maxw]
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_lorem_ipsum
|
68
|
+
if @paras == -1
|
69
|
+
Jekyll::KargWare::LoremIpsum::Parser.get_words(@words, @random)
|
70
|
+
else
|
71
|
+
arr_oneliner = Array.new
|
72
|
+
for i in 1..@paras
|
73
|
+
r = rand(@minw..@maxw)
|
74
|
+
arr_oneliner += [Jekyll::KargWare::LoremIpsum::Parser.get_words(r, @random)]
|
75
|
+
end
|
76
|
+
# arr_oneliner.join("\n") # No line wrap
|
77
|
+
# arr_oneliner.join("<br>") # OK, but no 2nd p
|
78
|
+
# arr_oneliner.join(" ") # No line wrap
|
79
|
+
# arr_oneliner.join(" \n")
|
80
|
+
arr_oneliner.join("\n\n")
|
81
|
+
# arr_oneliner.join(" - ")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
## FOR TESTING #############################
|
90
|
+
## ruby ./lib/jekyll-kw-loremipsum/parser.rb
|
91
|
+
## #########################################
|
92
|
+
|
93
|
+
# Jekyll::KargWare::LoremIpsum::Parser.new("1w").echo_config
|
94
|
+
# Jekyll::KargWare::LoremIpsum::Parser.new("2w").echo_config
|
95
|
+
# Jekyll::KargWare::LoremIpsum::Parser.new("3w").echo_config
|
96
|
+
# Jekyll::KargWare::LoremIpsum::Parser.new("34w").echo_config
|
97
|
+
# Jekyll::KargWare::LoremIpsum::Parser.new("foo bar 75w hello 115w foo bar").echo_config
|
98
|
+
# Jekyll::KargWare::LoremIpsum::Parser.new("hello 13p foo 9p bar 56p").echo_config
|
99
|
+
# Jekyll::KargWare::LoremIpsum::Parser.new("1 w").echo_config
|
100
|
+
# Jekyll::KargWare::LoremIpsum::Parser.new("foo 8w bar 3p hello 7miw 25maw foo bar").echo_config
|
101
|
+
# puts "######################"
|
102
|
+
|
103
|
+
# for i in 1..Jekyll::KargWare::LoremIpsum::Parser.arr_words_lorem_ipsum.size
|
104
|
+
# puts "%03d: %s" % [i, Jekyll::KargWare::LoremIpsum::Parser.get_words(i)]
|
105
|
+
# end
|
106
|
+
# puts "######################"
|
107
|
+
|
108
|
+
# puts "%03d: %s" % [650, Jekyll::KargWare::LoremIpsum::Parser.get_words(651)]
|
109
|
+
# puts "%03d: %s" % [1000, Jekyll::KargWare::LoremIpsum::Parser.get_words(1000)]
|
110
|
+
|
111
|
+
# cw = Jekyll::KargWare::LoremIpsum::Parser.new("7w")
|
112
|
+
# # cw = Jekyll::KargWare::LoremIpsum::Parser.new("8w")
|
113
|
+
# cw.echo_config
|
114
|
+
# puts cw.get_lorem_ipsum
|
115
|
+
# puts "######################"
|
116
|
+
|
117
|
+
# c3p = Jekyll::KargWare::LoremIpsum::Parser.new("5p 8miw 8maw")
|
118
|
+
# c3p.echo_config
|
119
|
+
# puts c3p.get_lorem_ipsum
|
120
|
+
# puts "######################"
|
121
|
+
|
122
|
+
# c3p = Jekyll::KargWare::LoremIpsum::Parser.new("5p 7miw 25maw")
|
123
|
+
# c3p.echo_config
|
124
|
+
# c3p.get_lorem_ipsum
|
125
|
+
# puts "######################"
|
126
|
+
|
127
|
+
# cr = Jekyll::KargWare::LoremIpsum::Parser.new("random 5p 8miw 8maw")
|
128
|
+
# cr.echo_config
|
129
|
+
# puts cr.get_lorem_ipsum
|
130
|
+
# puts "######################"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module KargWare
|
5
|
+
module LoremIpsum
|
6
|
+
class Error < StandardError; end
|
7
|
+
class Exception < Gem::Exception; end
|
8
|
+
|
9
|
+
class LoremIpsumTag < Liquid::Tag
|
10
|
+
# safe true
|
11
|
+
# priority :low
|
12
|
+
|
13
|
+
def initialize(tag_name, text, tokens)
|
14
|
+
super
|
15
|
+
@text = text.strip
|
16
|
+
tokens = tokens
|
17
|
+
|
18
|
+
@parser = Jekyll::KargWare::LoremIpsum::Parser.new(@text)
|
19
|
+
# @parser.echo_config
|
20
|
+
end
|
21
|
+
|
22
|
+
def render(context)
|
23
|
+
@parser.get_lorem_ipsum
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Liquid::Template.register_tag('kw_lorem_ipsum', Jekyll::KargWare::LoremIpsum::LoremIpsumTag)
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-kw-loremipsum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nicolas Karg
|
8
|
+
- n13.org - Open-Source by KargWare
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2022-03-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jekyll
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.8'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '3.8'
|
28
|
+
description: |2
|
29
|
+
LoremIpsum is a jekyll plugin. The plugin can be used as a tag for jekyll. You can get some dummy text for your webpage, without copy & pasting the Lorem Ipsum words yourself.
|
30
|
+
|
31
|
+
- Use the tag `{% kw_lorem_ipsum 30w %}` to get 30 different words.
|
32
|
+
- Use the tag `{% kw_lorem_ipsum random 4p 7miw 12maw %}` to get 4 paragraphs between 7 and 12 words.
|
33
|
+
email:
|
34
|
+
- rubygems.org@n13.org
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- README.md
|
40
|
+
- lib/jekyll-kw-loremipsum.rb
|
41
|
+
- lib/jekyll-kw-loremipsum/configuration.rb
|
42
|
+
- lib/jekyll-kw-loremipsum/parser.rb
|
43
|
+
- lib/jekyll-kw-loremipsum/version.rb
|
44
|
+
homepage: https://notes.n13.org/rubygems
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata:
|
48
|
+
homepage_uri: https://github.com/n13org/jekyll-kw-loremipsum
|
49
|
+
bug_tracker_uri: https://github.com/n13org/jekyll-kw-loremipsum/issues
|
50
|
+
source_code_uri: https://github.com/n13org/jekyll-kw-loremipsum
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 2.3.0
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.1.2
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: LoremIpsum is a jekyll tag-plugin.
|
70
|
+
test_files: []
|