pageflow-internal-links 0.2.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.scss-lint.yml +40 -0
  4. data/.travis.yml +13 -0
  5. data/CHANGELOG.md +8 -12
  6. data/Gemfile +1 -6
  7. data/README.md +8 -5
  8. data/app/assets/javascripts/pageflow/internal_links/editor/config.js +0 -10
  9. data/app/assets/javascripts/pageflow/internal_links/editor/models/page_link.js +18 -1
  10. data/app/assets/javascripts/pageflow/internal_links/editor/models/page_link_file_selection_handler.js +17 -0
  11. data/app/assets/javascripts/pageflow/internal_links/editor/views/edit_page_link_view.js +18 -8
  12. data/app/assets/javascripts/pageflow/internal_links/editor/views/grid_configuration_editor_view.js +1 -1
  13. data/app/assets/javascripts/pageflow/internal_links/editor/views/list_configuration_editor_view.js +1 -1
  14. data/app/assets/javascripts/pageflow/internal_links/editor/views/list_item_embedded_view.js +13 -4
  15. data/app/assets/javascripts/pageflow/internal_links/grid_page_type.js +3 -12
  16. data/app/assets/javascripts/pageflow/internal_links/list_page_type.js +25 -10
  17. data/app/assets/stylesheets/pageflow/{internal_links.css.scss → internal_links.scss} +0 -0
  18. data/app/assets/stylesheets/pageflow/internal_links/{editor.css.scss → editor.scss} +0 -0
  19. data/app/assets/stylesheets/pageflow/internal_links/editor/{embedded_grid_item.css.scss → embedded_grid_item.scss} +0 -0
  20. data/app/assets/stylesheets/pageflow/internal_links/grid.scss +3 -51
  21. data/app/assets/stylesheets/pageflow/internal_links/themes/default.scss +3 -0
  22. data/app/assets/stylesheets/pageflow/internal_links/themes/default/grid/colors.scss +41 -0
  23. data/app/assets/stylesheets/pageflow/internal_links/themes/default/grid/typography.scss +35 -0
  24. data/app/assets/stylesheets/pageflow/internal_links/themes/default/list_as_multiple_choice.scss +64 -11
  25. data/app/helpers/pageflow/internal_links/grid_helper.rb +1 -1
  26. data/app/helpers/pageflow/internal_links/list_helper.rb +1 -1
  27. data/app/helpers/pageflow/internal_links/page_links.rb +30 -8
  28. data/app/views/pageflow/internal_links/grid/page.html.erb +6 -16
  29. data/app/views/pageflow/internal_links/list/_page_link.html.erb +2 -3
  30. data/app/views/pageflow/internal_links/list/page.html.erb +6 -17
  31. data/bin/rspec +29 -0
  32. data/config/locales/de.yml +12 -1
  33. data/config/locales/en.yml +12 -13
  34. data/lib/pageflow/internal_links/grid_page_type.rb +4 -0
  35. data/lib/pageflow/internal_links/list_page_type.rb +4 -0
  36. data/lib/pageflow/internal_links/plugin.rb +1 -0
  37. data/lib/pageflow/internal_links/version.rb +1 -1
  38. data/pageflow-internal-links.gemspec +9 -3
  39. data/spec/integration/page_types_spec.rb +90 -0
  40. data/spec/spec_helper.rb +14 -0
  41. data/spec/support/config/factory_bot.rb +6 -0
  42. metadata +87 -13
@@ -2,3 +2,6 @@
2
2
  $directory: "pageflow/internal_links/themes/default/pictograms/grid");
3
3
  @include pageflow-page-type-pictograms("internal_links_list",
4
4
  $directory: "pageflow/internal_links/themes/default/pictograms/list");
