From: Paul Eggleton <paul.eggleton@linux.intel.com>
To: yocto@yoctoproject.org
Subject: [layerindex-web][PATCH 3/3] recipedetail: don't show homepage as link if not URL
Date: Wed, 26 Oct 2016 15:41:56 +1300 [thread overview]
Message-ID: <1477449716-24619-3-git-send-email-paul.eggleton@linux.intel.com> (raw)
In-Reply-To: <1477449716-24619-1-git-send-email-paul.eggleton@linux.intel.com>
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@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
prev parent reply other threads:[~2016-10-26 2:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 2:41 [layerindex-web][PATCH 1/3] editlayer: allow selecting web interface type Paul Eggleton
2016-10-26 2:41 ` [layerindex-web][PATCH 2/3] about: update contributors list Paul Eggleton
2016-10-26 2:41 ` Paul Eggleton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1477449716-24619-3-git-send-email-paul.eggleton@linux.intel.com \
--to=paul.eggleton@linux.intel.com \
--cc=yocto@yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.