Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jekyll/jekyll-redirect-from into …
Browse files Browse the repository at this point in the history
…pass-parameters-and-anchors
  • Loading branch information
swheaton committed Sep 19, 2024
2 parents 5321c9c + 6a751b2 commit ef1ddec
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 69 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Continuous Integration

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
ci:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: 'Ruby ${{ matrix.ruby_version }}'
runs-on: 'ubuntu-latest'

strategy:
fail-fast: false
matrix:
ruby_version:
- 2.5
- 2.7
- 3.0
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: "Set up Ruby ${{ matrix.ruby_version }}"
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby_version }}
bundler-cache: true
- name: Execute tests
run: bash script/test
- name: Check Style Offenses
run: bash script/fmt
- name: Test gem build
run: bundle exec gem build jekyll-redirect-from.gemspec
- name: Test gem install
run: bundle exec gem install jekyll-redirect-from --local --verbose

ghp:
if: "!contains(github.event.commits[0].message, '[ci skip]')"
name: Ruby 2.7 with GitHub Pages Gem
runs-on: 'ubuntu-latest'
env:
GH_PAGES: true
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: "Set up Ruby 2.7"
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
bundler-cache: true
- name: Execute tests
run: bash script/test
29 changes: 28 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@ inherit_gem:
rubocop-jekyll: .rubocop.yml

AllCops:
TargetRubyVersion: 2.4
TargetRubyVersion: 2.5
SuggestExtensions: false
Exclude:
- vendor/**/*

Layout/LineEndStringConcatenationIndentation:
Enabled: true

Lint/EmptyInPattern:
Enabled: false

Naming/InclusiveLanguage:
Enabled: false
Naming/MemoizedInstanceVariableName:
Exclude:
- 'lib/jekyll-redirect-from/page_without_a_file.rb'

Performance/MapCompact:
Enabled: true
Performance/RedundantEqualityComparisonBlock:
Enabled: true
Performance/RedundantSplitRegexpArgument:
Enabled: true

Style/InPatternThen:
Enabled: false
Style/MultilineInPatternThen:
Enabled: false
Style/QuotedSymbols:
Enabled: true
37 changes: 12 additions & 25 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-12-06 11:51:19 +0100 using RuboCop version 0.61.1.
# on 2021-09-17 12:49:45 UTC using RuboCop version 1.18.4.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 12
# Configuration parameters: CountComments, Max, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Exclude:
- 'spec/integrations_spec.rb'
- 'spec/jekyll_redirect_from/generator_spec.rb'
- 'spec/jekyll_redirect_from/redirect_page_spec.rb'
- 'spec/jekyll_redirect_from/redirectable_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 3
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Exclude:
- 'spec/jekyll_redirect_from/generator_spec.rb'
- 'spec/jekyll_redirect_from/redirect_page_spec.rb'
Max: 105

# Offense count: 1
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
# Offense count: 2
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'lib/jekyll-redirect-from/page_without_a_file.rb'
- 'spec/jekyll_redirect_from/generator_spec.rb'

# Offense count: 2
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: io, id, to, by, on, in, at, ip, db
Naming/MethodParameterName:
# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
- 'lib/jekyll-redirect-from/redirect_page.rb'
- 'spec/jekyll_redirect_from/generator_spec.rb'
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions History.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

* fix Gemfile to correctly install jekyll 3.9 (#224)
* Refactor specs for RedirectPage (#222)
* Lock to RuboCop v1.18.x (#242)
* Clean up gemspec (#243)

### Bug Fixes

* Refactor Redirectable mixin to reduce allocations (#241)

## 0.16.0 / 2020-01-26

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impractical to create new pages in the proper subdirectories so they, e.g.
Instead of dealing with maintaining those pages for redirection, let
`jekyll-redirect-from` handle it for you.

[![Build Status](https://travis-ci.org/jekyll/jekyll-redirect-from.svg?branch=master)](https://travis-ci.org/jekyll/jekyll-redirect-from)
[![Build Status](https://github.com/jekyll/jekyll-redirect-from/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/jekyll/jekyll-redirect-from/actions/workflows/ci.yml)

## How it Works

Expand Down Expand Up @@ -68,7 +68,7 @@ Redirects including a trailing slash will generate a corresponding subdirectory

For example...

```text
```yaml
redirect_from:
- /post/123456789/my-amazing-post
```
Expand All @@ -81,7 +81,7 @@ redirect_from:

While...

```text
```yaml
redirect_from:
- /post/123456789/my-amazing-post/
```
Expand All @@ -96,7 +96,7 @@ These pages will contain an HTTP-REFRESH meta tag which redirect to your URL.

You can also specify just **one url** like this:

```text
```yaml
title: My other awesome post
redirect_from: /post/123456798/
```
Expand Down
13 changes: 4 additions & 9 deletions jekyll-redirect-from.gemspec
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
# frozen_string_literal: true

require "English"
require_relative "lib/jekyll-redirect-from/version"

Gem::Specification.new do |spec|
spec.name = "jekyll-redirect-from"
spec.version = JekyllRedirectFrom::VERSION
spec.authors = ["Parker Moore"]
spec.email = ["[email protected]"]
spec.summary = "Seamlessly specify multiple redirection URLs " \
"for your pages and posts"
spec.summary = "Seamlessly specify multiple redirection URLs for your pages and posts"
spec.homepage = "https://github.com/jekyll/jekyll-redirect-from"
spec.license = "MIT"

spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)

spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
spec.files = `git ls-files lib`.split("\n").concat(%w(LICENSE.txt README.md History.markdown))
spec.require_paths = ["lib"]

spec.required_ruby_version = ">= 2.4.0"
spec.required_ruby_version = ">= 2.5.0"

spec.add_runtime_dependency "jekyll", ">= 3.3", "< 5.0"

spec.add_development_dependency "bundler"
spec.add_development_dependency "jekyll-sitemap", "~> 1.0"
spec.add_development_dependency "rake", "~> 12.0"
spec.add_development_dependency "rspec", "~> 3.5"
spec.add_development_dependency "rubocop-jekyll", "~> 0.10"
spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0"
end
14 changes: 4 additions & 10 deletions lib/jekyll-redirect-from/redirectable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ module Redirectable
# Returns a string representing the relative path or URL
# to which the document should be redirected
def redirect_to
if to_liquid["redirect_to"].is_a?(Array)
to_liquid["redirect_to"].compact.first
else
to_liquid["redirect_to"]
end
meta_data = to_liquid["redirect_to"]
meta_data.is_a?(Array) ? meta_data.compact.first : meta_data
end

# Returns an array representing the relative paths to other
# documents which should be redirected to this document
def redirect_from
if to_liquid["redirect_from"].is_a?(Array)
to_liquid["redirect_from"].compact
else
[to_liquid["redirect_from"]].compact
end
meta_data = to_liquid["redirect_from"]
meta_data.is_a?(Array) ? meta_data.compact : [meta_data].compact
end
end
end
2 changes: 1 addition & 1 deletion script/fmt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

echo "Rubocop $(bundle exec rubocop --version)"
echo "RuboCop $(bundle exec rubocop --version)"
bundle exec rubocop -D -E $@
success=$?
if ((success != 0)); then
Expand Down

0 comments on commit ef1ddec

Please sign in to comment.