summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-11-20 19:33:49 -0600
committerDan McGee <dan@archlinux.org>2012-11-20 19:33:49 -0600
commit402487b007e206b013ecbf8b3017dc1231f4bbbc (patch)
tree9f0887cffd45264880670601f5fa00a1eb5f1004
parentf7331a0eca351300685ebee494e810d8c82c35b1 (diff)
downloadarchweb-402487b007e206b013ecbf8b3017dc1231f4bbbc.tar.gz
archweb-402487b007e206b013ecbf8b3017dc1231f4bbbc.zip
Move some logic out of the templates to the Release model
This includes magnet URI generation, ISO paths, etc. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--releng/models.py18
-rw-r--r--templates/public/download.html16
2 files changed, 26 insertions, 8 deletions
diff --git a/releng/models.py b/releng/models.py
index 2f9a0785..c591bc0f 100644
--- a/releng/models.py
+++ b/releng/models.py
@@ -1,3 +1,5 @@
+from urllib import urlencode
+
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models.signals import pre_save
@@ -121,6 +123,22 @@ class Release(models.Model):
def __unicode__(self):
return self.version
+ def dir_path(self):
+ return "iso/%s/" % self.version
+
+ def iso_url(self):
+ return "iso/%s/archlinux-%s-dual.iso" % (self.version, self.version)
+
+ def magnet_uri(self):
+ query = {
+ 'dn': "archlinux-%s-dual.iso" % self.version,
+ 'tr': ("udp://tracker.archlinux.org:6969",
+ "http://tracker.archlinux.org:6969/announce"),
+ }
+ if self.torrent_infohash:
+ query['xt'] = "urn:btih:%s" % self.torrent_infohash
+ return "magnet:?%s" % urlencode(query, doseq=True)
+
for model in (Iso, Test, Release):
pre_save.connect(set_created_field, sender=model,
diff --git a/templates/public/download.html b/templates/public/download.html
index d0754e5b..5733ee94 100644
--- a/templates/public/download.html
+++ b/templates/public/download.html
@@ -44,9 +44,9 @@
download is finished, so you can seed it back to others.
<em>A web-seed capable client is recommended for fastest download speeds.</em></p>
<ul>
- <li><a href="https://www.archlinux.org/iso/{{ release.version }}/archlinux-{{ release.version }}-dual.iso.torrent"
- title="Download for both architectures">Download archlinux-{{ release.version }}-dual.iso.torrent</a>
- (<a href="magnet:?{% if release.torrent_infohash %}xt=urn:btih:{{ release.torrent_infohash }}&amp;{% endif %}dn=archlinux-{{ release.version }}-dual.iso&amp;tr=udp://tracker.archlinux.org:6969&amp;tr=http://tracker.archlinux.org:6969/announce">Magnet</a>)</li>
+ <li><a href="https://www.archlinux.org/{{ release.iso_url }}.torrent"
+ title="Download for both architectures">Download torrent for {{ release.version }}</a>
+ (<a href="{{ release.magnet_uri }}">Magnet</a>)</li>
</ul>
<h3>Netboot</h3>
@@ -69,11 +69,11 @@
<p>File integrity checksums for the latest releases can be found below:</p>
<ul>
- <li><a href="https://www.archlinux.org/iso/{{ release.version }}/archlinux-{{ release.version }}-dual.iso.sig"
+ <li><a href="https://www.archlinux.org/{{ release.iso_url }}.sig"
title="Get the latest PGP signature">PGP signature</a></li>
- <li><a href="https://www.archlinux.org/iso/{{ release.version }}/sha1sums.txt"
+ <li><a href="https://www.archlinux.org/{{ release.dir_path }}sha1sums.txt"
title="Get the latest SHA1 checksums">SHA1 checksums</a></li>
- <li><a href="https://www.archlinux.org/iso/{{ release.version }}/md5sums.txt"
+ <li><a href="https://www.archlinux.org/{{ release.dir_path }}md5sums.txt"
title="Get the latest MD5 checksums">MD5 checksums</a></li>
</ul>
@@ -85,8 +85,8 @@
{% else %}<h5>Worldwide</h5>{% endif %}
<ul>
{% for mirror_url in country.list %}
- <li><a href="{{ mirror_url.url }}iso/{{ release.version }}/"
- title="Download from {{ mirror_url.url }}iso/{{ release.version }}/">{{ mirror_url.mirror.name }}</a></li>
+ <li><a href="{{ mirror_url.url }}{{ release.dir_path }}"
+ title="Download from {{ mirror_url.url }}">{{ mirror_url.mirror.name }}</a></li>
{% endfor %}
</ul>
{% endfor %}