summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-02-27 10:08:04 -0600
committerDan McGee <dan@archlinux.org>2010-02-27 13:36:58 -0600
commit8314777c5858b8f9dd954ef906e19de1322a61d0 (patch)
treeb4ba12ced99c71ea844a05396abc9d4b64793223
parent1cea5fc32e5fe213137cac0323d27bcc9cbc7d8b (diff)
Make files view AJAX if supported
This will put the filelist inline on the package details page if using a capable browser. It should still fallback to a separate page if necessary (e.g. all those users using links on the site). Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--packages/views.py5
-rw-r--r--templates/packages/details.html19
-rw-r--r--templates/packages/files-ajax.html8
3 files changed, 30 insertions, 2 deletions
diff --git a/packages/views.py b/packages/views.py
index 9956b6ce..c5f87865 100644
--- a/packages/views.py
+++ b/packages/views.py
@@ -182,7 +182,10 @@ def files(request, name='', repo='', arch=''):
pkg = get_object_or_404(Package,
pkgname=name, repo__name__iexact=repo, arch__name=arch)
files = PackageFile.objects.filter(pkg=pkg).order_by('path')
- return render_to_response('packages/files.html', RequestContext(request, {'pkg':pkg,'files':files}))
+ template = 'packages/files.html'
+ if request.is_ajax():
+ template = 'packages/files-ajax.html'
+ return render_to_response(template, RequestContext(request, {'pkg':pkg,'files':files}))
@permission_required('main.change_package')
def unflag(request, pkgid):
diff --git a/templates/packages/details.html b/templates/packages/details.html
index f696231a..7e5216e3 100644
--- a/templates/packages/details.html
+++ b/templates/packages/details.html
@@ -8,7 +8,6 @@
<li><a href="{{ pkg.get_arch_svn_link }}">SVN Entries ({{pkg.repo|lower}}-{{pkg.arch}})</a></li>
<li><a href="{{ pkg.get_trunk_svn_link }}">SVN Entries (trunk)</a></li>
<li><a href="{{ pkg.get_bugs_link }}">Bug Reports</a></li>
- <li><a href="files/">View File List</a></li>
<li>
{% if pkg.needupdate %}
<span style="font-size:x-small"><em>This package has been flagged out-of-date</em></span>
@@ -102,6 +101,24 @@
</td>
</tr>
</table>
+ <div class="listing" id="filelist">
+ <h4>Files:</h4>
+ <ul style="font-size:small;list-style:none">
+ <li><a id="filelink" href="files/">View File List</a></li>
+ </ul>
+ </div>
</div>
+<script type="text/javascript" src="/media/jquery-1.4.1.min.js"></script>
+<script type="text/javascript">
+function ajaxifyFiles() {
+ $('#filelink').click(function(event) {
+ event.preventDefault();
+ $.get(this.href, function(data) {
+ $('#filelist').html(data);
+ });
+ });
+}
+$(document).ready(ajaxifyFiles);
+</script>
{% endblock %}
diff --git a/templates/packages/files-ajax.html b/templates/packages/files-ajax.html
new file mode 100644
index 00000000..9b4c83ad
--- /dev/null
+++ b/templates/packages/files-ajax.html
@@ -0,0 +1,8 @@
+<div class="listing" id="filelist">
+ <h4>Files:</h4>
+ <ul style="font-size:small;list-style:none">
+ {% for file in files %}
+ <li>{{ file.path }}</li>
+ {% endfor %}
+ </ul>
+</div>