pageflow-internal-links 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a24a0e3ee46c6a17e1c5558a32ea08a334c117dde8003f21753c9c08b534ddd
4
- data.tar.gz: 8638cddf9198cafa697dfb9ba4348d461506d13a553519b95f78acc43bf4cd58
3
+ metadata.gz: 97724ff942ba0daa911807073d14a9c8e0b9a39eb9f46d052791e8647224f2e5
4
+ data.tar.gz: 26567ba7d3c678627b68f647ed43dc21fa5de0cb282aa24cd2665946728adc1c
5
5
  SHA512:
6
- metadata.gz: cac06878b7958f08327d22374f8d40b6de5cab63cac49c911a1d59c28a53d5a63917fddc808e7a5970fdfd3f09debaf9ff47cc1d16f44c16ddf585a8156cc248
7
- data.tar.gz: f9e33adc8e4aee1bdddd26c7d0850b9439121315de0c04337584e46474d1dc7ce81c8354625373ecb3a9ccc4947ea9b08ac86b52bed753784906d64bff622a3b
6
+ metadata.gz: feb875f9c915927689fc905d0ece8c57c6a8aad3fe2e4c445f456195a8d988ebe120ee560e8155254b23a0cf54c92bdd98efe794bb3975929b1bb15343f41be1
7
+ data.tar.gz: 5eb81ad126c6f12ab82450f6ff309162d2c12081fb4eb63acb7731519dd8090089695609d8187ba068a5c92e8d626df73b47bedb84e342f1aef02da9302c5465
data/.travis.yml CHANGED
@@ -8,3 +8,6 @@ cache: bundler
8
8
 
9
9
  script:
10
10
  - bin/rspec
11
+
12
+ services:
13
+ - mysql
data/CHANGELOG.md CHANGED
@@ -1,16 +1,20 @@
1
1
  # CHANGELOG
2
2
 
3
- ### Version 1.2.0
3
+ ### Version 1.3.0
4
4
 
5
- 2019-04-08
5
+ 2019-11-04
6
6
 
