jekyll-clean-descriptions 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 372f2c803ddc552a23f4f765fb3ef577b3150843e98a9df5be8d11a59ccfb742
4
+ data.tar.gz: cdcf79364f800744a20c7185c101780f9f4b48533145638df3af3b1d80e75bfb
5
+ SHA512:
6
+ metadata.gz: 1cbc1d2e2241d1a037c0ed4b339686aa11aaae539ebe0580c15cf0865cbed3ca26f55a5cb837d395eeb32bccfe75ace097e97fc6ae4a2117a92b5e568160f513
7
+ data.tar.gz: 9e68985d1a9ab5cc895a164adc3da84f54a73cd0a80037ae2a3a181a0513dad15f2420788e25d24b517aebb21966dde80e63bdaf4dde2a56c9cb6b229337d5e0
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ jekyll-clean-descriptions*.gem
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 2.0.1
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jekyll-clean-descriptions.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 dusty candland
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # Jekyll::Clean::Descriptions
2
+
3
+ Use this to automatically create shorter descriptions based on the excerpt value.
4
+ It will clean HTML, remove new lines, and truncate to 160 characters.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ group :jekyll_plugins do
12
+ gem 'jekyll-clean-descriptions'
13
+ end
14
+ ```
15
+
16
+ Add to your `_config.yml` file:
17
+
18
+ ```yml
19
+ plugins:
20
+ gem 'jekyll-clean-descriptions'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install jekyll-clean-descriptions
30
+
31
+ ## Usage
32
+
33
+ Currently none. Uses Jekyll Hooks to automatically shorten post excerpts and set
34
+ a description variable for [jekyll-seo-tag]() and anything else that looks for
35
+ `page.description` to be set.
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/candland/jekyll-clean-descriptions.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll/clean/descriptions"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "jekyll/clean/descriptions/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jekyll-clean-descriptions"
8
+ spec.version = Jekyll::Clean::Descriptions::VERSION
9
+ spec.authors = ["dusty candland"]
10
+ spec.email = ["candland@gmail.com"]
11
+
12
+ spec.summary = %q{Clean and shorten Jekyll descriptions.}
13
+ spec.homepage = "https://github.com/candland/jekyll-clean-descriptions"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/candland/jekyll-clean-descriptions"
23
+ spec.metadata["changelog_uri"] = "https://github.com/candland/jekyll-clean-descriptions/CHANGELOG.md"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_dependency "jekyll", "~> 3.3"
39
+ spec.add_development_dependency "bundler", "~> 2.0"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "minitest", "~> 5.0"
42
+ end
@@ -0,0 +1,15 @@
1
+ require "jekyll/clean/descriptions/version"
2
+ require_relative "./descriptions/cleaner.rb"
3
+
4
+ module Jekyll
5
+ module Clean
6
+ module Descriptions
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
10
+ end
11
+ end
12
+
13
+ Jekyll::Hooks.register :posts, :pre_render do |container, payload|
14
+ Jekyll::Clean::Descriptions::Cleaner.new.call(container)
15
+ end
@@ -0,0 +1,46 @@
1
+ module Jekyll
2
+ module Clean
3
+ module Descriptions
4
+ class Cleaner
5
+ FORMAT_STRING_METHODS = [
6
+ :strip_html, :strip_newlines, :normalize_whitespace, :escape_once,
7
+ ].freeze
8
+
9
+ def filters
10
+ @filters ||= Filters.new(Liquid::Context.new)
11
+ end
12
+
13
+ def initialize
14
+ end
15
+
16
+ def call page
17
+ if !page.data['description']
18
+ if page.data['excerpt']
19
+ description = cleanup(page.data['excerpt'])
20
+ if description and !description.empty?
21
+ page.data['description'] = description
22
+ end
23
+ end
24
+ end
25
+ page
26
+ end
27
+
28
+ def cleanup description
29
+ description = FORMAT_STRING_METHODS.reduce(description) do |memo, method|
30
+ filters.public_send(method, memo)
31
+ end
32
+ filters.truncate(description, 160)
33
+ end
34
+
35
+ class Filters
36
+ include Jekyll::Filters
37
+ include Liquid::StandardFilters
38
+
39
+ def initialize(context)
40
+ @context = context
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,7 @@
1
+ module Jekyll
2
+ module Clean
3
+ module Descriptions
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-clean-descriptions
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - dusty candland
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-02-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ description:
70
+ email:
71
+ - candland@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - CHANGELOG.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - jekyll-clean-descriptions.gemspec
86
+ - lib/jekyll/clean/descriptions.rb
87
+ - lib/jekyll/clean/descriptions/cleaner.rb
88
+ - lib/jekyll/clean/descriptions/version.rb
89
+ homepage: https://github.com/candland/jekyll-clean-descriptions
90
+ licenses:
91
+ - MIT
92
+ metadata:
93
+ allowed_push_host: https://rubygems.org
94
+ homepage_uri: https://github.com/candland/jekyll-clean-descriptions
95
+ source_code_uri: https://github.com/candland/jekyll-clean-descriptions
96
+ changelog_uri: https://github.com/candland/jekyll-clean-descriptions/CHANGELOG.md
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.7.6
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Clean and shorten Jekyll descriptions.
117
+ test_files: []