5
+
6
+ @import "./default/grid/colors";
7
+ @import "./default/grid/typography";
@@ -0,0 +1,41 @@
1
+ /// Color of overlay displayed when hovering a grid item
2
+ $internal-links-grid-item-active-background-color: rgba(0, 0, 0, 0.8) !default;
3
+
4
+ /// Color of text displayed when hovering a grid item
5
+ $internal-links-grid-item-active-text-color: #fff !default;
6
+
7
+ /// Color of overlay displayed when hovering a grid item on an inverted page
8
+ $internal-links-grid-item-inverted-active-background-color: rgba(255, 255, 255, 0.8) !default;
9
+
10
+ /// Color of text displayed when hovering a grid item on an inverted page
11
+ $internal-links-grid-item-inverted-active-text-color: #000 !default;
12
+
13
+ .internal_links_page {
14
+ nav {
15
+ .title {
16
+ color: $internal-links-grid-item-active-text-color;
17
+ }
18
+
19
+ .placeholder,
20
+ .thumbnail {
21
+ &:after {
22
+ background-color: $internal-links-grid-item-active-background-color;
23
+ }
24
+ }
25
+ }
26
+ }
27
+
28
+ .invert .internal_links_page {
29
+ nav {
30
+ .thumbnail,
31
+ .placeholder {
32
+ &:after {
33
+ background-color: $internal-links-grid-item-inverted-active-background-color;
34
+ }
35
+ }
36
+
37
+ .title {
38
+ color: $internal-links-grid-item-inverted-active-text-color;
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,35 @@
1
+ // Typography of the title displayed in grid items
2
+ $internal-links-grid-item-typography: () !default;
3
+
4
+ // Typography of the title displayed in large grid item
5
+ $internal-links-grid-hero-item-typography: () !default;
6
+
7
+ .internal_links_page {
8
+ nav {
9
+ .title {
10
+ @include typography(
11
+ $internal-links-grid-item-typography,
12
+ (
13
+ text-transform: uppercase,
14
+ text-align: center,
15
+ line-height: 1.2em,
16
+ letter-spacing: 0.05em,
17
+ font-size: 0.8em
18
+ )
19
+ );
20
+ }
21
+
22
+ &[data-layout="hero_top_left"],
23
+ &[data-layout="hero_top_right"] {
24
+ .title {
25
+ @include typography(
26
+ $internal-links-grid-hero-item-typography,
27
+ (
28
+ font-size: 1em,
29
+ line-height: 1.4em
30
+ )
31
+ );
32
+ }
33
+ }
34
+ }
35
+ }
@@ -2,6 +2,14 @@
2
2
  $internal-links-list-main-color: $main-color-dark !default;
3
3
  $internal-links-list-item-background-color: rgba(48, 48, 48, 0.8) !default;
4
4
 
5
+ .page_text {
6
+ margin-bottom: 250px;
7
+
8
+ @include mobile {
9
+ margin-bottom: 0;
10
+ }
11
+ }
12
+
5
13
  nav {
6
14
  position: absolute;
7
15
  bottom: 6.666%;
@@ -46,21 +54,66 @@
46
54
  -ms-interpolation-mode: nearest-neighbor;
47
55
 
48
56
  .details {
49
- position: absolute;
50
- top: 50%;
51
- margin: 0;
52
- padding: 10%;
53
- width: 100%;
54
- box-sizing: border-box;
55
- @include transform(translate(0,-50%));
56
-
57
57
  p:last-of-type {
58
58
  margin: 0;
59
59
  }
60
60
  }
61
61
 
62
- .page_thumbnail {
63
- display: none;
62
+ &.no_custom_thumbnail {
63
+ .details {
64
+ position: absolute;
65
+ top: 50%;
66
+ margin: 0;
67
+ padding: 10%;
68
+ width: 100%;
69
+ box-sizing: border-box;
70
+ @include transform(translate(0,-50%));
71
+
72
+ p:last-of-type {
73
+ margin: 0;
74
+ }
75
+ }
76
+
77
+ .page_thumbnail {
78
+ display: none;
79
+ }
80
+ }
81
+
82
+ &.custom_thumbnail {
83
+ .details {
84
+ position: absolute;
85
+ bottom: 0;
86
+ left: 0;
87
+ right: 0;
88
+ padding: 7px 10px;
89
+ margin: 0;
90
+ font-size: 15px;
91
+
92
+ @media (max-width: 500px) {
93
+ font-size: 12px;
94
+ }
95
+ }
96
+
97
+ &.no_own_description {
98
+ .details {
99
+ display: none;
100
+ }
101
+ }
102
+
103
+ .page_thumbnail {
104
+ display: block;
105
+ position: absolute;
106
+ top: 0;
107
+ left: 0;
108
+ right: 0;
109
+ bottom: 35px;
110
+ padding: 0;
111
+ }
112
+
113
+ .page_thumbnail,
114
+ .page_thumbnail div {
115
+ background-position: 50% 50%;
116
+ }
64
117
  }
65
118
  }
66
119
  li:hover {
@@ -117,4 +170,4 @@
117
170
  }
118
171
  }
119
172
  }
120
- }
173
+ }
@@ -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,24 +29,28 @@ 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
- attributes['description'])
36
+ attributes['description'],
37
+ attributes['thumbnail_image_id'])
36
38
  end.sort_by(&:position)
37
39
  end
38
40
 
39
41
  def parse_legacy_hash(hash)
40
42
  hash.map do |position, target_page_id|
41
- PageLink.new(target_page_id, (position.to_i - 1), nil, nil)
43
+ PageLink.new(template, target_page_id, (position.to_i - 1), nil, nil, nil)
42
44
  end
43
45
  end
