Self hosted FLOSS fitness/workout, nutrition and weight tracker
Set opengraph properties for better sharing
Roland Geider72838bcc86bb
diff --git a/wger/core/templates/mobile/template.html b/wger/core/templates/mobile/template.htmlindex 3845cba36..7e3492ab1 100644--- a/wger/core/templates/mobile/template.html+++ b/wger/core/templates/mobile/template.html@@ -1,33 +1,32 @@<!DOCTYPE html>-{% load i18n staticfiles wger_extras compress django_bootstrap_breadcrumbs %}-{% block breadcrumbs %}- {% clear_breadcrumbs %}-{% endblock %}-<html>-<head>- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />- <meta charset="utf-8">- <meta name="author" content="Roland Geider">- <meta name="viewport" content="width=device-width, initial-scale=1">-- <!--+<!--This file is part of wger Workout Manager- wger Workout Manager is free software: you can redistribute it and/or modify+ wger is free software: you can redistribute it and/or modifyit under the terms of the GNU Affero General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.- wger Workout Manager is distributed in the hope that it will be useful,+ wger is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU Affero General Public License for more details.You should have received a copy of the GNU Affero General Public License- along with wger Workout Manager. If not, see <http://www.gnu.org/licenses/>.- -->+ along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.+-->+{% load i18n staticfiles wger_extras compress django_bootstrap_breadcrumbs %}+{% block breadcrumbs %}+ {% clear_breadcrumbs %}+{% endblock %}+<html>+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <meta charset="utf-8">+ <meta name="author" content="Roland Geider">+ <meta name="viewport" content="width=device-width, initial-scale=1"><title>{% block title %}{% endblock %}</title><link rel="icon" href="{% static 'images/favicon.png' %}" type="image/png">diff --git a/wger/core/templates/template.html b/wger/core/templates/template.htmlindex ac7d605a8..32fae73a3 100644--- a/wger/core/templates/template.html+++ b/wger/core/templates/template.html@@ -1,4 +1,21 @@<!DOCTYPE html>+<!--+ This file is part of wger Workout Manager++ wger is free software: you can redistribute it and/or modify+ it under the terms of the GNU Affero General Public License as published by+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ wger is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU Affero General Public License for more details.++ You should have received a copy of the GNU Affero General Public License+ along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.+-->+{% load i18n staticfiles wger_extras compress django_bootstrap_breadcrumbs %}{% block breadcrumbs %}{% clear_breadcrumbs %}@@ -7,25 +24,22 @@<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta charset="utf-8">- <meta name="author" content="Roland Geider"><meta name="viewport" content="width=device-width, initial-scale=1">+ <meta name="author" content="Roland Geider">- <!--- This file is part of Workout Manager+ <!-- OpenGraph -->+ {% block opengraph %}+ <meta property="og:url" content="{{ request_absolute_path }}">+ <meta property="og:image" content="{{ image_absolute_path }}">+ <meta property="og:type" content="website">+ {% endblock %}- Workout Manager is free software: you can redistribute it and/or modify- it under the terms of the GNU Affero General Public License as published by- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.+ <!-- twitter cards -->+ {% block twittercard %}+ <meta content="summary" name="twitter:card">+ <meta content="@wger_de" name="twitter:site">+ {% endblock %}- Workout Manager is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU Affero General Public License for more details.-- You should have received a copy of the GNU Affero General Public License- along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.- -->{% compress css %}<link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager.css' %}">diff --git a/wger/core/templates/template_features.html b/wger/core/templates/template_features.htmlindex 3f60b5c58..6337cd05c 100644--- a/wger/core/templates/template_features.html+++ b/wger/core/templates/template_features.html@@ -1,28 +1,44 @@<!DOCTYPE html>-{% load i18n staticfiles compress %}-<html lang="{{language.short_name}}">-<head>- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />- <meta charset="utf-8">- <meta name="author" content="Roland Geider">- <meta name="viewport" content="width=device-width, initial-scale=1">-- <!--- This file is part of Workout Manager+<!--+ This file is part of wger Workout Manager- Workout Manager is free software: you can redistribute it and/or modify+ wger is free software: you can redistribute it and/or modifyit under the terms of the GNU Affero General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.- Workout Manager is distributed in the hope that it will be useful,+ wger is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU Affero General Public License for more details.You should have received a copy of the GNU Affero General Public Licensealong with Workout Manager. If not, see <http://www.gnu.org/licenses/>.- -->+-->+++{% load i18n staticfiles compress %}+<html lang="{{language.short_name}}">+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <meta charset="utf-8">+ <meta name="author" content="Roland Geider">+ <meta name="viewport" content="width=device-width, initial-scale=1">+++ <!-- OpenGraph -->+ {% block opengraph %}+ <meta property="og:url" content="{{ request_absolute_path }}">+ <meta property="og:image" content="{{ image_absolute_path }}">+ <meta property="og:type" content="website">+ {% endblock %}++ <!-- twitter cards -->+ {% block twittercard %}+ <meta content="summary" name="twitter:card">+ <meta content="@wger_de" name="twitter:site">+ {% endblock %}+{% compress css %}<link rel="stylesheet" type="text/css" href="{% static 'css/workout-manager.css' %}">diff --git a/wger/exercises/models.py b/wger/exercises/models.pyindex f95cd6fa0..0533e0f72 100644--- a/wger/exercises/models.py+++ b/wger/exercises/models.py@@ -17,6 +17,7 @@import siximport logging+import bleachfrom django.db import modelsfrom django.template.loader import render_to_string@@ -276,6 +277,13 @@ class Exercise(AbstractSubmissionModel, AbstractLicenseModel, models.Model):'''return self.exerciseimage_set.accepted().filter(is_main=True).first()+ @property+ def description_clean(self):+ '''+ Return the exercise description with all markup removed+ '''+ return bleach.clean(self.description, strip=True)+def get_owner_object(self):'''Exercise has no owner informationdiff --git a/wger/exercises/templates/exercise/view.html b/wger/exercises/templates/exercise/view.htmlindex b3a975f64..fcec7cfa7 100644--- a/wger/exercises/templates/exercise/view.html+++ b/wger/exercises/templates/exercise/view.html@@ -5,17 +5,31 @@{% load thumbnail %}{% load cache %}-{% block header %}+{# #}+{# Opengraph #}+{# #}+{% block opengraph %}+ {{ block.super }}+ <meta property="og:title" content="{{ exercise.name }}">+ <meta property="og:description" content="{{ exercise.description_clean }}">{% endblock %}-<!--- Title--->+++{# #}+{# Title #}+{# #}{% block title %}{{ exercise.name }}{% endblock %}-<!--- Main Content--->+{# #}+{# Header #}+{# #}+{% block header %}{% endblock %}+++{# #}+{# Content #}+{# #}{% block content %}{% if exercise.status == exercise.STATUS_PENDING %}@@ -71,9 +85,7 @@ included in the database.{% endblocktrans %}{% endcache %}-{# #}{# Comments #}-{# #}{% with comments=exercise.exercisecomment_set.all %}{% if comments %}<h3>{% trans "Comments for this exercise" %}</h3>@@ -121,9 +133,7 @@ included in the database.{% endblocktrans %}{% endif %}-{# #}{# Images #}-{# #}{% with images=exercise.exerciseimage_set.accepted %}{% if images %}<h3>{% trans "Images" %}</h3>@@ -297,9 +307,9 @@ $(document).ready(function() {{% endblock %}-<!--- Side bar--->+{# #}+{# Side bar #}+{# #}{% block sidebar %}<h3>{% trans "Back to overview" %}</h3>diff --git a/wger/manager/templates/mobile/workout/calendar.html b/wger/manager/templates/mobile/workout/calendar.htmlindex 931b44c4f..9cb8e3d47 100644--- a/wger/manager/templates/mobile/workout/calendar.html+++ b/wger/manager/templates/mobile/workout/calendar.html@@ -4,8 +4,29 @@{% load wger_extras %}{% load cache %}++{# #}+{# Opengraph #}+{# #}+{% block opengraph %}+ {{ block.super }}+ <meta property="og:title" content="{% trans 'Calendar' %}">++ {% with username=owner_user.username %}+ <meta property="og:description" content="{% blocktrans %}Calendar for {{username}}{% endblocktrans %}">+ {% endwith %}+{% endblock %}+++{# #}+{# Title #}+{# #}{% block title %}{% trans "Calendar" %}{% endblock %}++{# #}+{# Header #}+{# #}{% block header %}<script>$(document).ready(function() {@@ -22,6 +43,10 @@ $(document).ready(function() {</script>{% endblock %}++{# #}+{# Content #}+{# #}{% block content %}{% cache cache_timeout workout-log-mobile is_owner owner_user.id current_year current_month %}{{calendar|safe}}@@ -155,7 +180,9 @@ $(document).ready(function() {{% endblock %}-+{# #}+{# Side bar #}+{# #}{% block sidebar %}<div class="modal fade" id="calendar-day-select-popup"><div class="modal-dialog">diff --git a/wger/manager/templates/mobile/workout/view.html b/wger/manager/templates/mobile/workout/view.htmlindex 7ff3edc1d..12acfd643 100644--- a/wger/manager/templates/mobile/workout/view.html+++ b/wger/manager/templates/mobile/workout/view.html@@ -3,8 +3,25 @@{% load staticfiles %}{% load wger_extras %}+{# #}+{# Opengraph #}+{# #}+{% block opengraph %}+ {{ block.super }}+ <meta property="og:title" content="{% trans 'Workout' %}">+ <meta property="og:description" content="{{ workout }} / {{owner_user.username}}">+{% endblock %}+++{# #}+{# Title #}+{# #}{% block title %}{% trans "Workout" %} – {{ workout.creation_date }}{% endblock %}++{# #}+{# Header #}+{# #}{% block header %}<script>function custom_modal_init()@@ -30,6 +47,9 @@ $(document).ready(function() {{% endblock %}+{# #}+{# Content #}+{# #}{% block content %}{% if workout.comment %}<p>@@ -69,9 +89,9 @@ $(document).ready(function() {-<!--- Side bar--->+{# #}+{# Side bar #}+{# #}{% block sidebar %}<h3>{% trans "Steps" %}</h3>diff --git a/wger/manager/templates/workout/calendar.html b/wger/manager/templates/workout/calendar.htmlindex 38e5e2a41..619b1e0a6 100644--- a/wger/manager/templates/workout/calendar.html+++ b/wger/manager/templates/workout/calendar.html@@ -4,8 +4,29 @@{% load wger_extras %}{% load cache %}++{# #}+{# Opengraph #}+{# #}+{% block opengraph %}+ {{ block.super }}+ <meta property="og:title" content="{% trans 'Calendar' %}">++ {% with username=owner_user.username %}+ <meta property="og:description" content="{% blocktrans %}Calendar for {{username}}{% endblocktrans %}">+ {% endwith %}+{% endblock %}+++{# #}+{# Title #}+{# #}{% block title %}{% trans "Calendar" %}{% endblock %}++{# #}+{# Header #}+{# #}{% block header %}<script>$(document).ready(function() {@@ -19,6 +40,10 @@ $(document).ready(function() {</script>{% endblock %}++{# #}+{# Content #}+{# #}{% block content %}{% cache cache_timeout workout-log-full is_owner owner_user.id current_year current_month %}{{calendar|safe}}@@ -121,7 +146,9 @@ $(document).ready(function() {{% endblock %}-+{# #}+{# Side bar #}+{# #}{% block sidebar %}<div class="modal fade" id="ecalendar-day-select-popup"><div class="modal-dialog">diff --git a/wger/manager/templates/workout/log.html b/wger/manager/templates/workout/log.htmlindex e48bf28c9..473de63df 100644--- a/wger/manager/templates/workout/log.html+++ b/wger/manager/templates/workout/log.html@@ -3,8 +3,26 @@{% load staticfiles %}{% load wger_extras %}++{# #}+{# Opengraph #}+{# #}+{% block opengraph %}+ {{ block.super }}+ <meta property="og:title" content="{% trans 'Weight log' %}">+ <meta property="og:description" content="{% trans 'Weight log' %} / {{ workout }} / {{ owner_user.username }}">+{% endblock %}+++{# #}+{# Title #}+{# #}{% block title %}{% trans "Weight log for workout" %}{% endblock %}++{# #}+{# Header #}+{# #}{% block header %}<script>$(document).ready(function() {@@ -13,6 +31,10 @@ $(document).ready(function() {</script>{% endblock %}++{# #}+{# Content #}+{# #}{% block content %}{% if workout.comment %}<p>@@ -77,10 +99,9 @@ $(document).ready(function() {{% endblock %}--<!--- Side bar--->+{# #}+{# Side bar #}+{# #}{% block sidebar %}<h3>{% trans "Options" %}</h3><p>diff --git a/wger/manager/templates/workout/view.html b/wger/manager/templates/workout/view.htmlindex 48413a2bb..1c3c5ef68 100644--- a/wger/manager/templates/workout/view.html+++ b/wger/manager/templates/workout/view.html@@ -3,8 +3,25 @@{% load staticfiles %}{% load wger_extras %}+{# #}+{# Opengraph #}+{# #}+{% block opengraph %}+ {{ block.super }}+ <meta property="og:title" content="{% trans 'Workout' %}">+ <meta property="og:description" content="{{ workout }} / {{owner_user.username}}">+{% endblock %}+++{# #}+{# Title #}+{# #}{% block title %}{% trans "Workout" %} – {{ workout.creation_date }}{% endblock %}++{# #}+{# Header #}+{# #}{% block header %}<script>function custom_modal_init()@@ -28,6 +45,10 @@ $(document).ready(function() {</script>{% endblock %}++{# #}+{# Content #}+{# #}{% block content %}@@ -63,9 +84,9 @@ $(document).ready(function() {-<!--- Side bar--->+{# #}+{# Side bar #}+{# #}{% block sidebar %}<h3>{% trans "Steps" %}</h3>diff --git a/wger/nutrition/templates/mobile/plan/view.html b/wger/nutrition/templates/mobile/plan/view.htmlindex 920d4e852..0503ab375 100644--- a/wger/nutrition/templates/mobile/plan/view.html+++ b/wger/nutrition/templates/mobile/plan/view.html@@ -1,9 +1,26 @@{% extends "base.html" %}{% load i18n staticfiles wger_extras %}++{# #}+{# Opengraph #}+{# #}+{% block opengraph %}+ {{ block.super }}+ <meta property="og:title" content="{% trans 'Nutrition plan' %}">+ <meta property="og:description" content="{{ plan }} / {{owner_user.username}}">+{% endblock %}+++{# #}+{# Title #}+{# #}{% block title %}{% trans "Nutrition plan" %} – {{ plan.creation_date}}{% endblock %}+{# #}+{# Header #}+{# #}{% block header %}<script>function custom_modal_init()@@ -21,7 +38,9 @@ $(document).ready(function() {{% endblock %}-+{# #}+{# Content #}+{# #}{% block content %}{% if plan.description %}<p>@@ -240,7 +259,9 @@ $(document).ready(function() {{% endblock %}-+{# #}+{# Side bar #}+{# #}{% block sidebar %}<h3>{% trans "Energy" %}</h3><table id="nutritional-data-energy" class="table">diff --git a/wger/nutrition/templates/plan/view.html b/wger/nutrition/templates/plan/view.htmlindex dbe2d480e..822fee893 100644--- a/wger/nutrition/templates/plan/view.html+++ b/wger/nutrition/templates/plan/view.html@@ -3,9 +3,25 @@{% load staticfiles %}{% load wger_extras %}+{# #}+{# Opengraph #}+{# #}+{% block opengraph %}+ {{ block.super }}+ <meta property="og:title" content="{% trans 'Nutrition plan' %}">+ <meta property="og:description" content="{{ plan }} / {{owner_user.username}}">+{% endblock %}+++{# #}+{# Title #}+{# #}{% block title %}{% trans "Nutrition plan" %} – {{ plan.creation_date}}{% endblock %}+{# #}+{# Header #}+{# #}{% block header %}<script>function custom_modal_init()@@ -18,6 +34,9 @@ function custom_modal_init()+{# #}+{# Content #}+{# #}{% block content %}{% if plan.description %}<p>@@ -241,7 +260,9 @@ function custom_modal_init(){% endblock %}-+{# #}+{# Side bar #}+{# #}{% block sidebar %}<h3>{% trans "Energy" %}</h3><table class="table table-condensed" id="nutritional-data-energy">diff --git a/wger/software/templates/functions.html b/wger/software/templates/functions.htmlindex 6cd8d5099..73a449b8d 100644--- a/wger/software/templates/functions.html+++ b/wger/software/templates/functions.html@@ -1,9 +1,22 @@{% extends "base_features.html" %}{% load i18n staticfiles wger_extras %}+{# #}+{# Opengraph #}+{# #}+{% block opengraph %}+ {{ block.super }}+ <meta property="og:title" content="{% trans 'Features' %} - wger">++ {% with username=owner_user.username %}+ <meta property="og:description" content="{% blocktrans %}wger Workout Manager is a free, open source web application that manages your exercises and workouts. {% endblocktrans %}">+ {% endwith %}+{% endblock %}-+{# #}+{# Content #}+{# #}{% block content %}<div class="jumbotron"><div class="row">diff --git a/wger/utils/context_processor.py b/wger/utils/context_processor.pyindex e41b82dfa..d289dedf9 100644--- a/wger/utils/context_processor.py+++ b/wger/utils/context_processor.py@@ -14,6 +14,8 @@# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.from django.conf import settings+from django.core.urlresolvers import reverse+from django.templatetags.static import staticfrom wger import get_versionfrom wger.utils import constants@@ -25,6 +27,8 @@ def processor(request):language = load_language()full_path = request.get_full_path()i18n_path = {}+ static_path = static('images/logos/logo-marketplace-256.png')+for lang in settings.LANGUAGES:i18n_path[lang[0]] = u'/{0}{1}'.format(lang[0], full_path[3:])@@ -41,6 +45,11 @@ def processor(request):# The current path'request_full_path': full_path,+ # The current full path with host+ 'request_absolute_path': request.build_absolute_uri(),+ 'image_absolute_path': request.build_absolute_uri(static_path),++# Translation links'i18n_path': i18n_path,