jekyll-recker 1.2.2 → 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7c17927e227e392e2bf48faf7e623e463ab8ef3647f83ddbca8217980bbb511
4
- data.tar.gz: e59bab85cee9f9c5e5d2aedbf4a3978df4f68bc0b06657a31e5e45b7f37f0ac4
3
+ metadata.gz: 853460ad6e8cc68998d94ec9b8370fcc8c91ac36e464c20bb503a430c0b61775
4
+ data.tar.gz: b41ff9a6f988de20e74265844092d6bda6a458f3720e9ac49c8276f07702c0e7
5
5
  SHA512:
6
- metadata.gz: bf113a841c5986758ab082aadcdd094d5db6ffbdfe8d53e877b3a37093f3a457cb2b44431b8d0b5b41dde677d0912f1d0e72422e90831089485058f3f96acbd7
7
- data.tar.gz: 17758558184be22b37e0fae164c77226e8d5cee64d4884367ddbbc1566348cf7f1a56634a68ec09a37d5d464398e052364cc0ad5b36ffba1b63a66f7fcc41099
6
+ metadata.gz: 3e8981f6cfe48b770faca2e93836c4f85994237e981cb2b767d760cc23f9decfdc4f24f800daf1b759258efd9b9ff060444034cb3d91a4534a471f5ca19306e0
7
+ data.tar.gz: 3d9c4aaacc354e02570cf31c18761a02b529cd6b624a389e6e8effe50db599678850e1ec19ea32e0353e33905a97e72e1e40f9060b1324ce112357473e110a03
@@ -0,0 +1,105 @@
1
+ # jekyll-recker
2
+
3
+ The Greatest Jekyll Plugin in the World. For a live example, check
4
+ out [my personal website].
5
+
6
+ ## Installation
7
+
8
+ Add `jekyll-recker` to the `jekyll_plugins` group in your `Gemfile`.
9
+
10
+ group :jekyll_plugins do
11
+ gem 'jekyll-recker'
12
+ end
13
+
14
+ Then add the plugin to jekyll site's `config.yml` file.
15
+
16
+ pugins:
17
+ - jekyll-recker
18
+
19
+ If you'd like to make your site look like mine too, set the theme in
20
+ `config.yml` too.
21
+
22
+ theme: jekyll-recker
23
+
24
+ ## Usage
25
+
26
+ ### Share
27
+
28
+ Use the `share` jekyll command to post a link to your latest published
29
+ blog post to any or all of the configured Shares.
30
+
31
+ # TODO: example of `be jekyll share`
32
+
33
+ Perform a test run with the `--dry` flag.
34
+
35
+ # TODO: example of `be jekyll share --dry`
36
+
37
+ Send to all configured shares, or just pick one of them.
38
+
39
+ $ jekyll share slack
40
+ $ jekyll share twitter
41
+
42
+ #### Slack
43
+
44
+ Send the latest published post to a slack channel.
45
+
46
+ ![example slack]
47
+
48
+ Configure the slack share in `_config.yml`.
49
+
50
+ recker:
51
+ slack:
52
+ myteam:
53
+ channel: '#blogs'
54
+ username: 'blogbot'
55
+ emoji: ':robot:'
56
+ webhook_cmd: cat ~/.secrets/slack-webhook.txt
57
+
58
+ Use the `webhook_cmd` option to shell out to `gpg` or another CLI
59
+ password manager. Alternatively, you can supply the private incoming
60
+ webhook using an environment variable.
61
+
62
+ export SLACK_MYTEAM_WEBHOOK="https://.../" # SLACK_ + MyTeam.upcase + _WEBHOOK
63
+
64
+ Multiple teams are supported as well.
65
+
66
+ recker:
67
+ slack:
68
+ MyTeamA:
69
+ channel: '#blogs'
70
+ username: 'blogbot'
71
+ emoji: ':robot:'
72
+ MyTeamB:
73
+ channel: '#blogs'
74
+ username: 'blogbot'
75
+ emoji: ':robot:'
76
+ MyTeamC:
77
+ channel: '#blogs'
78
+ username: 'blogbot'
79
+ emoji: ':robot:'
80
+
81
+ #### Twitter
82
+
83
+ Send a tweet with a link to the latest published post.
84
+
85
+ ![example tweet]
86
+
87
+ Configure the tweet share in `_config.yml`.
88
+
89
+ recker:
90
+ twitter:
91
+ access_token_secret_cmd: pass twitter/reckerbot/access-token-secret
92
+ access_token_cmd: pass twitter/reckerbot/access-token
93
+ consumer_api_key_cmd: pass twitter/reckerbot/consumer-api-key
94
+ consumer_api_secret_cmd: pass twitter/reckerbot/consumer-api-secret-key
95
+
96
+ Alternatively, ensure these environment variables are set.
97
+
98
+ export TWITTER_ACCESS_TOKEN_SECRET="..."
99
+ export TWITTER_ACCESS_TOKEN="..."
100
+ export TWITTER_CONSUMER_API_KEY="..."
101
+ export TWITTER_CONSUMER_API_SECRET="..."
102
+
103
+ [example slack]: screenshots/example-slack.png
104
+ [example tweet]: screenshots/example-tweet.png
105
+ [my personal website]: https://www.alexrecker.com
@@ -0,0 +1,14 @@
1
+ <figure>
2
+ {%- if include.url %}
3
+ <a href="{{ include.url }}">
4
+ {%- endif %}
5
+ <img alt="{{ alt | default: include.filename }}" src="{{ site.baseurl }}assets/images/{{ include.filename }}"/>
6
+ {%- if include.url %}
7
+ </a>
8
+ {%- endif %}
9
+ {%- if include.caption %}
10
+ <figcaption>
11
+ <p>{{ include.caption }}</p>
12
+ </figcaption>
13
+ {%- endif %}
14
+ </figure>
@@ -1,5 +1,14 @@
1
1
  <footer>
