jekyll-recker 1.2.3 → 1.8.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -7
  3. data/_includes/figure.html +14 -0
  4. data/_includes/footer.html +10 -1
  5. data/_includes/head.html +21 -0
  6. data/_includes/nav.html +3 -6
  7. data/_includes/pager.html +13 -0
  8. data/_layouts/home.html +13 -9
  9. data/_layouts/page.html +13 -8
  10. data/_layouts/post.html +20 -28
  11. data/lib/jekyll-recker.rb +17 -17
  12. data/lib/jekyll_recker/commands.rb +27 -0
  13. data/lib/jekyll_recker/configuration.rb +37 -0
  14. data/lib/jekyll_recker/error.rb +6 -0
  15. data/lib/jekyll_recker/extensions.rb +38 -0
  16. data/lib/jekyll_recker/filters.rb +13 -0
  17. data/lib/jekyll_recker/generators.rb +110 -0
  18. data/lib/jekyll_recker/mixins.rb +43 -0
  19. data/lib/{jekyll-recker → jekyll_recker}/shell.rb +5 -5
  20. data/lib/jekyll_recker/social.rb +175 -0
  21. data/lib/jekyll_recker/tags.rb +14 -0
  22. data/lib/jekyll_recker/utils.rb +37 -0
  23. data/lib/jekyll_recker/version.rb +5 -0
  24. metadata +103 -24
  25. data/_layouts/default.html +0 -16
  26. data/assets/inconsolata.css +0 -27
  27. data/assets/jekyll-recker.scss +0 -107
  28. data/assets/open-sans.css +0 -63
  29. data/lib/jekyll-recker/commands.rb +0 -12
  30. data/lib/jekyll-recker/commands/share.rb +0 -25
  31. data/lib/jekyll-recker/commands/slack.rb +0 -31
  32. data/lib/jekyll-recker/commands/tweet.rb +0 -31
  33. data/lib/jekyll-recker/configuration.rb +0 -35
  34. data/lib/jekyll-recker/error.rb +0 -8
  35. data/lib/jekyll-recker/generators.rb +0 -17
  36. data/lib/jekyll-recker/logger.rb +0 -20
  37. data/lib/jekyll-recker/mixins.rb +0 -27
  38. data/lib/jekyll-recker/slack.rb +0 -70
  39. data/lib/jekyll-recker/stats.rb +0 -109
  40. data/lib/jekyll-recker/tags.rb +0 -16
  41. data/lib/jekyll-recker/twitter.rb +0 -83
  42. data/lib/jekyll-recker/version.rb +0 -7
  43. data/lib/jekyll-recker/words.rb +0 -82
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd8510af30e4a225fa87cd6d3ba197cd38517634947897ca60ccfccc80055dbd
4
- data.tar.gz: 94e7fee9f82e53e73658cadee253f7dcb592404c81cf785dd74b86772dbd9052
3
+ metadata.gz: 78979b0c186d78e9296b547ead2c4f5a908945d7fe83fa498984e9dfa8766fc6
4
+ data.tar.gz: dc418d310aec0d6245d637e4ac5f20c428f07f954d7416cb03794781d58e263c
5
5
  SHA512:
6
- metadata.gz: 892465a9e44dd0317193f1f927fab37e50e88648c7360eadd314bc8eb36ace26449ed0c18c7b5e88e2c1f17c2f12daf3d06e770877db231c6d2d8719a25bee89
7
- data.tar.gz: 3a742c9c17d0079d309f40da244b7db9c7df5b49c7ee76598e4b84364abdfd13ea08605f05213562a2306b0f6982722a49c831f43ba4df55cc221535951857c2
6
+ metadata.gz: 70a080461c6462a80c0296a5573f91f2d8f0eb5995d9fda6be73d018af4cd1999cd1816fb7ca18949a18abd06a05740daefc358f2db9f26e37d4249b21207ad4
7
+ data.tar.gz: 96d7b050be0ad82ae2da7d1e1cadfe4aa328f4f3a780a800243d2027646a16babc22c030619289f8122899accfc24c40546fa2fa443aa70373b15c0280facaa0
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # jekyll-recker
2
2
 
3
- This is the jekyll plugin I use for [my personal website]. The source
4
- code is available on [github].
3
+ The Greatest Jekyll Plugin in the World. For a live example, check
4
+ out [my personal website].
5
5
 
