jekyll-glossary_tooltip 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c5f83067cb6ca64783230d5cbd9631e418b60fff839a7cdef44df1d1c7ec0412
4
+ data.tar.gz: 7f79aa92250c38f1650a4e5fdb9a2d1322f113a7689753270408312c12c928a4
5
+ SHA512:
6
+ metadata.gz: e55ab549deddf53b0c1831d562f7814990da41e919a1686aa816390748a0c93ccee9368671b35346a9c0c352d58a4bd874501e270d13d62185642d4ff834b189
7
+ data.tar.gz: 969838c0f5cef1cd11786fb04c4d95d476d6974cac0ef3c04701c3b524e3dcdbcc9957d3ce19d09ec6f7df119b627a42cc67cc08a7dcff44ddf670d1a3bf3dcf
data/.ackrc ADDED
@@ -0,0 +1,3 @@
1
+ --ignore-dir=coverage/
2
+ --ignore-dir=spec/dest
3
+ --ignore-dir=.jekyll-cache
data/.codeclimate.yml ADDED
@@ -0,0 +1,24 @@
1
+ # Reference: https://docs.codeclimate.com/docs/advanced-configuration#section-checks
2
+ # Reference of plugins: https://docs.codeclimate.com/docs/list-of-engines
3
+
4
+ version: "2"
5
+ plugins:
6
+ rubocop:
7
+ enabled: true
8
+ channel: rubocop-1-18-3
9
+ fixme:
10
+ enabled: true
11
+ eslint:
12
+ enabled: true
13
+ duplication:
14
+ enabled: true
15
+ config:
16
+ languages:
17
+ - ruby
18
+ - javascript
19
+ ratings:
20
+ paths:
21
+ - "**.rb"
22
+ - "**.js"
23
+ exclude_paths:
24
+ - script/
data/.editorconfig ADDED
@@ -0,0 +1,20 @@
1
+ # Modified version of https://github.com/ruby/ruby/blob/master/.editorconfig
2
+
3
+ root = true
4
+
5
+ [*]
6
+ end_of_line = lf
7
+ indent_size = 4
8
+ indent_style = space
9
+ insert_final_newline = true
10
+ tab_width = 4
11
+ trim_trailing_whitespace = true
12
+
13
+ [*.rb]
14
+ indent_size = 2
15
+
16
+ [*.gemspec]
17
+ indent_size = 2
18
+
19
+ [*.yml]
20
+ indent_size = 2
@@ -0,0 +1,9 @@
1
+ # Reference: https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
2
+ version: 2
3
+ updates:
4
+ - package-ecosystem: "bundler"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "monthly"
8
+ #ignore:
9
+ #- dependency-name: "rubocop"
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ # Contrary to ruby apps, ruby gems should not check in Gemfile.lock.
2
+ # Reference: https://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/
3
+ Gemfile.lock
4
+ # Same for Appraisals generated Gemfiles
5
+ gemfiles/*gemfile.lock
6
+ gemfiles/Gemfile*.lock
7
+
8
+ # Bundle local config
9
+ .bundle/
10
+
11
+ # Package gem from ($rake install)
12
+ pkg/
13
+
14
+ # simplecov
15
+ coverage/
16
+
17
+ # rspec
18
+ .jekyll-cache/
19
+ .rspec_status
20
+ spec/dest/
21
+ spec/reports/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,150 @@
1
+ # See pages relaed at https://docs.rubocop.org/rubocop/1.12/cops_layout.html
2
+
3
+ # Rubocop extensions
4
+ require:
5
+ - rubocop-rake
6
+ - rubocop-rspec
7
+
8
+ AllCops:
9
+ TargetRubyVersion: 3.0
10
+ Include:
11
+ - lib/**/*.rb
12
+ - spec/**/*.rb
13
+ Exclude:
14
+ # Travis: during build there will be a lot of rubocop config files in this pat which will cause build failure as the refer to gems which are not installed by this project.
15
+ # See https://github.com/rubocop/rubocop/issues/9832
16
+ - gemfiles/vendor/bundle/**/*
17
+
18
+ Gemspec/DateAssignment:
19
+ Enabled: true
20
+
21
+ Layout/LineEndStringConcatenationIndentation:
22
+ Enabled: true
23
+
24
+ Lint/AmbiguousAssignment:
25
+ Enabled: true
26
+ Lint/DeprecatedConstants:
27
+ Enabled: true
28
+ Lint/DuplicateBranch:
29
+ Enabled: true
30
+ Lint/DuplicateRegexpCharacterClassElement:
31
+ Enabled: true
32
+ Lint/EmptyBlock:
33
+ Enabled: true
34
+ Lint/EmptyClass:
35
+ Enabled: true
36
+ Layout/EmptyLineBetweenDefs:
37
+ Enabled: true
38
+ Exclude:
39
+ - lib/jekyll-glossary_tooltip/errors.rb
40
+ Lint/EmptyInPattern:
41
+ Enabled: true
42
+ Lint/LambdaWithoutLiteralBlock:
43
+ Enabled: true
44
+ Layout/LineLength:
45
+ Max: 120
46
+ Lint/NoReturnInBeginEndBlocks:
47
+ Enabled: true
48
+ Lint/NumberedParameterAssignment:
49
+ Enabled: true
50
+ Lint/OrAssignmentToConstant:
51
+ Enabled: true
52
+ Lint/RedundantDirGlobSort:
53
+ Enabled: true
54
+ Layout/SpaceBeforeBrackets:
55
+ Enabled: true
56
+ Lint/SymbolConversion:
57
+ Enabled: true
58
+ Lint/ToEnumArguments:
59
+ Enabled: true
60
+ Lint/TripleQuotes:
61
+ Enabled: true
62
+ Lint/UnexpectedBlockArity:
63
+ Enabled: true
64
+ Lint/UnmodifiedReduceAccumulator:
65
+ Enabled: true
66
+ Lint/UnreachableCode:
67
+ Severity: error
68
+ Lint/UselessAccessModifier:
69
+ Enabled: false
70
+
71
+ Metrics/BlockLength:
72
+ Enabled: true
73
+ Max: 100
74
+ Metrics/MethodLength:
75
+ Enabled: true
76
+ Max: 15
77
+
78
+ Naming/FileName:
79
+ Enabled: false
80
+ Exclude:
81
+ - lib/jekyll-glossary_tooltip.rb
82
+ Naming/InclusiveLanguage:
83
+ Enabled: true
84
+
85
+ Style/ArgumentsForwarding:
86
+ Enabled: true
87
+ Style/CollectionCompact:
88
+ Enabled: true
89
+ Style/Documentation:
90
+ Enabled: true
91
+ Exclude:
92
+ - lib/jekyll-glossary_tooltip/errors.rb
93
+ Style/DocumentDynamicEvalDefinition:
94
+ Enabled: true
95
+ Style/EndlessMethod:
96
+ Enabled: true
97
+ Style/HashConversion:
98
+ Enabled: true
99
+ Style/HashExcept:
100
+ Enabled: true
101
+ Style/IfWithBooleanLiteralBranches:
102
+ Enabled: true
103
+ Style/InPatternThen:
104
+ Enabled: true
105
+ Style/MultilineInPatternThen:
106
+ Enabled: true
107
+ Style/NegatedIfElseCondition:
108
+ Enabled: true
109
+ Style/NilLambda:
110
+ Enabled: true
111
+ Style/QuotedSymbols:
112
+ Enabled: true
113
+ Style/RedundantArgument:
114
+ Enabled: true
115
+ Style/RegexpLiteral:
116
+ Enabled: false
117
+ Style/SingleLineMethods:
118
+ Enabled: true
119
+ Exclude:
120
+ - lib/jekyll-glossary_tooltip/errors.rb
121
+ Style/StringChars:
122
+ Enabled: true
123
+ Style/StringLiterals:
124
+ Enabled: true
125
+ EnforcedStyle: double_quotes
126
+ Style/StringLiteralsInInterpolation:
127
+ Enabled: true
128
+ EnforcedStyle: double_quotes
129
+ Style/SwapValues:
130
+ Enabled: true
131
+
132
+
133
+ # Reference: https://github.com/rubocop/rubocop-rake/blob/master/config/default.yml
134
+ Rake:
135
+ Enabled: true
136
+
137
+ # Reference:
138
+ # https://docs.rubocop.org/rubocop-rspec/cops_rspec.html
139
+ # https://github.com/rubocop/rubocop-rspec/blob/master/config/default.yml
140
+ RSpec:
141
+ Enabled: true
142
+ RSpec/FilePath:
143
+ # Disable to match structure of lib/. For jekyll plugin inclusion convention features, not having lib/jekyll/sth.rb but lib/jekyll-sth.rb
144
+ Enabled: false
145
+ RSpec/IdenticalEqualityAssertion:
146
+ Enabled: true
147
+ RSpec/Rails/AvoidSetupHook:
148
+ Enabled: false
149
+ RSpec/BeforeAfterAll:
150
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.1
data/.simplecov ADDED
@@ -0,0 +1,6 @@
1
+ # vi: ft=ruby
2
+
3
+ SimpleCov.start do
4
+ enable_coverage :branch # Add branch coverage statistics.
5
+ minimum_coverage 90 # Minimum coverage percentage.
6
+ end
data/.travis.yml ADDED
@@ -0,0 +1,30 @@
1
+ # NOTE run $(travis lint) after modyifing this file.
2
+
3
+ # Travis
4
+ # - build lifecycle: https://docs.travis-ci.com/user/job-lifecycle
5
+ # - config doc: https://config.travis-ci.com/
6
+ # - ruby defaults: https://docs.travis-ci.com/user/languages/ruby/
7
+ # Codeclimate setup: https://docs.codeclimate.com/docs/travis-ci-test-coverage
8
+
9
+ version: ~> 1.0
10
+ env:
11
+ global:
12
+ - CC_TEST_REPORTER_ID=8b8822cdaba8bb6c0a9d3f05bea9bc94dbf866ccdd1204913f5673b61caa61b1
13
+ language: ruby
14
+ # Buid matrix (rvm x gemfile = 2x2) with one version from each supported major version in range defined in .gemspec for
15
+ rvm:
16
+ - 2.7.0
17
+ - 3.0.1
18
+ gemfile:
19
+ - gemfiles/jekyll_3.7.x.gemfile
20
+ - gemfiles/jekyll_4.x.x.gemfile
21
+ cache: bundler
22
+ before_install: gem install bundler -v 2.2.18
23
+ #install: bundle install # Default
24
+ before_script:
25
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
26
+ - chmod +x ./cc-test-reporter
27
+ - ./cc-test-reporter before-build
28
+ #script: bundle exec rake # Default
29
+ after_script:
30
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Appraisals ADDED
@@ -0,0 +1,11 @@
1
+ # Override jekyll verion from .gemspec
2
+
3
+ appraise "jekyll-3.7.x" do
4
+ gem "jekyll", "~> 3.7"
5
+ gem "kramdown", "2.3.1"
6
+ gem "kramdown-parser-gfm", "~> 1.0"
7
+ end
8
+
9
+ appraise "jekyll-4.x.x" do
10
+ gem "jekyll", "~> 4.0"
11
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## [0.1.0] - 2021-08-05
2
+ - First release version. The plugin is fully working but I suspect that there might be a few point releases just to nail the release process. Once this is working, there will soon be an 1.0.0 release!
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,4 @@
1
+ # How to contribute
2
+ Please use GitHub tooling (issues, PRs) to disucssion and code contributions!
3
+
4
+ When you open an PR, Travis will build your code, run tests, liters and so on.
data/Gemfile ADDED
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Put require=false on gem's that we don't need to import in code (cli exec only)
4
+
5
+ source "https://rubygems.org"
6
+
7
+ # Include dependencies from the .gemspec
8
+ gemspec
9
+
10
+ # Development dependencies
11
+ # Should rather be here than in the .gemspec
12
+ # Reference: https://github.com/rubygems/bundler/pull/7222
13
+ # However there's an argument for using gemspec too: https://bundler.io/guides/creating_gem.html#testing-our-gem
14
+ group :development, :test do
15
+ gem "rake", "~> 13.0", require: false
16
+ gem "travis", "~> 1.0", require: false
17
+ gem "appraisal", "~> 2.4", require: false
18
+ gem "gem-release", "~> 2.0", require: false
19
+ end
20
+
21
+ group :test do
22
+ gem "rspec", "~> 3.0"
23
+ gem "rubocop", "~> 1.18", require: false
24
+ gem "rubocop-rake", "~> 0.6", require: false
25
+ gem "rubocop-rspec", "~> 2.4", require: false
26
+ gem "simplecov", "~> 0.21"
27
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Erik Westrup
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.
data/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # Jekyll Glossary Tooltip Tag Plugin UNRELEASED
2
+ [![Gem Version](https://badge.fury.io/rb/jekyll-glossary_tooltip.svg)](https://badge.fury.io/rb/jekyll-glossary_tooltip)
3
+ [![Gem Downloads](https://ruby-gem-downloads-badge.herokuapp.com/jekyll-glossary_tooltip?color=brightgreen&type=total&label=gem%20downloads)](https://rubygems.org/gems/jekyll-glossary_tooltip)
4
+ [![Travis Build Status](https://img.shields.io/travis/erikw/jekyll-glossary_tooltip/main?logo=travis)](https://travis-ci.com/erikw/jekyll-glossary_tooltip)
5
+ [![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/7ffb648ec4b77f3f9eb8/maintainability)](https://codeclimate.com/github/erikw/jekyll-glossary_tooltip/maintainability)
6
+ [![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/7ffb648ec4b77f3f9eb8/test_coverage)](https://codeclimate.com/github/erikw/jekyll-glossary_tooltip/test_coverage)
7
+
8
+ <img src="/img/tooltip_screenshot.png" width="256" align="right" alt="Screenshot of the glossary tooltip term definition" title="Example of tooltip definition of the term 'Jekyll'.">
9
+
10
+
11
+ This plugin simplifies for your readers and you by making it easy to define terms or abbreviations that needs an explanation. Define a common dictionary of terms and their definition in a YAML file. Then inside markdown files you can use the provided glossary liquid tag to insert a tooltip for a defined word from the dictionary. The tooltip will show the term definition on mouse hover.
12
+
13
+ It's also possible to provide an optional URL to further term definition or source reference. To also support mobile devices, this URL link is placed inside the tooltip pop-up itself, rather than making the term itself clickable. This is so that on mobile device, you will first tap the word to get the hover tooltip, then click the link in the tooltip if desired.
14
+
15
+
16
+ # Installation
17
+ 1. Add this gem to your Jekyll site's Gemfile
18
+ - Simply with `$ bundle add jekyll-glossary_tooltip` when standing in the Jekyll project
19
+ - Or manually by adding to `Gemfile`
20
+ ```ruby
21
+ gem 'jekyll-glossary_tooltip'
22
+ ```
23
+ and then running `$ bundle install`.
24
+ 1. In your site's `_config.yml`, enable the plugin:
25
+ ```yml
26
+ plugins:
27
+ - jekyll-glossary_tooltip
28
+ ```
29
+ 1. Create a `_data/glossary.yml` file, according to the 'Glossary Term Definition File' section below, with your terms.
30
+ 1. Use the liquid tag in a page like `{% glossary term_name %}`
31
+ 1. Add CSS styling for the tooltip from [jekyll-glossary_tooltip.css](lib/jekyll-glossary_tooltip/jekyll-glossary_tooltip.css). You need to make sure that the pages where you will use the glossary tag have this styling applied. Typically this would mean 1) copying this file to your `assets/css/` directory 2) editing your theme's template for blog posts (or what pages you desire) to include this CSS in the header like `<link rel="stylesheet" href="/assets/css/jekyll-glossary_tooltip.css">`. However you could also copy this file's content in to your `main.css` or `main.scss` or however you build your site's CSS.
32
+ 1. Now just build your site and you will get nice nice term definition tooltips on mouse hover (or mobile, tap) for you terms!
33
+ ```console
34
+ $ bundle exec jekyll build
35
+ ```
36
+
37
+ # Usage
38
+ ## Glossary Term Definition File
39
+ Create a file `_data/glossary.yml` to host your shared term definition entries. This file should contain a list of term entries like
40
+
41
+ ```markdown
42
+ - term: a_term_name # Can contain spaces
43
+ definition: A description of the term
44
+ url: https://jekyllrb.com/ # Is optional
45
+ - term: another term
46
+ definition: Some other term definition text
47
+ ```
48
+
49
+ This could look something like:
50
+ ```markdown
51
+ - term: Jekyll
52
+ definition: A Static Site Generator (SSG) built with ruby. Widely adopted as of GitHub Pages inclusion.
53
+ url: https://jekyllrb.com/
54
+ - term: SSG
55
+ definition: A Static Site Generator compiles the website before deployment. Then the generated web content is simply retrieved as-is by the client without any code running at retrieve time.
56
+ - term: Jamstack
57
+ definition: JavaScript + API + Markup - a way of buildin and hosting websites.
58
+ url: https://jamstack.org/
59
+ ```
60
+
61
+
62
+ ## Tag Usage
63
+ On any page where you've made sure include the needed CSS styling, you can use the glossary tag simply like
64
+
65
+ ```markdown
66
+ Here I'm taling about {% glossary term_name %} in a blog post.
67
+
68
+ The term name can contain spaces like {% glossary operating system }.
69
+
70
+ Even if the term is defined in _data/glossary.yml as 'term_name', the matching is case-insensitive meaning that I can look it up using {% glossary TeRM_NaME %}. Note that the term is displayed as defined in the tag rather than the definition, here meaing 'TeRM_NaME'.
71
+ ```
72
+
73
+
74
+ ## CSS Style Override
75
+ Simply modify the rules [jekyll-glossary_tooltip.css](lib/jekyll-glossary_tooltip/jekyll-glossary_tooltip.css) that you copied to your project. The tooltip is based on this [tutorial](https://www.w3schools.com/css/css_tooltip.asp). View the generated HTML output to see the HTML tags that are styled, or check the [tag.rb](lib/jekyll-glossary_tooltip/tag.rb) implementation in the method `render()`.
76
+
77
+
78
+ # Development
79
+ The structure of this plugin was inspired by [https://ayastreb.me/writing-a-jekyll-plugin/](https://ayastreb.me/writing-a-jekyll-plugin/), the plugin jekyll-sitemap and the [Bundler Gem tutorial](https://bundler.io/guides/creating_gem.html).
80
+
81
+ After checking out the repo;
82
+ 1. Install [RVM](https://rvm.io/rvm/install) and install a supported ruby version (see .gemspec)
83
+ 1. run `script/setup` to install dependencies
84
+ 1. run `script/test` to run the tests
85
+ 1. You can also run `script/console` for an interactive prompt that will allow you to experiment.
86
+
87
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
88
+
89
+
90
+ ## Local development
91
+ Following the setup at [how-to-specify-local-ruby-gems-in-your-gemfile](https://rossta.net/blog/how-to-specify-local-ruby-gems-in-your-gemfile.html), these are the steps needed to build a jekyll site with a local clone of this plugin for local testing.
92
+
93
+ 1. Clone this repo to your machine, say at `~/src/jekyll-glossary_tooltip`
94
+ 1. In your Jekyll project's `Gemfile`:
95
+ - Remove the `gem 'jekyll-glossary_tooltip'` part
96
+ - Add instead `gem 'jekyll-glossary_tooltip', github: 'erikw/jekyll-glossary_tooltip', branch: 'main'`
97
+ 1. Configure bundler to use a local path for this gem in this project:
98
+ - `$ bundle config --local local.jekyll-glossary_tooltip ~/src/jekyll-glossary_tooltip`
99
+ 1. Update the project: `$ bundle install`
100
+ 1. Now the project will build with the local clone of this plugin when issuing e.g. `bundle exec jekyll build`
101
+ 1. When you're done:
102
+ - Remove the local override with: `$ bundle config --delete local.jekyll-glossary_tooltip`
103
+ - Optionally restore the original gem include in `Gemfile` or keep building from a branch in the github repo.
104
+
105
+ ## Releasing
106
+ Instructions for releasing on rubygems.org below. Optionally make a GitHub [release](https://github.com/erikw/jekyll-glossary_tooltip/releases) after this for the pushed git tag.
107
+
108
+ ## Using bundler/gem_tasks rake tasks
109
+ Following instructions from [bundler.io](https://bundler.io/guides/creating_gem.html#releasing-the-gem):
110
+ ```console
111
+ $ vi -p lib/jekyll-glossary_tooltip/version.rb CHANGELOG.md
112
+ $ bundle exec rake build
113
+ $ ver=$(ruby -r ./lib/jekyll-glossary_tooltip/version.rb -e 'puts Jekyll::GlossaryTooltip::VERSION')
114
+
115
+ # Optional: test locally by including in another project
116
+ $ gem install pkg/jekyll-glossary_tooltip-$ver.gem
117
+
118
+ $ bundle exec rake release
119
+ ```
120
+
121
+ ## Using gem-release gem extension
122
+ Using [gem-release](https://github.com/svenfuchs/gem-release):
123
+ ```console
124
+ $ vi CHANGELOG.md && git add CHANGELOG.md && git commit -m "Update CHANGELOG.md" && git push
125
+ $ gem bump --version minor --tag --sign --push --release
126
+ ```
127
+ For `--version`, use `major|minor|patch` as needed.
128
+
129
+ ## Multi-versions
130
+ * For ruby, just use RVM to switch between supported ruby version specified in `.gemspec`.
131
+ * To run with different jekyll versions, [Appraisal](https://github.com/thoughtbot/appraisal) is used with [`Appraisals`](Appraisals) to generate different [`gemfiles/`](gemfiles/)
132
+ - To use a specific Gemfile, run like
133
+ ```console
134
+ $ BUNDLE_GEMFILE=gemfiles/jekyll_4.x.x.gemfile bundle exec rake spec
135
+ $ bundle exec appraisal jekyll-4.x.x rake spec
136
+ ```
137
+ - To run `rake spec` for all gemfiles:
138
+ ```console
139
+ $ bundle exec appraisal rake spec
140
+ ```
141
+ - To generate new/updated gemfiles from `Appraisals`
142
+ ```console
143
+ $ bundle exec appraisal install
144
+ $ bundle exec appraisal generate --travis
145
+ ```
146
+
147
+ ## Travis
148
+ To use the [travis cli client](https://github.com/travis-ci/travis.rb) (installed from `Gemfile`):
149
+ 1. Get a GitHub OAuth token by
150
+ - going to [github.com/settings/tokens](https://github.com/settings/tokens)
151
+ - create a new token named `travis-cli`
152
+ - Set the scopes `repo`, `read:org`, `user:email` according to the [docs](https://docs.travis-ci.com/user/github-oauth-scopes).
153
+ 1. Set travis.com as the default so we don't need to add `--pro` to most commands
154
+ ```console
155
+ $ bundle exec travis endpoint --set-default --api-endpoint https://api.travis-ci.com/
156
+ ```
157
+ 1. Login with the cli client
158
+ ```console
159
+ $ bundle exec travis login --github-token $GITHUB_TOKEN
160
+ ```
161
+ 1. Now the cli client can be used (might need `--pro` to use travis.com)
162
+ ```console
163
+ $ bundle exec travis lint
164
+ $ bundle exec travis accounts
165
+ $ bundle exec travis status
166
+ $ bundle exec travis branches
167
+ $ bundle exec travis monitor
168
+ ```
169
+
170
+ # Contributing
171
+ Bug reports and pull requests are welcome on GitHub at https://github.com/erikw/jekyll-glossary_tooltip.
172
+
173
+ # License
174
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run $(rake -T) to list all tasks.
4
+
5
+ # Include default tasks like build, release, install etc. See https://github.com/rubygems/rubygems/blob/master/bundler/lib/bundler/gem_helper.rb#L46
6
+ require "bundler/gem_tasks"
7
+
8
+ # rspec: Testing framework. Adds 'spec' rake task.
9
+ require "rspec/core/rake_task"
10
+ RSpec::Core::RakeTask.new(:spec)
11
+
12
+ # rubocop: Linting. Adds 'rubocop' rake task.
13
+ require "rubocop/rake_task"
14
+ RuboCop::RakeTask.new(:rubocop) do |t|
15
+ # See https://docs.rubocop.org/rubocop/usage/basic_usage.html
16
+ t.options = ['--display-cop-names', '--parallel']
17
+ end
18
+
19
+ # default task: Add spec and rubocop to default tasks.
20
+ task default: %i[spec rubocop]
data/SECURITY.md ADDED
@@ -0,0 +1,12 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | ------------------ |
7
+ | 1.x.x | :white_check_mark: |
8
+ | < 1.0 | :x: |
9
+
10
+
11
+ ## Reporting a Vulnerability
12
+ Please open a GitHub Issue in this repository for any potential issues!
@@ -0,0 +1 @@
1
+ These Gemfiles are used from the CI pipeline in the build matrix to test specific versions of dependencies. They are generated by [Appraisal](https://github.com/thoughtbot/appraisal).
@@ -0,0 +1,23 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "~> 3.7"
6
+ gem "kramdown", "2.3.1"
7
+ gem "kramdown-parser-gfm", "~> 1.0"
8
+
9
+ group :development, :test do
10
+ gem "rake", "~> 13.0", require: false
11
+ gem "travis", "~> 1.0", require: false
12
+ gem "appraisal", "~> 2.4", require: false
13
+ end
14
+
15
+ group :test do
16
+ gem "rspec", "~> 3.0"
17
+ gem "rubocop", "~> 1.18", require: false
18
+ gem "rubocop-rake", "~> 0.6", require: false
19
+ gem "rubocop-rspec", "~> 2.4", require: false
20
+ gem "simplecov", "~> 0.21"
21
+ end
22
+
23
+ gemspec path: "../"
@@ -0,0 +1,21 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "jekyll", "~> 4.0"
6
+
7
+ group :development, :test do
8
+ gem "rake", "~> 13.0", require: false
9
+ gem "travis", "~> 1.0", require: false
10
+ gem "appraisal", "~> 2.4", require: false
11
+ end
12
+
13
+ group :test do
14
+ gem "rspec", "~> 3.0"
15
+ gem "rubocop", "~> 1.18", require: false
16
+ gem "rubocop-rake", "~> 0.6", require: false
17
+ gem "rubocop-rspec", "~> 2.4", require: false
18
+ gem "simplecov", "~> 0.21"
19
+ end
20
+
21
+ gemspec path: "../"
Binary file
Binary file
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/jekyll-glossary_tooltip/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jekyll-glossary_tooltip"
7
+ spec.version = Jekyll::GlossaryTooltip::VERSION
8
+ spec.authors = ["Erik Westrup"]
9
+ spec.email = ["erik.westrup@gmail.com"]
10
+
11
+ spec.summary = "Jekyll plugin providing a glossary liquid tag that will show a tooltip of a term definition in your site"
12
+ spec.description = "This plugin simplifies for your readers and you by making it easy to define terms or abbreviations that needs an explanation. Define a common dictionary of terms and their definition in a YAML file. Then inside markdown files you can use the provided glossary liquid tag to insert a tooltip for a defined word from the dictionary. The tooltip will show the term definition on mouse hover."
13
+ spec.homepage = "https://github.com/erikw/jekyll-glossary_tooltip/"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.7", "< 4"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/erikw/jekyll-glossary_tooltip/"
19
+ spec.metadata["changelog_uri"] = "https://github.com/erikw/jekyll-glossary_tooltip/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "jekyll", ">= 3.7", "< 5.0"
31
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "jekyll-glossary_tooltip/version"
4
+ require_relative "jekyll-glossary_tooltip/tag"
5
+
6
+ module Jekyll
7
+ # Module for the plugin.
8
+ module GlossaryTooltip
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module GlossaryTooltip
5
+ module Errors
6
+ class MissingTermDefinition < StandardError
7
+ def initialize(term_name); super("Glossary entry for '#{term_name}' does not contain a definition!") end
8
+ end
9
+ class MissingTermEntry < StandardError
10
+ def initialize(term_name); super("The term '#{term_name}' was not defined in the glossary") end
11
+ end
12
+ class MultipleTermEntries < StandardError
13
+ def initialize(term_name); super("The term '#{term_name}' was defined multiple times in the glossary") end
14
+ end
15
+ class NoGlossaryFile < StandardError; def initialize; super("No data.glossary found") end end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,38 @@
1
+ /* Tooltip from https://www.w3schools.com/css/css_tooltip.asp */
2
+ .jekyll-glossary {
3
+ position: relative;
4
+ display: inline-block;
5
+ border-bottom: 3px dotted blue;
6
+ cursor: help;
7
+ }
8
+
9
+ .jekyll-glossary .jekyll-glossary-tooltip {
10
+ visibility: hidden;
11
+ width: 120px;
12
+ background-color: black;
13
+ color: #fff;
14
+ text-align: center;
15
+ font-size: 0.5em;
16
+ padding: 5px;
17
+ border-radius: 6px;
18
+
19
+ /* Position the tooltip text - see examples below! */
20
+ position: absolute;
21
+ z-index: 1;
22
+
23
+ width: 160px;
24
+ bottom: 100%;
25
+ left: 50%;
26
+ margin-left: -80px; /* Use half of the width to center the tooltip */
27
+
28
+ }
29
+
30
+ /* Show the tooltip text when you mouse over the tooltip container */
31
+ .jekyll-glossary:hover .jekyll-glossary-tooltip {
32
+ visibility: visible;
33
+ }
34
+
35
+ /* Style the source link (if there is one provided in the glossary entry). */
36
+ .jekyll-glossary-source-link:before {
37
+ content: "[source]"; // "(reference)", "<link>" or whatever you want.
38
+ }
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll"
4
+ require "jekyll-glossary_tooltip/errors"
5
+
6
+ module Jekyll
7
+ module GlossaryTooltip
8
+ # Custom liquid tag implementation.
9
+ class Tag < Liquid::Tag
10
+ def initialize(tag_name, text, tokens)
11
+ super
12
+ @term_query = text.strip
13
+ end
14
+
15
+ def render(context)
16
+ entry = lookup_entry(context.registers[:site], @term_query)
17
+ <<~HTML
18
+ <span class="jekyll-glossary">
19
+ #{@term_query}
20
+ <span class="jekyll-glossary-tooltip">#{entry["definition"]}#{render_tooltip_url(entry)}</span>
21
+ </span>
22
+ HTML
23
+ end
24
+
25
+ private
26
+
27
+ LOG_TAG = "Glossary Tag:"
28
+
29
+ def render_tooltip_url(entry)
30
+ # The content of the anchor is set from the CSS class jekyll-glossary-source-link,
31
+ # so that the plugin user can customize the text without touching ruby source.
32
+ entry["url"] ? "<br><a class=\"jekyll-glossary-source-link\" href=\"#{entry["url"]}\"></a>" : ""
33
+ end
34
+
35
+ def lookup_entry(site, term_name)
36
+ entry = read_term_entry_from_config(site, term_name)
37
+ raise Errors::MissingTermDefinition, term_name unless entry["definition"]
38
+
39
+ entry["url"] = nil unless entry.key?("url")
40
+ entry
41
+ end
42
+
43
+ # Retrieve a term from the glossary via the site.
44
+ def read_term_entry_from_config(site, term_name)
45
+ raise Errors::NoGlossaryFile unless site.data["glossary"]
46
+
47
+ entries = site.data["glossary"].select do |entry|
48
+ entry.key?("term") and term_name.casecmp(entry["term"]).zero?
49
+ end
50
+
51
+ case entries.length
52
+ when 0
53
+ raise Errors::MissingTermEntry, term_name
54
+ when 1
55
+ entries[0]
56
+ else
57
+ raise Errors::MultipleTermEntries, term_name
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ Liquid::Template.register_tag("glossary", Jekyll::GlossaryTooltip::Tag)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module GlossaryTooltip
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
data/script/build ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env sh
2
+ set -eux
3
+ bundle exec rake $*
data/script/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "jekyll-glossary_tooltip"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/script/lint ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env sh
2
+ set -eux
3
+ bundle exec rake rubocop $*
data/script/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ rvm install ruby-$(cat .ruby-version)
7
+ gem install bundler -v 2.2.18
8
+ bundle install
data/script/test ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env sh
2
+ set -eux
3
+ bundle exec rake spec $*
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-glossary_tooltip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Erik Westrup
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-08-05 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.7'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.7'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ description: This plugin simplifies for your readers and you by making it easy to
34
+ define terms or abbreviations that needs an explanation. Define a common dictionary
35
+ of terms and their definition in a YAML file. Then inside markdown files you can
36
+ use the provided glossary liquid tag to insert a tooltip for a defined word from
37
+ the dictionary. The tooltip will show the term definition on mouse hover.
38
+ email:
39
+ - erik.westrup@gmail.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - ".ackrc"
45
+ - ".codeclimate.yml"
46
+ - ".editorconfig"
47
+ - ".github/dependabot.yml"
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - ".rubocop.yml"
51
+ - ".ruby-version"
52
+ - ".simplecov"
53
+ - ".travis.yml"
54
+ - Appraisals
55
+ - CHANGELOG.md
56
+ - CONTRIBUTING.md
57
+ - Gemfile
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - SECURITY.md
62
+ - gemfiles/README.md
63
+ - gemfiles/jekyll_3.7.x.gemfile
64
+ - gemfiles/jekyll_4.x.x.gemfile
65
+ - img/tooltip_screenshot.png
66
+ - img/tooltip_screenshot.xcf
67
+ - jekyll-glossary_tooltip.gemspec
68
+ - lib/jekyll-glossary_tooltip.rb
69
+ - lib/jekyll-glossary_tooltip/errors.rb
70
+ - lib/jekyll-glossary_tooltip/jekyll-glossary_tooltip.css
71
+ - lib/jekyll-glossary_tooltip/tag.rb
72
+ - lib/jekyll-glossary_tooltip/version.rb
73
+ - script/build
74
+ - script/console
75
+ - script/lint
76
+ - script/setup
77
+ - script/test
78
+ homepage: https://github.com/erikw/jekyll-glossary_tooltip/
79
+ licenses:
80
+ - MIT
81
+ metadata:
82
+ homepage_uri: https://github.com/erikw/jekyll-glossary_tooltip/
83
+ source_code_uri: https://github.com/erikw/jekyll-glossary_tooltip/
84
+ changelog_uri: https://github.com/erikw/jekyll-glossary_tooltip/blob/main/CHANGELOG.md
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '2.7'
94
+ - - "<"
95
+ - !ruby/object:Gem::Version
96
+ version: '4'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.2.15
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Jekyll plugin providing a glossary liquid tag that will show a tooltip of
107
+ a term definition in your site
108
+ test_files: []