summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2014-10-18 13:48:07 -0500
committerDan McGee <dan@archlinux.org>2014-10-18 13:48:07 -0500
commit2f19529c922172007ff3894ad0e0fca0b3e33f5b (patch)
tree7287ec88e69e2d09e6c73e6a9ba3a013b354c9ab /templates
parentf4a6eff33815a713b1141ea94a872bd7c6233699 (diff)
Convert details sub-tempates to Jinja2
This is a start at improving performance of rendering the package details page, our most-visited and slowest page on the production website. The Django template system is not very efficient due to our heavy use of broken out templates and pulling of various attributes and such on related packages. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'templates')
-rw-r--r--templates/packages/details.html10
-rw-r--r--templates/packages/details_depend.html.jinja (renamed from templates/packages/details_depend.html)10
-rw-r--r--templates/packages/details_link.html.jinja1
-rw-r--r--templates/packages/details_relatedto.html2
-rw-r--r--templates/packages/details_relatedto.html.jinja3
-rw-r--r--templates/packages/details_requiredby.html.jinja (renamed from templates/packages/details_requiredby.html)2
6 files changed, 15 insertions, 13 deletions
diff --git a/templates/packages/details.html b/templates/packages/details.html
index bfa2de16..c4c1f6b2 100644
--- a/templates/packages/details.html
+++ b/templates/packages/details.html
@@ -134,19 +134,19 @@
{% with pkg.provides.all as all_related %}{% if all_related %}
<tr>
<th>Provides:</th>
- <td class="wrap relatedto">{% include "packages/details_relatedto.html" %}</td>
+ <td class="wrap relatedto">{% include "packages/details_relatedto.html.jinja" %}</td>
</tr>
{% endif %}{% endwith %}
{% with pkg.replaces.all as all_related %}{% if all_related %}
<tr>
<th>Replaces:</th>
- <td class="wrap relatedto">{% include "packages/details_relatedto.html" %}</td>
+ <td class="wrap relatedto">{% include "packages/details_relatedto.html.jinja" %}</td>
</tr>
{% endif %}{% endwith %}
{% with pkg.conflicts.all as all_related %}{% if all_related %}
<tr>
<th>Conflicts:</th>
- <td class="wrap relatedto">{% include "packages/details_relatedto.html" %}</td>
+ <td class="wrap relatedto">{% include "packages/details_relatedto.html.jinja" %}</td>
</tr>
{% endif %}{% endwith %}
{% with pkg.reverse_conflicts as rev_conflicts %}{% if rev_conflicts %}
@@ -205,7 +205,7 @@
<h3 title="{{ pkg.pkgname }} has the following dependencies">
Dependencies ({{deps|length}})</h3>
{% if deps %}<ul id="pkgdepslist">
- {% for depend in deps %}{% include "packages/details_depend.html" %}{% endfor %}
+ {% for depend in deps %}{% include "packages/details_depend.html.jinja" %}{% endfor %}
</ul>{% endif %}
</div>
{% endwith %}
@@ -214,7 +214,7 @@
<h3 title="Packages that require {{ pkg.pkgname }}">
Required By ({{rqdby|length}})</h3>
{% if rqdby %}<ul id="pkgreqslist">
- {% for req in rqdby %}{% include "packages/details_requiredby.html" %}{% endfor %}
+ {% for req in rqdby %}{% include "packages/details_requiredby.html.jinja" %}{% endfor %}
</ul>{% endif %}
</div>
{% endwith %}
diff --git a/templates/packages/details_depend.html b/templates/packages/details_depend.html.jinja
index b89ffbfa..404793b6 100644
--- a/templates/packages/details_depend.html
+++ b/templates/packages/details_depend.html.jinja
@@ -1,11 +1,11 @@
-{% load package_extras %}<li>{% ifequal depend.pkg None %}
-{% if depend.providers %}{{ depend.dep.name }}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }} <span class="virtual-dep">({% multi_pkg_details depend.providers %})</span>
-{% else %}{{ depend.dep.name }}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }} <span class="virtual-dep">(virtual)</span>
+{% import 'packages/details_link.html.jinja' as details %}<li>{% if depend.pkg == None %}
+{% if depend.providers %}{{ depend.dep.name }}{{ depend.dep.comparison|default("") }}{{ depend.dep.version|default("") }} <span class="virtual-dep">({% for pkg in depend.providers %}{{ details.details_link(pkg) }}{% if not loop.last %}, {% endif %}{% endfor %})</span>
+{% else %}{{ depend.dep.name }}{{ depend.dep.comparison|default("") }}{{ depend.dep.version|default("") }} <span class="virtual-dep">(virtual)</span>
{% endif %}{% else %}
-{% pkg_details_link depend.pkg %}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }}
+{{ details.details_link(depend.pkg) }}{{ depend.dep.comparison|default("") }}{{ depend.dep.version|default("") }}
{% if depend.pkg.repo.testing %} <span class="testing-dep"> (testing)</span>
{% endif %}{% if depend.pkg.repo.staging %} <span class="staging-dep"> (staging)</span>
-{% endif %}{% endifequal %}
+{% endif %}{% endif %}
{% if depend.dep.deptype == 'O' %} <span class="opt-dep"> (optional)</span>
{% endif %}{% if depend.dep.deptype == 'M' %} <span class="make-dep"> (make)</span>
{% endif %}{% if depend.dep.deptype == 'C' %} <span class="check-dep"> (check)</span>
diff --git a/templates/packages/details_link.html.jinja b/templates/packages/details_link.html.jinja
new file mode 100644
index 00000000..b7e75fe5
--- /dev/null
+++ b/templates/packages/details_link.html.jinja
@@ -0,0 +1 @@
+{% macro details_link(pkg) %}<a href="{{ pkg.get_absolute_url() }}" title="View package details for {{ pkg.pkgname }}">{{ pkg.pkgname }}</a>{% endmacro %}
diff --git a/templates/packages/details_relatedto.html b/templates/packages/details_relatedto.html
deleted file mode 100644
index e14375d3..00000000
--- a/templates/packages/details_relatedto.html
+++ /dev/null
@@ -1,2 +0,0 @@
-{% load package_extras %}{% for related in all_related %}{% with related.get_best_satisfier as best_satisfier %}<span class="related">{% ifequal best_satisfier None %}{{ related.name }}{% else %}{% pkg_details_link best_satisfier %}{% endifequal %}{{ related.comparison|default:"" }}{{ related.version|default:"" }}{% if not forloop.last %}, {% endif %}</span>
-{% endwith %}{% endfor %}
diff --git a/templates/packages/details_relatedto.html.jinja b/templates/packages/details_relatedto.html.jinja
new file mode 100644
index 00000000..955fdd37
--- /dev/null
+++ b/templates/packages/details_relatedto.html.jinja
@@ -0,0 +1,3 @@
+{% import 'packages/details_link.html.jinja' as details %}{% for related in all_related %}{% with best_satisfier = related.get_best_satisfier() %}
+<span class="related">{% if best_satisfier == None %}{{ related.name }}{% else %}{{ details.details_link(best_satisfier) }}{% endif %}{{ related.comparison|default("") }}{{ related.version|default("") }}{% if not loop.last %}, {% endif %}</span>
+{% endwith %}{% endfor %}
diff --git a/templates/packages/details_requiredby.html b/templates/packages/details_requiredby.html.jinja
index 504a322f..b083a7fc 100644
--- a/templates/packages/details_requiredby.html
+++ b/templates/packages/details_requiredby.html.jinja
@@ -1,4 +1,4 @@
-{% load package_extras %}<li>{% pkg_details_link req.pkg %}
+{% import 'packages/details_link.html.jinja' as details %}<li>{{ details.details_link(req.pkg) }}
{% if req.name != pkg.pkgname %}<span class="virtual-dep"> (requires {{ req.name }})</span>
{% endif %}{% if req.pkg.repo.testing %}<span class="testing-dep"> (testing)</span>
{% endif %}{% if req.pkg.repo.staging %}<span class="staging-dep"> (staging)</span>