6
6
  ## Installation
7
7
 
@@ -95,12 +95,11 @@ Configure the tweet share in `_config.yml`.
95
95
 
96
96
  Alternatively, ensure these environment variables are set.
97
97
 
98
- export ACCESS_TOKEN_SECRET="..."
99
- export ACCESS_TOKEN="..."
100
- export CONSUMER_API_KEY="..."
101
- export CONSUMER_API_SECRET="..."
98
+ export TWITTER_ACCESS_TOKEN_SECRET="..."
99
+ export TWITTER_ACCESS_TOKEN="..."
100
+ export TWITTER_CONSUMER_API_KEY="..."
101
+ export TWITTER_CONSUMER_API_SECRET="..."
102
102
 
103
103
  [example slack]: screenshots/example-slack.png
104
104
  [example tweet]: screenshots/example-tweet.png
105
- [github]: https://www.github.com/arecker/blog
106
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 doc/index.html %}">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.md %}" class="{% if page.active == 'stats' %}active{% endif %}">stats</a>
5
- <a href="{% link projects.md %}" class="{% if page.active == 'projects' %}active{% endif %}">projects</a>
6
- <a href="{% link contact.md %}" 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>
@@ -2,22 +2,22 @@
2
2
 
3
3
  require 'jekyll'
4
4
 
