pageflow-chart 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -6
- data/README.md +2 -2
- data/app/assets/javascripts/pageflow/chart/consent.js +16 -0
- data/app/assets/javascripts/pageflow/chart/editor/views/configuration_editor.js +5 -6
- data/app/assets/javascripts/pageflow/chart/editor/views/embedded/iframe_embedded_view.js +25 -3
- data/app/assets/javascripts/pageflow/chart/page_type.js +61 -53
- data/app/assets/javascripts/pageflow/chart.js +2 -3
- data/app/assets/stylesheets/pageflow/chart/editor.scss +1 -3
- data/app/assets/stylesheets/pageflow/chart.scss +9 -15
- data/app/helpers/pageflow/chart/scraped_sites_helper.rb +17 -8
- data/app/views/pageflow/chart/page.html.erb +9 -2
- data/chart.gemspec +1 -1
- data/config/locales/de.yml +4 -0
- data/config/locales/en.yml +4 -0
- data/lib/pageflow/chart/configuration.rb +4 -3
- data/lib/pageflow/chart/plugin.rb +10 -0
- data/lib/pageflow/chart/version.rb +1 -1
- data/lib/pageflow/chart.rb +4 -0
- data/spec/helpers/pageflow/chart/scraped_sites_helper_spec.rb +59 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eaf6b87c76738d2e7efa81a3732a96ef09820bc1b2ca74e9a6e79c71532862c
|
4
|
+
data.tar.gz: 8ad985582dbd2205427546becca4aaa6033394f6c5b6b91e6be69f248bf7f9e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f95634d293e9fe2c59600172e89e07ca177166ae1da0224bdbb96c8331a4406e68d7650fcc89c360f8ddbdeca5f81deaa66fe030a97470d7dd5f4c49f5baacb6
|
7
|
+
data.tar.gz: 5127f6494bd7819de6f6203b96f4cf5a6074db0953ee5d06fff2c5b0337f699bd5794fc0070267a9cfbb8c86c314e94707a235f81fc8e6fd9c199b6a2100f032
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
### Version 2.
|
3
|
+
### Version 2.4.0
|
4
4
|
|
5
|
-
|
5
|
+
2022-07-18
|
6
6
|
|
7
|
-
[Compare changes](https://github.com/codevise/pageflow-chart/compare/2-
|
7
|
+
[Compare changes](https://github.com/codevise/pageflow-chart/compare/2-3-stable...v2.4.0)
|
8
8
|
|
9
|
-
-
|
10
|
-
([#
|
9
|
+
- Use rebrushed button style in editor
|
10
|
+
([#61](https://github.com/codevise/pageflow-chart/pull/61))
|
11
|
+
- Make chart urls protocol relative
|
12
|
+
([#60](https://github.com/codevise/pageflow-chart/pull/60))
|
13
|
+
- Display original chart instead of scraped site
|
14
|
+
([#59](https://github.com/codevise/pageflow-chart/pull/59))
|
15
|
+
- Embed opt-in
|
16
|
+
([#58](https://github.com/codevise/pageflow-chart/pull/58))
|
11
17
|
|
12
18
|
See
|
13
|
-
[2-
|
19
|
+
[2-3-stable branch](https://github.com/codevise/pageflow-chart/blob/2-3-stable/CHANGELOG.md)
|
14
20
|
for previous changes.
|
data/README.md
CHANGED
@@ -17,10 +17,10 @@ Mount the engine:
|
|
17
17
|
# config/routes.rb
|
18
18
|
mount Pageflow::Chart::Engine, at: '/chart'
|
19
19
|
|
20
|
-
Register the
|
20
|
+
Register the plugin:
|
21
21
|
|
22
22
|
# config/initializers/pageflow.rb
|
23
|
-
config.
|
23
|
+
config.plugin(Pageflow::Chart.plugin)
|
24
24
|
|
25
25
|
Include javascript/stylesheets:
|
26
26
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
pageflow.chart.consent = {
|
2
|
+
ensureVendorRegistered: function(options) {
|
3
|
+
if (this.registered) {
|
4
|
+
return;
|
5
|
+
}
|
6
|
+
|
7
|
+
this.registered = true;
|
8
|
+
options = options || {}
|
9
|
+
|
10
|
+
pageflow.consent.registerVendor('datawrapper', {
|
11
|
+
paradigm: options.skip ? 'skip' : 'lazy opt-in',
|
12
|
+
displayName: I18n.t('pageflow.public.chart.consent_vendor_name'),
|
13
|
+
description: I18n.t('pageflow.public.chart.consent_vendor_description')
|
14
|
+
});
|
15
|
+
}
|
16
|
+
};
|
@@ -7,14 +7,13 @@ pageflow.ConfigurationEditorView.register('chart', {
|
|
7
7
|
});
|
8
8
|
|
9
9
|
this.tab('files', function() {
|
10
|
-
this.input('
|
11
|
-
supportedHosts: supportedHosts,
|
10
|
+
this.input('chart_url', pageflow.UrlInputView, {
|
12
11
|
displayPropertyName: 'display_scraped_site_url',
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
collection: 'pageflow_chart_scraped_sites'
|
12
|
+
supportedHosts: supportedHosts,
|
13
|
+
required: true,
|
14
|
+
permitHttps: true
|
17
15
|
});
|
16
|
+
|
18
17
|
this.view(pageflow.chart.DatawrapperAdView);
|
19
18
|
this.input('full_width', pageflow.CheckBoxInputView);
|
20
19
|
this.group('background');
|
@@ -4,22 +4,43 @@ pageflow.chart.IframeEmbeddedView = Backbone.Marionette.View.extend({
|
|
4
4
|
},
|
5
5
|
|
6
6
|
render: function() {
|
7
|
-
this.
|
7
|
+
if (this.model.has('chart_url')) {
|
8
|
+
this.updateChartUrl();
|
9
|
+
}
|
10
|
+
else if (this.model.has('scraped_site_id')) {
|
11
|
+
this.updateScrapedSite();
|
12
|
+
}
|
13
|
+
|
8
14
|
return this;
|
9
15
|
},
|
10
16
|
|
11
17
|
update: function() {
|
12
|
-
if (this.model.hasChanged(
|
18
|
+
if (this.model.hasChanged('chart_url')) {
|
19
|
+
this.updateChartUrl();
|
20
|
+
}
|
21
|
+
else if (this.model.hasChanged('scraped_site_id')) {
|
13
22
|
this.updateScrapedSite();
|
14
23
|
}
|
15
24
|
},
|
16
25
|
|
26
|
+
updateChartUrl: function() {
|
27
|
+
var url = this.model.get('chart_url');
|
28
|
+
|
29
|
+
if (url) {
|
30
|
+
url = url.replace(/^https?:/, '');
|
31
|
+
}
|
32
|
+
|
33
|
+
this.$el.attr('src', url);
|
34
|
+
this.$el.removeAttr('data-use-custom-theme');
|
35
|
+
this.$el.removeAttr('data-customize-layout');
|
36
|
+
},
|
37
|
+
|
17
38
|
updateScrapedSite: function() {
|
18
39
|
if (this.scrapedSite) {
|
19
40
|
this.stopListening(this.scrapedSite);
|
20
41
|
}
|
21
42
|
|
22
|
-
this.scrapedSite = this.model.getReference(
|
43
|
+
this.scrapedSite = this.model.getReference('scraped_site_id',
|
23
44
|
'pageflow_chart_scraped_sites');
|
24
45
|
this.updateAttributes();
|
25
46
|
|
@@ -33,6 +54,7 @@ pageflow.chart.IframeEmbeddedView = Backbone.Marionette.View.extend({
|
|
33
54
|
|
34
55
|
if (scrapedSite && scrapedSite.isReady()) {
|
35
56
|
this.$el.attr('src', scrapedSite.get('html_file_url'));
|
57
|
+
this.$el.attr('data-customize-layout', 'true');
|
36
58
|
|
37
59
|
if (scrapedSite.get('use_custom_theme')) {
|
38
60
|
this.$el.attr('data-use-custom-theme', 'true');
|
@@ -1,8 +1,19 @@
|
|
1
|
-
pageflow.
|
1
|
+
pageflow.pageType.registerInitializer('chart', function() {
|
2
|
+
pageflow.chart.consent.ensureVendorRegistered({
|
3
|
+
skip: !pageflow.features.isEnabled('chart_embed_opt_in')
|
4
|
+
});
|
5
|
+
});
|
2
6
|
|
7
|
+
pageflow.react.registerPageTypeWithDefaultBackground('chart', _.extend({
|
3
8
|
prepareNextPageTimeout: 0,
|
4
9
|
|
5
10
|
enhance: function(pageElement, configuration) {
|
11
|
+
pageElement.thirdPartyEmbedConsent();
|
12
|
+
|
13
|
+
if (!pageflow.features.isEnabled('chart_embed_opt_in')) {
|
14
|
+
pageElement.find('.opt_out_wrapper').hide();
|
15
|
+
}
|
16
|
+
|
6
17
|
var scroller = pageElement.find('.scroller');
|
7
18
|
|
8
19
|
pageElement.find('.bigscreen_toggler').on('click', function() {
|
@@ -41,9 +52,11 @@ pageflow.react.registerPageTypeWithDefaultBackground('chart', _.extend({
|
|
41
52
|
var that = this;
|
42
53
|
var iframe = pageElement.find('iframe');
|
43
54
|
var scroller = pageElement.find('.scroller');
|
44
|
-
var iframeOverlay = pageElement.find('.iframe_overlay');
|
45
55
|
|
46
|
-
if(!
|
56
|
+
if (!iframe.data('customizeLayout')) {
|
57
|
+
pageElement.find('.iframeWrapper').addClass('active');
|
58
|
+
}
|
59
|
+
else if(!this.layoutCustomized) {
|
47
60
|
iframe.load(function() {
|
48
61
|
$(this).contents().find('.fs-btn').css('display','none');
|
49
62
|
$(this).contents().find('body').addClass($("[data-theme]").attr('data-theme'));
|
@@ -80,63 +93,21 @@ pageflow.react.registerPageTypeWithDefaultBackground('chart', _.extend({
|
|
80
93
|
head.append('<link rel="stylesheet" type="text/css" href="' + path + '">');
|
81
94
|
},
|
82
95
|
|
83
|
-
_initEventSimulation: function(element, iframe, wrapper) {
|
84
|
-
element.on('click', function(event) {
|
85
|
-
var contentElement = iframe.contents()[0];
|
86
|
-
|
87
|
-
element.css('display', 'none');
|
88
|
-
|
89
|
-
if (contentElement && event) {
|
90
|
-
var offset = iframe.offset();
|
91
|
-
var options = $.extend({}, event, {
|
92
|
-
screenX: event.screenX - offset.left,
|
93
|
-
screenY: event.screenY - offset.top,
|
94
|
-
clientX: event.clientX - offset.left,
|
95
|
-
clientY: event.clientY - offset.top,
|
96
|
-
});
|
97
|
-
|
98
|
-
var lastElement = $(contentElement.elementFromPoint(event.pageX - offset.left,
|
99
|
-
event.pageY - offset.top));
|
100
|
-
|
101
|
-
lastElement.simulate('mousedown', options);
|
102
|
-
lastElement.simulate('mousemove', options);
|
103
|
-
lastElement.simulate('click', options);
|
104
|
-
lastElement.simulate('mouseup', options);
|
105
|
-
|
106
|
-
element.css('cursor', lastElement.css('cursor'));
|
107
|
-
}
|
108
|
-
|
109
|
-
element.css('display', 'block');
|
110
|
-
|
111
|
-
event.preventDefault();
|
112
|
-
event.stopPropagation();
|
113
|
-
});
|
114
|
-
|
115
|
-
iframe.load(function() {
|
116
|
-
iframe.contents().find('*').on('mousemove', function() {
|
117
|
-
wrapper.addClass('hovering');
|
118
|
-
});
|
119
|
-
|
120
|
-
iframe.contents().on('mouseout', function() {
|
121
|
-
wrapper.removeClass('hovering');
|
122
|
-
});
|
123
|
-
});
|
124
|
-
},
|
125
|
-
|
126
96
|
prepare: function(pageElement, configuration) {
|
127
97
|
this._loadIframe(pageElement);
|
128
98
|
},
|
129
99
|
|
130
100
|
activating: function(pageElement, configuration) {
|
101
|
+
this._listenToHeightMessage(pageElement);
|
131
102
|
this._loadIframe(pageElement);
|
132
103
|
this.resize(pageElement, configuration);
|
133
104
|
this.customizeLayout(pageElement, configuration);
|
134
|
-
this._initEventSimulation(pageElement.find('.iframe_overlay'), pageElement.find('iframe'), pageElement.find('.iframeWrapper'));
|
135
105
|
},
|
136
106
|
|
137
107
|
activated: function(pageElement, configuration) {},
|
138
108
|
|
139
109
|
deactivating: function(pageElement, configuration) {
|
110
|
+
this._stopListeningToHeightMessages();
|
140
111
|
$('body').removeClass('bigScreen');
|
141
112
|
},
|
142
113
|
|
@@ -159,19 +130,56 @@ pageflow.react.registerPageTypeWithDefaultBackground('chart', _.extend({
|
|
159
130
|
embeddedEditorViews: function() {
|
160
131
|
return {
|
161
132
|
'iframe': {
|
162
|
-
view: pageflow.chart.IframeEmbeddedView
|
163
|
-
options: {propertyName: 'scraped_site_id'}
|
133
|
+
view: pageflow.chart.IframeEmbeddedView
|
164
134
|
}
|
165
135
|
};
|
166
136
|
},
|
167
137
|
|
168
138
|
_loadIframe: function(pageElement) {
|
169
|
-
|
170
|
-
|
139
|
+
if (this.loadIframeCalled) {
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
|
143
|
+
this.loadIframeCalled = true;
|
171
144
|
|
172
|
-
|
173
|
-
|
145
|
+
pageflow.consent.requireAccepted('datawrapper').then(function(result) {
|
146
|
+
if (result === 'fulfilled') {
|
147
|
+
pageElement.find('iframe[data-src]').each(function() {
|
148
|
+
var iframe = $(this);
|
149
|
+
|
150
|
+
if (!iframe.attr('src')) {
|
151
|
+
iframe.attr('src', iframe.data('src'));
|
152
|
+
}
|
153
|
+
});
|
174
154
|
}
|
175
155
|
});
|
156
|
+
},
|
157
|
+
|
158
|
+
_listenToHeightMessage: function(pageElement) {
|
159
|
+
this._messageListener = this._messageListener || function(event) {
|
160
|
+
if (typeof event.data['datawrapper-height'] !== 'undefined') {
|
161
|
+
var iframe = pageElement.find('iframe')
|
162
|
+
|
163
|
+
for (var chartId in event.data['datawrapper-height']) {
|
164
|
+
if (iframe.attr('src').indexOf(chartId) > -1) {
|
165
|
+
var iframeWrapper = pageElement.find('.iframeWrapper')
|
166
|
+
var height = event.data['datawrapper-height'][chartId] + 'px';
|
167
|
+
|
168
|
+
if (iframeWrapper.css('height') !== height) {
|
169
|
+
var scroller = pageElement.find('.scroller');
|
170
|
+
|
171
|
+
iframeWrapper.css('height', height);
|
172
|
+
scroller.scroller('refresh');
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
window.addEventListener('message', this._messageListener);
|
180
|
+
},
|
181
|
+
|
182
|
+
_stopListeningToHeightMessages: function() {
|
183
|
+
window.removeEventListener('message', this._messageListener);
|
176
184
|
}
|
177
185
|
}, pageflow.defaultPageContent));
|
@@ -62,18 +62,6 @@
|
|
62
62
|
}
|
63
63
|
}
|
64
64
|
|
65
|
-
.iframe_overlay {
|
66
|
-
.has_mobile_platform & {
|
67
|
-
position: absolute;
|
68
|
-
top: 0;
|
69
|
-
left: 0;
|
70
|
-
width: 100%;
|
71
|
-
height: 100%;
|
72
|
-
pointer-events: all;
|
73
|
-
background-color: transparent;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
65
|
.text_position_right &.widescreened {
|
78
66
|
@include position-end(auto);
|
79
67
|
@include position-start(8%);
|
@@ -102,19 +90,18 @@
|
|
102
90
|
}
|
103
91
|
}
|
104
92
|
|
105
|
-
&:hover .bigscreen_toggler
|
93
|
+
&:hover .bigscreen_toggler {
|
106
94
|
opacity: 1;
|
107
95
|
}
|
108
96
|
|
109
97
|
.bigScreen & {
|
110
98
|
position: absolute;
|
111
99
|
width: 86% !important;
|
112
|
-
height: 87%;
|
113
100
|
top: 10%;
|
114
101
|
left: 5% !important;
|
115
102
|
z-index: 201;
|
116
103
|
margin-top: 0 !important;
|
117
|
-
max-height:
|
104
|
+
max-height: 84% !important;
|
118
105
|
|
119
106
|
.bigscreen_toggler {
|
120
107
|
background-position: -25px 0;
|
@@ -131,4 +118,11 @@
|
|
131
118
|
}
|
132
119
|
}
|
133
120
|
}
|
121
|
+
|
122
|
+
.opt_out_wrapper {
|
123
|
+
position: absolute;
|
124
|
+
top: 100%;
|
125
|
+
right: 0;
|
126
|
+
left: 0;
|
127
|
+
}
|
134
128
|
}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Pageflow
|
2
2
|
module Chart
|
3
3
|
module ScrapedSitesHelper
|
4
|
+
include RevisionFileHelper
|
5
|
+
|
4
6
|
IFRAME_ATTRIBUTES = {
|
5
7
|
style: 'width: 100%; height: 100%',
|
6
8
|
scrolling: 'auto',
|
@@ -11,22 +13,29 @@ module Pageflow
|
|
11
13
|
webkitallowfullscreen: 'true'
|
12
14
|
}
|
13
15
|
|
14
|
-
def scraped_site_iframe(
|
15
|
-
scraped_site = find_file_in_entry(ScrapedSite, scraped_site_id)
|
16
|
+
def scraped_site_iframe(configuration)
|
16
17
|
data_attributes = {}
|
17
18
|
|
18
|
-
if
|
19
|
+
if configuration['chart_url']
|
19
20
|
data_attributes = {
|
20
|
-
src:
|
21
|
+
src: configuration['chart_url'].gsub(/^https?:/, '')
|
22
|
+
}
|
23
|
+
elsif (scraped_site = find_scraped_site(configuration))
|
24
|
+
data_attributes = {
|
25
|
+
src: scraped_site.html_file_url,
|
26
|
+
customize_layout: true,
|
27
|
+
use_custom_theme: scraped_site.use_custom_theme ? true : nil
|
21
28
|
}
|
22
|
-
|
23
|
-
if scraped_site.use_custom_theme
|
24
|
-
data_attributes[:use_custom_theme] = true
|
25
|
-
end
|
26
29
|
end
|
27
30
|
|
28
31
|
content_tag(:iframe, '', IFRAME_ATTRIBUTES.merge(data: data_attributes))
|
29
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def find_scraped_site(configuration)
|
37
|
+
find_file_in_entry(ScrapedSite, configuration['scraped_site_id'])
|
38
|
+
end
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
@@ -7,9 +7,16 @@
|
|
7
7
|
|
8
8
|
<div class="content">
|
9
9
|
<div class="iframeWrapper">
|
10
|
-
<%= scraped_site_iframe(configuration
|
11
|
-
|
10
|
+
<%= scraped_site_iframe(configuration) %>
|
11
|
+
<%= third_party_embed_opt_in(
|
12
|
+
entry: entry,
|
13
|
+
vendor_name: 'datawrapper',
|
14
|
+
message: t('pageflow.public.chart.opt_in_prompt')
|
15
|
+
) %>
|
12
16
|
<div class="bigscreen_toggler" tabindex="4" title="<%= t('pageflow.public.chart.toggle') %>"><%= t('pageflow.public.chart.toggle') %></div>
|
17
|
+
<div class="opt_out_wrapper">
|
18
|
+
<%= third_party_embed_opt_out_info(entry) %>
|
19
|
+
</div>
|
13
20
|
</div>
|
14
21
|
<div class="scroller">
|
15
22
|
<div>
|
data/chart.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.required_ruby_version = '~> 2.1'
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'pageflow', '~> 15.x'
|
21
|
+
spec.add_runtime_dependency 'pageflow', '~> 15.7.x'
|
22
22
|
spec.add_runtime_dependency 'nokogiri', '~> 1.0'
|
23
23
|
spec.add_runtime_dependency 'pageflow-public-i18n', '~> 1.0'
|
24
24
|
|
data/config/locales/de.yml
CHANGED
@@ -31,6 +31,8 @@ de:
|
|
31
31
|
|
32
32
|
Typische Anwendungsbeispiele: Statistiken, Diagramme, Zahlen&Fakten
|
33
33
|
page_attributes:
|
34
|
+
chart_url:
|
35
|
+
label: Diagramm URL
|
34
36
|
full_width:
|
35
37
|
inline_help: Verbreitert das Diagramm, so dass es die maximal verfügbare Breite nutzt.
|
36
38
|
label: Gesamte Breite nutzen
|
@@ -39,3 +41,5 @@ de:
|
|
39
41
|
page_type_category_name: Daten und Diagramme
|
40
42
|
page_type_description: Einbindung von Diagrammen, die mit Datawrapper erstellt wurden
|
41
43
|
page_type_name: Diagramm
|
44
|
+
chart_embed_opt_in:
|
45
|
+
feature_name: Opt-In für Datawrapper Embeds
|
data/config/locales/en.yml
CHANGED
@@ -17,6 +17,8 @@ en:
|
|
17
17
|
menu_item: Chart
|
18
18
|
text: "# Chart\n\nIntegration of a Datawrapper-Diagram\n\nHere you can add animated infographics to your Pageflow. The diagram is embedded into a background-picture/video and text. To enlarge the graphic you simply have to click on it. \n\nBut first of all you have to create your graphic externally and generate a link. You can find examples and requirements for this under www.datawrapper.de.\n\nNote that Datawrapper offers a special layout option for charts that shall be embedded into a Pageflow: In the \"Visualize\" step of the chart creation wizard, click the \"Design\" tab and select the \"Pageflow\" layout. That way a color scheme is used which complements Pageflow's look.\n\nExamples of application: statistics, diagrams, numbers & facts"
|
19
19
|
page_attributes:
|
20
|
+
chart_url:
|
21
|
+
label: Chart URL
|
20
22
|
full_width:
|
21
23
|
inline_help: Extends the chart to use the maximum width available.
|
22
24
|
label: Use full width
|
@@ -25,3 +27,5 @@ en:
|
|
25
27
|
page_type_category_name: Data and Charts
|
26
28
|
page_type_description: Embedded Datawrapper chart
|
27
29
|
page_type_name: Chart
|
30
|
+
chart_embed_opt_in:
|
31
|
+
feature_name: Opt-in for Datawrapper embeds
|
@@ -64,9 +64,10 @@ module Pageflow
|
|
64
64
|
@paperclip_base_path = ':pageflow_s3_root'
|
65
65
|
@scraped_sites_root_url = nil
|
66
66
|
@supported_hosts = [
|
67
|
-
'
|
68
|
-
'
|
69
|
-
'
|
67
|
+
'cf.datawrapper.de',
|
68
|
+
'charts.datawrapper.de',
|
69
|
+
'datawrapper.dwcdn.de',
|
70
|
+
'datawrapper.dwcdn.net'
|
70
71
|
]
|
71
72
|
@use_custom_theme = false
|
72
73
|
@datawrapper_themes_with_transparent_background_support = ['pageflow']
|
data/lib/pageflow/chart.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'pageflow/used_file_test_helper'
|
4
|
+
|
5
|
+
module Pageflow
|
6
|
+
module Chart
|
7
|
+
describe ScrapedSitesHelper do
|
8
|
+
include UsedFileTestHelper
|
9
|
+
|
10
|
+
before { Pageflow::Chart.config.use_custom_theme = false }
|
11
|
+
|
12
|
+
it 'renders iframe with data-src attribute for scraped site' do
|
13
|
+
scraped_site = create_used_file(:scraped_site, :processed)
|
14
|
+
|
15
|
+
html = scraped_site_iframe('scraped_site_id' => scraped_site.perma_id)
|
16
|
+
|
17
|
+
iframe = Capybara.string(html).find('iframe')
|
18
|
+
expect(iframe['data-src']).to match(%r{original/index\.html})
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'renders no data-custom-theme attribute by default' do
|
22
|
+
scraped_site = create_used_file(:scraped_site, :processed)
|
23
|
+
|
24
|
+
html = scraped_site_iframe('scraped_site_id' => scraped_site.perma_id)
|
25
|
+
|
26
|
+
iframe = Capybara.string(html).find('iframe')
|
27
|
+
expect(iframe['data-use-custom-theme']).to be_blank
|
28
|
+
expect(iframe['data-customize-layout']).to eq('true')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'renders data-custom-theme if site has custom theme' do
|
32
|
+
Pageflow::Chart.config.use_custom_theme = true
|
33
|
+
scraped_site = create_used_file(:scraped_site, :processed)
|
34
|
+
|
35
|
+
html = scraped_site_iframe('scraped_site_id' => scraped_site.perma_id)
|
36
|
+
|
37
|
+
iframe = Capybara.string(html).find('iframe')
|
38
|
+
expect(iframe['data-use-custom-theme']).to eq('true')
|
39
|
+
expect(iframe['data-customize-layout']).to eq('true')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'renders iframe with data-src attribute for chart_url' do
|
43
|
+
html = scraped_site_iframe('chart_url' => 'https://example.com/chart')
|
44
|
+
|
45
|
+
iframe = Capybara.string(html).find('iframe')
|
46
|
+
expect(iframe['data-src']).to eq('//example.com/chart')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'renders no data-custom-theme attribute for chart_url' do
|
50
|
+
html = scraped_site_iframe('chart_url' => 'https://example.com/chart')
|
51
|
+
|
52
|
+
iframe = Capybara.string(html).find('iframe')
|
53
|
+
|
54
|
+
expect(iframe['data-customize-layout']).to be_blank
|
55
|
+
expect(iframe['data-use-custom-theme']).to be_blank
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pageflow-chart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codevise Solutions Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-18 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: 15.x
|
19
|
+
version: 15.7.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: 15.x
|
26
|
+
version: 15.7.x
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- app/assets/images/pageflow/ov-chart.png
|
180
180
|
- app/assets/javascripts/pageflow/chart.js
|
181
181
|
- app/assets/javascripts/pageflow/chart/asset_urls.js.erb
|
182
|
+
- app/assets/javascripts/pageflow/chart/consent.js
|
182
183
|
- app/assets/javascripts/pageflow/chart/editor.js
|
183
184
|
- app/assets/javascripts/pageflow/chart/editor/config.js
|
184
185
|
- app/assets/javascripts/pageflow/chart/editor/models/scraped_site.js
|
@@ -216,6 +217,7 @@ files:
|
|
216
217
|
- lib/pageflow/chart/downloader.rb
|
217
218
|
- lib/pageflow/chart/engine.rb
|
218
219
|
- lib/pageflow/chart/page_type.rb
|
220
|
+
- lib/pageflow/chart/plugin.rb
|
219
221
|
- lib/pageflow/chart/refresh_tag_following_downloader.rb
|
220
222
|
- lib/pageflow/chart/scraper.rb
|
221
223
|
- lib/pageflow/chart/version.rb
|
@@ -226,6 +228,7 @@ files:
|
|
226
228
|
- spec/fixtures/data.csv
|
227
229
|
- spec/fixtures/datawrapper.html
|
228
230
|
- spec/fixtures/index.html
|
231
|
+
- spec/helpers/pageflow/chart/scraped_sites_helper_spec.rb
|
229
232
|
- spec/integration/file_type_spec.rb
|
230
233
|
- spec/integration/page_type_spec.rb
|
231
234
|
- spec/jobs/pageflow/chart/scrape_site_job_spec.rb
|
@@ -259,8 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
262
|
- !ruby/object:Gem::Version
|
260
263
|
version: '0'
|
261
264
|
requirements: []
|
262
|
-
|
263
|
-
rubygems_version: 2.7.5
|
265
|
+
rubygems_version: 3.0.8
|
264
266
|
signing_key:
|
265
267
|
specification_version: 4
|
266
268
|
summary: Pagetype for Embedded Datawrapper Charts
|
@@ -272,6 +274,7 @@ test_files:
|
|
272
274
|
- spec/fixtures/data.csv
|
273
275
|
- spec/fixtures/datawrapper.html
|
274
276
|
- spec/fixtures/index.html
|
277
|
+
- spec/helpers/pageflow/chart/scraped_sites_helper_spec.rb
|
275
278
|
- spec/integration/file_type_spec.rb
|
276
279
|
- spec/integration/page_type_spec.rb
|
277
280
|
- spec/jobs/pageflow/chart/scrape_site_job_spec.rb
|