From 69625b7d34851085a9ad300fdc0c404404082386 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 24 Nov 2017 10:58:16 +0100 Subject: [PATCH 1/9] fixes url images on social meta tags partial --- app/views/shared/_social_media_meta_tags.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/_social_media_meta_tags.html.erb b/app/views/shared/_social_media_meta_tags.html.erb index 8c1196c96..d4d8a42b8 100644 --- a/app/views/shared/_social_media_meta_tags.html.erb +++ b/app/views/shared/_social_media_meta_tags.html.erb @@ -3,7 +3,7 @@ - + <% if setting['url'] %> @@ -14,7 +14,7 @@ <% end %> - + From 510d4822a407653b30b58a2b2e6265df8331dd25 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 24 Nov 2017 14:12:01 +0100 Subject: [PATCH 2/9] adds new setting for site title meta tag --- config/locales/en/settings.yml | 1 + config/locales/es/settings.yml | 1 + db/dev_seeds.rb | 1 + db/seeds.rb | 1 + 4 files changed, 4 insertions(+) diff --git a/config/locales/en/settings.yml b/config/locales/en/settings.yml index 0d5862408..2295660ac 100644 --- a/config/locales/en/settings.yml +++ b/config/locales/en/settings.yml @@ -48,6 +48,7 @@ en: map_zoom: Zoom mailer_from_name: Origin email name mailer_from_address: Origin email address + meta_title: "Site title (SEO)" meta_description: "Site description (SEO)" meta_keywords: "Keywords (SEO)" verification_offices_url: Verification offices URL diff --git a/config/locales/es/settings.yml b/config/locales/es/settings.yml index fcf2eb1db..ae31d0a4a 100644 --- a/config/locales/es/settings.yml +++ b/config/locales/es/settings.yml @@ -48,6 +48,7 @@ es: map_zoom: Zoom mailer_from_name: Nombre email remitente mailer_from_address: Dirección email remitente + meta_title: "Título del sitio (SEO)" meta_description: "Descripción del sitio (SEO)" meta_keywords: "Palabras clave (SEO)" verification_offices_url: URL oficinas verificación diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 60493e0a5..f24efa4da 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -55,6 +55,7 @@ section "Creating Settings" do Setting.create(key: 'comments_body_max_length', value: '1000') Setting.create(key: 'mailer_from_name', value: 'CONSUL') Setting.create(key: 'mailer_from_address', value: 'noreply@consul.dev') + Setting.create(key: 'meta_title', value: 'CONSUL') Setting.create(key: 'meta_description', value: 'Citizen Participation and Open Government Application') Setting.create(key: 'meta_keywords', value: 'citizen participation, open government') Setting.create(key: 'verification_offices_url', value: 'http://oficinas-atencion-ciudadano.url/') diff --git a/db/seeds.rb b/db/seeds.rb index fcfa6340c..0e49983a5 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -65,6 +65,7 @@ Setting["org_name"] = "CONSUL" Setting["place_name"] = "CONSUL-land" # Meta tags for SEO +Setting["meta_title"] = nil Setting["meta_description"] = nil Setting["meta_keywords"] = nil From 7fcbd99311f38786d083623ea747cdcea33a73c1 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 24 Nov 2017 14:13:19 +0100 Subject: [PATCH 3/9] adds social media meta tags to welcome index page --- app/views/welcome/index.html.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index e27f4436e..de64d9cd8 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -4,6 +4,11 @@ <%= render "shared/canonical", href: root_url %> <% end %> +<% provide :social_media_meta_tags do %> + <%= render "shared/social_media_meta_tags", + social_url: root_url %> +<% end %> +
From ccbd99f88bf8dfc58988078cd0ee44ee3d40cc3d Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 24 Nov 2017 14:13:45 +0100 Subject: [PATCH 4/9] improves social media meta tags partial with settings --- app/views/shared/_social_media_meta_tags.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/shared/_social_media_meta_tags.html.erb b/app/views/shared/_social_media_meta_tags.html.erb index d4d8a42b8..8782aad17 100644 --- a/app/views/shared/_social_media_meta_tags.html.erb +++ b/app/views/shared/_social_media_meta_tags.html.erb @@ -1,11 +1,11 @@ - - + + - + <% if setting['url'] %> /> <% end %> @@ -16,5 +16,5 @@ - + From 80d99b71a990a4ae420d6098cc56801917624a03 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 24 Nov 2017 14:14:41 +0100 Subject: [PATCH 5/9] adds specs --- spec/features/social_media_meta_tags_spec.rb | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 spec/features/social_media_meta_tags_spec.rb diff --git a/spec/features/social_media_meta_tags_spec.rb b/spec/features/social_media_meta_tags_spec.rb new file mode 100644 index 000000000..6cc8ee41a --- /dev/null +++ b/spec/features/social_media_meta_tags_spec.rb @@ -0,0 +1,31 @@ +require 'rails_helper' + +feature 'Social media meta tags' do + + context 'Setting social media meta tags' do + + before do + Setting['meta_keywords'] = "citizen, participation, open government" + Setting['meta_title'] = "CONSUL" + Setting['meta_description'] = "Citizen Participation and Open Government Application" + end + + after do + Setting['meta_keywords'] = nil + Setting['meta_title'] = nil + Setting['meta_description'] = nil + end + + scenario 'Social media meta tags partial render settings content' do + + visit root_path + + expect(page).to have_css 'meta[name="keywords"][content="citizen, participation, open government"]', visible: false + expect(page).to have_css 'meta[name="twitter:title"][content="CONSUL"]', visible: false + expect(page).to have_css 'meta[name="twitter:title"][content="CONSUL"]', visible: false + expect(page).to have_css 'meta[property="og:title"][content="CONSUL"]', visible: false + expect(page).to have_css 'meta[property="og:description"][content="Citizen Participation and Open Government Application"]', visible: false + end + end + +end From fe987dd7e9d9a9713b05c362b6ffc7e0abbee909 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 24 Nov 2017 14:29:40 +0100 Subject: [PATCH 6/9] =?UTF-8?q?removes=20unnecessary=20blank=20spaces=20?= =?UTF-8?q?=F0=9F=99=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shared/_social_media_meta_tags.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/shared/_social_media_meta_tags.html.erb b/app/views/shared/_social_media_meta_tags.html.erb index 8782aad17..2b08ca61e 100644 --- a/app/views/shared/_social_media_meta_tags.html.erb +++ b/app/views/shared/_social_media_meta_tags.html.erb @@ -1,9 +1,9 @@ - - - - - + + + + + <% if setting['url'] %> From 1534e6fc421766ede68a34dffad9de4e97afaaf5 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 24 Nov 2017 21:36:38 +0100 Subject: [PATCH 7/9] unifies social media meta tags specs --- spec/features/proposals_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 28049644b..192e7949f 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -153,8 +153,8 @@ feature 'Proposals' do proposal = create(:proposal) visit proposal_path(proposal) - expect(page.html).to include "" - expect(page.html).to include "" + expect(page).to have_css "meta[name='twitter:title'][content=\"#{proposal.title}\"]", visible: false + expect(page).to have_css "meta[property='og:title'][content=\"#{proposal.title}\"]", visible: false end scenario 'Create' do From 8bef6d81c82bffef8a6c57c39947a90a40f8e02a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 27 Nov 2017 13:23:47 +0100 Subject: [PATCH 8/9] Fix value for metatag, and use twitter_handle settings value --- app/views/shared/_social_media_meta_tags.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/_social_media_meta_tags.html.erb b/app/views/shared/_social_media_meta_tags.html.erb index 2b08ca61e..a72ab250e 100644 --- a/app/views/shared/_social_media_meta_tags.html.erb +++ b/app/views/shared/_social_media_meta_tags.html.erb @@ -1,13 +1,13 @@ - + <% if setting['url'] %> - /> + <% end %> <% if setting['facebook_handle'] %> From 33f47e7a63ec8b975015449f209ce4d39ff1d0fd Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 27 Nov 2017 13:24:07 +0100 Subject: [PATCH 9/9] Increase social media meta tags spec --- spec/features/social_media_meta_tags_spec.rb | 39 ++++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/spec/features/social_media_meta_tags_spec.rb b/spec/features/social_media_meta_tags_spec.rb index 6cc8ee41a..d04df78f6 100644 --- a/spec/features/social_media_meta_tags_spec.rb +++ b/spec/features/social_media_meta_tags_spec.rb @@ -4,27 +4,50 @@ feature 'Social media meta tags' do context 'Setting social media meta tags' do + let(:meta_keywords) { 'citizen, participation, open government' } + let(:meta_title) { 'CONSUL TEST' } + let(:meta_description) { 'Citizen Participation and Open Government Application' } + let(:twitter_handle) { '@consul_test' } + let(:url) { 'http://consul.dev' } + let(:facebook_handle) { 'consultest' } + let(:org_name) { 'CONSUL TEST' } + before do - Setting['meta_keywords'] = "citizen, participation, open government" - Setting['meta_title'] = "CONSUL" - Setting['meta_description'] = "Citizen Participation and Open Government Application" + Setting['meta_keywords'] = meta_keywords + Setting['meta_title'] = meta_title + Setting['meta_description'] = meta_description + Setting['twitter_handle'] = twitter_handle + Setting['url'] = url + Setting['facebook_handle'] = facebook_handle + Setting['org_name'] = org_name end after do Setting['meta_keywords'] = nil Setting['meta_title'] = nil Setting['meta_description'] = nil + Setting['twitter_handle'] = nil + Setting['url'] = 'http://example.com' + Setting['facebook_handle'] = nil + Setting['org_name'] = 'CONSUL' end scenario 'Social media meta tags partial render settings content' do visit root_path - expect(page).to have_css 'meta[name="keywords"][content="citizen, participation, open government"]', visible: false - expect(page).to have_css 'meta[name="twitter:title"][content="CONSUL"]', visible: false - expect(page).to have_css 'meta[name="twitter:title"][content="CONSUL"]', visible: false - expect(page).to have_css 'meta[property="og:title"][content="CONSUL"]', visible: false - expect(page).to have_css 'meta[property="og:description"][content="Citizen Participation and Open Government Application"]', visible: false + expect(page).to have_css 'meta[name="keywords"][content="'+ meta_keywords + '"]', visible: false + expect(page).to have_css 'meta[name="twitter:site"][content="'+ twitter_handle + '"]', visible: false + expect(page).to have_css 'meta[name="twitter:title"][content="'+ meta_title + '"]', visible: false + expect(page).to have_css 'meta[name="twitter:description"][content="' + meta_description + '"]', visible: false + expect(page).to have_css 'meta[name="twitter:image"][content="http://www.example.com/social_media_icon_twitter.png"]', visible: false + expect(page).to have_css 'meta[property="og:title"][content="'+ meta_title + '"]', visible: false + expect(page).to have_css 'meta[property="article:publisher"][content="' + url + '"]', visible: false + expect(page).to have_css 'meta[property="article:author"][content="https://www.facebook.com/' + facebook_handle + '"]', visible: false + expect(page).to have_css 'meta[property="og:url"][content="http://www.example.com/"]', visible: false + expect(page).to have_css 'meta[property="og:image"][content="http://www.example.com/social_media_icon.png"]', visible: false + expect(page).to have_css 'meta[property="og:site_name"][content="' + org_name + '"]', visible: false + expect(page).to have_css 'meta[property="og:description"][content="' + meta_description + '"]', visible: false end end