[yocto] [layerindex-web][PATCH 3/3] recipedetail: don't show homepage as link if not URL
Paul Eggleton
paul.eggleton at linux.intel.com
Tue Oct 25 19:41:56 PDT 2016
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 <paul.eggleton at linux.intel.com>
---
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 @@
</tr>
<tr>
<th>Homepage</th>
- <td>{% if recipe.homepage %}<a href="{{ recipe.homepage }}">{{ recipe.homepage }}</a>{% endif %}</td>
+ <td>
+ {% if recipe.homepage_url_only %}
+ <a href="{{ recipe.homepage }}">{{ recipe.homepage }}</a>
+ {% elif recipe.homepage %}
+ {{ recipe.homepage }}
+ {% endif %}
+ </td>
</tr>
{% if recipe.bugtracker %}
<tr>
--
2.5.5
More information about the yocto
mailing list