LEFT | RIGHT |
1 {# | 1 {# |
2 # This file is part of website-defaults | 2 # This file is part of website-defaults |
3 # Copyright (C) 2016-2017 eyeo GmbH | 3 # Copyright (C) 2016-2017 eyeo GmbH |
4 # | 4 # |
5 # website-defaults is free software: you can redistribute it and/or | 5 # website-defaults is free software: you can redistribute it and/or |
6 # modify it under the terms of the GNU General Public License as published by | 6 # modify it under the terms of the GNU General Public License as published by |
7 # the Free Software Foundation, either version 3 of the License, or | 7 # the Free Software Foundation, either version 3 of the License, or |
8 # (at your option) any later version. | 8 # (at your option) any later version. |
9 # | 9 # |
10 # website-defaults is distributed in the hope that it will be useful, | 10 # website-defaults is distributed in the hope that it will be useful, |
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 # GNU General Public License for more details. | 13 # GNU General Public License for more details. |
14 # | 14 # |
15 # You should have received a copy of the GNU General Public License | 15 # You should have received a copy of the GNU General Public License |
16 # along with website-defaults. If not, see <http://www.gnu.org/licenses/>. | 16 # along with website-defaults. If not, see <http://www.gnu.org/licenses/>. |
17 #} | 17 #} |
18 | 18 |
19 {# open graph #} | 19 {% macro meta_tag(property, content, defaultContent=None) -%} |
| 20 {% if content %} |
| 21 <meta property="{{ property }}" content="{{ content }}"> |
| 22 {% elif defaultContent %} |
| 23 <meta property="{{ property }}" content="{{ defaultContent }}"> |
| 24 {% endif %} |
| 25 {%- endmacro %} |
20 | 26 |
21 {% if host and page %} | 27 {% set social_media_meta = [ |
22 <meta property="og:url" content="{{ host }}/{{ page }}"> | 28 ('og:url', og_url, get_canonical_url(page)), |
23 {% endif %} | 29 ('og:type', og_type, 'website'), |
24 {% if og_type %} | 30 ('og:site_name', og_site_name, get_string('site-name', 'global') if has_string
('site-name', 'global') else None), |
25 <meta property="og:type" content="{{ og_type }}"> | 31 ('og:title', og_title, title | translate('page-title', 'Meta data') if title e
lse None), |
26 {% endif %} | 32 ('og:description', og_description, description | translate('page-description',
'Meta data') if description else None), |
27 {% if og_site_name %} | 33 ('og:image', og_image, image), |
28 <meta property="og:site_name" content="{{ og_site_name }}"> | 34 ('og:image:alt', og_image_alt, image_alt), |
29 {% endif %} | 35 ('og:locale', og_locale, locale | to_og_locale), |
30 {% if og_title %} | 36 ('fb:app_id', facebook_id, None), |
31 <meta property="og:title" content="{{ og_title }}"> | 37 ('twitter:site', twitter_site, '@eyeo'), |
32 {% elif title %} | 38 ('twitter:card', twitter_card, 'summary_large_image' if og_image or twitter_im
age or image else 'summary'), |
33 <meta property="og:title" content="{{ title }}"> | 39 ('twitter:image', twitter_image, None), |
34 {% endif %} | 40 ('twitter:image:alt', twitter_image_alt, None), |
35 {% if og_description %} | 41 ('p:domain_verify', pinterest_id, None), |
36 <meta property="og:description" content="{{ og_description }}"> | 42 ] %} |
37 {% elif description %} | 43 |
38 <meta property="og:description" content="{{ description }}"> | 44 {% for property, content, defaultContent in social_media_meta %} |
39 {% endif %} | 45 {{ meta_tag(property, content, defaultContent) }} |
40 {% if og_image %} | 46 {% endfor %} |
41 <meta property="og:image" content="{{ og_image }}"> | 47 |
42 {% elif og_site_image %} | 48 {% for alternate_locale in available_locales %} |
43 <meta property="og:image" content="{{ og_site_image }}"> | |
44 {% endif %} | |
45 <meta property="og:locale" content="{{ locale }}"> | |
46 {% for alternate_locale in locales %} | |
47 {% if alternate_locale != locale %} | 49 {% if alternate_locale != locale %} |
48 <meta property="og:locale:alternate" content="{{ alternate_locale }}"> | 50 {{ meta_tag(('og:locale:alternate', alternate_locale | to_og_locale)) }} |
49 {% endif %} | 51 {% endif %} |
50 {% endfor %} | 52 {% endfor %} |
51 | |
52 {# facebook #} | |
53 | |
54 {% if facebook_id %} | |
55 <meta property="fb:app_id" content="{{ facebook_id }}"> | |
56 {% endif %} | |
57 | |
58 {# twitter #} | |
59 | |
60 {% if twitter_site %} | |
61 <meta name="twitter:site" content="@{{ twitter_site }}"> | |
62 {% endif %} | |
63 {% if twitter_card %} | |
64 <meta name="twitter:card" content="{{ twitter_card }}"> | |
65 {% elif og_image or og_site_image %} | |
66 <meta name="twitter:card" content="summary_large_image"> | |
67 {% else %} | |
68 <meta name="twitter:card" content="summary"> | |
69 {% endif %} | |
70 {% if twitter_image_alt %} | |
71 <meta name="twitter:image:alt" content="{{ twitter_image_alt }}"> | |
72 {% endif %} | |
73 | |
74 {# pinterest #} | |
75 | |
76 {% if pinterest_id %} | |
77 <meta name="p:domain_verify" content="{{ pinterest_id }}"> | |
78 {% endif %} | |
LEFT | RIGHT |