jekyll-recker 2.2.0 → 2.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/assets/site.css +114 -0
- data/lib/jekyll_recker/commands.rb +1 -1
- data/lib/jekyll_recker/date.rb +4 -0
- data/lib/jekyll_recker/entry.rb +17 -2
- data/lib/jekyll_recker/filters.rb +1 -1
- data/lib/jekyll_recker/generators.rb +125 -70
- data/lib/jekyll_recker/graphs.rb +38 -29
- data/lib/jekyll_recker/logging.rb +5 -4
- data/lib/jekyll_recker/math.rb +8 -0
- data/lib/jekyll_recker/site.rb +70 -1
- data/lib/jekyll_recker/social.rb +32 -24
- data/lib/jekyll_recker/version.rb +1 -1
- data/tmp/.gitignore +2 -0
- metadata +116 -3
- data/lib/jekyll_recker/generators/image_resize.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdf9c611731a2e0718c709f65098e3008bbc0d87fa90ab8fc63f7bbcdf915af7
|
4
|
+
data.tar.gz: fe79480653eef7c46b5df4dcc2769e7904181ec14f8a42f0b36a0e2ab9f309fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 951fbcab06f8f1fad983451ff63ff90af992813998abcb612a75f9c4fb58b7aa65932fee89fe6cd7af82584b0738711ace1eae8b100f3d0ed78f9c04f2f1dbe3
|
7
|
+
data.tar.gz: 59e1751c79042d60b43f1abd226802438c908c9c8a754fe280f18ec0d0749bb686abafa46f91eebc2a697e0cf398668e72a5025383c25cff8676426a71ecca2f
|
data/assets/site.css
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
body {
|
2
|
+
max-width: 750px;
|
3
|
+
margin: 0 auto;
|
4
|
+
padding: 10px;
|
5
|
+
font-size: 16px;
|
6
|
+
line-height: 1.5;
|
7
|
+
-webkit-font-smoothing: antialiased;
|
8
|
+
-moz-osx-font-smoothing: grayscale;
|
9
|
+
}
|
10
|
+
|
11
|
+
* {
|
12
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
13
|
+
}
|
14
|
+
|
15
|
+
.post p {
|
16
|
+
font-size: 18px;
|
17
|
+
}
|
18
|
+
|
19
|
+
code, pre, .code {
|
20
|
+
font-family: monospace;
|
21
|
+
}
|
22
|
+
|
23
|
+
.title {
|
24
|
+
margin: 0;
|
25
|
+
}
|
26
|
+
|
27
|
+
.subtitle {
|
28
|
+
font-size: 18px;
|
29
|
+
margin: 0;
|
30
|
+
}
|
31
|
+
|
32
|
+
blockquote, small, figcaption, .subtitle {
|
33
|
+
color: #6f7370;
|
34
|
+
}
|
35
|
+
|
36
|
+
figure {
|
37
|
+
text-align: left;
|
38
|
+
}
|
39
|
+
|
40
|
+
figure img {
|
41
|
+
width: 100%;
|
42
|
+
height: auto;
|
43
|
+
max-width: 625px;
|
44
|
+
margin-right: auto;
|
45
|
+
display: block;
|
46
|
+
}
|
47
|
+
|
48
|
+
figure figcaption p {
|
49
|
+
font-style: italic;
|
50
|
+
line-height: 1.3;
|
51
|
+
margin-top: 10px;
|
52
|
+
}
|
53
|
+
|
54
|
+
figure {
|
55
|
+
text-align: left;
|
56
|
+
margin-top: 20px;
|
57
|
+
margin-bottom: 20px;
|
58
|
+
margin-left: 0;
|
59
|
+
max-width: 400px;
|
60
|
+
}
|
61
|
+
|
62
|
+
.float-right {
|
63
|
+
float: right;
|
64
|
+
}
|
65
|
+
|
66
|
+
.clearfix::after {
|
67
|
+
content: "";
|
68
|
+
clear: both;
|
69
|
+
display: block;
|
70
|
+
}
|
71
|
+
|
72
|
+
.column {
|
73
|
+
float: left;
|
74
|
+
width: 50%;
|
75
|
+
}
|
76
|
+
|
77
|
+
.show-on-mobile {
|
78
|
+
display: none;
|
79
|
+
}
|
80
|
+
|
81
|
+
@media screen and (max-width: 600px) {
|
82
|
+
.column {
|
83
|
+
width: 100%;
|
84
|
+
}
|
85
|
+
|
86
|
+
.hide-on-mobile {
|
87
|
+
display: none;
|
88
|
+
}
|
89
|
+
|
90
|
+
.show-on-mobile {
|
91
|
+
display: block;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
/* Clear floats after the columns */
|
96
|
+
.row:after {
|
97
|
+
content: "";
|
98
|
+
display: table;
|
99
|
+
clear: both;
|
100
|
+
}
|
101
|
+
|
102
|
+
.crowded h3, .crowded h2, .crowded p, .crowded ul {
|
103
|
+
margin-bottom: 0px;
|
104
|
+
margin-top: 5px;
|
105
|
+
}
|
106
|
+
|
107
|
+
td, nav span a {
|
108
|
+
padding-right: 5px;
|
109
|
+
}
|
110
|
+
|
111
|
+
footer small::after {
|
112
|
+
content:"\a";
|
113
|
+
white-space: pre;
|
114
|
+
}
|
data/lib/jekyll_recker/date.rb
CHANGED
data/lib/jekyll_recker/entry.rb
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
module JekyllRecker
|
4
4
|
# Entry
|
5
5
|
class Entry
|
6
|
+
include Date
|
7
|
+
include Filters
|
8
|
+
|
6
9
|
def initialize(doc)
|
7
10
|
@doc = doc
|
8
11
|
end
|
@@ -12,12 +15,24 @@ module JekyllRecker
|
|
12
15
|
end
|
13
16
|
|
14
17
|
def date
|
15
|
-
@date ||=
|
18
|
+
@date ||= time_to_date(@doc.date)
|
19
|
+
end
|
20
|
+
|
21
|
+
def title
|
22
|
+
uyd_date(date)
|
23
|
+
end
|
24
|
+
|
25
|
+
def subtitle
|
26
|
+
@doc.data['title']
|
27
|
+
end
|
28
|
+
|
29
|
+
def url
|
30
|
+
@doc.url
|
16
31
|
end
|
17
32
|
|
18
33
|
def words
|
19
34
|
content.split.map do |token|
|
20
|
-
token.gsub!(/[^0-9a-z ]/i, '')
|
35
|
+
token.gsub!(/[^0-9a-z ']/i, '')
|
21
36
|
token.downcase
|
22
37
|
end
|
23
38
|
end
|
@@ -1,112 +1,167 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'bundler'
|
4
|
-
|
5
3
|
module JekyllRecker
|
6
4
|
# Generators Module
|
7
5
|
module Generators
|
8
|
-
#
|
9
|
-
|
6
|
+
# Stats Generator
|
7
|
+
class Stats < Jekyll::Generator
|
10
8
|
include Date
|
11
9
|
include Logging
|
12
10
|
include Math
|
13
11
|
|
14
|
-
|
15
|
-
|
12
|
+
attr_reader :site
|
13
|
+
|
14
|
+
def generate(site)
|
15
|
+
@site = Site.new(site)
|
16
|
+
info 'calculating statistics'
|
17
|
+
site.data['stats'] = stats
|
16
18
|
end
|
17
19
|
|
18
|
-
def
|
19
|
-
@
|
20
|
+
def stats
|
21
|
+
@stats ||= {
|
22
|
+
'total_words' => total(site.word_counts),
|
23
|
+
'average_words' => average(site.word_counts),
|
24
|
+
'total_posts' => site.entries.size,
|
25
|
+
'consecutive_posts' => calculate_streaks(site.dates).first['days'],
|
26
|
+
'swears' => calculate_swears
|
27
|
+
}
|
20
28
|
end
|
21
29
|
|
22
|
-
|
23
|
-
|
30
|
+
private
|
31
|
+
|
32
|
+
def calculate_swears
|
33
|
+
results = Hash[count_swears]
|
34
|
+
results['total'] = total(results.values)
|
35
|
+
results
|
24
36
|
end
|
25
37
|
|
26
|
-
def
|
27
|
-
|
38
|
+
def count_swears
|
39
|
+
occurences(swears, site.words).reject { |_k, v| v.zero? }.sort_by { |_k, v| -v }
|
28
40
|
end
|
29
41
|
|
30
|
-
def
|
31
|
-
|
42
|
+
def swears
|
43
|
+
site.recker_config.fetch('swears', [])
|
32
44
|
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Graphs Generator
|
48
|
+
class Graphs < Jekyll::Generator
|
49
|
+
include Logging
|
50
|
+
|
51
|
+
attr_reader :site
|
33
52
|
|
34
|
-
def
|
35
|
-
|
53
|
+
def generate(site)
|
54
|
+
@site = Site.new(site)
|
55
|
+
if @site.production? && @site.recker_config.fetch('production_skip_graphs', true)
|
56
|
+
info 'skipping graphs (production)'
|
57
|
+
else
|
58
|
+
info 'generating graphs'
|
59
|
+
JekyllRecker::Graphs.generate_graphs(@site)
|
60
|
+
end
|
36
61
|
end
|
37
62
|
end
|
38
63
|
|
39
|
-
#
|
40
|
-
class
|
41
|
-
|
42
|
-
|
64
|
+
# Image Resize Generator
|
65
|
+
class ImageResize < Jekyll::Generator
|
66
|
+
require 'fastimage'
|
67
|
+
require 'mini_magick'
|
68
|
+
|
69
|
+
include Logging
|
70
|
+
|
71
|
+
attr_reader :site
|
43
72
|
|
44
73
|
def generate(site)
|
45
|
-
@site = site
|
46
|
-
|
47
|
-
|
48
|
-
if production?
|
49
|
-
logger.info 'production detected. skipping graphs'
|
74
|
+
@site = Site.new(site)
|
75
|
+
if @site.production? && @site.recker_config.fetch('production_skip_images', true)
|
76
|
+
info 'skipping image resizing (production)'
|
50
77
|
else
|
51
|
-
|
52
|
-
|
53
|
-
|
78
|
+
info 'checking images sizes'
|
79
|
+
resizeable_images.each do |f, d|
|
80
|
+
info "resizing #{f} to fit #{d}"
|
81
|
+
image = MiniMagick::Image.new(f)
|
82
|
+
image.resize d
|
83
|
+
end
|
54
84
|
end
|
55
85
|
end
|
56
86
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
}
|
87
|
+
def too_big?(width, height)
|
88
|
+
width > 800 || height > 800
|
89
|
+
end
|
90
|
+
|
91
|
+
def images_without_graphs
|
92
|
+
site.images.reject { |i| i.include?('/graphs/') }
|
93
|
+
end
|
94
|
+
|
95
|
+
def resizeable_images
|
96
|
+
with_sizes = images_without_graphs.map { |f| [f, FastImage.size(f)].flatten }
|
97
|
+
with_sizes.select! { |f| too_big?(f[1], f[2]) }
|
98
|
+
with_sizes.map do |f, w, h|
|
99
|
+
dimensions = if w > h
|
100
|
+
'800x600'
|
101
|
+
else
|
102
|
+
'600x800'
|
103
|
+
end
|
104
|
+
[f, dimensions]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Code Coverage Generator
|
110
|
+
class CodeCoverage < Jekyll::Generator
|
111
|
+
include Logging
|
112
|
+
|
113
|
+
attr_reader :site
|
114
|
+
|
115
|
+
def generate(site)
|
116
|
+
@site = Site.new(site)
|
117
|
+
info 'running tests'
|
118
|
+
Shell.run 'rspec'
|
119
|
+
info 'reading code coverage'
|
120
|
+
@site.data['coverage'] = JSON.parse(File.read(tmp_file))
|
68
121
|
end
|
69
122
|
|
70
123
|
private
|
71
124
|
|
72
|
-
def
|
73
|
-
|
125
|
+
def tmp_file
|
126
|
+
site.tmp_join('coverage.json')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# Yard Generator
|
131
|
+
class Yard < Jekyll::Generator
|
132
|
+
include Logging
|
133
|
+
|
134
|
+
attr_reader :site
|
135
|
+
|
136
|
+
def generate(site)
|
137
|
+
@site = Site.new(site)
|
138
|
+
info 'generating documentation'
|
139
|
+
target = @site.site_join(docs_path)
|
140
|
+
Shell.run "yard -o #{target} -q"
|
74
141
|
end
|
75
142
|
|
76
|
-
def
|
77
|
-
|
78
|
-
recker.fetch('graphs', 'assets/images/graphs/')
|
143
|
+
def docs_path
|
144
|
+
site.recker_config.fetch('yard_docs_path', 'doc')
|
79
145
|
end
|
146
|
+
end
|
80
147
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
148
|
+
# Git History Generator
|
149
|
+
class GitHistory < Jekyll::Generator
|
150
|
+
include Logging
|
151
|
+
|
152
|
+
attr_reader :site
|
153
|
+
|
154
|
+
def generate(site)
|
155
|
+
@site = Site.new(site)
|
156
|
+
info 'reading git history'
|
157
|
+
site.data['git'] = {
|
158
|
+
'commit_count' => commit_count
|
159
|
+
}
|
91
160
|
end
|
92
161
|
|
93
|
-
def
|
94
|
-
|
95
|
-
ass
|
96
|
-
asshole
|
97
|
-
booger
|
98
|
-
crap
|
99
|
-
damn
|
100
|
-
fart
|
101
|
-
fuck
|
102
|
-
hell
|
103
|
-
jackass
|
104
|
-
piss
|
105
|
-
poop
|
106
|
-
shit
|
107
|
-
]
|
162
|
+
def commit_count
|
163
|
+
@commit_count ||= Shell.run('git rev-list --count master').chomp
|
108
164
|
end
|
109
165
|
end
|
110
|
-
require 'jekyll_recker/generators/image_resize.rb'
|
111
166
|
end
|
112
167
|
end
|
data/lib/jekyll_recker/graphs.rb
CHANGED
@@ -1,48 +1,57 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'bundler'
|
4
|
-
|
5
3
|
module JekyllRecker
|
6
4
|
# Graphs module
|
7
5
|
module Graphs
|
8
|
-
def generate_graphs(
|
9
|
-
|
10
|
-
|
6
|
+
def self.generate_graphs(site)
|
7
|
+
require 'gruff'
|
8
|
+
WordCount.new(site).write
|
9
|
+
Swears.new(site).write
|
10
|
+
end
|
11
|
+
|
12
|
+
# Base Graph
|
13
|
+
module Base
|
14
|
+
attr_reader :site
|
15
|
+
|
16
|
+
def graphs_join(path)
|
17
|
+
File.join site.root, @graphs_dir, path
|
18
|
+
end
|
11
19
|
end
|
12
20
|
|
13
21
|
# Word Count Graph
|
14
22
|
class WordCount
|
15
|
-
|
16
|
-
|
17
|
-
|
23
|
+
include Base
|
24
|
+
|
25
|
+
def initialize(site)
|
26
|
+
@site = site
|
27
|
+
@graphs_dir = site.graphs_dir
|
18
28
|
end
|
19
29
|
|
20
|
-
def
|
21
|
-
|
30
|
+
def posts
|
31
|
+
site.entries[0..6].reverse
|
32
|
+
end
|
33
|
+
|
34
|
+
def word_counts
|
35
|
+
site.word_counts[0..6].reverse
|
22
36
|
end
|
23
37
|
|
24
38
|
def title
|
25
39
|
format = '%m/%d/%y'
|
26
|
-
first =
|
27
|
-
last =
|
40
|
+
first = posts.first.date.strftime(format)
|
41
|
+
last = posts.last.date.strftime(format)
|
28
42
|
"Word Count: #{first} - #{last}"
|
29
43
|
end
|
30
44
|
|
31
45
|
def labels
|
32
|
-
Hash[
|
33
|
-
end
|
34
|
-
|
35
|
-
# TODO: copied from jekyll
|
36
|
-
def number_of_words(input)
|
37
|
-
input.split.length
|
46
|
+
Hash[posts.each_with_index.map { |p, i| [i, p.date.strftime('%a')] }]
|
38
47
|
end
|
39
48
|
|
40
49
|
def write
|
41
|
-
g = Gruff::Line.new('800x600')
|
50
|
+
g = ::Gruff::Line.new('800x600')
|
42
51
|
g.theme = Gruff::Themes::PASTEL
|
43
52
|
g.hide_legend = true
|
44
53
|
g.labels = labels
|
45
|
-
g.data :words,
|
54
|
+
g.data :words, word_counts
|
46
55
|
g.title = title
|
47
56
|
g.x_axis_label = 'Day'
|
48
57
|
g.y_axis_label = 'Word Count'
|
@@ -53,26 +62,26 @@ module JekyllRecker
|
|
53
62
|
|
54
63
|
# Swears Chart
|
55
64
|
class Swears
|
56
|
-
|
65
|
+
include Base
|
57
66
|
|
58
|
-
def initialize(
|
59
|
-
@
|
60
|
-
@graphs_dir = graphs_dir
|
67
|
+
def initialize(site)
|
68
|
+
@site = site
|
61
69
|
end
|
62
70
|
|
63
|
-
|
64
|
-
|
65
|
-
|
71
|
+
def results
|
72
|
+
data = site.data['stats']['swears'].clone
|
73
|
+
data.delete('total')
|
74
|
+
data
|
66
75
|
end
|
67
76
|
|
68
77
|
def write
|
69
|
-
g = Gruff::Pie.new('800x600')
|
78
|
+
g = ::Gruff::Pie.new('800x600')
|
70
79
|
g.theme = Gruff::Themes::PASTEL
|
71
80
|
g.hide_legend = false
|
72
81
|
g.legend_at_bottom = true
|
73
82
|
g.minimum_value = 0
|
74
83
|
results.each { |w, n| g.data w, n }
|
75
|
-
g.write(graphs_join('swears.png'))
|
84
|
+
g.write(site.graphs_join('swears.png'))
|
76
85
|
end
|
77
86
|
end
|
78
87
|
end
|
@@ -9,11 +9,12 @@ module JekyllRecker
|
|
9
9
|
base.extend(self)
|
10
10
|
end
|
11
11
|
|
12
|
+
def info(msg)
|
13
|
+
Jekyll.logger.info 'jekyll-recker:', msg
|
14
|
+
end
|
15
|
+
|
12
16
|
def logger
|
13
|
-
|
14
|
-
STDOUT,
|
15
|
-
formatter: proc { |_severity, _datetime, _progname, msg| "jekyll-recker: #{msg}\n" }
|
16
|
-
)
|
17
|
+
::Jekyll.logger
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
data/lib/jekyll_recker/math.rb
CHANGED
@@ -11,5 +11,13 @@ module JekyllRecker
|
|
11
11
|
def total(numlist)
|
12
12
|
numlist.inject(0) { |sum, x| sum + x }
|
13
13
|
end
|
14
|
+
|
15
|
+
def occurences(keys, targets)
|
16
|
+
results = Hash.new(0)
|
17
|
+
targets.each do |target|
|
18
|
+
results[target] += 1 if keys.include? target
|
19
|
+
end
|
20
|
+
results
|
21
|
+
end
|
14
22
|
end
|
15
23
|
end
|
data/lib/jekyll_recker/site.rb
CHANGED
@@ -11,14 +11,83 @@ module JekyllRecker
|
|
11
11
|
@entries ||= build_entries
|
12
12
|
end
|
13
13
|
|
14
|
+
def latest
|
15
|
+
entries.first
|
16
|
+
end
|
17
|
+
|
14
18
|
def production?
|
15
19
|
ENV['JEKYLL_ENV'] == 'production'
|
16
20
|
end
|
17
21
|
|
22
|
+
def data
|
23
|
+
@site.data
|
24
|
+
end
|
25
|
+
|
26
|
+
def url
|
27
|
+
@site.config['url']
|
28
|
+
end
|
29
|
+
|
30
|
+
def word_counts
|
31
|
+
entries.collect(&:word_count)
|
32
|
+
end
|
33
|
+
|
34
|
+
def words
|
35
|
+
entries.collect(&:words).flatten
|
36
|
+
end
|
37
|
+
|
38
|
+
def dates
|
39
|
+
entries.collect(&:date)
|
40
|
+
end
|
41
|
+
|
42
|
+
def images
|
43
|
+
exts = ['.jpg', 'jpeg', '.png', '.svg']
|
44
|
+
@site.static_files.collect(&:path).select { |f| exts.include? File.extname(f) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def root
|
48
|
+
File.absolute_path(File.join(__dir__, '../../'))
|
49
|
+
end
|
50
|
+
|
51
|
+
def root_join(path)
|
52
|
+
File.join(root, path)
|
53
|
+
end
|
54
|
+
|
55
|
+
def recker_config
|
56
|
+
@site.config.fetch('recker', {})
|
57
|
+
end
|
58
|
+
|
59
|
+
def config
|
60
|
+
@site.config
|
61
|
+
end
|
62
|
+
|
63
|
+
def graphs_dir
|
64
|
+
recker_config.fetch('graphs', 'assets/images/graphs/')
|
65
|
+
end
|
66
|
+
|
67
|
+
def data_dir
|
68
|
+
File.join root, '_data'
|
69
|
+
end
|
70
|
+
|
71
|
+
def tmp_join(path)
|
72
|
+
File.join root, 'tmp', path
|
73
|
+
end
|
74
|
+
|
75
|
+
def graphs_join(path)
|
76
|
+
File.join root, 'assets/images/graphs/', path
|
77
|
+
end
|
78
|
+
|
79
|
+
def site_join(path)
|
80
|
+
File.join(root, '_site', path)
|
81
|
+
end
|
82
|
+
|
18
83
|
private
|
19
84
|
|
20
85
|
def build_entries
|
21
|
-
@site.posts.docs
|
86
|
+
@site.posts.docs
|
87
|
+
.select(&:published?)
|
88
|
+
.sort_by(&:date)
|
89
|
+
.reverse
|
90
|
+
.map { |p| Entry.new(p) }
|
22
91
|
end
|
23
92
|
end
|
24
93
|
end
|
data/lib/jekyll_recker/social.rb
CHANGED
@@ -19,17 +19,19 @@ module JekyllRecker
|
|
19
19
|
class Share
|
20
20
|
include Logging
|
21
21
|
|
22
|
+
attr_reader :site
|
23
|
+
|
22
24
|
def self.share(site, dry: false)
|
23
25
|
backend = new(site, dry: dry)
|
24
|
-
|
26
|
+
info "#{backend.name} - building configuration"
|
25
27
|
backend.configure!
|
26
28
|
|
27
|
-
|
29
|
+
info "#{backend.name} - sharing \"#{backend.latest_title}\""
|
28
30
|
backend.post!
|
29
31
|
end
|
30
32
|
|
31
33
|
def initialize(site, dry: false)
|
32
|
-
@site = site
|
34
|
+
@site = Site.new(site)
|
33
35
|
@dry = dry
|
34
36
|
end
|
35
37
|
|
@@ -38,29 +40,28 @@ module JekyllRecker
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def config
|
41
|
-
|
43
|
+
site.recker_config.fetch(config_key, {})
|
42
44
|
end
|
43
45
|
|
44
46
|
def config_key
|
45
47
|
self.class.const_get(:KEY)
|
46
48
|
end
|
47
|
-
alias name
|
49
|
+
alias name config_key
|
48
50
|
|
49
51
|
def post_body
|
50
|
-
url = File.join @site.config['url'], latest.url
|
51
52
|
<<~BODY
|
52
|
-
#{latest.
|
53
|
-
#{latest.
|
54
|
-
#{url}
|
53
|
+
#{latest.title}
|
54
|
+
#{latest.subtitle}
|
55
|
+
#{File.join site.url, latest.url}
|
55
56
|
BODY
|
56
57
|
end
|
57
58
|
|
58
|
-
def
|
59
|
-
|
59
|
+
def latest_title
|
60
|
+
latest.title
|
60
61
|
end
|
61
62
|
|
62
|
-
def
|
63
|
-
latest
|
63
|
+
def latest
|
64
|
+
site.latest
|
64
65
|
end
|
65
66
|
|
66
67
|
def configure!
|
@@ -89,22 +90,29 @@ module JekyllRecker
|
|
89
90
|
end
|
90
91
|
|
91
92
|
def post!
|
92
|
-
message_body = ::Slack::Notifier::Util::LinkFormatter.format(post_body)
|
93
93
|
workspaces.each do |key, config|
|
94
|
-
|
94
|
+
info "posting to #{key} workspace"
|
95
95
|
if @dry
|
96
|
-
|
96
|
+
puts "BEGIN MESSAGE\n#{post_body.strip}\nEND MESSAGE"
|
97
97
|
else
|
98
|
-
|
99
|
-
@creds[key].strip,
|
100
|
-
channel: config.fetch('channel'),
|
101
|
-
username: config.fetch('username'),
|
102
|
-
icon_emoji: config.fetch('emoji')
|
103
|
-
).post(text: message_body)
|
98
|
+
post(key, config)
|
104
99
|
end
|
105
100
|
end
|
106
101
|
end
|
107
102
|
|
103
|
+
def post(key, config)
|
104
|
+
::Slack::Notifier.new(
|
105
|
+
@creds[key].strip,
|
106
|
+
channel: config.fetch('channel'),
|
107
|
+
username: config.fetch('username'),
|
108
|
+
icon_emoji: config.fetch('emoji')
|
109
|
+
).post(text: post_body)
|
110
|
+
end
|
111
|
+
|
112
|
+
def post_body
|
113
|
+
::Slack::Notifier::Util::LinkFormatter.format(super)
|
114
|
+
end
|
115
|
+
|
108
116
|
private
|
109
117
|
|
110
118
|
def extract_from_config(data)
|
@@ -139,8 +147,8 @@ module JekyllRecker
|
|
139
147
|
|
140
148
|
def post!
|
141
149
|
if dry?
|
142
|
-
|
143
|
-
|
150
|
+
info('tweeting in dry mode, printing message')
|
151
|
+
puts "BEGIN TWEET\n#{post_body}END TWEET"
|
144
152
|
else
|
145
153
|
@client.update(post_body)
|
146
154
|
end
|
data/tmp/.gitignore
ADDED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-recker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Recker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fastimage
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gruff
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: jekyll
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +52,90 @@ dependencies:
|
|
24
52
|
- - "~>"
|
25
53
|
- !ruby/object:Gem::Version
|
26
54
|
version: '3.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mini_magick
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: slack-notifier
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: twitter
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: yard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
27
139
|
description:
|
28
140
|
email:
|
29
141
|
- alex@reckerfamily.com
|
@@ -31,13 +143,13 @@ executables: []
|
|
31
143
|
extensions: []
|
32
144
|
extra_rdoc_files: []
|
33
145
|
files:
|
146
|
+
- assets/site.css
|
34
147
|
- lib/jekyll-recker.rb
|
35
148
|
- lib/jekyll_recker/commands.rb
|
36
149
|
- lib/jekyll_recker/date.rb
|
37
150
|
- lib/jekyll_recker/entry.rb
|
38
151
|
- lib/jekyll_recker/filters.rb
|
39
152
|
- lib/jekyll_recker/generators.rb
|
40
|
-
- lib/jekyll_recker/generators/image_resize.rb
|
41
153
|
- lib/jekyll_recker/graphs.rb
|
42
154
|
- lib/jekyll_recker/logging.rb
|
43
155
|
- lib/jekyll_recker/math.rb
|
@@ -46,6 +158,7 @@ files:
|
|
46
158
|
- lib/jekyll_recker/social.rb
|
47
159
|
- lib/jekyll_recker/tags.rb
|
48
160
|
- lib/jekyll_recker/version.rb
|
161
|
+
- tmp/.gitignore
|
49
162
|
homepage: https://www.github.com/arecker/blog
|
50
163
|
licenses:
|
51
164
|
- GPLv3
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module JekyllRecker
|
4
|
-
module Generators
|
5
|
-
# Image Resize Generator
|
6
|
-
class ImageResize < Jekyll::Generator
|
7
|
-
include Base
|
8
|
-
|
9
|
-
def generate(site)
|
10
|
-
@site = site
|
11
|
-
if production?
|
12
|
-
logger.info 'production detected, skipping images'
|
13
|
-
return
|
14
|
-
else
|
15
|
-
logger.info 'loading image resizing deps'
|
16
|
-
require 'fastimage'
|
17
|
-
require 'mini_magick'
|
18
|
-
end
|
19
|
-
logger.info 'checking images'
|
20
|
-
resizeable_images.each do |f, d|
|
21
|
-
logger.info "resizing #{f} to fit #{d}"
|
22
|
-
image = MiniMagick::Image.new(f)
|
23
|
-
image.resize d
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def image?(file)
|
28
|
-
['.jpg', 'jpeg', '.png', '.svg'].include? File.extname(file)
|
29
|
-
end
|
30
|
-
|
31
|
-
def too_big?(width, height)
|
32
|
-
width > 800 || height > 800
|
33
|
-
end
|
34
|
-
|
35
|
-
def graph?(file)
|
36
|
-
file.include?('/graphs/')
|
37
|
-
end
|
38
|
-
|
39
|
-
def images
|
40
|
-
@site.static_files.collect(&:path).select { |f| image?(f) }
|
41
|
-
end
|
42
|
-
|
43
|
-
def resizeable_images
|
44
|
-
without_graphs = images.reject { |i| graph?(i) }
|
45
|
-
with_sizes = without_graphs.map { |f| [f, FastImage.size(f)].flatten }
|
46
|
-
with_sizes.select! { |f| too_big?(f[1], f[2]) }
|
47
|
-
with_sizes.map do |f, w, h|
|
48
|
-
dimensions = if w > h
|
49
|
-
'800x600'
|
50
|
-
else
|
51
|
-
'600x800'
|
52
|
-
end
|
53
|
-
[f, dimensions]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|