[Git][noosfero/noosfero][master] 2 commits: metadata: Use lead instead of body for description
Bráulio Bhavamitra
gitlab at mg.gitlab.com
Thu May 5 08:02:30 BRT 2016
Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero
Commits:
f2bfd9e0 by Larissa Reis at 2016-04-26T12:11:47-03:00
metadata: Use lead instead of body for description
Most social networks limit the description length so it's not
necessary to put the whole article body in the description meta tag so
we use the lead instead.
Also if the article is reasonably long, the user could be unable to
share it, getting a "Request-URI Too Large" error.
- - - - -
27b6a398 by Bráulio Bhavamitra at 2016-05-05T11:01:55+00:00
Merge branch 'metadata-description-too-long' into 'master'
metadata: Use lead instead of body for description
Most social networks limit the description length so it's not necessary to put the whole article body in the description meta tag so we use the lead instead.
Also if the article is reasonably long, the user could be unable to share it, getting a "Request-URI Too Large" error.
See merge request !873
- - - - -
2 changed files:
- plugins/metadata/lib/ext/article.rb
- plugins/metadata/test/functional/content_viewer_controller_test.rb
Changes:
=====================================
plugins/metadata/lib/ext/article.rb
=====================================
--- a/plugins/metadata/lib/ext/article.rb
+++ b/plugins/metadata/lib/ext/article.rb
@@ -23,14 +23,14 @@ class Article
'locale:locale' => proc{ |a, c| a.language || a.environment.default_language },
'locale:alternate' => proc{ |a, c| a.alternate_languages },
- description: proc{ |a, plugin| ActionView::Base.full_sanitizer.sanitize a.body },
+ description: proc{ |a, plugin| ActionView::Base.full_sanitizer.sanitize a.lead },
rich_attachment: "",
}
metadata_spec namespace: :twitter, key_attr: :name, tags: {
card: 'summary',
description: proc do |a, plugin|
- description = a.body.to_s || a.environment.name
+ description = a.lead.to_s || a.environment.name
plugin.helpers.truncate plugin.helpers.strip_tags(description), length: 200
end,
title: proc{ |a, plugin| "#{a.title} - #{a.profile.name}" },
=====================================
plugins/metadata/test/functional/content_viewer_controller_test.rb
=====================================
--- a/plugins/metadata/test/functional/content_viewer_controller_test.rb
+++ b/plugins/metadata/test/functional/content_viewer_controller_test.rb
@@ -23,18 +23,18 @@ class ContentViewerControllerTest < ActionController::TestCase
end
should 'add meta tags with article info' do
- a = TinyMceArticle.create(name: 'Article to be shared', body: 'This article should be shared with all social networks', profile: profile)
+ a = TinyMceArticle.create(name: 'Article to be shared', body: '<p>This article should be shared with all social networks</p>', profile: profile)
get :view_page, profile: profile.identifier, page: [ a.name.to_slug ]
assert_tag tag: 'meta', attributes: { name: 'twitter:title', content: /#{a.name} - #{a.profile.name}/ }
- assert_tag tag: 'meta', attributes: { name: 'twitter:description', content: a.body }
+ assert_tag tag: 'meta', attributes: { name: 'twitter:description', content: a.lead.gsub(/<\/?p>/,'') }
assert_no_tag tag: 'meta', attributes: { name: 'twitter:image' }
assert_tag tag: 'meta', attributes: { property: 'og:type', content: 'article' }
assert_tag tag: 'meta', attributes: { property: 'og:url', content: /\/#{profile.identifier}\/#{a.name.to_slug}/ }
assert_tag tag: 'meta', attributes: { property: 'og:title', content: /#{a.name} - #{a.profile.name}/ }
assert_tag tag: 'meta', attributes: { property: 'og:site_name', content: a.profile.name }
- assert_tag tag: 'meta', attributes: { property: 'og:description', content: a.body }
+ assert_tag tag: 'meta', attributes: { property: 'og:description', content: a.lead.gsub(/<\/?p>/,'') }
assert_no_tag tag: 'meta', attributes: { property: 'og:image' }
end
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/86aac3efddd05006c12002224208f39c6232faa6...27b6a398fbe8d8a81a6ef9c68524f05455c02d55
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160505/c78c03fe/attachment-0001.html>
More information about the Noosfero-dev
mailing list