Add bin and edit workflow
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s

This commit is contained in:
2026-09-16 13:11:16 -06:00
parent c8ac4fcae5
commit 4cee170d66
17576 changed files with 895740 additions and 2 deletions
@@ -0,0 +1,69 @@
require:
# - rubocop-jekyll
- rubocop-md
- rubocop-performance
- rubocop-rake
- rubocop-rspec
# inherit_gem:
# rubocop-jekyll: .rubocop.yml
AllCops:
Exclude:
- binstub/**/*
- vendor/**/*
- Gemfile*
- jekyll_download_link.gemspec
NewCops: enable
Gemspec/DeprecatedAttributeAssignment:
Enabled: false
Gemspec/RequireMFA:
Enabled: false
Gemspec/RequiredRubyVersion:
Enabled: false
Layout/InitialIndentation:
Exclude:
- README.md
Layout/HashAlignment:
EnforcedColonStyle: table
Exclude:
- jekyll_download_link.gemspec
Layout/LineLength:
Max: 150
Lint/RedundantCopDisableDirective:
Exclude:
- jekyll_download_link.gemspec
Lint/SymbolConversion:
Exclude:
- jekyll_download_link.gemspec
Metrics/BlockLength:
Exclude:
- jekyll_download_link.gemspec
- spec/**/*
Max: 35
Metrics/ClassLength:
Exclude:
- spec/**/*
Naming/FileName:
Exclude:
- Rakefile
RSpec/MultipleExpectations:
Enabled: false
Style/FrozenStringLiteralComment:
Enabled: false
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: comma
@@ -0,0 +1,28 @@
# Change Log
## 1.0.3 / 2024-07-24
* Updated to `jekyll_plugin_support` v1.0.0
## 1.0.2 / 2023-12-02
* Now depends on `jekyll_plugin_support`
* Demo website added
* Better Rubocop support
* Pinned to `json` gem v3.6.2 because Jekyll 4.3.2 requires it
## 1.0.1 / 2022-04-05
* Updated to `jekyll_plugin_logger` v2.1.0
## 1.0.0 / 2022-03-16
* Published as a gem
## 2020-10-03
* Initial version published at https://www.mslinn.com/blog/2020/10/03/jekyll-plugins.html
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2020 Mike Slinn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@@ -0,0 +1,144 @@
# `jekyll_download_link` [![Gem Version](https://badge.fury.io/rb/jekyll_download_link.svg)](https://badge.fury.io/rb/jekyll_download_link)
`jekyll_download_link` is a Jekyll tag plugin that generates a link to the given URI,
which must be a file on the server.
The file name can be absolute or relative to the top-level directory of the website.
## Usage
```html
{% download_link cloud9.tar %}
```
Generates:
```html
<a href="/cloud9.tar"><code>cloud9.tar</code></a> (4.5 KB)
```
Which renders as:<br>
<a href="/cloud9.tar">`cloud9.tar`</a> (4.5 KB)
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'jekyll_download_link'
```
And then execute:
```shell
$ bundle install
```
## Additional Information
More information is available on
[Mike Slinn&rsquo;s website](https://mslinn.com/jekyll/3000-jekyll-plugins.html#download_link).
## Development
After checking out the repo, run `bin/setup` to install dependencies.
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
### Build and Install Locally
To build and install this gem onto your local machine, type:
```shell
$ bundle exec rake install
jekyll_download_link 1.0.0 built to pkg/jekyll_download_link-0.1.0.gem.
jekyll_download_link (1.0.0) installed.
```
Examine the newly built gem:
```shell
$ gem info jekyll_download_link
*** LOCAL GEMS ***
jekyll_download_link (1.0.0)
Author: Mike Slinn
Homepage:
https://github.com/mslinn/jekyll_download_link
License: MIT
Installed at: /home/mslinn/.gems
Generates Jekyll logger with colored output.
```
## Demo Website
A test/demo website is provided in the `demo` directory.
You can run it under a debugger, or let it run free.
The `demo/_bin/debug` script can set various parameters for the demo.
View the help information with the `-h` option:
```shell
$ demo/_bin/debug -h
debug - Run the demo Jekyll website.
By default the demo Jekyll website runs without restriction under ruby-debug-ide and debase.
View it at http://localhost:4444
Options:
-h Show this error message
-r Run freely, without a debugger
```
### Debugging the Demo
To run under a debugger, for example Visual Studio Code:
1. Set breakpoints.
2. Initiate a debug session from the command line:
```shell
$ demo/bin/debug
```
3. Once the `Fast Debugger` signon appears, launch the Visual Studio Code launch configuration called `Attach rdebug-ide`.
4. View the generated website at [`http://localhost:4444`](http://localhost:4444).
### Build and Push to RubyGems
To release a new version,
1. Update the version number in `version.rb`.
2. Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
3. Run the following:
```shell
$ bundle exec rake release
```
The above creates a git tag for the version, commits the created tag,
and pushes the new `.gem` file to [RubyGems.org](https://rubygems.org).
## Contributing
1. Fork the project
2. Create a descriptively named feature branch
3. Add your feature
4. Submit a pull request
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,5 @@
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
@@ -0,0 +1,36 @@
require_relative 'lib/jekyll_download_link/version'
Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
github = 'https://github.com/mslinn/jekyll_download_link'
spec.authors = ['Mike Slinn']
spec.bindir = 'exe'
spec.description = <<~END_OF_DESC
Provides a Jekyll tag that generates an href to a file for the user to download, plus human-friendly filesize.
END_OF_DESC
spec.email = ['mslinn@mslinn.com']
spec.files = Dir['.rubocop.yml', 'LICENSE.*', 'Rakefile', '{lib,spec}/**/*', '*.gemspec', '*.md']
spec.homepage = 'https://www.mslinn.com/jekyll_plugins/jekyll_download_link.html'
spec.license = 'MIT'
spec.metadata = {
'allowed_push_host' => 'https://rubygems.org',
'bug_tracker_uri' => "#{github}/issues",
'changelog_uri' => "#{github}/CHANGELOG.md",
'homepage_uri' => spec.homepage,
'source_code_uri' => github,
}
spec.name = 'jekyll_download_link'
spec.post_install_message = <<~END_MESSAGE
Thanks for installing #{spec.name}!
END_MESSAGE
spec.require_paths = ['lib']
spec.required_ruby_version = '>= 2.6.0'
spec.summary = 'Provides a Jekyll tag that generates an href to a file for the user to download, plus human-friendly filesize.'
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
spec.version = JekyllDownloadLinkVersion::VERSION
spec.add_dependency 'jekyll', '>= 4.3.3'
spec.add_dependency 'jekyll_plugin_support', '>= 1.0.0'
end
@@ -0,0 +1,36 @@
require 'jekyll_plugin_support'
require_relative 'jekyll_download_link/version'
module JekyllPluginDownloadLinkName
PLUGIN_NAME = 'download_link'.freeze
end
# Generates an href to a file for the user to download from the site.
# Also shows the file size in a human-readable format.
class DownloadLink < JekyllSupport::JekyllTagNoArgParsing
include JekyllDownloadLinkVersion
def self.as_size(string)
units = %w[B KB MB GB TB]
size, unit = units.reduce(string.to_f) do |(fsize, _), utype|
fsize > 512 ? [fsize / 1024, utype] : (break [fsize, utype])
end
fmt_str = "#{size > 9 || size.modulo(1) < 0.1 ? '%d' : '%.1f'} %s"
format(fmt_str, size, unit)
end
def render_impl
@filename = @argument_string.delete('"').delete("'").strip
source = @config['source']
file_fq = File.join(source, @filename)
abort "Error: '#{file_fq}' not found. See the link tag in" unless File.exist?(file_fq)
size_str = self.class.as_size(File.size(file_fq))
"<a href='/#{@filename}'><code>#{@filename}</code></a> (#{size_str})"
end
JekyllSupport::JekyllPluginHelper.register(self, JekyllPluginDownloadLinkName::PLUGIN_NAME)
end
@@ -0,0 +1,3 @@
module JekyllDownloadLinkVersion
VERSION = '1.0.3'.freeze
end
@@ -0,0 +1,19 @@
require 'jekyll_plugin_support'
require_relative '../lib/jekyll_download_link'
RSpec.describe(DownloadLink) do
let(:config) { instance_double(Configuration) }
let(:context) do
context_ = instance_double(Liquid::Context)
context_.config = config
context_
end
it 'generates proper size comment' do
expect(described_class.as_size('123')).to eq('123 B')
expect(described_class.as_size('123456')).to eq('120 KB')
expect(described_class.as_size('123456789')).to eq('117 MB')
expect(described_class.as_size('123456789012')).to eq('114 GB')
expect(described_class.as_size('123456789012345')).to eq('112 TB')
end
end
@@ -0,0 +1,10 @@
require 'jekyll'
require_relative '../lib/jekyll_download_link'
RSpec.configure do |config|
config.filter_run_when_matching focus: true
# config.order = 'random'
# See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
config.example_status_persistence_file_path = 'spec/status_persistence.txt'
end
@@ -0,0 +1,3 @@
example_id | status | run_time |
--------------------------------- | ------ | --------------- |
./spec/download_link_spec.rb[1:1] | passed | 0.00116 seconds |