5
- module Jekyll
6
- # Recker
7
- module Recker
8
- require 'jekyll-recker/logger.rb'
9
- require 'jekyll-recker/mixins.rb'
5
+ # jekyll-recker
6
+ #
7
+ # The greatest jekyll plugin in the world
8
+ module JekyllRecker
9
+ autoload :Configuration, 'jekyll_recker/configuration.rb'
10
+ autoload :Error, 'jekyll_recker/error.rb'
11
+ autoload :Mixins, 'jekyll_recker/mixins.rb'
12
+ autoload :Shell, 'jekyll_recker/shell.rb'
13
+ autoload :Social, 'jekyll_recker/social.rb'
14
+ autoload :VERSION, 'jekyll_recker/version.rb'
15
+ autoload :Utils, 'jekyll_recker/utils.rb'
10
16
 
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'
22
- end
17
+ # Eager loads!
18
+ require 'jekyll_recker/commands.rb'
19
+ require 'jekyll_recker/extensions.rb'
20
+ require 'jekyll_recker/filters.rb'
21
+ require 'jekyll_recker/generators.rb'
22
+ require 'jekyll_recker/tags.rb'
23
23
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllRecker
4
+ # Commands
5
+ module Commands
6
+ # Share
7
+ class Share < Jekyll::Command
8
+ include Mixins::Logging
9
+
10
+ def self.init_with_program(prog)
11
+ prog.command(:share) do |c|
12
+ c.syntax 'share'
13
+ c.description 'Share latest post with each configured backend'
14
+ c.option 'dry', '-d', '--dry', 'perform dry run'
15
+ c.action { |args, opts| action(args, opts) }
16
+ end
17
+ end
18
+
19
+ def self.action(args, options)
20
+ JekyllRecker::Social.action(args, options)
21
+ rescue ::JekyllRecker::Error => e
22
+ logger.error e.message
23
+ exit 1
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllRecker
4
+ # Configuration
5
+ module Configuration
6
+ def self.jekyll
7
+ @jekyll ||= Jekyll.configuration
8
+ end
9
+
10
+ def self.recker
11
+ jekyll.fetch('recker', {})
12
+ end
13
+
14
+ def self.facebook
15
+ recker.fetch('facebook', {})
16
+ end
17
+
18
+ def self.twitter
19
+ recker.fetch('twitter', {})
20
+ end
21
+
22
+ def self.slack
23
+ recker.fetch('slack', {})
24
+ end
25
+
26
+ def self.site
27
+ @site = Jekyll::Site.new(jekyll)
28
+ @site.reset
29
+ @site.read
30
+ @site
31
+ end
32
+
33
+ def self.latest_post
34
+ @latest_post ||= site.posts.docs.last
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllRecker
4
+ # Error
5
+ class Error < StandardError; end
6
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Integer extensions
4
+ class Integer
5
+ def pretty
6
+ JekyllRecker::Utils.prettify_number(self)
7
+ end
8
+ end
9
+
10
+ # String extensions
11
+ class String
12
+ def words
13
+ JekyllRecker::Utils.to_word_list(self)
14
+ end
15
+
16
+ def word_count
17
+ JekyllRecker::Utils.to_word_list(self).count
18
+ end
19
+
20
+ def pretty_path(home = nil)
21
+ JekyllRecker::Utils.prettify_path(self, home)
22
+ end
23
+
24
+ def to_and_array
25
+ JekyllRecker::Utils.and_list_to_array(self)
26
+ end
27
+ end
28
+
29
+ # Array extensions
30
+ class Array
31
+ def to_and_list
32
+ JekyllRecker::Utils.array_to_and_list(self)
33
+ end
34
+
35
+ def to_weighted_list
36
+ JekyllRecker::Utils.to_weighted_list(self)
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllRecker
4
+ # Filters
5
+ module Filters
6
+ # Converts a date object to standard Uhh Yeah Dude format.
7
+ def uyd_date(date)
8
+ date.strftime('%A, %B %d %Y')
9
+ end
10
+ end
11
+ end
12
+
13
+ Liquid::Template.register_filter(JekyllRecker::Filters)
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllRecker
4
+ module Generators
5
+ # Stats Module
6
+ #
7
+ # Functions for stats generators.
8
+ # @abstract
9
+ module Stats
10
+ include Mixins::Logging
11
+ include Jekyll::Filters
12
+
13
+ def key
14
+ self.class.const_get(:KEY)
15
+ end
16
+
17
+ def generate(site)
18
+ @site = site
19
+ logger.info "crunching stats.#{key}"
20
+ @site.data['stats'] ||= {}
21
+ @site.data['stats'][key] = crunch
22
+ end
23
+
24
+ def crunch
25
+ raise NotImplementedError, '#crunch not implemented!'
26
+ end
27
+
28
+ # Calculates the average of a list of numbers.
29
+ #
30
+ # @param [Array<Numeric>] numlist list of numbers to be averaged.
31
+ # @return [Numeric] rounded, calculated average of numlist.
32
+ def average(numlist)
33
+ calc = numlist.inject { |sum, el| sum + el }.to_f / numlist.size
34
+ calc.round
35
+ end
36
+
37
+ # Calculates the total of a list of numbers.
38
+ #
39
+ # @param [Array<Numeric>] numlist list of numbers to be totaled.
40
+ # @return [Numeric] calculated total of numlist.
41
+ def total(numlist)
42
+ numlist.inject(0) { |sum, x| sum + x }
43
+ end
44
+
45
+ def entries
46
+ @site.posts.docs.select(&:published?)
47
+ end
48
+ end
49
+
50
+ # Post Count Generator
51
+ class PostCount < Jekyll::Generator
52
+ include Stats
53
+
54
+ KEY = 'posts'
55
+
56
+ def crunch
57
+ entries.count.pretty
58
+ end
59
+ end
60
+
61
+ # Word Count Generator
62
+ class Words < Jekyll::Generator
63
+ include Stats
64
+
65
+ KEY = 'words'
66
+
67
+ def crunch
68
+ total_counts = entries.collect(&:content).map { |c| number_of_words(c) }
69
+ {
70
+ 'average' => average(total_counts).pretty,
71
+ 'total' => total(total_counts).pretty
72
+ }
73
+ end
74
+ end
75
+
76
+ # Streak Count Generator
77
+ class Streaks < Jekyll::Generator
78
+ include Stats
79
+
80
+ KEY = 'days'
81
+
82
+ def crunch
83
+ streaks.take(1).map do |count, dates|
84
+ {
85
+ 'days' => count.pretty,
86
+ 'start' => dates[0],
87
+ 'end' => dates[1]
88
+ }
89
+ end.first
90
+ end
91
+
92
+ private
93
+
94
+ def streaks
95
+ _streaks = []
96
+ entry_dates.slice_when do |prev, curr|
97
+ curr != prev - 1
98
+ end.each do |dates|
99
+ first, last = dates.minmax
100
+ _streaks << [(last - first).to_i, [first, last]]
101
+ end
102
+ _streaks
103
+ end
104
+
105
+ def entry_dates
106
+ entries.collect(&:date).map { |t| Date.new(t.year, t.month, t.day) }.sort.reverse
107
+ end
108
+ end
109
+ end
110
+ end