Self hosted FLOSS fitness/workout, nutrition and weight tracker
Automatically generate the internationalised sitemap links
Roland Geiderd423c52ac175
diff --git a/wger/manager/templates/robots.txt b/wger/manager/templates/robots.txtindex b0c8a26c1..51638c7f4 100644--- a/wger/manager/templates/robots.txt+++ b/wger/manager/templates/robots.txt@@ -1,2 +1,2 @@-Sitemap: http://wger.de/de/sitemap.xml-Sitemap: http://wger.de/en/sitemap.xml\ No newline at end of file+{% for lang in languages %}Sitemap: http://wger.de/{{lang.0}}/sitemap.xml+{% endfor %}diff --git a/wger/manager/tests/__init__.py b/wger/manager/tests/__init__.pyindex ff239963a..545bf89a5 100644--- a/wger/manager/tests/__init__.py+++ b/wger/manager/tests/__init__.py@@ -12,4 +12,5 @@ from wger.manager.tests.copy_workout import *from wger.manager.tests.pdf import *from wger.manager.tests.feedback import *from wger.manager.tests.sitemap import *+from wger.manager.tests.robots_txt import *from wger.manager.tests.temporary_users import *diff --git a/wger/manager/tests/robots_txt.py b/wger/manager/tests/robots_txt.pynew file mode 100644index 000000000..5f67aba4d--- /dev/null+++ b/wger/manager/tests/robots_txt.py@@ -0,0 +1,32 @@+# This file is part of wger Workout Manager.+#+# wger 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.+#+# wger 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 General Public License for more details.+#+# You should have received a copy of the GNU Affero General Public License++from django.core.urlresolvers import reverse++from django.contrib.auth.models import User++from wger.manager.tests.testcase import WorkoutManagerTestCase+from wger.exercises.models import Language+++class RobotsTxtTestCase(WorkoutManagerTestCase):+ '''+ Tests the generated robots.txt+ '''++ def test_robots(self):++ response = self.client.get(reverse('robots'))+ for lang in Language.objects.all():+ self.assertTrue('wger.de/{{0}}/sitemap.xml'.format(lang.short_name) in response.content)diff --git a/wger/urls.py b/wger/urls.pyindex 6238cee78..b9dfba67f 100644--- a/wger/urls.py+++ b/wger/urls.py@@ -33,7 +33,7 @@ urlpatterns = i18n_patterns('',urlpatterns = urlpatterns + patterns('',url(r'^robots\.txt$',TextTemplateView.as_view(template_name="robots.txt"),- ),+ name='robots'),url(r'^manifest\.webapp$',WebappManifestView.as_view(template_name="manifest.webapp"),),diff --git a/wger/utils/generic_views.py b/wger/utils/generic_views.pyindex b518ecf2b..4a3d7095c 100644--- a/wger/utils/generic_views.py+++ b/wger/utils/generic_views.py@@ -322,6 +322,8 @@ class WebappManifestView(TemplateView):This is used in the mozilla market place'''+ template_name = 'manifest.webapp'+def render_to_response(self, context, **response_kwargs):response_kwargs['content_type'] = 'application/x-web-app-manifest+json'return super(WebappManifestView, self).render_to_response(context, **response_kwargs)