pugin 1.6.12 → 1.6.13
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa2303a50ba0e6a86c506265d2748664a39f4a35
|
4
|
+
data.tar.gz: d4bd50bd73a9840757aa22c9239e5a3e9a611668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e78cd869d87ac8109d970b7b57138e10640b65189d9653a5720f7065d74c713bdf4f145b892e77e2886e6a0327c3c7c2fa9d7bff4418614ffe8d2190557835f
|
7
|
+
data.tar.gz: 25fe2cac9ce5486dfff96aae00dba787e460d54e29be49b0f5cb4b837638d325d37da7accbfb9da99309ad4bbfb184519e125822c516185c5b4da66ca02405d3
|
@@ -1,7 +1,9 @@
|
|
1
|
+
- page_title = content_for(:title).nil? ? I18n.t('pugin.layouts.pugin.website_brand') : "#{content_for(:title)} - #{ I18n.t('pugin.layouts.pugin.website_brand')}"
|
2
|
+
|
1
3
|
!!! 5
|
2
4
|
%html{lang:'en'}
|
3
5
|
%head
|
4
|
-
%title=
|
6
|
+
%title= page_title
|
5
7
|
%link{rel: 'stylesheet', href: "#{Pugin::ASSET_LOCATION_URL}/#{Pugin::ASSET_VERSION}/stylesheets/main.css" }
|
6
8
|
- if Pugin::Feature::AssetOverrides.enabled?
|
7
9
|
%link{rel: 'stylesheet', href: "https://s3-eu-west-1.amazonaws.com/web1live.static-assets-public/_hybrid-bills/stylesheets/main.css" }
|
@@ -17,6 +19,7 @@
|
|
17
19
|
/ ========================
|
18
20
|
- Pugin.alternates.each do |alternate|
|
19
21
|
%link{rel: 'alternate', type: alternate[:type], href: alternate[:href].html_safe}
|
22
|
+
= render partial: 'pugin/meta/opengraph', locals: { page_title: page_title }
|
20
23
|
%body
|
21
24
|
- if ENV['GTM_KEY']
|
22
25
|
= render partial: 'pugin/javascript/google_tag_manager_noscript'
|
@@ -0,0 +1,7 @@
|
|
1
|
+
%meta{ property: 'og:title', content: page_title }
|
2
|
+
%meta{ property: 'og:type', content: 'website' }
|
3
|
+
%meta{ property: 'og:url', content: request.original_url }
|
4
|
+
%meta{ property: 'og:image', content: opengraph_image[:url].html_safe }
|
5
|
+
%meta{ property: 'og:image:width', content: opengraph_image[:width] }
|
6
|
+
%meta{ property: 'og:image:height', content: opengraph_image[:height] }
|
7
|
+
%meta{ name: 'twitter:card', content: opengraph_image[:twitter_card] }
|
data/lib/pugin.rb
CHANGED
@@ -4,6 +4,7 @@ module Pugin
|
|
4
4
|
ASSET_VERSION = '1.7.5'.freeze
|
5
5
|
ASSET_LOCATION_URL = ENV.fetch('ASSET_LOCATION_URL', 'https://s3-eu-west-1.amazonaws.com/web1live.pugin-website')
|
6
6
|
STATIC_ASSET_LOCATION_URL = ENV.fetch('STATIC_ASSET_LOCATION_URL', 'https://s3-eu-west-1.amazonaws.com/web1live.static-assets')
|
7
|
+
STATIC_ASSET_PUBLIC_LOCATION_URL = ENV.fetch('STATIC_ASSET_PUBLIC_LOCATION_URL', 'https://s3-eu-west-1.amazonaws.com/web1live.static-assets-public')
|
7
8
|
class << self
|
8
9
|
attr_writer :alternates
|
9
10
|
|
data/lib/pugin/version.rb
CHANGED
data/lib/pugin/view_helpers.rb
CHANGED
@@ -1,10 +1,25 @@
|
|
1
1
|
module Pugin
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
module ViewHelpers
|
3
|
+
def navigation_link(route_symbol:, route_args:, letter:)
|
4
|
+
url = send(route_symbol, *route_args, letter) unless route_args.empty?
|
5
|
+
url = send(route_symbol, letter) unless url
|
6
|
+
return link_to(letter, url, data: { 'atoz-see': 'true' })
|
7
|
+
end
|
8
|
+
|
9
|
+
def opengraph_image_standards
|
10
|
+
{ width: '400', height: '400', twitter_card: 'summary', url: "#{STATIC_ASSET_PUBLIC_LOCATION_URL}/opengraph-oblong.png" }
|
11
|
+
end
|
12
|
+
|
13
|
+
def opengraph_image
|
14
|
+
image_hash = if @image
|
15
|
+
{url: "#{ENV['IMAGE_SERVICE_URL']}/#{@image.graph_id}.jpeg?crop=CU_1:1&width=400&quality=100"}
|
16
|
+
elsif @person && !@image
|
17
|
+
{url: "#{ENV['IMAGE_SERVICE_URL']}/#{@person.image_id}.jpeg?crop=CU_1:1&width=400&quality=100"}
|
18
|
+
else
|
19
|
+
{width: '1200', height: '630', twitter_card: 'summary_large_image' }
|
20
|
+
end
|
6
21
|
|
7
|
-
|
8
|
-
end
|
22
|
+
opengraph_image_standards.merge(image_hash)
|
9
23
|
end
|
24
|
+
end
|
10
25
|
end
|
@@ -69,4 +69,63 @@ describe 'pugin/layouts/_layout.html.haml', type: :view do
|
|
69
69
|
expect(rendered).not_to include('<link href=\'https://api.example.com/\' rel=\'alternate\' type=\'application/bar\'>')
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
context 'renders OpenGraph tags' do
|
74
|
+
before :each do
|
75
|
+
render
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'renders og:title' do
|
79
|
+
expect(rendered).to include("<meta content='UK Parliament' property='og:title'>")
|
80
|
+
end
|
81
|
+
it 'renders og:type' do
|
82
|
+
expect(rendered).to include("<meta content='website' property='og:type'>")
|
83
|
+
end
|
84
|
+
it 'renders og:url' do
|
85
|
+
expect(rendered).to include("property='og:url'")
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'correctly on person' do
|
89
|
+
let(:member) { Class.new }
|
90
|
+
|
91
|
+
before :each do
|
92
|
+
allow(member).to receive(:image_id).and_return('1234')
|
93
|
+
@person = member
|
94
|
+
render
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'renders og:image' do
|
98
|
+
expect(response).to include("<meta content='https://api.parliament.uk/Staging/photo/1234.jpeg?crop=CU_1:1&width=400&quality=100' property='og:image'>")
|
99
|
+
expect(response).to include("<meta content='400' property='og:image:width'>")
|
100
|
+
expect(response).to include("<meta content='400' property='og:image:height'>")
|
101
|
+
expect(response).to include("<meta content='summary' name='twitter:card'>")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'correctly on media' do
|
106
|
+
let(:media) { Class.new }
|
107
|
+
|
108
|
+
before :each do
|
109
|
+
allow(media).to receive(:graph_id).and_return('5678')
|
110
|
+
@image = media
|
111
|
+
render
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'renders og:image' do
|
115
|
+
expect(response).to include("<meta content='https://api.parliament.uk/Staging/photo/5678.jpeg?crop=CU_1:1&width=400&quality=100' property='og:image'>")
|
116
|
+
expect(response).to include("<meta content='400' property='og:image:width'>")
|
117
|
+
expect(response).to include("<meta content='400' property='og:image:height'>")
|
118
|
+
expect(response).to include("<meta content='summary' name='twitter:card'>")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'correctly on other pages' do
|
123
|
+
it 'renders og:image' do
|
124
|
+
expect(rendered).to include("<meta content='#{Pugin::STATIC_ASSET_PUBLIC_LOCATION_URL}/opengraph-oblong.png' property='og:image'>")
|
125
|
+
expect(response).to include("<meta content='1200' property='og:image:width'>")
|
126
|
+
expect(response).to include("<meta content='630' property='og:image:height'>")
|
127
|
+
expect(response).to include("<meta content='summary_large_image' name='twitter:card'>")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
72
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Rayner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -215,6 +215,7 @@ files:
|
|
215
215
|
- app/views/pugin/javascript/_pingdom.haml
|
216
216
|
- app/views/pugin/layouts/_layout.html.haml
|
217
217
|
- app/views/pugin/layouts/pugin.html.erb
|
218
|
+
- app/views/pugin/meta/_opengraph.html.haml
|
218
219
|
- app/views/pugin/parties/list/_list.html.haml
|
219
220
|
- app/views/pugin/parties/list/current/current_party.html.haml
|
220
221
|
- app/views/pugin/parties/list/former/former_party.html.haml
|