2
- built with <a href="https://jekyllrb.com/">jekyll</a> using <a href="{% link README.org %}">jekyll-recker</a> v{% recker_version %}
2
+ <nav>
3
+ find me on: &nbsp
4
+ <a href="mailto:{{ site.email }}">email</a>
5
+ <a href="https://www.github.com/{{ site.github_username }}">github</a>
6
+ <a href="https://www.twitter.com/{{ site.twitter_username }}">twitter</a>
7
+ <a href="{{ site.basurl }}/assets/public.gpg.asc">gpg</a>
8
+ <a href="https://www.linkedin.com/in/{{ site.linkedin_username }}">linkedin</a>
9
+ <a href="https://www.facebook.com/{{ site.facebook_username }}">facebook</a>
10
+ </nav>
11
+ built with <a href="https://jekyllrb.com/">jekyll</a> using <a href="https://www.github.com/arecker/jekyll-recker/">jekyll-recker</a> v{% recker_version %}
3
12
  <br/>
4
13
  <small>&copy; copyright {{ 'now' | date: '%Y' }}, {{ site.author }}</small>
5
14
  </footer>
@@ -0,0 +1,21 @@
1
+ {%- capture title %}{{ include.title | default: page.title }}{%- endcapture %}
2
+ {%- capture description %}{{ include.description | default: site.description }}{%- endcapture %}
3
+ {%- capture image %}{{ include.image | default: page.image }}{%- endcapture %}
4
+ <head>
5
+ <meta charset="UTF-8"/>
6
+ <title>{{ title }} | {{ description }}</title>
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <meta name="twitter:card" content="summary" />
9
+ <meta name="twitter:site" content="@{{ site.twitter_username }}" />
10
+ <meta name="twitter:title" content="{{ include.title }}" />
11
+ <meta name="twitter:description" content="{{ include.description }}" />
12
+ <meta property="og:url" content="{{ site.url }}{{ page.url }}" />
13
+ <meta property="og:type" content="article" />
14
+ <meta property="og:title" content="{{ title }}"/>
15
+ <meta property="og:description" content="{{ description }}" />
16
+ {%- if image %}
17
+ <meta name="twitter:image" content="{{ site.url }}{{ site.base_url }}/assets/images/{{ image }}"/>
18
+ <meta property="og:image" content="{{ site.url }}{{ site.base_url }}/assets/images/{{ image }}"/>
19
+ {%- endif %}
20
+ <link href="{{ site.baseurl }}/assets/jekyll-recker.css" rel="stylesheet"/>
21
+ </head>
@@ -1,8 +1,5 @@
1
1
  <nav>
