jekyll_bitly_next 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.actrc +3 -0
- data/.github/workflows/test.yml +37 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +15 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +20 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +208 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/jekyll_bitly_next.gemspec +40 -0
- data/lib/jekyll_bitly_next/bitly_filter.rb +41 -0
- data/lib/jekyll_bitly_next/version.rb +3 -0
- data/lib/jekyll_bitly_next.rb +5 -0
- metadata +256 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 70f9f3d668ef6fbdeabb2fac964163424b534688ac8292be18a4dbc9ee22e6a6
|
|
4
|
+
data.tar.gz: 45b69d5038baf2ce88aefe4ca9ec278292ff051b76baaa7c1fc0b56876b83afb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2a2496d3b4d9ce71cc98c52c13175a7d8104cc3165cc44b713384260c22bf80ab72f5aa648649dd2a129ef7e1233bb406a84ce73a4433ca3077d1bc787bfd89e
|
|
7
|
+
data.tar.gz: b96534ea4e7da0ea895e7d0979967b39acc05da2ac1196acd02c296f1017e7ed1ab9333ddfc834e1ea286288119bfe717b74b4b83508bbb4abc81edf3fbffbe8
|
data/.actrc
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master, main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master, main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
ruby-version: ['2.7', '3.0', '3.1', '3.2']
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout code
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
21
|
+
uses: ruby/setup-ruby@v1
|
|
22
|
+
with:
|
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
24
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
25
|
+
|
|
26
|
+
- name: Create .env file for tests
|
|
27
|
+
run: |
|
|
28
|
+
echo "BITLY_TOKEN=${{ secrets.BITLY_TOKEN }}" > .env
|
|
29
|
+
|
|
30
|
+
- name: Run tests
|
|
31
|
+
env:
|
|
32
|
+
BITLY_TOKEN: ${{ secrets.BITLY_TOKEN }}
|
|
33
|
+
run: bundle exec rspec
|
|
34
|
+
|
|
35
|
+
- name: Run RuboCop
|
|
36
|
+
run: bundle exec rubocop
|
|
37
|
+
continue-on-error: true # Allow RuboCop to fail without failing the entire workflow
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.0.0] - 2025-10-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Initial release as `jekyll_bitly_next`
|
|
9
|
+
- Forked from unmaintained `jekyll-bitly` gem
|
|
10
|
+
- Maintained and updated dependencies
|
|
11
|
+
- Improved documentation and examples
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Renamed gem from `jekyll-bitly` to `jekyll_bitly_next`
|
|
15
|
+
- Updated README with better examples and security warnings
|
|
16
|
+
- Updated repository links
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
*This is a maintained fork of [jekyll-bitly](https://github.com/tbjers/jekyll-bitly)*
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at hello@xorcode.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2011-2017 Xorcode Development, LLC
|
|
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,208 @@
|
|
|
1
|
+
# Jekyll Bitly Next
|
|
2
|
+
|
|
3
|
+
[](https://github.com/saiqulhaq/jekyll_bitly_next/actions/workflows/test.yml)
|
|
4
|
+
|
|
5
|
+
A modern, maintained Jekyll plugin that provides Bitly URL shortening filters for your Jekyll sites.
|
|
6
|
+
|
|
7
|
+
## 🔗 About
|
|
8
|
+
|
|
9
|
+
This gem is a maintained fork of [jekyll-bitly](https://github.com/tbjers/jekyll-bitly), which is no longer actively maintained. It provides seamless integration with Bitly's API to automatically shorten URLs in your Jekyll pages and posts.
|
|
10
|
+
|
|
11
|
+
## ✨ Features
|
|
12
|
+
|
|
13
|
+
- 🚀 Simple Liquid filter for URL shortening
|
|
14
|
+
- 🔐 Secure token management via config or environment variables
|
|
15
|
+
- 💾 Automatic caching of shortened URLs
|
|
16
|
+
- 🎯 Zero configuration required after token setup
|
|
17
|
+
- 🧪 Fully tested and maintained
|
|
18
|
+
|
|
19
|
+
## 📦 Installation
|
|
20
|
+
|
|
21
|
+
### Using Bundler (Recommended)
|
|
22
|
+
|
|
23
|
+
Add this line to your `Gemfile`:
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
gem 'jekyll_bitly_next'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Then execute:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bundle install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Manual Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
gem install jekyll_bitly_next
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Configure Jekyll
|
|
42
|
+
|
|
43
|
+
Add the plugin to your `_config.yml`:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
plugins:
|
|
47
|
+
- jekyll_bitly_next
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Note:** Older Jekyll versions used `gems:` instead of `plugins:`. If you're using an older version, use:
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
gems:
|
|
54
|
+
- jekyll_bitly_next
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 🔑 Configuration
|
|
58
|
+
|
|
59
|
+
### Step 1: Get Your Bitly API Token
|
|
60
|
+
|
|
61
|
+
1. Log in to your Bitly account
|
|
62
|
+
2. Navigate to [https://app.bitly.com/settings/api/](https://app.bitly.com/settings/api/)
|
|
63
|
+
3. Generate a new API token
|
|
64
|
+
4. Copy the token for use in the next step
|
|
65
|
+
|
|
66
|
+
### Step 2: Configure the Token
|
|
67
|
+
|
|
68
|
+
You can configure your Bitly token using either of these methods:
|
|
69
|
+
|
|
70
|
+
#### Option 1: Jekyll Config (Recommended for local development)
|
|
71
|
+
|
|
72
|
+
Add to your `_config.yml`:
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
bitly:
|
|
76
|
+
token: YOUR_BITLY_API_TOKEN_HERE
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**⚠️ Security Warning:** Never commit your API token to public repositories. Add `_config.yml` to `.gitignore` or use environment variables for production.
|
|
80
|
+
|
|
81
|
+
#### Option 2: Environment Variable (Recommended for production)
|
|
82
|
+
|
|
83
|
+
Set the `BITLY_TOKEN` environment variable:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Linux/macOS
|
|
87
|
+
export BITLY_TOKEN=YOUR_BITLY_API_TOKEN_HERE
|
|
88
|
+
|
|
89
|
+
# Windows (Command Prompt)
|
|
90
|
+
set BITLY_TOKEN=YOUR_BITLY_API_TOKEN_HERE
|
|
91
|
+
|
|
92
|
+
# Windows (PowerShell)
|
|
93
|
+
$env:BITLY_TOKEN="YOUR_BITLY_API_TOKEN_HERE"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
For permanent setup, add it to your `.bashrc`, `.zshrc`, or system environment variables.
|
|
97
|
+
|
|
98
|
+
**Priority:** Config file settings take precedence over environment variables.
|
|
99
|
+
|
|
100
|
+
## 🚀 Usage
|
|
101
|
+
|
|
102
|
+
### Basic Usage
|
|
103
|
+
|
|
104
|
+
Use the `bitly` filter in your Jekyll templates, pages, or posts:
|
|
105
|
+
|
|
106
|
+
```liquid
|
|
107
|
+
[Visit the Bitly gem]({{ 'https://github.com/philnash/bitly' | bitly }})
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Advanced Examples
|
|
111
|
+
|
|
112
|
+
**In blog posts:**
|
|
113
|
+
|
|
114
|
+
```liquid
|
|
115
|
+
---
|
|
116
|
+
layout: post
|
|
117
|
+
title: "My Awesome Post"
|
|
118
|
+
canonical_url: https://yourdomain.com/2025/10/awesome-post
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
Share this post: {{ page.canonical_url | bitly }}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**In layouts:**
|
|
125
|
+
|
|
126
|
+
```liquid
|
|
127
|
+
<a href="{{ page.url | absolute_url | bitly }}" class="share-link">
|
|
128
|
+
Share on Twitter
|
|
129
|
+
</a>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**With site variables:**
|
|
133
|
+
|
|
134
|
+
```liquid
|
|
135
|
+
{% assign short_url = site.url | append: page.url | bitly %}
|
|
136
|
+
<meta property="og:url" content="{{ short_url }}" />
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## 🛠️ Development
|
|
140
|
+
|
|
141
|
+
### Prerequisites
|
|
142
|
+
|
|
143
|
+
- Ruby 2.7 or higher
|
|
144
|
+
- Bundler
|
|
145
|
+
|
|
146
|
+
### Setup
|
|
147
|
+
|
|
148
|
+
1. Clone the repository:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
git clone https://github.com/saiqulhaq/jekyll_bitly_next.git
|
|
152
|
+
cd jekyll_bitly_next
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
2. Install dependencies:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
bin/setup
|
|
159
|
+
# or
|
|
160
|
+
bundle install
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
3. Run the tests:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
bundle exec rspec
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
4. Run an interactive console:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
bin/console
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Making Changes
|
|
176
|
+
|
|
177
|
+
1. Create a feature branch: `git checkout -b my-feature`
|
|
178
|
+
2. Make your changes
|
|
179
|
+
3. Add tests for your changes
|
|
180
|
+
4. Run tests: `bundle exec rspec`
|
|
181
|
+
5. Commit your changes: `git commit -am 'Add new feature'`
|
|
182
|
+
6. Push to the branch: `git push origin my-feature`
|
|
183
|
+
7. Create a Pull Request
|
|
184
|
+
|
|
185
|
+
## 🤝 Contributing
|
|
186
|
+
|
|
187
|
+
We welcome contributions! Here's how you can help:
|
|
188
|
+
|
|
189
|
+
1. **Report bugs:** Open an issue on [GitHub](https://github.com/saiqulhaq/jekyll_bitly_next/issues)
|
|
190
|
+
2. **Suggest features:** Open an issue with your ideas
|
|
191
|
+
3. **Submit pull requests:** Fork, create a feature branch, and submit a PR
|
|
192
|
+
4. **Improve documentation:** Help us make the docs better
|
|
193
|
+
|
|
194
|
+
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project, you agree to abide by its terms.
|
|
195
|
+
|
|
196
|
+
## 📝 Changelog
|
|
197
|
+
|
|
198
|
+
See [CHANGELOG.md](CHANGELOG.md) for a list of changes in each version.
|
|
199
|
+
|
|
200
|
+
## 📄 License
|
|
201
|
+
|
|
202
|
+
This gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
203
|
+
|
|
204
|
+
## 🙏 Credits
|
|
205
|
+
|
|
206
|
+
- Original gem by [Torgny Bjers](https://github.com/tbjers)
|
|
207
|
+
- Maintained by [Saiqul Haq](https://github.com/saiqulhaq)
|
|
208
|
+
- Built with [Bitly API](https://dev.bitly.com/)
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "jekyll"
|
|
5
|
+
require "jekyll_bitly_next"
|
|
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
|
data/bin/setup
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require "jekyll_bitly_next/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "jekyll_bitly_next"
|
|
7
|
+
spec.version = JekyllBitlyNext::VERSION
|
|
8
|
+
spec.authors = ["Torgny Bjers", "Saiqul Haq"]
|
|
9
|
+
spec.email = ["torgny.bjers@gmail.com", "saiqulhaq@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Jekyll Bit.ly filter"
|
|
12
|
+
spec.description = "Jekyll filter that uses Bit.ly to shorten URLs."
|
|
13
|
+
spec.homepage = "https://github.com/saiqulhaq/jekyll_bitly_next"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = ">= 2.7.0"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
|
19
|
+
end
|
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
21
|
+
spec.bindir = "exe"
|
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
|
+
spec.require_paths = ["lib"]
|
|
24
|
+
|
|
25
|
+
spec.add_runtime_dependency "bitly", "~> 3.0.0"
|
|
26
|
+
spec.add_runtime_dependency "dry-core", "~> 1.0.0"
|
|
27
|
+
|
|
28
|
+
spec.add_development_dependency "byebug"
|
|
29
|
+
spec.add_development_dependency "capybara"
|
|
30
|
+
spec.add_development_dependency "csv"
|
|
31
|
+
spec.add_development_dependency "dotenv"
|
|
32
|
+
spec.add_development_dependency "jekyll"
|
|
33
|
+
spec.add_development_dependency "nokogiri"
|
|
34
|
+
spec.add_development_dependency "rake"
|
|
35
|
+
spec.add_development_dependency "rspec", "~> 3"
|
|
36
|
+
spec.add_development_dependency "rubocop"
|
|
37
|
+
spec.add_development_dependency "selenium-webdriver"
|
|
38
|
+
spec.add_development_dependency "vcr"
|
|
39
|
+
spec.add_development_dependency "webmock"
|
|
40
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require "bitly"
|
|
2
|
+
require "singleton"
|
|
3
|
+
require "dry-core"
|
|
4
|
+
require "dry/core/cache"
|
|
5
|
+
require "liquid"
|
|
6
|
+
|
|
7
|
+
module Jekyll
|
|
8
|
+
class BitlyFilterCache
|
|
9
|
+
include Singleton
|
|
10
|
+
extend Dry::Core::Cache
|
|
11
|
+
|
|
12
|
+
def initialize
|
|
13
|
+
config = Jekyll.configuration({})
|
|
14
|
+
token = if config && config["bitly"] && config["bitly"]["token"]
|
|
15
|
+
config["bitly"]["token"]
|
|
16
|
+
else
|
|
17
|
+
ENV["BITLY_TOKEN"]
|
|
18
|
+
end
|
|
19
|
+
@bitly_client = Bitly::API::Client.new(token: token) if token
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def shorten(long_url)
|
|
23
|
+
raise "Please setup the Bitly token first in _config.yml" if @bitly_client.nil?
|
|
24
|
+
|
|
25
|
+
long_url.strip!
|
|
26
|
+
fetch_or_store(self.class.to_s, long_url) do
|
|
27
|
+
bitlink = @bitly_client.shorten(long_url: long_url)
|
|
28
|
+
short_url = bitlink.link
|
|
29
|
+
short_url
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
module BitlyFilter
|
|
35
|
+
def bitly(long_url)
|
|
36
|
+
BitlyFilterCache.instance.shorten(long_url)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Liquid::Template.register_filter(Jekyll::BitlyFilter)
|
metadata
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jekyll_bitly_next
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Torgny Bjers
|
|
8
|
+
- Saiqul Haq
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bitly
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 3.0.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 3.0.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: dry-core
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 1.0.0
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 1.0.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: byebug
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: capybara
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: csv
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: dotenv
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: jekyll
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: nokogiri
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: rake
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: rspec
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '3'
|
|
146
|
+
type: :development
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - "~>"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '3'
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: rubocop
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - ">="
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: '0'
|
|
160
|
+
type: :development
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - ">="
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: '0'
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: selenium-webdriver
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - ">="
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: '0'
|
|
174
|
+
type: :development
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - ">="
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '0'
|
|
181
|
+
- !ruby/object:Gem::Dependency
|
|
182
|
+
name: vcr
|
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
|
184
|
+
requirements:
|
|
185
|
+
- - ">="
|
|
186
|
+
- !ruby/object:Gem::Version
|
|
187
|
+
version: '0'
|
|
188
|
+
type: :development
|
|
189
|
+
prerelease: false
|
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
191
|
+
requirements:
|
|
192
|
+
- - ">="
|
|
193
|
+
- !ruby/object:Gem::Version
|
|
194
|
+
version: '0'
|
|
195
|
+
- !ruby/object:Gem::Dependency
|
|
196
|
+
name: webmock
|
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
|
198
|
+
requirements:
|
|
199
|
+
- - ">="
|
|
200
|
+
- !ruby/object:Gem::Version
|
|
201
|
+
version: '0'
|
|
202
|
+
type: :development
|
|
203
|
+
prerelease: false
|
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
205
|
+
requirements:
|
|
206
|
+
- - ">="
|
|
207
|
+
- !ruby/object:Gem::Version
|
|
208
|
+
version: '0'
|
|
209
|
+
description: Jekyll filter that uses Bit.ly to shorten URLs.
|
|
210
|
+
email:
|
|
211
|
+
- torgny.bjers@gmail.com
|
|
212
|
+
- saiqulhaq@gmail.com
|
|
213
|
+
executables: []
|
|
214
|
+
extensions: []
|
|
215
|
+
extra_rdoc_files: []
|
|
216
|
+
files:
|
|
217
|
+
- ".actrc"
|
|
218
|
+
- ".github/workflows/test.yml"
|
|
219
|
+
- ".gitignore"
|
|
220
|
+
- ".rspec"
|
|
221
|
+
- ".rubocop.yml"
|
|
222
|
+
- ".travis.yml"
|
|
223
|
+
- CHANGELOG.md
|
|
224
|
+
- CODE_OF_CONDUCT.md
|
|
225
|
+
- Gemfile
|
|
226
|
+
- LICENSE.txt
|
|
227
|
+
- README.md
|
|
228
|
+
- Rakefile
|
|
229
|
+
- bin/console
|
|
230
|
+
- bin/setup
|
|
231
|
+
- jekyll_bitly_next.gemspec
|
|
232
|
+
- lib/jekyll_bitly_next.rb
|
|
233
|
+
- lib/jekyll_bitly_next/bitly_filter.rb
|
|
234
|
+
- lib/jekyll_bitly_next/version.rb
|
|
235
|
+
homepage: https://github.com/saiqulhaq/jekyll_bitly_next
|
|
236
|
+
licenses:
|
|
237
|
+
- MIT
|
|
238
|
+
metadata: {}
|
|
239
|
+
rdoc_options: []
|
|
240
|
+
require_paths:
|
|
241
|
+
- lib
|
|
242
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
243
|
+
requirements:
|
|
244
|
+
- - ">="
|
|
245
|
+
- !ruby/object:Gem::Version
|
|
246
|
+
version: 2.7.0
|
|
247
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
|
+
requirements:
|
|
249
|
+
- - ">="
|
|
250
|
+
- !ruby/object:Gem::Version
|
|
251
|
+
version: '0'
|
|
252
|
+
requirements: []
|
|
253
|
+
rubygems_version: 3.6.9
|
|
254
|
+
specification_version: 4
|
|
255
|
+
summary: Jekyll Bit.ly filter
|
|
256
|
+
test_files: []
|