7
- [Compare changes](https://github.com/codevise/pageflow-internal-links/compare/1-1-stable...v1.2.0)
7
+ [Compare changes](https://github.com/codevise/pageflow-internal-links/compare/1-2-stable...v1.3.0)
8
8
 
9
- - Adapt page dom for pageflow 14
10
- ([#17](https://github.com/codevise/pageflow-internal-links/pull/17))
11
- - Setup page type lint specs
12
- ([#16](https://github.com/codevise/pageflow-internal-links/pull/16))
9
+ - Rewrite helpers to use image file perma ids
10
+ ([#21](https://github.com/codevise/pageflow-internal-links/pull/21))
11
+ - Specify mysql service for Travis build
12
+ ([#20](https://github.com/codevise/pageflow-internal-links/pull/20))
13
+ - Specify export_version
14
+ ([#19](https://github.com/codevise/pageflow-internal-links/pull/19))
15
+ - Extend pageflow version requirement to < 16
16
+ ([#18](https://github.com/codevise/pageflow-internal-links/pull/18))
13
17
 
14
18
  See
15
- [1-1-stable branch](https://github.com/codevise/pageflow-internal-links/blob/1-1-stable/CHANGELOG.md)
19
+ [1-2-stable branch](https://github.com/codevise/pageflow-internal-links/blob/1-2-stable/CHANGELOG.md)
16
20
  for previous changes.
@@ -3,7 +3,7 @@ module Pageflow
3
3
  module GridHelper
4
4
  def internal_links_grid(entry, configuration)
5
5
  Grid.new(self,
6
- InternalLinks::PageLinks.deserialize(entry, configuration),
6
+ InternalLinks::PageLinks.deserialize(self, entry, configuration),
7
7
  configuration['linked_pages_layout']).render
8
8
  end
9
9
 
@@ -3,7 +3,7 @@ module Pageflow
3
3
  module ListHelper
4
4
  def internal_links_list(entry, configuration)
5
5
  render('pageflow/internal_links/list/list',
6
- page_links: InternalLinks::PageLinks.deserialize(entry, configuration))
6
+ page_links: InternalLinks::PageLinks.deserialize(self, entry, configuration))
7
7
  end
8
8
  end
9
9
  end
@@ -1,8 +1,8 @@
1
1
  module Pageflow
2
2
  module InternalLinks
3
- class PageLinks < Struct.new(:entry, :configuration)
4
- def self.deserialize(entry, configuration)
5
- new(entry, configuration).deserialize
3
+ class PageLinks < Struct.new(:template, :entry, :configuration)
4
+ def self.deserialize(template, entry, configuration)
5
+ new(template, entry, configuration).deserialize
6
6
  end
7
7
 
8
8
  def deserialize
@@ -29,7 +29,8 @@ module Pageflow
29
29
 
30
30
  def parse_collection(collection)
31
31
  collection.map do |attributes|
32
- PageLink.new(attributes['target_page_id'],
32
+ PageLink.new(template,
33
+ attributes['target_page_id'],
33
34
  attributes['position'].to_i,
34
35
  attributes['page_transition'],
35
36
  attributes['description'],
@@ -39,12 +40,13 @@ module Pageflow
39
40
 
40
41
  def parse_legacy_hash(hash)
41
42
  hash.map do |position, target_page_id|
42
- PageLink.new(target_page_id, (position.to_i - 1), nil, nil, nil)
43
+ PageLink.new(template, target_page_id, (position.to_i - 1), nil, nil, nil)
43
44
  end
44
45
  end
45
46
  end
46
47
 
47
- class PageLink < Struct.new(:target_page_id,
48
+ class PageLink < Struct.new(:template,
49
+ :target_page_id,
48
50
  :position,
49
51
  :page_transition,
50
52
  :optional_description,
@@ -62,7 +64,7 @@ module Pageflow
62
64
 
63
65
  def thumbnail_file
64
66
  custom_thumbnail_file ||
65
- (target_page && target_page.thumbnail_file)
67
+ (target_page && template.page_thumbnail_file(target_page))
66
68
  end
67
69
 
68
70
  def css_class
@@ -87,7 +89,8 @@ module Pageflow
87
89
  private
88
90
 
89
91
  def custom_thumbnail_file
90
- @custom_thumbnail_file = ImageFile.find_by_id(custom_thumbnail_image_id)
92
+ @custom_thumbnail_file = template.find_file_in_entry(ImageFile,
93
+ custom_thumbnail_image_id)
91
94
  end
92
95
 
93
96
  def target_page_description
@@ -14,6 +14,10 @@ module Pageflow
14
14
  def view_helpers
15
15
  [GridHelper]
16
16
  end
17
+
18
+ def export_version
19
+ VERSION
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -14,6 +14,10 @@ module Pageflow
14
14
  def view_helpers
15
15
  [InternalLinks::ListHelper]
16
16
  end
17
+
18
+ def export_version
19
+ VERSION
20
+ end
17
21
  end
18
22
  end
19
23
  end
@@ -1,5 +1,5 @@
1
1
  module Pageflow
2
2
  module InternalLinks
3
- VERSION = '1.2.0'.freeze
3
+ VERSION = '1.3.0'.freeze
4
4
  end
5
5
  end
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = '~> 2.1'
20
20
 
21
- spec.add_runtime_dependency 'pageflow', '~> 14.x'
21
+ spec.add_runtime_dependency 'pageflow', '~> 15.x'
22
22
 
23
23
  spec.add_development_dependency 'bundler', ['>= 1.0', '< 3']
24
- spec.add_development_dependency 'pageflow-support', '~> 14.x'
24
+ spec.add_development_dependency 'pageflow-support', '~> 15.x'
25
25
  spec.add_development_dependency 'rake', '~> 12.0'
26
26
  spec.add_development_dependency 'rspec-rails', '~> 3.0'
27
27
 
@@ -1,5 +1,90 @@
1
1
  require 'spec_helper'
2
2
  require 'pageflow/lint'
3
+ require 'pageflow/used_file_test_helper'
3
4
 
4
5
  Pageflow::Lint.page_type(Pageflow::InternalLinks.grid_page_type)
5
6
  Pageflow::Lint.page_type(Pageflow::InternalLinks.list_page_type)
7
+
8
+ module Pageflow
9
+ module InternalLinks
10
+ describe 'page type', type: :helper do
11
+ include RenderPageTestHelper
12
+ include UsedFileTestHelper
13
+
14
+ before do
15
+ pageflow_configure do |config|
16
+ config.plugin(InternalLinks.plugin)
17
+ config.features.enable_by_default('page_type.internal_links_list')
18
+ end
19
+
20
+ helper.extend(Pageflow::FileThumbnailsHelper)
21
+ helper.extend(Pageflow::PagesHelper)
22
+ end
23
+
24
+ describe 'grid' do
25
+ it 'renders internal links' do
26
+ revision = create(:revision)
27
+ other_page = create(:page, revision: revision)
28
+ page = create(:page,
29
+ template: InternalLinks.grid_page_type.name,
30
+ revision: revision,
31
+ configuration: {
32
+ internal_links: [
33
+ {
34
+ target_page_id: other_page.perma_id
35
+ }
36
+ ]
37
+ })
38
+
39
+ html = render_page(page)
40
+
41
+ expect(html).to have_selector("nav a[data-page=#{other_page.perma_id}]")
42
+ end
43
+ end
44
+
45
+ describe 'list' do
46
+ it 'renders internal links' do
47
+ revision = create(:revision)
48
+ other_page = create(:page, revision: revision)
49
+ page = create(:page,
50
+ template: InternalLinks.list_page_type.name,
51
+ revision: revision,
52
+ configuration: {
53
+ internal_links: [
54
+ {
55
+ target_page_id: other_page.perma_id
56
+ }
57
+ ]
58
+ })
59
+
60
+ html = render_page(page)
61
+
62
+ expect(html).to have_selector("nav a[data-page=#{other_page.perma_id}]")
63
+ end
64
+
65
+ it 'looks up custom thumbnail by perma id' do
66
+ revision = create(:revision)
67
+ entry = Pageflow::PublishedEntry.new(create(:entry), revision)
68
+ other_page = create(:page, revision: revision)
69
+ image_file = create_used_file(:image_file, entry: entry)
70
+ page = create(:page,
71
+ template: InternalLinks.list_page_type.name,
72
+ revision: revision,
73
+ configuration: {
74
+ internal_links: [
75
+ {
76
+ target_page_id: other_page.perma_id,
77
+ thumbnail_image_id: image_file.perma_id
78
+ }
79
+ ]
80
+ })
81
+
82
+ html = render_page(page)
83
+
84
+ expect(html)
85
+ .to have_selector("nav a .pageflow_image_file_link_thumbnail_large_#{image_file.perma_id}")
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,6 @@
1
+ require 'factory_bot_rails'
2
+
3
+ RSpec.configure do |config|
4
+ # Allow to use build and create methods without FactoryBot prefix.
5
+ config.include FactoryBot::Syntax::Methods
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pageflow-internal-links
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codevise Solutions
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-08 00:00:00.000000000 Z
11
+ date: 2019-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pageflow
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 14.x
19
+ version: 15.x
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: 14.x
26
+ version: 15.x
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 14.x
53
+ version: 15.x
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 14.x
60
+ version: 15.x
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -181,6 +181,7 @@ files:
181
181
  - pageflow-internal-links.gemspec
182
182
  - spec/integration/page_types_spec.rb
183
183
  - spec/spec_helper.rb
184
+ - spec/support/config/factory_bot.rb
184
185
  homepage: https://github.com/codevise/pageflow-internal-links
185
186
  licenses:
186
187
  - MIT
@@ -208,3 +209,4 @@ summary: Pageflow page types for linking to other pages.
208
209
  test_files:
209
210
  - spec/integration/page_types_spec.rb
210
211
  - spec/spec_helper.rb
212
+ - spec/support/config/factory_bot.rb