2
- <a href="{{ site.baseurl }}/" class="{% if page.active == 'index' %}active{% endif %}">index</a>
3
- <a href="{% link archive.html %}" class="{% if page.active == 'archive' %}active{% endif %}">archive</a>
4
- <a href="{% link stats.org %}" class="{% if page.active == 'stats' %}active{% endif %}">stats</a>
5
- <a href="{% link projects.html %}" class="{% if page.active == 'projects' %}active{% endif %}">projects</a>
6
- <a href="{% link contact.html %}" class="{% if page.active == 'contact' %}active{% endif %}">contact</a>
2
+ <a href="{{ site.baseurl }}/" class="{% if page.active == 'index' %}active{% endif %}">index.html</a>
3
+ <a href="{{ site.basurl }}/feed.xml">feed.xml</a>
7
4
  <span class="float-right hide-on-mobile">{{ page.slug }}</span>
8
- </nav>
5
+ </nav>
@@ -0,0 +1,13 @@
1
+ <nav class="clearfix">
2
+ {%- if page.next -%}
3
+ <a href="{{ page.next.url }}">
4
+ ⟵ {{ page.next.slug }}
5
+ </a>
6
+ {%- endif -%}
7
+ {%- if page.previous -%}
8
+ <a class="float-right" href="{{ page.previous.url }}">
9
+ {{ page.previous.slug }} ⟶
10
+ </a>
11
+ {%- endif -%}
12
+ </nav>
13
+
@@ -1,9 +1,13 @@
1
- ---
2
- layout: default
3
- ---
4
- {% include header.html title=site.title subtitle=site.description %}
5
- <hr/>
6
- {% include nav.html %}
7
- <hr/>
8
- {{ content }}
9
-
1
+ <!doctype html>
2
+ <html lang="en">
3
+ {% include head.html title=site.title %}
4
+ <body>
5
+ {% include header.html title=site.title subtitle=site.description %}
6
+ <hr/>
7
+ {% include nav.html %}
8
+ <hr/>
9
+ {{ content }}
10
+ <hr/>
11
+ {% include footer.html %}
12
+ </body>
13
+ </html>
@@ -1,8 +1,13 @@
1
- ---
2
- layout: default
3
- ---
4
- {% include header.html title=page.title subtitle=page.description %}
5
- <hr/>
6
- {% include nav.html %}
7
- <hr/>
8
- {{ content }}
1
+ <!doctype html>
2
+ <html lang="en">
3
+ {% include head.html title=site.title %}
4
+ <body>
5
+ {% include header.html title=page.title subtitle=page.description %}
6
+ <hr/>
7
+ {% include nav.html %}
8
+ <hr/>
9
+ {{ content }}
10
+ <hr/>
11
+ {% include footer.html %}
12
+ </body>
13
+ </html>
@@ -1,28 +1,20 @@
1
- ---
2
- layout: default
3
- ---
4
- {% capture datestring %}{{ page.date | date: '%A, %B %d %Y' }}{% endcapture %}
5
- {% include header.html title=datestring subtitle=page.title %}
6
- <hr/>
7
- {% include nav.html %}
8
- <hr/>
9
- {%- if page.image -%}
10
- <br/>
11
- <figure>
12
- <img alt="page.image" src="{{ site.baseurl }}assets/images/{{ page.image }}"/>
13
- </figure>
14
- <br/>
15
- {%- endif -%}
16
- {{ content }}
17
- <nav class="clearfix">
18
- {%- if page.next -%}
19
- <a href="{{ page.next.url }}">
20
- ⟵ {{ page.next.slug }}
21
- </a>
22
- {%- endif -%}
23
- {%- if page.previous -%}
24
- <a class="float-right" href="{{ page.previous.url }}">
25
- {{ page.previous.slug }} ⟶
26
- </a>
27
- </nav>
28
- {%- endif -%}
1
+ {%- capture datestring %}{{ page.date | uyd_date }}{% endcapture %}
2
+ <!doctype html>
3
+ <html lang="en">
4
+ {% include head.html title=datestring description=page.title %}
5
+ <body>
6
+ {% include header.html title=datestring subtitle=page.title %}
7
+ <hr/>
8
+ {% include nav.html %}
9
+ <hr/>
10
+ {%- if page.image -%}
11
+ <br/>
12
+ {% include figure.html filename=page.image %}
13
+ <br/>
14
+ {%- endif -%}
15
+ {{ content }}
16
+ {% include pager.html %}
17
+ <hr/>
18
+ {% include footer.html %}
19
+ </body>
20
+ </html>
@@ -5,19 +5,17 @@ require 'jekyll'
5
5
  module Jekyll
