page_meta 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/CODEOWNERS +4 -0
- data/.github/FUNDING.yml +3 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +38 -0
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/ruby-tests.yml +61 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +14 -46
- data/.travis.yml +8 -7
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +80 -0
- data/README.md +56 -33
- data/Rakefile +6 -2
- data/gemfiles/6.0.gemfile +6 -0
- data/gemfiles/6.1.gemfile +6 -0
- data/lib/page_meta/action.rb +3 -2
- data/lib/page_meta/base.rb +3 -3
- data/lib/page_meta/hash_meta_tag.rb +1 -0
- data/lib/page_meta/link.rb +4 -4
- data/lib/page_meta/meta_tag.rb +4 -4
- data/lib/page_meta/naming.rb +1 -1
- data/lib/page_meta/translator.rb +3 -2
- data/lib/page_meta/version.rb +1 -1
- data/page_meta.gemspec +15 -6
- metadata +53 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0727fb1af7a2848d3cd1e6f2d44efd3c106c44588cd604d9738c0d1b90bdb67d
|
4
|
+
data.tar.gz: fd339b23e757843cab438e5078d17253bcbaca18bf4351082706a2ec81da065d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 790616651e1425832a679050c2d6c9b1805d4236f88fedcf3b622a0176cf7020be0f78672094b1660417c06c8283dc123a143ae1f666393f0afc4bcee26013d7
|
7
|
+
data.tar.gz: 0c6981527e16056706a51088ad995a70167e8e55c47bd86c7c1613a394aea0835f4b047f642186a883c98c78f903dff905b7e804b63067a4bd838d4416509105
|
data/.github/CODEOWNERS
ADDED
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
name: "🐛 Bug Report"
|
3
|
+
about: Report a reproducible bug or regression.
|
4
|
+
title: 'Bug: '
|
5
|
+
labels: 'Status: Unconfirmed'
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
<!--
|
10
|
+
- Please provide a clear and concise description of what the bug is.
|
11
|
+
- If possible, add an example reproducing your issue.
|
12
|
+
- Please test using the latest version of page_meta
|
13
|
+
to make sure your issue has not already been fixed.
|
14
|
+
-->
|
15
|
+
|
16
|
+
## Description
|
17
|
+
|
18
|
+
[Add bug description here]
|
19
|
+
|
20
|
+
## How to reproduce
|
21
|
+
|
22
|
+
[Add steps on how to reproduce this issue]
|
23
|
+
|
24
|
+
## What do you expect
|
25
|
+
|
26
|
+
[Describe what do you expect to happen]
|
27
|
+
|
28
|
+
## What happened instead
|
29
|
+
|
30
|
+
[Describe the actual results]
|
31
|
+
|
32
|
+
## Software:
|
33
|
+
|
34
|
+
- Gem version: [Add gem version here]
|
35
|
+
- Ruby version: [Add version here]
|
36
|
+
|
37
|
+
## Full backtrace
|
38
|
+
|
39
|
+
```text
|
40
|
+
[Paste full backtrace here]
|
41
|
+
```
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
name: "💡 Feature request"
|
3
|
+
about: Have an idea that may be useful? Make a suggestion!
|
4
|
+
title: 'Feature Request: '
|
5
|
+
labels: 'Feature request'
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
## Description
|
10
|
+
|
11
|
+
_A clear and concise description of what the problem is._
|
12
|
+
|
13
|
+
## Describe the solution
|
14
|
+
|
15
|
+
_A clear and concise description of what you want to happen._
|
16
|
+
|
17
|
+
## Alternatives you considered
|
18
|
+
|
19
|
+
_A clear and concise description of any alternative solutions or features you've considered._
|
20
|
+
|
21
|
+
## Additional context
|
22
|
+
|
23
|
+
_Add any other context, screenshots, links, etc about the feature request here._
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<!--
|
2
|
+
If you're making a doc PR or something tiny where the below is irrelevant,
|
3
|
+
delete this template and use a short description, but in your description aim to
|
4
|
+
include both what the change is, and why it is being made, with enough context
|
5
|
+
for anyone to understand.
|
6
|
+
-->
|
7
|
+
|
8
|
+
<details>
|
9
|
+
<summary>PR Checklist</summary>
|
10
|
+
|
11
|
+
### PR Structure
|
12
|
+
|
13
|
+
- [ ] This PR has reasonably narrow scope (if not, break it down into smaller
|
14
|
+
PRs).
|
15
|
+
- [ ] This PR avoids mixing refactoring changes with feature changes (split into
|
16
|
+
two PRs otherwise).
|
17
|
+
- [ ] This PR's title starts is concise and descriptive.
|
18
|
+
|
19
|
+
### Thoroughness
|
20
|
+
|
21
|
+
- [ ] This PR adds tests for the most critical parts of the new functionality or
|
22
|
+
fixes.
|
23
|
+
- [ ] I've updated any docs, `.md` files, etc… affected by this change.
|
24
|
+
|
25
|
+
</details>
|
26
|
+
|
27
|
+
### What
|
28
|
+
|
29
|
+
[TODO: Short statement about what is changing.]
|
30
|
+
|
31
|
+
### Why
|
32
|
+
|
33
|
+
[TODO: Why this change is being made. Include any context required to understand
|
34
|
+
the why.]
|
35
|
+
|
36
|
+
### Known limitations
|
37
|
+
|
38
|
+
[TODO or N/A]
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
# Documentation:
|
3
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
4
|
+
|
5
|
+
version: 2
|
6
|
+
updates:
|
7
|
+
- package-ecosystem: "github-actions"
|
8
|
+
directory: "/"
|
9
|
+
schedule:
|
10
|
+
interval: "daily"
|
11
|
+
|
12
|
+
- package-ecosystem: "bundler"
|
13
|
+
directory: "/"
|
14
|
+
schedule:
|
15
|
+
interval: "daily"
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
name: ruby-tests
|
3
|
+
|
4
|
+
on:
|
5
|
+
pull_request:
|
6
|
+
branches:
|
7
|
+
- main
|
8
|
+
push:
|
9
|
+
branches:
|
10
|
+
- main
|
11
|
+
|
12
|
+
schedule:
|
13
|
+
- cron: "0 10 * * *"
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
build:
|
17
|
+
name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
|
18
|
+
runs-on: "ubuntu-latest"
|
19
|
+
strategy:
|
20
|
+
fail-fast: false
|
21
|
+
matrix:
|
22
|
+
ruby: [2.7.x, 3.0.x]
|
23
|
+
gemfile:
|
24
|
+
- Gemfile
|
25
|
+
- gemfiles/6.1.gemfile
|
26
|
+
- gemfiles/6.0.gemfile
|
27
|
+
|
28
|
+
steps:
|
29
|
+
- uses: actions/checkout@v1
|
30
|
+
|
31
|
+
- uses: actions/cache@v2
|
32
|
+
with:
|
33
|
+
path: vendor/bundle
|
34
|
+
key: >
|
35
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{
|
36
|
+
hashFiles(matrix.gemfile) }}
|
37
|
+
restore-keys: >
|
38
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{
|
39
|
+
hashFiles(matrix.gemfile) }}
|
40
|
+
|
41
|
+
- name: Set up Ruby
|
42
|
+
uses: actions/setup-ruby@v1
|
43
|
+
with:
|
44
|
+
ruby-version: ${{ matrix.ruby }}
|
45
|
+
|
46
|
+
- name: Install gem dependencies
|
47
|
+
env:
|
48
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
49
|
+
run: |
|
50
|
+
gem install bundler
|
51
|
+
bundle config path vendor/bundle
|
52
|
+
bundle update --jobs 4 --retry 3
|
53
|
+
|
54
|
+
- name: Run Tests
|
55
|
+
env:
|
56
|
+
PGHOST: localhost
|
57
|
+
PGUSER: postgres
|
58
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
59
|
+
run: |
|
60
|
+
bundle exec rake
|
61
|
+
bundle exec rubocop
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,50 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Metrics/LineLength:
|
5
|
-
Enabled: false
|
6
|
-
|
7
|
-
Style/Documentation:
|
8
|
-
Enabled: false
|
9
|
-
|
10
|
-
Style/StringLiterals:
|
11
|
-
EnforcedStyle: double_quotes
|
12
|
-
|
13
|
-
Layout/SpaceInsideBlockBraces:
|
14
|
-
EnforcedStyle: space
|
15
|
-
EnforcedStyleForEmptyBraces: space
|
16
|
-
SpaceBeforeBlockParameters: false
|
1
|
+
---
|
2
|
+
inherit_gem:
|
3
|
+
rubocop-fnando: .rubocop.yml
|
17
4
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
Style/SymbolArray:
|
29
|
-
Enabled: true
|
30
|
-
|
31
|
-
Style/PercentLiteralDelimiters:
|
32
|
-
PreferredDelimiters:
|
33
|
-
'%': '[]'
|
34
|
-
'%i': '[]'
|
35
|
-
'%q': '[]'
|
36
|
-
'%Q': '[]'
|
37
|
-
'%r': '[]'
|
38
|
-
'%s': '[]'
|
39
|
-
'%w': '[]'
|
40
|
-
'%W': '[]'
|
41
|
-
'%x': '[]'
|
42
|
-
|
43
|
-
Metrics/MethodLength:
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.7
|
7
|
+
NewCops: enable
|
8
|
+
Exclude:
|
9
|
+
- test/support/dummy.rb
|
10
|
+
- vendor/**/*
|
11
|
+
- bin/**/*
|
12
|
+
- gemfiles/vendor/**/*
|
13
|
+
|
14
|
+
Layout/LineLength:
|
44
15
|
Enabled: false
|
45
16
|
|
46
|
-
|
17
|
+
Metrics:
|
47
18
|
Enabled: false
|
48
|
-
|
49
|
-
Style/Alias:
|
50
|
-
EnforcedStyle: prefer_alias_method
|
data/.travis.yml
CHANGED
@@ -2,16 +2,17 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
sudo: false
|
4
4
|
rvm:
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.2.8
|
5
|
+
- 2.7.1
|
6
|
+
- 2.6.5
|
8
7
|
before_install: gem install bundler --pre
|
9
8
|
before_script:
|
10
|
-
- "curl -L
|
11
|
-
-
|
12
|
-
|
9
|
+
- "curl -L
|
10
|
+
https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
|
11
|
+
> ./cc-test-reporter"
|
12
|
+
- chmod +x ./cc-test-reporter
|
13
|
+
- "./cc-test-reporter before-build"
|
13
14
|
after_script:
|
14
|
-
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
15
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
15
16
|
notifications:
|
16
17
|
email: false
|
17
18
|
env:
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
<!--
|
4
|
+
Prefix your message with one of the following:
|
5
|
+
|
6
|
+
- [Added] for new features.
|
7
|
+
- [Changed] for changes in existing functionality.
|
8
|
+
- [Deprecated] for soon-to-be removed features.
|
9
|
+
- [Removed] for now removed features.
|
10
|
+
- [Fixed] for any bug fixes.
|
11
|
+
- [Security] in case of vulnerabilities.
|
12
|
+
-->
|
13
|
+
|
14
|
+
## 1.0.0
|
15
|
+
|
16
|
+
- Initial release.
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Contributing to page_meta
|
2
|
+
|
3
|
+
👍🎉 First off, thanks for taking the time to contribute! 🎉👍
|
4
|
+
|
5
|
+
The following is a set of guidelines for contributing to this project. These are
|
6
|
+
mostly guidelines, not rules. Use your best judgment, and feel free to propose
|
7
|
+
changes to this document in a pull request.
|
8
|
+
|
9
|
+
## Code of Conduct
|
10
|
+
|
11
|
+
Everyone interacting in this project's codebases, issue trackers, chat rooms and
|
12
|
+
mailing lists is expected to follow the
|
13
|
+
[code of conduct](https://github.com/fnando/page_meta/blob/main/CODE_OF_CONDUCT.md).
|
14
|
+
|
15
|
+
## Reporting bugs
|
16
|
+
|
17
|
+
This section guides you through submitting a bug report. Following these
|
18
|
+
guidelines helps maintainers and the community understand your report, reproduce
|
19
|
+
the behavior, and find related reports.
|
20
|
+
|
21
|
+
- Before creating bug reports, please check the open issues; somebody may
|
22
|
+
already have submitted something similar, and you may not need to create a new
|
23
|
+
one.
|
24
|
+
- When you are creating a bug report, please include as many details as
|
25
|
+
possible, with an example reproducing the issue.
|
26
|
+
|
27
|
+
## Contributing with code
|
28
|
+
|
29
|
+
Before making any radicals changes, please make sure you discuss your intention
|
30
|
+
by [opening an issue on Github](https://github.com/fnando/page_meta/issues).
|
31
|
+
|
32
|
+
When you're ready to make your pull request, follow checklist below to make sure
|
33
|
+
your contribution is according to how this project works.
|
34
|
+
|
35
|
+
1. [Fork](https://help.github.com/forking/) page_meta
|
36
|
+
2. Create a topic branch - `git checkout -b my_branch`
|
37
|
+
3. Make your changes using [descriptive commit messages](#commit-messages)
|
38
|
+
4. Update CHANGELOG.md describing your changes by adding an entry to the
|
39
|
+
"Unreleased" section. If this section is not available, create one right
|
40
|
+
before the last version.
|
41
|
+
5. Push to your branch - `git push origin my_branch`
|
42
|
+
6. [Create a pull request](https://help.github.com/articles/creating-a-pull-request)
|
43
|
+
7. That's it!
|
44
|
+
|
45
|
+
## Styleguides
|
46
|
+
|
47
|
+
### Commit messages
|
48
|
+
|
49
|
+
- Use the present tense ("Add feature" not "Added feature")
|
50
|
+
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
|
51
|
+
- Limit the first line to 72 characters or less
|
52
|
+
- Reference issues and pull requests liberally after the first line
|
53
|
+
|
54
|
+
### Changelog
|
55
|
+
|
56
|
+
- Add a message describing your changes to the "Unreleased" section. The
|
57
|
+
changelog message should follow the same style as the commit message.
|
58
|
+
- Prefix your message with one of the following:
|
59
|
+
- `[Added]` for new features.
|
60
|
+
- `[Changed]` for changes in existing functionality.
|
61
|
+
- `[Deprecated]` for soon-to-be removed features.
|
62
|
+
- `[Removed]` for now removed features.
|
63
|
+
- `[Fixed]` for any bug fixes.
|
64
|
+
- `[Security]` in case of vulnerabilities.
|
65
|
+
|
66
|
+
### Ruby code
|
67
|
+
|
68
|
+
- This project uses [Rubocop](https://rubocop.org) to enforce code style. Before
|
69
|
+
submitting your changes, make sure your tests are passing and code conforms to
|
70
|
+
the expected style by running `rake`.
|
71
|
+
- Do not change the library version. This will be done by the maintainer
|
72
|
+
whenever a new version is about to be released.
|
73
|
+
|
74
|
+
### JavaScript code
|
75
|
+
|
76
|
+
- This project uses [ESLint](https://eslint.org) to enforce code style. Before
|
77
|
+
submitting your changes, make sure your tests are passing and code conforms to
|
78
|
+
the expected style by running `yarn test:ci`.
|
79
|
+
- Do not change the library version. This will be done by the maintainer
|
80
|
+
whenever a new version is about to be released.
|
data/README.md
CHANGED
@@ -1,42 +1,43 @@
|
|
1
|
-
#
|
1
|
+
# page_meta
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Tests](https://github.com/fnando/page_meta/workflows/ruby-tests/badge.svg)](https://github.com/fnando/page_meta)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/fnando/page_meta/badges/gpa.svg)](https://codeclimate.com/github/fnando/page_meta)
|
5
|
-
[![Test Coverage](https://codeclimate.com/github/fnando/page_meta/badges/coverage.svg)](https://codeclimate.com/github/fnando/page_meta/coverage)
|
6
5
|
[![Gem](https://img.shields.io/gem/v/page_meta.svg)](https://rubygems.org/gems/page_meta)
|
7
6
|
[![Gem](https://img.shields.io/gem/dt/page_meta.svg)](https://rubygems.org/gems/page_meta)
|
8
7
|
|
9
|
-
Easily define `<meta>` and `<link>` tags. I18n support for descriptions,
|
8
|
+
Easily define `<meta>` and `<link>` tags. I18n support for descriptions,
|
9
|
+
keywords and titles.
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
|
-
|
13
|
+
```bash
|
14
|
+
gem install page_meta
|
15
|
+
```
|
16
|
+
|
17
|
+
Or add the following line to your project's Gemfile:
|
14
18
|
|
15
19
|
```ruby
|
16
20
|
gem "page_meta"
|
17
21
|
```
|
18
22
|
|
19
|
-
And then execute:
|
20
|
-
|
21
|
-
$ bundle
|
22
|
-
|
23
|
-
Or install it yourself as:
|
24
|
-
|
25
|
-
$ gem install page_meta
|
26
|
-
|
27
23
|
## Usage
|
28
24
|
|
29
|
-
Your controller and views have an object called `page_meta`. You can use it to
|
25
|
+
Your controller and views have an object called `page_meta`. You can use it to
|
26
|
+
define meta tags and links. By default, it will include the encoding and
|
27
|
+
language meta tags.
|
30
28
|
|
31
29
|
```html
|
32
|
-
<meta charset="utf-8"
|
33
|
-
<meta name="language" content="en"
|
34
|
-
<meta itemprop="language" content="en"
|
30
|
+
<meta charset="utf-8" />
|
31
|
+
<meta name="language" content="en" />
|
32
|
+
<meta itemprop="language" content="en" />
|
35
33
|
```
|
36
34
|
|
37
|
-
You can use I18n to define titles, descriptions and keywords. These values will
|
35
|
+
You can use I18n to define titles, descriptions and keywords. These values will
|
36
|
+
be inferred from the controller and action names. For an action
|
37
|
+
`SiteController#index` you'll need the following translation scope:
|
38
38
|
|
39
39
|
```yaml
|
40
|
+
---
|
40
41
|
page_meta:
|
41
42
|
titles:
|
42
43
|
base: "%{value} • MyApp"
|
@@ -44,16 +45,19 @@ page_meta:
|
|
44
45
|
index: "Welcome to MyApp"
|
45
46
|
```
|
46
47
|
|
47
|
-
The title can without the `base` context can be accessed through
|
48
|
+
The title can without the `base` context can be accessed through
|
49
|
+
`page_meta.title.simple`.
|
48
50
|
|
49
51
|
```erb
|
50
52
|
<%= page_meta.title %> // Welcome to MyApp • MyApp
|
51
53
|
<%= page_meta.title.simple %> // Welcome to MyApp
|
52
54
|
```
|
53
55
|
|
54
|
-
Sometimes you need to render some dynamic value. In this case, you can use the
|
56
|
+
Sometimes you need to render some dynamic value. In this case, you can use the
|
57
|
+
I18n placeholders.
|
55
58
|
|
56
59
|
```yaml
|
60
|
+
---
|
57
61
|
en:
|
58
62
|
page_meta:
|
59
63
|
titles:
|
@@ -75,13 +79,14 @@ end
|
|
75
79
|
|
76
80
|
Some actions are aliased, so you don't have to duplicate the translations:
|
77
81
|
|
78
|
-
|
79
|
-
|
80
|
-
|
82
|
+
- Action `create` points to `new`
|
83
|
+
- Action `update` points to `edit`
|
84
|
+
- Action `destroy` points to `remove`
|
81
85
|
|
82
86
|
The same concept is applied to descriptions and keywords.
|
83
87
|
|
84
88
|
```yaml
|
89
|
+
---
|
85
90
|
en:
|
86
91
|
page_meta:
|
87
92
|
descriptions:
|
@@ -95,7 +100,8 @@ en:
|
|
95
100
|
|
96
101
|
### Defining meta tags
|
97
102
|
|
98
|
-
To define other meta tags, you have to use `PageMeta::Base#tag` like the
|
103
|
+
To define other meta tags, you have to use `PageMeta::Base#tag` like the
|
104
|
+
following:
|
99
105
|
|
100
106
|
```ruby
|
101
107
|
class Workshops Controller < ApplicationController
|
@@ -158,7 +164,8 @@ page_meta.link :last, href: article_url(articles.last)
|
|
158
164
|
page_meta.link :first, href: article_url(articles.first)
|
159
165
|
```
|
160
166
|
|
161
|
-
The hash can be any of the link tag's attributes. The following example defines
|
167
|
+
The hash can be any of the link tag's attributes. The following example defines
|
168
|
+
the Safari 9 Pinned Tab icon:
|
162
169
|
|
163
170
|
```ruby
|
164
171
|
page_meta.link :mask_icon, color: "#4078c0", href: helpers.asset_url("mask_icon.svg")
|
@@ -182,26 +189,42 @@ To render all tags, just do something like this:
|
|
182
189
|
|
183
190
|
#### Rendering titles and descriptions
|
184
191
|
|
185
|
-
You may want to render title and description on your page. In this case, you may
|
192
|
+
You may want to render title and description on your page. In this case, you may
|
193
|
+
use something like this:
|
186
194
|
|
187
195
|
```erb
|
188
196
|
<h1><%= page_meta.title.simple %></h1>
|
189
197
|
<p><%= page_meta.description.simple %></p>
|
190
198
|
```
|
191
199
|
|
192
|
-
If your description contains HTML, you can use
|
200
|
+
If your description contains HTML, you can use
|
201
|
+
`page_meta.description(html: true).simple` instead. It will use Rails'
|
202
|
+
`html_safe` helpers to safely retrieve the translation, just like regular Rails
|
203
|
+
would do.
|
204
|
+
[Please read Rails docs](http://guides.rubyonrails.org/i18n.html#using-safe-html-translations)
|
205
|
+
for more info.
|
193
206
|
|
194
|
-
##
|
207
|
+
## Maintainer
|
195
208
|
|
196
|
-
|
209
|
+
- [Nando Vieira](https://github.com/fnando)
|
197
210
|
|
198
|
-
|
211
|
+
## Contributors
|
199
212
|
|
200
|
-
|
213
|
+
- https://github.com/fnando/page_meta/contributors
|
201
214
|
|
202
|
-
|
215
|
+
## Contributing
|
203
216
|
|
217
|
+
For more details about how to contribute, please read
|
218
|
+
https://github.com/fnando/page_meta/blob/main/CONTRIBUTING.md.
|
204
219
|
|
205
220
|
## License
|
206
221
|
|
207
|
-
The gem is available as open source under the terms of the
|
222
|
+
The gem is available as open source under the terms of the
|
223
|
+
[MIT License](https://opensource.org/licenses/MIT). A copy of the license can be
|
224
|
+
found at https://github.com/fnando/page_meta/blob/main/LICENSE.md.
|
225
|
+
|
226
|
+
## Code of Conduct
|
227
|
+
|
228
|
+
Everyone interacting in the page_meta project's codebases, issue trackers, chat
|
229
|
+
rooms and mailing lists is expected to follow the
|
230
|
+
[code of conduct](https://github.com/fnando/page_meta/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "bundler/setup"
|
3
4
|
require "bundler/gem_tasks"
|
4
5
|
require "rake/testtask"
|
6
|
+
require "rubocop/rake_task"
|
7
|
+
|
8
|
+
RuboCop::RakeTask.new
|
5
9
|
|
6
10
|
Rake::TestTask.new(:test) do |t|
|
7
11
|
t.libs << "test"
|
8
|
-
t.libs << "lib"
|
9
12
|
t.test_files = FileList["test/**/*_test.rb"]
|
13
|
+
t.warning = false
|
10
14
|
end
|
11
15
|
|
12
|
-
task default:
|
16
|
+
task default: %i[test rubocop]
|
data/lib/page_meta/action.rb
CHANGED
@@ -4,10 +4,11 @@ module PageMeta
|
|
4
4
|
class Action
|
5
5
|
# rubocop:disable Style/MutableConstant
|
6
6
|
ALIASES = {
|
7
|
-
"update"
|
8
|
-
"create"
|
7
|
+
"update" => "edit",
|
8
|
+
"create" => "new",
|
9
9
|
"destroy" => "remove"
|
10
10
|
}
|
11
|
+
# rubocop:enable Style/MutableConstant
|
11
12
|
|
12
13
|
def initialize(action)
|
13
14
|
@action = action
|
data/lib/page_meta/base.rb
CHANGED
@@ -46,7 +46,7 @@ module PageMeta
|
|
46
46
|
compute_default_meta_tags
|
47
47
|
render_meta_tags + render_links
|
48
48
|
end
|
49
|
-
|
49
|
+
alias to_s render
|
50
50
|
|
51
51
|
def naming
|
52
52
|
@naming ||= Naming.new(controller)
|
@@ -55,14 +55,14 @@ module PageMeta
|
|
55
55
|
def render_meta_tags
|
56
56
|
meta_tags
|
57
57
|
.map {|name, value| MetaTag.build(name, value).render }
|
58
|
-
.join
|
58
|
+
.join
|
59
59
|
.html_safe
|
60
60
|
end
|
61
61
|
|
62
62
|
def render_links
|
63
63
|
links
|
64
64
|
.map {|info| Link.build(info[:rel], info[:options]).render }
|
65
|
-
.join
|
65
|
+
.join
|
66
66
|
.html_safe
|
67
67
|
end
|
68
68
|
|
data/lib/page_meta/link.rb
CHANGED
@@ -5,10 +5,10 @@ module PageMeta
|
|
5
5
|
def self.build(rel, options)
|
6
6
|
klass_name = "::PageMeta::Link::#{rel.to_s.camelize}"
|
7
7
|
klass = begin
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
const_get(klass_name)
|
9
|
+
rescue ActionView::Template::Error, NameError
|
10
|
+
Link
|
11
|
+
end
|
12
12
|
klass.new(rel, options)
|
13
13
|
end
|
14
14
|
|
data/lib/page_meta/meta_tag.rb
CHANGED
@@ -7,10 +7,10 @@ module PageMeta
|
|
7
7
|
def self.build(name, content)
|
8
8
|
klass_name = "::PageMeta::MetaTag::#{name.to_s.camelize}"
|
9
9
|
klass = begin
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
const_get(klass_name)
|
11
|
+
rescue ActionView::Template::Error, NameError
|
12
|
+
MetaTag
|
13
|
+
end
|
14
14
|
klass.new(name, content)
|
15
15
|
end
|
16
16
|
|
data/lib/page_meta/naming.rb
CHANGED
data/lib/page_meta/translator.rb
CHANGED
@@ -15,6 +15,7 @@ module PageMeta
|
|
15
15
|
|
16
16
|
def to_s
|
17
17
|
return "" if simple.blank?
|
18
|
+
|
18
19
|
t("page_meta.#{scope}.base", value: simple, default: simple)
|
19
20
|
end
|
20
21
|
|
@@ -25,8 +26,8 @@ module PageMeta
|
|
25
26
|
def simple
|
26
27
|
override_options = options.merge(default: "")
|
27
28
|
|
28
|
-
translation = t("#{translation_scope}_html", override_options) if html
|
29
|
-
translation = t(translation_scope, override_options) if translation.blank?
|
29
|
+
translation = t("#{translation_scope}_html", **override_options) if html
|
30
|
+
translation = t(translation_scope, **override_options) if translation.blank?
|
30
31
|
translation
|
31
32
|
end
|
32
33
|
end
|
data/lib/page_meta/version.rb
CHANGED
data/page_meta.gemspec
CHANGED
@@ -7,22 +7,31 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = PageMeta::VERSION
|
8
8
|
spec.authors = ["Nando Vieira"]
|
9
9
|
spec.email = ["fnando.vieira@gmail.com"]
|
10
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
11
|
+
spec.metadata = {
|
12
|
+
"rubygems_mfa_required" => "true"
|
13
|
+
}
|
10
14
|
|
11
|
-
spec.summary = "Easily define <meta> and <link> tags. I18n support
|
15
|
+
spec.summary = "Easily define <meta> and <link> tags. I18n support " \
|
16
|
+
"for descriptions, keywords and titles."
|
12
17
|
spec.description = spec.summary
|
13
18
|
spec.homepage = "https://github.com/fnando/page_meta"
|
14
19
|
spec.license = "MIT"
|
15
20
|
|
16
|
-
spec.files = `git ls-files -z
|
21
|
+
spec.files = `git ls-files -z`
|
22
|
+
.split("\x0")
|
23
|
+
.reject {|f| f.match(%r{^(test|spec|features)/}) }
|
17
24
|
spec.bindir = "exe"
|
18
|
-
spec.executables = spec.files.grep(%r
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
19
26
|
spec.require_paths = ["lib"]
|
20
27
|
|
21
|
-
spec.add_dependency "rails"
|
28
|
+
spec.add_dependency "rails", ">=6.0"
|
22
29
|
|
23
30
|
spec.add_development_dependency "bundler"
|
24
|
-
spec.add_development_dependency "rake"
|
25
31
|
spec.add_development_dependency "minitest-utils"
|
26
|
-
spec.add_development_dependency "simplecov"
|
27
32
|
spec.add_development_dependency "pry-meta"
|
33
|
+
spec.add_development_dependency "rake"
|
34
|
+
spec.add_development_dependency "rubocop"
|
35
|
+
spec.add_development_dependency "rubocop-fnando"
|
36
|
+
spec.add_development_dependency "simplecov"
|
28
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: page_meta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest-utils
|
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: pry-meta
|
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'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rake
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +81,7 @@ dependencies:
|
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
84
|
+
name: rubocop
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
87
|
- - ">="
|
@@ -67,7 +95,7 @@ dependencies:
|
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
98
|
+
name: rubocop-fnando
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - ">="
|
@@ -81,7 +109,7 @@ dependencies:
|
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
112
|
+
name: simplecov
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - ">="
|
@@ -102,16 +130,27 @@ executables: []
|
|
102
130
|
extensions: []
|
103
131
|
extra_rdoc_files: []
|
104
132
|
files:
|
133
|
+
- ".github/CODEOWNERS"
|
134
|
+
- ".github/FUNDING.yml"
|
135
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
136
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
137
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
138
|
+
- ".github/dependabot.yml"
|
139
|
+
- ".github/workflows/ruby-tests.yml"
|
105
140
|
- ".gitignore"
|
106
141
|
- ".rubocop.yml"
|
107
142
|
- ".travis.yml"
|
143
|
+
- CHANGELOG.md
|
108
144
|
- CODE_OF_CONDUCT.md
|
145
|
+
- CONTRIBUTING.md
|
109
146
|
- Gemfile
|
110
147
|
- LICENSE.txt
|
111
148
|
- README.md
|
112
149
|
- Rakefile
|
113
150
|
- bin/console
|
114
151
|
- bin/setup
|
152
|
+
- gemfiles/6.0.gemfile
|
153
|
+
- gemfiles/6.1.gemfile
|
115
154
|
- lib/page_meta.rb
|
116
155
|
- lib/page_meta/action.rb
|
117
156
|
- lib/page_meta/base.rb
|
@@ -133,8 +172,9 @@ files:
|
|
133
172
|
homepage: https://github.com/fnando/page_meta
|
134
173
|
licenses:
|
135
174
|
- MIT
|
136
|
-
metadata:
|
137
|
-
|
175
|
+
metadata:
|
176
|
+
rubygems_mfa_required: 'true'
|
177
|
+
post_install_message:
|
138
178
|
rdoc_options: []
|
139
179
|
require_paths:
|
140
180
|
- lib
|
@@ -142,16 +182,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
182
|
requirements:
|
143
183
|
- - ">="
|
144
184
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
185
|
+
version: 2.7.0
|
146
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
187
|
requirements:
|
148
188
|
- - ">="
|
149
189
|
- !ruby/object:Gem::Version
|
150
190
|
version: '0'
|
151
191
|
requirements: []
|
152
|
-
|
153
|
-
|
154
|
-
signing_key:
|
192
|
+
rubygems_version: 3.2.32
|
193
|
+
signing_key:
|
155
194
|
specification_version: 4
|
156
195
|
summary: Easily define <meta> and <link> tags. I18n support for descriptions, keywords
|
157
196
|
and titles.
|