From 7ddf8f58d63d5571df7b952a98c13c6a7c39e074 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 25 Oct 2016 20:58:31 +1300 Subject: [PATCH] recipedetail: don't show homepage as link if not URL Sometimes people put values that aren't URLs into the HOMEPAGE variable. If that's the case, then we should not turn that value into a link which will be invalid. Signed-off-by: Paul Eggleton --- layerindex/models.py | 6 ++++++ templates/layerindex/recipedetail.html | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/layerindex/models.py b/layerindex/models.py index 869d4a3..746fad4 100644 --- a/layerindex/models.py +++ b/layerindex/models.py @@ -292,6 +292,12 @@ class Recipe(models.Model): else: return self.filename.split('_')[0] + def homepage_url_only(self): + if '://' in self.homepage: + return self.homepage + else: + return None + def __str__(self): return os.path.join(self.filepath, self.filename) diff --git a/templates/layerindex/recipedetail.html b/templates/layerindex/recipedetail.html index c0199a1..5b83886 100644 --- a/templates/layerindex/recipedetail.html +++ b/templates/layerindex/recipedetail.html @@ -72,7 +72,13 @@ Homepage - {% if recipe.homepage %}{{ recipe.homepage }}{% endif %} + + {% if recipe.homepage_url_only %} + {{ recipe.homepage }} + {% elif recipe.homepage %} + {{ recipe.homepage }} + {% endif %} + {% if recipe.bugtracker %}