6
6
  # Recker
7
7
  module Recker
8
- require 'jekyll-recker/logger.rb'
9
- require 'jekyll-recker/mixins.rb'
8
+ require 'jekyll_recker/mixins.rb'
10
9
 
11
- require 'jekyll-recker/commands.rb'
12
- require 'jekyll-recker/configuration.rb'
13
- require 'jekyll-recker/error.rb'
14
- require 'jekyll-recker/generators.rb'
15
- require 'jekyll-recker/shell.rb'
16
- require 'jekyll-recker/slack.rb'
17
- require 'jekyll-recker/stats.rb'
18
- require 'jekyll-recker/tags.rb'
19
- require 'jekyll-recker/twitter.rb'
20
- require 'jekyll-recker/version.rb'
21
- require 'jekyll-recker/words.rb'
10
+ require 'jekyll_recker/commands.rb'
11
+ require 'jekyll_recker/configuration.rb'
12
+ require 'jekyll_recker/error.rb'
13
+ require 'jekyll_recker/filters.rb'
14
+ require 'jekyll_recker/generators.rb'
15
+ require 'jekyll_recker/shell.rb'
16
+ require 'jekyll_recker/social.rb'
17
+ require 'jekyll_recker/tags.rb'
18
+ require 'jekyll_recker/version.rb'
19
+ require 'jekyll_recker/words.rb'
22
20
  end
23
21
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Recker
5
+ # Commands
6
+ module Commands
7
+ # Share
8
+ class Share < Jekyll::Command
9
+ include Mixins::Logging
10
+
11
+ def self.init_with_program(prog)
12
+ prog.command(:share) do |c|
13
+ c.syntax 'share'
14
+ c.description 'Share latest post with each configured backend'
15
+ c.option 'dry', '-d', '--dry', 'perform dry run'
16
+ c.action { |args, opts| action(args, opts) }
17
+ end
18
+ end
19
+
20
+ def self.action(args, options)
21
+ args += %w[slack twitter] if args.empty?
22
+ Recker::Social::Slack.share(dry: options['dry']) if args.include?('slack')
23
+ Recker::Social::Twitter.share(dry: options['dry']) if args.include?('twitter')
24
+ rescue ReckerError => e
25
+ logger.error e.message
26
+ exit 1
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Jekyll
2
4
  module Recker
3
5
  # Configuration
@@ -10,6 +12,10 @@ module Jekyll
10
12
  jekyll.fetch('recker', {})
11
13
  end
12
14
 
15
+ def self.facebook
16
+ recker.fetch('facebook', {})
17
+ end
18
+
13
19
  def self.twitter
14
20
  recker.fetch('twitter', {})
15
21
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Recker
5
+ # Filters
6
+ module Filters
7
+ # Converts a date object to standard Uhh Yeah Dude format.
8
+ def uyd_date(date)
9
+ date.strftime('%A, %B %d %Y')
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ Liquid::Template.register_filter(Jekyll::Recker::Filters)
@@ -1,41 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'date'
4
-
5
3
  module Jekyll
