Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: includes/meta/social.tmpl

Issue 29680647: Issue 5329 - Provide a template for social media meta data in website-defaults (Closed) Base URL: https://hg.adblockplus.org/website-defaults
Patch Set: Created Jan. 26, 2018, 11:28 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 {% set social_media_meta = [
2 ('og:url',
juliandoucette 2018/01/30 04:04:40 NIT: I'm really not digging this ('multi', line
ire 2018/01/30 08:19:08 I don't think it's very ideal either, but I also t
juliandoucette 2018/01/31 19:03:22 Acknowledged.
3 og_url,
4 get_canonical_url(page)),
5 ('og:type',
juliandoucette 2018/01/30 04:04:40 NIT: I think the default is website and we don't n
ire 2018/01/30 08:19:08 I doesn't seem that this data is implied without b
juliandoucette 2018/01/31 19:03:21 Acknowledged.
6 og_type,
7 'website'),
8 ('og:site_name',
9 og_site_name,
10 get_string('name', 'site') if has_string('name', 'site') else None),
ire 2018/01/26 11:33:59 I changed this to use the same site name string as
juliandoucette 2018/01/30 04:04:39 NIT: `condition and output` can replace `output if
juliandoucette 2018/01/30 04:04:40 Acknowledged.
ire 2018/01/30 08:19:08 Are you saying a valid way to write this is `has_s
juliandoucette 2018/01/31 19:03:21 Yes. But apparently you can also just drop the `el
ire 2018/02/01 09:07:01 The line `has_string('name', 'site') and get_strin
11 ('og:title',
12 og_title,
ire 2018/01/26 11:33:59 Should `og_title` be translated as well (since tit
juliandoucette 2018/01/30 04:04:40 Yes.
ire 2018/01/30 08:19:08 Done.
13 title | translate('title', 'Meta data') if title else None),
14 ('og:description',
15 og_description,
16 description | translate('page-description', 'Meta data') if description else None),
17 ('og:image',
18 og_image,
19 featured_img_url),
20 ('og:image:alt',
21 og_image_alt,
22 featured_img_alt),
23 ('og:locale',
24 og_locale,
25 locale | to_og_locale),
26
27 ('twitter:site',
28 twitter_site,
29 config.get('social', 'twitter') if config.has_option('social', 'twitter') el se '@eyeo'),
ire 2018/01/26 11:33:59 I think the site's twitter username, facebook id,
juliandoucette 2018/01/30 04:04:40 NIT: Long line
juliandoucette 2018/01/30 04:04:40 Acknowledged.
ire 2018/01/30 08:19:08 I can't think of any better way to write this than
juliandoucette 2018/01/31 19:03:21 Acknowledged.
30 ('twitter:card',
31 twitter_card,
32 'summary_large_image' if og_image or twitter_image or featured_img_url else 'summary'),
33 ('twitter:image',
juliandoucette 2018/01/30 04:04:40 NIT: We may not want to add og:image and twitter:i
ire 2018/01/30 08:19:08 Ack. But there's no reason to exclude it now, is t
juliandoucette 2018/01/31 19:03:21 We should not maintain code that we do not and pro
ire 2018/02/01 09:07:01 It will be used for pages that already have a feat
34 twitter_image,
35 featured_img_url),
36 ('twitter:image:alt',
37 twitter_image_alt,
38 featured_img_alt),
39
40 ('fb:app_id',
41 facebook_id,
42 config.get('social', 'facebook_id') if config.has_option('social', 'facebook _id') else None),
43
44 ('p:domain_verify',
45 pinterest_id,
46 config.has_option('social', 'pinterest_id') if config.has_option('social', ' pinterest_id') else None),
47 ] %}
48
49 {% macro meta_tag(property, content, defaultContent=None) -%}
juliandoucette 2018/01/30 04:04:40 NIT: We could use this macro elsewhere if you sepa
ire 2018/01/30 08:19:07 Done.
50 {% if content or defaultContent %}
51 <meta property='{{ property }}' content='{{ content or defaultContent }}'>
52 {% endif %}
53 {%- endmacro %}
54
55 {% for property, content, defaultContent in social_media_meta %}
juliandoucette 2018/01/30 04:04:40 NIT: You could use a for in loop here instead of d
ire 2018/01/30 08:19:08 That seems more messy to me. I think it's better t
juliandoucette 2018/01/31 19:03:21 Acknowledged.
56 {{ meta_tag(property, content, defaultContent) }}
57 {% endfor %}
58
59 {% for alternate_locale in available_locales %}
60 {% if alternate_locale != locale %}
61 {{ meta_tag(('og:locale:alternate', alternate_locale | to_og_locale)) }}
juliandoucette 2018/01/30 04:04:40 Detail: This implementation is correct but it does
ire 2018/01/30 08:19:08 Ack. I think you're right it should go into standa
62 {% endif %}
63 {% endfor %}
OLDNEW

Powered by Google App Engine
This is Rietveld