jekyll-google_search_console_verification_file 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ackrc +3 -0
- data/.codeclimate.yml +23 -0
- data/.editorconfig +20 -0
- data/.github/dependabot.yml +9 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.rubocop.yml +133 -0
- data/.ruby-version +1 -0
- data/.simplecov +6 -0
- data/.travis.yml +30 -0
- data/Appraisals +11 -0
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTING.md +4 -0
- data/Gemfile +26 -0
- data/LICENSE.txt +21 -0
- data/README.md +144 -0
- data/Rakefile +20 -0
- data/SECURITY.md +12 -0
- data/gemfiles/README.md +1 -0
- data/gemfiles/jekyll_3.7.x.gemfile +23 -0
- data/gemfiles/jekyll_4.x.x.gemfile +21 -0
- data/jekyll-google_search_console_verification_file.gemspec +31 -0
- data/lib/jekyll-google_search_console_verification_file.rb +10 -0
- data/lib/jekyll-google_search_console_verification_file/generator.rb +63 -0
- data/lib/jekyll-google_search_console_verification_file/template.html +1 -0
- data/lib/jekyll-google_search_console_verification_file/version.rb +7 -0
- data/script/build +3 -0
- data/script/console +15 -0
- data/script/lint +3 -0
- data/script/setup +8 -0
- data/script/test +3 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2a6ca17ec0bd69f37d9d9e92f524f679724d6a67ded417aafab55508b3a9fe1f
|
4
|
+
data.tar.gz: 7df68efc8d1976dd260bca2ad95afd42d673cafacb541dbbe8ea62b8b854389b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23c8646764aa5a745488b879bde235ecaae2294d6d074e06d1a7ee140e1a507455e7b371ad4d7808fc506657b34c91c3eaac261f9aeb324aadc156f3b472ec95
|
7
|
+
data.tar.gz: 647cc1e5df74cda1e2b3ba90e6bdff7d93d437875c947ea676c8e7cc31cb8afe6c5692016ae6d8e205041466dc5c44013049d9d492b476e695e94920e35c7892
|
data/.ackrc
ADDED
data/.codeclimate.yml
ADDED
@@ -0,0 +1,23 @@
|
|
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
|
+
fixme:
|
9
|
+
enabled: true
|
10
|
+
eslint:
|
11
|
+
enabled: true
|
12
|
+
duplication:
|
13
|
+
enabled: true
|
14
|
+
config:
|
15
|
+
languages:
|
16
|
+
- ruby
|
17
|
+
- javascript
|
18
|
+
ratings:
|
19
|
+
paths:
|
20
|
+
- "**.rb"
|
21
|
+
- "**.js"
|
22
|
+
exclude_paths:
|
23
|
+
- 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
data/.rubocop.yml
ADDED
@@ -0,0 +1,133 @@
|
|
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
|
+
Lint/EmptyInPattern:
|
37
|
+
Enabled: true
|
38
|
+
Lint/LambdaWithoutLiteralBlock:
|
39
|
+
Enabled: true
|
40
|
+
Layout/LineLength:
|
41
|
+
Max: 120
|
42
|
+
Lint/NoReturnInBeginEndBlocks:
|
43
|
+
Enabled: true
|
44
|
+
Lint/NumberedParameterAssignment:
|
45
|
+
Enabled: true
|
46
|
+
Lint/OrAssignmentToConstant:
|
47
|
+
Enabled: true
|
48
|
+
Lint/RedundantDirGlobSort:
|
49
|
+
Enabled: true
|
50
|
+
Layout/SpaceBeforeBrackets:
|
51
|
+
Enabled: true
|
52
|
+
Lint/SymbolConversion:
|
53
|
+
Enabled: true
|
54
|
+
Lint/ToEnumArguments:
|
55
|
+
Enabled: true
|
56
|
+
Lint/TripleQuotes:
|
57
|
+
Enabled: true
|
58
|
+
Lint/UnexpectedBlockArity:
|
59
|
+
Enabled: true
|
60
|
+
Lint/UnmodifiedReduceAccumulator:
|
61
|
+
Enabled: true
|
62
|
+
Lint/UnreachableCode:
|
63
|
+
Severity: error
|
64
|
+
Lint/UselessAccessModifier:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Metrics/BlockLength:
|
68
|
+
Enabled: true
|
69
|
+
Max: 100
|
70
|
+
|
71
|
+
Naming/FileName:
|
72
|
+
Enabled: false
|
73
|
+
Exclude:
|
74
|
+
- lib/jekyll-google_search_console_verification_file.rb
|
75
|
+
Naming/InclusiveLanguage:
|
76
|
+
Enabled: true
|
77
|
+
|
78
|
+
Style/ArgumentsForwarding:
|
79
|
+
Enabled: true
|
80
|
+
Style/CollectionCompact:
|
81
|
+
Enabled: true
|
82
|
+
Style/DocumentDynamicEvalDefinition:
|
83
|
+
Enabled: true
|
84
|
+
Style/EndlessMethod:
|
85
|
+
Enabled: true
|
86
|
+
Style/HashConversion:
|
87
|
+
Enabled: true
|
88
|
+
Style/HashExcept:
|
89
|
+
Enabled: true
|
90
|
+
Style/IfWithBooleanLiteralBranches:
|
91
|
+
Enabled: true
|
92
|
+
Style/InPatternThen:
|
93
|
+
Enabled: true
|
94
|
+
Style/MultilineInPatternThen:
|
95
|
+
Enabled: true
|
96
|
+
Style/NegatedIfElseCondition:
|
97
|
+
Enabled: true
|
98
|
+
Style/NilLambda:
|
99
|
+
Enabled: true
|
100
|
+
Style/QuotedSymbols:
|
101
|
+
Enabled: true
|
102
|
+
Style/RedundantArgument:
|
103
|
+
Enabled: true
|
104
|
+
Style/StringChars:
|
105
|
+
Enabled: true
|
106
|
+
Style/StringLiterals:
|
107
|
+
Enabled: true
|
108
|
+
EnforcedStyle: double_quotes
|
109
|
+
Style/StringLiteralsInInterpolation:
|
110
|
+
Enabled: true
|
111
|
+
EnforcedStyle: double_quotes
|
112
|
+
Style/SwapValues:
|
113
|
+
Enabled: true
|
114
|
+
|
115
|
+
|
116
|
+
# Reference: https://github.com/rubocop/rubocop-rake/blob/master/config/default.yml
|
117
|
+
Rake:
|
118
|
+
Enabled: true
|
119
|
+
|
120
|
+
# Reference:
|
121
|
+
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html
|
122
|
+
# https://github.com/rubocop/rubocop-rspec/blob/master/config/default.yml
|
123
|
+
RSpec:
|
124
|
+
Enabled: true
|
125
|
+
RSpec/FilePath:
|
126
|
+
# Disable to match structure of lib/. For jekyll plugin inclusion convention features, not having lib/jekyll/sth.rb but lib/jekyll-sth.rb
|
127
|
+
Enabled: false
|
128
|
+
RSpec/IdenticalEqualityAssertion:
|
129
|
+
Enabled: true
|
130
|
+
RSpec/Rails/AvoidSetupHook:
|
131
|
+
Enabled: false
|
132
|
+
RSpec/BeforeAfterAll:
|
133
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.1
|
data/.simplecov
ADDED
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=9a84a9f695de3b120b6fcead4e089b45420f7518fb2123dc5424f862d381c4ff
|
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
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,26 @@
|
|
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
|
+
end
|
19
|
+
|
20
|
+
group :test do
|
21
|
+
gem "rspec", "~> 3.0"
|
22
|
+
gem "rubocop", "~> 1.18", require: false
|
23
|
+
gem "rubocop-rake", "~> 0.6", require: false
|
24
|
+
gem "rubocop-rspec", "~> 2.4", require: false
|
25
|
+
gem "simplecov", "~> 0.21"
|
26
|
+
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,144 @@
|
|
1
|
+
# Jekyll Google Search Console Verification File Generator Plugin - UNRELEASED
|
2
|
+
[![Travis Build Status](https://img.shields.io/travis/erikw/jekyll-google_search_console_verification_file/main?logo=travis)](https://travis-ci.com/erikw/jekyll-google_search_console_verification_file)
|
3
|
+
[![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/59050f3f66ed1f1ee32e/maintainability)](https://codeclimate.com/github/erikw/jekyll-google_search_console_verification_file/maintainability)
|
4
|
+
[![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/59050f3f66ed1f1ee32e/test_coverage)](https://codeclimate.com/github/erikw/jekyll-google_search_console_verification_file/test_coverage)
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
This is a very simple plugin that will generate a Google Search Console (GSC from here) [verification file](https://support.google.com/webmasters/answer/9008080?hl=en) to your `_site/` directory in a Jekyll project. This file is used by GSC to verify that you own the site and looks for example like my [googlef47733b3288357e4.html](https://erikw.me/googlef47733b3288357e4.html).
|
10
|
+
|
11
|
+
## Why?
|
12
|
+
Why use this plugin?
|
13
|
+
|
14
|
+
### Tl;DR
|
15
|
+
* Don't stuff bloating `<meta>` tag to all your HTML pages; use simple file in the site's root
|
16
|
+
* Generate what can be generated; keep your source tree clean!
|
17
|
+
|
18
|
+
|
19
|
+
### !TL;DidRead
|
20
|
+
There are multiple ways to [verify](https://support.google.com/webmasters/answer/9008080?hl=en) the ownership of your site. The two simpler ways, both suitable for Github Pages owners, are to add an `<meta> tag to your pages` or upload a special unique file to the root of the site. For adding the meta tag, there are excellent plugins making this very easy for example [jekyll-seo-tag](http://jekyll.github.io/jekyll-seo-tag/usage/). If you want to the meta tag, I recommend this plugin.
|
21
|
+
|
22
|
+
However if you feel that it's bloated to add this `<meta>` tag to the header all you pages, keeping file size and page load speed in mind, you may one to go for the file based verification method instead.
|
23
|
+
|
24
|
+
So with the file based method, why not just add the file you downloaded from GSC to your source directory and let Jekyll put it in `_site/` on generation? As we're using a SSG (Static Site Generator), we should generate everything we can. It's verdantly nice to keep the source tree clean and make everything that can be a configuration that generates what is needed.
|
25
|
+
|
26
|
+
Thus, this plugin exist to solve this problem. Give the plugin the unique code GSC provided you and it will generate the file for you in `_site/`!
|
27
|
+
|
28
|
+
Note that if you do place a verification file in the root of the source tree, this will override the generation by this plugin.
|
29
|
+
|
30
|
+
# Installation
|
31
|
+
1. Add this gem to your Jekyll site's Gemfile
|
32
|
+
- Simply with `$ bundle add jekyll-google-search-console-verification-file` when standing in the Jekyll project
|
33
|
+
- Or manually by adding to `Gemfile`
|
34
|
+
```ruby
|
35
|
+
gem 'jekyll-google-search-console-verification-file'
|
36
|
+
```
|
37
|
+
and then running `$ bundle install`.
|
38
|
+
1. In your site's `_config.yml`, enable the plugin:
|
39
|
+
```yml
|
40
|
+
plugins:
|
41
|
+
- jekyll-google-search-console-verification-file
|
42
|
+
```
|
43
|
+
1. Get the GSC unique code for you website.
|
44
|
+
1. Register your website at [Google Search Console](https://search.google.com/search-console?resource_id=https://erikw.me/)
|
45
|
+
1. From the main dashboard of your site at GSC: _Settings > Ownership Verification > HTML File_ and download the unique file
|
46
|
+
1. Instead of putting this file in our jekyll site, just copy the unique code from the HTML file name e.g. from `googlef47733b3288357e4.html` copy `f47733b3288357e4`.
|
47
|
+
1. In your site's `_config.yml`, configure this plugin with the code from the previous step:
|
48
|
+
```yml
|
49
|
+
google_search_console:
|
50
|
+
verification_file_code: 47733b3288357e4
|
51
|
+
```
|
52
|
+
1. Now just build your site and verify that the verification file now exist!
|
53
|
+
```bash
|
54
|
+
$ bundle exec jekyll build
|
55
|
+
$ ls _site/ | grep "google.*\.html"
|
56
|
+
google47733b3288357e4.html
|
57
|
+
```
|
58
|
+
|
59
|
+
# Development
|
60
|
+
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).
|
61
|
+
|
62
|
+
After checking out the repo;
|
63
|
+
1. Install [RVM](https://rvm.io/rvm/install) and install a supported ruby version (see .gemspec)
|
64
|
+
1. run `script/setup` to install dependencies
|
65
|
+
1. run `script/test` to run the tests
|
66
|
+
1. You can also run `script/console` for an interactive prompt that will allow you to experiment.
|
67
|
+
|
68
|
+
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).
|
69
|
+
|
70
|
+
|
71
|
+
## Local development
|
72
|
+
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.
|
73
|
+
|
74
|
+
1. Clone this repo to your machine, say at `~/src/jekyll-google_search_console_verification_file`
|
75
|
+
1. In your Jekyll project's `Gemfile`:
|
76
|
+
- Remove the `gem 'jekyll-google_search_console_verification_file'` part
|
77
|
+
- Add instead `gem 'jekyll-google_search_console_verification_file', github: 'erikw/jekyll-google_search_console_verification_file', branch: 'main'`
|
78
|
+
1. Configure bundler to use a local path for this gem in this project:
|
79
|
+
- `$ bundle config --local local.jekyll-google_search_console_verification_file ~/src/jekyll-google_search_console_verification_file`
|
80
|
+
1. Update the project: `$ bundle install`
|
81
|
+
1. Now the project will build with the local clone of this plugin when issuing e.g. `bundle exec jekyll build`
|
82
|
+
1. When you're done:
|
83
|
+
- Remove the local override with: `$ bundle config --delete local.jekyll-google_search_console_verification_file`
|
84
|
+
- Optionally restore the original gem include in `Gemfile` or keep building from a branch in the github repo.
|
85
|
+
|
86
|
+
## Releasing
|
87
|
+
## Using gem bundler/gem_tasks
|
88
|
+
```console
|
89
|
+
$ vi -p lib/jekyll-google_search_console_verification_file/version.rb CHANGELOG.md
|
90
|
+
$ bundle exec rake build
|
91
|
+
$ ver=$(ruby -r jekyll-google_search_console_verification_file/version -e 'puts Jekyll::GoogleSearchConsoleVerificationFile::VERSION')
|
92
|
+
|
93
|
+
# Optional: test locally by including in another project
|
94
|
+
$ gem install pkg/jekyll-google_search_console_verification_file-$ver.gem
|
95
|
+
|
96
|
+
$ bundle exec rake release
|
97
|
+
```
|
98
|
+
|
99
|
+
## Multi-versions
|
100
|
+
* For ruby, just use RVM to switch between supported ruby version specified in `.gemspec`.
|
101
|
+
* To run with different jekyll versions, [Appraisal](https://github.com/thoughtbot/appraisal) is used with [`Appraisals`](Appraisals) to generate different [`gemfiles/`](gemfiles/)
|
102
|
+
- To use a specific Gemfile, run like
|
103
|
+
```console
|
104
|
+
$ BUNDLE_GEMFILE=gemfiles/jekyll_4.x.x.gemfile bundle exec rake spec
|
105
|
+
$ bundle exec appraisal jekyll-4.x.x rake spec
|
106
|
+
```
|
107
|
+
- To run `rake spec` for all gemfiles:
|
108
|
+
```console
|
109
|
+
$ bundle exec appraisal rake spec
|
110
|
+
```
|
111
|
+
- To generate new/updated gemfiles from `Appraisals`
|
112
|
+
```console
|
113
|
+
$ bundle exec appraisal install
|
114
|
+
$ bundle exec appraisal generate --travis
|
115
|
+
```
|
116
|
+
|
117
|
+
## Travis
|
118
|
+
To use the [travis cli client](https://github.com/travis-ci/travis.rb) (installed from `Gemfile`):
|
119
|
+
1. Get a GitHub OAuth token by
|
120
|
+
- going to [github.com/settings/tokens](https://github.com/settings/tokens)
|
121
|
+
- create a new token named `travis-cli`
|
122
|
+
- Set the scopes `repo`, `read:org`, `user:email` according to the [docs](https://docs.travis-ci.com/user/github-oauth-scopes).
|
123
|
+
1. Set travis.com as the default so we don't need to add `--pro` to most commands
|
124
|
+
```console
|
125
|
+
$ bundle exec travis endpoint --set-default --api-endpoint https://api.travis-ci.com/
|
126
|
+
```
|
127
|
+
1. Login with the cli client
|
128
|
+
```console
|
129
|
+
$ bundle exec travis login --github-token $GITHUB_TOKEN
|
130
|
+
```
|
131
|
+
1. Now the cli client can be used (might need `--pro` to use travis.com)
|
132
|
+
```console
|
133
|
+
$ bundle exec travis lint
|
134
|
+
$ bundle exec travis accounts
|
135
|
+
$ bundle exec travis status
|
136
|
+
$ bundle exec travis branches
|
137
|
+
$ bundle exec travis monitor
|
138
|
+
```
|
139
|
+
|
140
|
+
# Contributing
|
141
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/erikw/jekyll-google_search_console_verification_file.
|
142
|
+
|
143
|
+
# License
|
144
|
+
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!
|
data/gemfiles/README.md
ADDED
@@ -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: "../"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/jekyll-google_search_console_verification_file/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "jekyll-google_search_console_verification_file"
|
7
|
+
spec.version = Jekyll::GoogleSearchConsoleVerificationFile::VERSION
|
8
|
+
spec.authors = ["Erik Westrup"]
|
9
|
+
spec.email = ["erik.westrup@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Generate a Google Search Console verification file from your _config.yml e.g. google47733b3288357e4.html to the root of your Jekyll site."
|
12
|
+
spec.description = "This is a very simple plugin that will generate a Google Search Console (GSC from here) verification file to your _site/ directory in a Jekyll project. This file is used by GSC to verify that you own the site and looks for example like https://erikw.me/googlef47733b3288357e4.html."
|
13
|
+
spec.homepage = "https://github.com/erikw/jekyll-google_search_console_verification_file/tree/dev"
|
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-google_search_console_verification_file/tree/dev"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/erikw/jekyll-google_search_console_verification_file/blob/dev/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-google_search_console_verification_file/version"
|
4
|
+
require_relative "jekyll-google_search_console_verification_file/generator"
|
5
|
+
|
6
|
+
module Jekyll
|
7
|
+
# Module for the plugin.
|
8
|
+
module GoogleSearchConsoleVerificationFile
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
module GoogleSearchConsoleVerificationFile
|
7
|
+
# Generator for the verification file.
|
8
|
+
class Generator < Jekyll::Generator
|
9
|
+
safe true
|
10
|
+
priority :lowest
|
11
|
+
|
12
|
+
# Plugin entry point.
|
13
|
+
def generate(site)
|
14
|
+
@site = site
|
15
|
+
@site.pages << verification_file unless a_verification_file_exist?
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# Configuration keys in _config.yml
|
21
|
+
CONF_NS = "google_search_console"
|
22
|
+
CONF_CODE = "verification_file_code"
|
23
|
+
# The 'progname' argument to the logger class.
|
24
|
+
LOG_TAG = "Google Search Console Verification File Generator:"
|
25
|
+
|
26
|
+
# Get the verification code from _config.yml
|
27
|
+
def verification_code
|
28
|
+
err_msg = "#{LOG_TAG} #{CONF_NS}.#{CONF_CODE} must be set in _config.html"
|
29
|
+
raise ArgumentError, err_msg unless @site.config[CONF_NS]&.[](CONF_CODE)
|
30
|
+
|
31
|
+
@site.config[CONF_NS][CONF_CODE]
|
32
|
+
end
|
33
|
+
|
34
|
+
# Check if a GSC verification file already exist in the source that will be put in the root of the generated site.
|
35
|
+
def a_verification_file_exist?
|
36
|
+
file_pattern = %r{/google.+\.html?}
|
37
|
+
exists = @site.static_files.any? { |p| p.url =~ file_pattern }
|
38
|
+
warn_msg = "Found a verification file in source tree matching /#{file_pattern.source}/; not generating one..."
|
39
|
+
Jekyll.logger.warn LOG_TAG, warn_msg if exists
|
40
|
+
exists
|
41
|
+
end
|
42
|
+
|
43
|
+
# Get path of the template file.
|
44
|
+
def source_path(file = "jekyll-google_search_console_verification_file/template.html")
|
45
|
+
File.expand_path "../#{file}", __dir__
|
46
|
+
end
|
47
|
+
|
48
|
+
# Path of the output file.
|
49
|
+
def destination_path
|
50
|
+
"google#{verification_code}.html"
|
51
|
+
end
|
52
|
+
|
53
|
+
# Construct a file object from a template with content that can be added to generated pages
|
54
|
+
def verification_file
|
55
|
+
Jekyll.logger.info LOG_TAG, "Generating #{destination_path}"
|
56
|
+
page = PageWithoutAFile.new(@site, __dir__, "", destination_path)
|
57
|
+
page.content = File.read(source_path)
|
58
|
+
page.data["layout"] = nil
|
59
|
+
page
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
google-site-verification: google{{ site.google_search_console.verification_file_code }}.html
|
data/script/build
ADDED
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-google_search_console_verification_file"
|
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
data/script/setup
ADDED
data/script/test
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-google_search_console_verification_file
|
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-07-04 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 is a very simple plugin that will generate a Google Search Console
|
34
|
+
(GSC from here) verification file to your _site/ directory in a Jekyll project.
|
35
|
+
This file is used by GSC to verify that you own the site and looks for example like
|
36
|
+
https://erikw.me/googlef47733b3288357e4.html.
|
37
|
+
email:
|
38
|
+
- erik.westrup@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- ".ackrc"
|
44
|
+
- ".codeclimate.yml"
|
45
|
+
- ".editorconfig"
|
46
|
+
- ".github/dependabot.yml"
|
47
|
+
- ".gitignore"
|
48
|
+
- ".rspec"
|
49
|
+
- ".rubocop.yml"
|
50
|
+
- ".ruby-version"
|
51
|
+
- ".simplecov"
|
52
|
+
- ".travis.yml"
|
53
|
+
- Appraisals
|
54
|
+
- CHANGELOG.md
|
55
|
+
- CONTRIBUTING.md
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- SECURITY.md
|
61
|
+
- gemfiles/README.md
|
62
|
+
- gemfiles/jekyll_3.7.x.gemfile
|
63
|
+
- gemfiles/jekyll_4.x.x.gemfile
|
64
|
+
- jekyll-google_search_console_verification_file.gemspec
|
65
|
+
- lib/jekyll-google_search_console_verification_file.rb
|
66
|
+
- lib/jekyll-google_search_console_verification_file/generator.rb
|
67
|
+
- lib/jekyll-google_search_console_verification_file/template.html
|
68
|
+
- lib/jekyll-google_search_console_verification_file/version.rb
|
69
|
+
- script/build
|
70
|
+
- script/console
|
71
|
+
- script/lint
|
72
|
+
- script/setup
|
73
|
+
- script/test
|
74
|
+
homepage: https://github.com/erikw/jekyll-google_search_console_verification_file/tree/dev
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata:
|
78
|
+
homepage_uri: https://github.com/erikw/jekyll-google_search_console_verification_file/tree/dev
|
79
|
+
source_code_uri: https://github.com/erikw/jekyll-google_search_console_verification_file/tree/dev
|
80
|
+
changelog_uri: https://github.com/erikw/jekyll-google_search_console_verification_file/blob/dev/CHANGELOG.md
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.7'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '4'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubygems_version: 3.2.15
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Generate a Google Search Console verification file from your _config.yml
|
103
|
+
e.g. google47733b3288357e4.html to the root of your Jekyll site.
|
104
|
+
test_files: []
|