44
46
  end
45
47
 
46
- class PageLink < Struct.new(:target_page_id,
48
+ class PageLink < Struct.new(:template,
49
+ :target_page_id,
47
50
  :position,
48
51
  :page_transition,
49
- :optional_description)
52
+ :optional_description,
53
+ :custom_thumbnail_image_id)
50
54
 
51
55
  attr_accessor :target_page
52
56
 
@@ -58,6 +62,19 @@ module Pageflow
58
62
  optional_description.presence || target_page_description
59
63
  end
60
64
 
65
+ def thumbnail_file
66
+ custom_thumbnail_file ||
67
+ (target_page && template.page_thumbnail_file(target_page))
68
+ end
69
+
70
+ def css_class
71
+ [
72
+ 'page_link',
73
+ custom_thumbnail_file ? 'custom_thumbnail' : 'no_custom_thumbnail',
74
+ optional_description.present? ? 'own_description' : 'no_own_description'
75
+ ].compact.join(' ')
76
+ end
77
+
61
78
  def data_attributes
62
79
  {}.tap do |result|
63
80
  result[:page] = target_page.perma_id if target_page
@@ -71,6 +88,11 @@ module Pageflow
71
88
 
72
89
  private
73
90
 
91
+ def custom_thumbnail_file
92
+ @custom_thumbnail_file = template.find_file_in_entry(ImageFile,
93
+ custom_thumbnail_image_id)
94
+ end
95
+
74
96
  def target_page_description
75
97
  target_page ? target_page.configuration['description'] : ''
76
98
  end
@@ -1,24 +1,14 @@
1
- <div class="blackLayer"></div>
1
+ <div class="black_layer"></div>
2
2
  <div class="content_and_background internal_links_page">
3
- <div class="backgroundArea">
4
- <%= background_image_div(configuration, 'background_image') %>
3
+ <div class="page_background">
4
+ <%= page_background_asset(page) %>
5
5
  <%= shadow_div :opacity => configuration['gradient_opacity'] %>
6
6
  </div>
7
7
  <div class="content scroller">
8
8
  <div>
9
- <div class="contentWrapper">
10
- <div class="page_header">
11
- <h2>
12
- <span class="tagline"><%= configuration['tagline'] %></span>
13
- <span class="title"><%= configuration['title'] %></span>
14
- <span class="subtitle"><%= configuration['subtitle'] %></span>
15
- </h2>
16
- <%= background_image_tag(configuration['background_image_id'], {"class" => "print_image"}) %>
17
- </div>
18
- <div class="contentText">
19
- <p><%= raw configuration['text'] %></p>
20
- </div>
21
- <%= internal_links_grid(@entry, configuration) %>
9
+ <div class="content_wrapper">
10
+ <%= page_default_content(page) %>
11
+ <%= internal_links_grid(entry, configuration) %>
22
12
  </div>
23
13
  </div>
24
14
  </div>
@@ -1,10 +1,9 @@
1
1
  <li>
2
- <%= link_to("#", class: 'page_link', data: page_link.data_attributes) do %>
2
+ <%= link_to("#", class: page_link.css_class, data: page_link.data_attributes) do %>
3
3
  <%= content_tag(:div,
4
4
  '',
5
5
  class: ['page_thumbnail',
6
- page_link.target_page ? page_thumbnail_image_class(page_link.target_page, false) : nil].compact * ' ') %>
7
-
6
+ file_thumbnail_css_class(page_link.thumbnail_file, :link_thumbnail_large)].compact * ' ') %>
8
7
  <div class="details">
9
8
  <p class="page_description">
10
9
  <%= raw(strip_links(page_link.description)) %>
@@ -1,25 +1,14 @@
1
- <div class="blackLayer"></div>
1
+ <div class="black_layer"></div>
2
2
  <div class="content_and_background internal_links_list_page">
3
- <div class="backgroundArea">
4
- <%= background_image_div(configuration, 'background_image') %>
3
+ <div class="page_background">
4
+ <%= page_background_asset(page) %>
5
5
  <%= shadow_div :opacity => configuration['gradient_opacity'] %>
6
6
  </div>
7
7
  <div class="content scroller">
8
8
  <div>
9
- <div class="contentWrapper">
10
- <div class="page_header">
11
- <h2>
12
- <span class="tagline"><%= configuration['tagline'] %></span>
13
- <span class="title"><%= configuration['title'] %></span>
14
- <span class="subtitle"><%= configuration['subtitle'] %></span>
15
- </h2>
16
- <%= background_image_tag(configuration['background_image_id'], {"class" => "print_image"}) %>
17
- </div>
18
- <div class="contentText">
19
- <p><%= raw configuration['text'] %></p>
20
- </div>
21
-
22
- <%= internal_links_list(@entry, configuration) %>
9
+ <div class="content_wrapper">
10
+ <%= page_default_content(page) %>
11
+ <%= internal_links_list(entry, configuration) %>
23
12
  </div>