6
4
  module Recker
7
- # Stats
8
- module Stats
9
- include Jekyll::Recker::LoggingMixin
10
-
11
- def self.crunch(site)
12
- stats = {}
13
- BaseCruncher.descendants.each do |cruncher_class|
14
- cruncher = cruncher_class.new(site)
15
- logger.info "crunching stats.#{cruncher.stats_key}"
16
- stats[cruncher.stats_key] = cruncher.crunch
17
- end
18
- stats
19
- end
20
-
21
- # Base Cruncher
22
- class BaseCruncher
5
+ module Generators
6
+ # Stats Module
7
+ #
8
+ # Functions for stats generators.
9
+ # @abstract
10
+ module Stats
11
+ include Mixins::Logging
23
12
  include Jekyll::Filters
24
- include DescendantsMixin
25
13
 
26
- def initialize(site)
27
- @site = site
14
+ def key
15
+ self.class.const_get(:KEY)
28
16
  end
29
17
 
30
- private
18
+ def generate(site)
19
+ @site = site
20
+ logger.info "crunching stats.#{key}"
21
+ @site.data['stats'] ||= {}
22
+ @site.data['stats'][key] = crunch
23
+ end
31
24
 
32
- attr_reader :journal
25
+ def crunch
26
+ raise NotImplementedError, '#crunch not implemented!'
27
+ end
33
28
 
29
+ # Calculates the average of a list of numbers.
30
+ #
31
+ # @param [Array<Numeric>] numlist list of numbers to be averaged.
32
+ # @return [Numeric] rounded, calculated average of numlist.
34
33
  def average(numlist)
35
34
  calc = numlist.inject { |sum, el| sum + el }.to_f / numlist.size
36
35
  calc.round
37
36
  end
38
37
 
38
+ # Calculates the total of a list of numbers.
39
+ #
40
+ # @param [Array<Numeric>] numlist list of numbers to be totaled.
41
+ # @return [Numeric] calculated total of numlist.
39
42
  def total(numlist)
40
43
  numlist.inject(0) { |sum, x| sum + x }
41
44
  end
@@ -45,22 +48,22 @@ module Jekyll
45
48
  end
46
49
  end
47
50
 
48
- # PostCountCruncher
49
- class PostCountCruncher < BaseCruncher
50
- def stats_key
51
- 'posts'
52
- end
51
+ # Post Count Generator
52
+ class PostCount < Jekyll::Generator
53
+ include Stats
54
+
55
+ KEY = 'posts'
53
56
 
54
57
  def crunch
55
58
  entries.count.pretty
56
59
  end
57
60
  end
58
61
 
59
- # WordCountCruncher
60
- class WordCountCruncher < BaseCruncher
61
- def stats_key
62
- 'words'
63
- end
62
+ # Word Count Generator
63
+ class Words < Jekyll::Generator
64
+ include Stats
65
+
66
+ KEY = 'words'
64
67
 
65
68
  def crunch
66
69
  total_counts = entries.collect(&:content).map { |c| number_of_words(c) }
@@ -71,11 +74,11 @@ module Jekyll
71
74
  end
72
75
  end
73
76
 
74
- # Streak Cruncher
75
- class StreakCruncher < BaseCruncher
76
- def stats_key
77
- 'days'
78
- end
77
+ # Streak Count Generator
78
+ class Streaks < Jekyll::Generator
79
+ include Stats
80
+
81
+ KEY = 'days'
79
82
 
80
83
  def crunch
81
84
  streaks.take(1).map do |count, dates|
@@ -94,7 +97,7 @@ module Jekyll
94
97
  entry_dates.slice_when do |prev, curr|
95
98
  curr != prev - 1
96
99
  end.each do |dates|
97
- first, last = dates.min, dates.max
100
+ first, last = dates.minmax
98
101
  _streaks << [(last - first).to_i, [first, last]]
99
102
  end
100
103
  _streaks