administrate-field-hyperlink 0.2.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +5 -0
- data/administrate-field-hyperlink.gemspec +1 -1
- data/app/views/fields/hyperlink/_index.html.erb +3 -1
- data/app/views/fields/hyperlink/_show.html.erb +3 -1
- data/example.png +0 -0
- data/lib/administrate/field/hyperlink.rb +8 -1
- data/lib/administrate/field/hyperlink/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d29f7778a1a81a1561da42b08b4b73b2fed336dbabb351ffc58b646f3a9d289e
|
4
|
+
data.tar.gz: 5279a0cec0b96469ec39220ddd7e2d45bdccdc669b19d814fc206ecf375c0d50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffd04faba7aae164458549486e7a52faa654e348461b5a26c06929a7b37544e2da7e2c371f15cd1eef6a259939ea4f255febeba5f0570088450f396f359bcda0
|
7
|
+
data.tar.gz: b7e8b49cbf287e99220be74ec65f654cfeeb09efcf5708f846e272d8b187121703a334508e6c5f5b87f5390afe3400759ee6f7575d1d2d1e239917ecd4d7fd71
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.3.0
|
4
|
+
|
5
|
+
- Add `label` option
|
6
|
+
- Add `fallback_href` option
|
7
|
+
- Allow `nil` and `''` values for hyperlinks
|
8
|
+
- Add `present?` which is `true` if the field should show, `false` otherwise
|
9
|
+
|
3
10
|
## 0.2.0
|
4
11
|
|
5
12
|
Fix an issue with dependency and version management
|
data/README.md
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
|
7
7
|
A string field that is shows a hyperlink.
|
8
8
|
|
9
|
+

|
10
|
+
|
9
11
|
## Installation
|
10
12
|
|
11
13
|
Add this line to your application's Gemfile:
|
@@ -52,6 +54,8 @@ end
|
|
52
54
|
| option | default | description |
|
53
55
|
|--------|-------|-------------|
|
54
56
|
| `scheme` | `https://` | Scheme to use if there is none given |
|
57
|
+
| `fallback_href` | nil | `href` to use if the value is `blank?` |
|
58
|
+
| `label` | `self#href` | The label to use instead of the `href` |
|
55
59
|
|
56
60
|
## Related
|
57
61
|
|
@@ -67,6 +71,7 @@ end
|
|
67
71
|
|
68
72
|
- [`Administrate::Field::Code`](https://github.com/XPBytes/administrate-field-code): :pencil: A `text` field that shows code.
|
69
73
|
- [`Adminisrtate::Field::JsonEditor`](https://github.com/XPBytes/administrate-field-json_editor): :pencil: A `text` field that shows a [JSON editor](https://github.com/josdejong/jsoneditor).
|
74
|
+
- [`Administrate::Field::LazyBelongsTo`](https://github.com/XPBytes/administrate-field-lazy_belongs_to): :pencil: A `belongs to`-like field that lazily loads candidates from a custom endpoint.
|
70
75
|
- [`Administrate::Field::ScopedBelongsTo`](https://github.com/XPBytes/administrate-field-scoped_belongs_to): :pencil: A `belongs_to` field that yields itself to the scope `lambda`.
|
71
76
|
- [`Administrate::Field::ScopedHasMany`](https://github.com/XPBytes/administrate-field-scoped_has_many): :pencil: A `has_many` field that yields itself to the scope `lambda`.
|
72
77
|
- [`Administrate::Field::TimeAgo`](https://github.com/XPBytes/administrate-field-time_ago): :pencil: A `date_time` field that shows its data as `time_ago` since.
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.metadata['homepage_uri'] = spec.homepage
|
21
21
|
spec.metadata['source_code_uri'] = spec.homepage
|
22
|
-
spec.metadata['changelog_uri'] = spec.homepage + '/CHANGELOG.md'
|
22
|
+
spec.metadata['changelog_uri'] = spec.homepage + '/blob/master/CHANGELOG.md'
|
23
23
|
else
|
24
24
|
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
25
25
|
'public gem pushes.'
|
@@ -16,4 +16,6 @@ By default, the attribute is rendered as a hyperlink to the data with the trunca
|
|
16
16
|
[2]: http://www.rubydoc.info/gems/administrate/Administrate/Field/String
|
17
17
|
%>
|
18
18
|
|
19
|
-
|
19
|
+
<% if field.present? %>
|
20
|
+
<%= link_to field.truncate, field.href, target: '_blank', rel: 'noopener noreferrer' %>
|
21
|
+
<% end %>
|
@@ -16,4 +16,6 @@ By default, the attribute is rendered as a hyperlink to the data with the entire
|
|
16
16
|
[2]: http://www.rubydoc.info/gems/administrate/Administrate/Field/String
|
17
17
|
%>
|
18
18
|
|
19
|
-
|
19
|
+
<% if field.present? %>
|
20
|
+
<%= link_to field.data, field.href, target: '_blank', rel: 'noopener noreferrer' %>
|
21
|
+
<% end %>
|
data/example.png
ADDED
Binary file
|
@@ -9,11 +9,18 @@ module Administrate
|
|
9
9
|
class Engine < ::Rails::Engine
|
10
10
|
end
|
11
11
|
|
12
|
+
def present?
|
13
|
+
(data.presence | options.fetch(:fallback_href) { nil }).present?
|
14
|
+
end
|
15
|
+
|
12
16
|
def to_s
|
13
|
-
|
17
|
+
options.fetch(:label) do
|
18
|
+
data.presence || options.fetch(:fallback_href) { nil }
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
22
|
def href
|
23
|
+
return options.fetch(:fallback_href) { nil } unless data.present?
|
17
24
|
return data if data.include?('://') || data.start_with?('//')
|
18
25
|
|
19
26
|
"#{options.fetch(:scheme) { 'https://' }}#{data}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate-field-hyperlink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derk-Jan Karrenbeld
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- app/views/fields/hyperlink/_form.html.erb
|
110
110
|
- app/views/fields/hyperlink/_index.html.erb
|
111
111
|
- app/views/fields/hyperlink/_show.html.erb
|
112
|
+
- example.png
|
112
113
|
- lib/administrate/field/hyperlink.rb
|
113
114
|
- lib/administrate/field/hyperlink/version.rb
|
114
115
|
homepage: https://github.com/XPBytes/administrate-field-hyperlink
|
@@ -117,7 +118,7 @@ licenses:
|
|
117
118
|
metadata:
|
118
119
|
homepage_uri: https://github.com/XPBytes/administrate-field-hyperlink
|
119
120
|
source_code_uri: https://github.com/XPBytes/administrate-field-hyperlink
|
120
|
-
changelog_uri: https://github.com/XPBytes/administrate-field-hyperlink/CHANGELOG.md
|
121
|
+
changelog_uri: https://github.com/XPBytes/administrate-field-hyperlink/blob/master/CHANGELOG.md
|
121
122
|
post_install_message:
|
122
123
|
rdoc_options: []
|
123
124
|
require_paths:
|
@@ -133,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
134
|
- !ruby/object:Gem::Version
|
134
135
|
version: '0'
|
135
136
|
requirements: []
|
136
|
-
|
137
|
-
rubygems_version: 2.7.6
|
137
|
+
rubygems_version: 3.0.3
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: A string field that shows a hyperlink.
|