24
13
  </div>
25
14
  </div>
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -1,4 +1,8 @@
1
1
  de:
2
+ activerecord:
3
+ attributes:
4
+ pageflow/internal_links/page_link:
5
+ thumbnail_image_id: Bild
2
6
  pageflow:
3
7
  internal_links:
4
8
  editor:
@@ -13,7 +17,6 @@ de:
13
17
  views:
14
18
  edit_page_link_view:
15
19
  confirm_destroy: Verweis wirklich löschen?
16
- default_page_transition: "(Standard)"
17
20
  grid:
18
21
  help_entries:
19
22
  page_type:
@@ -25,6 +28,8 @@ de:
25
28
  Im Gegensatz zur externen Verweis-Seite, werden hier interne Seiten innerhalb des
26
29
  Pageflows verlinkt. Dies bietet sich an, um den User gezielt durch den Pageflow zu leiten.
27
30
 
31
+ Für den Hintergrund kann ein Bild oder Video verwendet werden.
32
+
28
33
  Typische Anwendungsbeispiele: Willkommens-Seite, Kapitel-Startseite
29
34
  page_attributes:
30
35
  linked_pages_layout:
@@ -46,6 +51,8 @@ de:
46
51
 
47
52
  Links auf andere Seiten des Pageflows dargestellt als horizontal angeordnete Boxen mit einem kurzen Text.
48
53
 
54
+ Für den Hintergrund kann ein Bild oder Video verwendet werden.
55
+
49
56
  Typische Anwendungsbeispiele: Frage/Antwort-Seite, interaktives Interview, Quiz
50
57
  page_type_category_name: Verweise
51
58
  page_type_description: Verweise auf andere Seiten als Reihe von Antworten
@@ -56,3 +63,7 @@ de:
56
63
  label: Beschreibung
57
64
  internal_links_list:
58
65
  page_type_feature_name: Multiple Choice Seitentyp
66
+ ui:
67
+ inline_help:
68
+ pageflow/internal_links/page_link:
69
+ thumbnail_image_id: Ein Bild in der Verweis-Box anzeigen.
@@ -1,4 +1,8 @@
1
1
  en:
2
+ activerecord:
3
+ attributes:
4
+ pageflow/internal_links/page_link:
5
+ thumbnail_image_id: Image
2
6
  pageflow:
3
7
  internal_links:
4
8
  editor:
@@ -13,21 +17,11 @@ en:
13
17
  views:
14
18
  edit_page_link_view:
15
19
  confirm_destroy: Really delete this link?
16
- default_page_transition: Default page transition
17
20
  grid:
18
21
  help_entries:
19
22
  page_type:
20
23
  menu_item: Internal Links Grid
21
- text: |-
22
- # Internal Links Grid
23
-
24
- References to other pages inside a Pageflow
25
-
26
- In contrast to external link, you can link to pages inside
27
- your Pageflow. This page type helps you guide your users
28
- through your Pageflow.
29
-
30
- Examples of application: Welcome page, chapter homepage
24
+ text: "# Internal Links Grid\n\nReferences to other pages inside a Pageflow\n\nIn contrast to external link, you can link to pages inside\nyour Pageflow. This page type helps you guide your users\nthrough your Pageflow. \n\nYou can use an image or video for the background.\n\nExamples of application: Welcome page, chapter homepage"
31
25
  page_attributes:
32
26
  linked_pages_layout:
33
27
  inline_help: Emphasize one of the thumbnails.
@@ -43,13 +37,14 @@ en:
43
37
  help_entries:
44
38
  page_type:
45
39
  menu_item: Multiple Choice
46
- text: |+
40
+ text: |-
47
41
  # Multiple Choice
48
42
 
49
43
  A collection of links to other pages of the Pageflow displayed as a row of boxes with some text.
50
44
 
51
- Examples of application: Question/answer page, interactive interview, quiz
45
+ You can use an image or video for the background.
52
46
 
47
+ Examples of application: Question/answer page, interactive interview, quiz
53
48
  page_type_category_name: Links
54
49
  page_type_description: Links to other pages as collection of answers
55
50
  page_type_name: Multiple Choice
@@ -59,3 +54,7 @@ en:
59
54
  label: Description
60
55
  internal_links_list:
61
56
  page_type_feature_name: Multiple Choice Page Type
57
+ ui:
58
+ inline_help:
59
+ pageflow/internal_links/page_link:
60
+ thumbnail_image_id: Display image inside of page link box.