diff options
author | 2012-11-08 15:21:02 +0100 | |
---|---|---|
committer | 2012-11-08 15:22:53 +0100 | |
commit | c648d7e7565297c57ca514d58f2c8e61f7084c99 (patch) | |
tree | 7c6ad9d0f3c6788246c552f41a93864b21198e93 | |
parent | euscanwww: Use Version.tag to be more DRY (diff) | |
download | euscan-c648d7e7565297c57ca514d58f2c8e61f7084c99.tar.gz euscan-c648d7e7565297c57ca514d58f2c8e61f7084c99.tar.bz2 euscan-c648d7e7565297c57ca514d58f2c8e61f7084c99.zip |
euscanwww: Showing ebuild and metadata in package details page
Signed-off-by: volpino <fox91@anche.no>
-rw-r--r-- | euscanwww/djeuscan/templates/euscan/_package_details.html | 11 | ||||
-rw-r--r-- | euscanwww/djeuscan/urls.py | 4 | ||||
-rw-r--r-- | euscanwww/djeuscan/views.py | 33 | ||||
-rw-r--r-- | euscanwww/htdocs/img/metadata.png | bin | 0 -> 798 bytes |
4 files changed, 45 insertions, 3 deletions
diff --git a/euscanwww/djeuscan/templates/euscan/_package_details.html b/euscanwww/djeuscan/templates/euscan/_package_details.html index 79efa9d..4736354 100644 --- a/euscanwww/djeuscan/templates/euscan/_package_details.html +++ b/euscanwww/djeuscan/templates/euscan/_package_details.html @@ -62,7 +62,16 @@ <img src="{{ STATIC_URL }}img/unstable-icon.png" alt="unstable" title="{{ version.vtype }}" /> {% endif %} - {{ version.version }}-{{ version.revision }} :{{ version.slot }} [{{ version.overlay }}] + {% if version.ebuild_path %} + <a href="{% url "package_version_ebuild" package.category package.name version.tag %}"> + {{ version.version }}-{{ version.revision }} :{{ version.slot }} [{{ version.overlay }}] + </a> + {% endif %} + {% if version.metadata_path %} + <a href="{% url "package_version_metadata" package.category package.name version.tag %}"> + <img src="{{ STATIC_URL }}img/metadata.png" alt="Metadata" /> + </a> + {% endif %} </li> {% endfor %} </ul> diff --git a/euscanwww/djeuscan/urls.py b/euscanwww/djeuscan/urls.py index ded690f..c3035df 100644 --- a/euscanwww/djeuscan/urls.py +++ b/euscanwww/djeuscan/urls.py @@ -23,6 +23,10 @@ package_patterns = patterns('djeuscan.views', url(r'^unfavourite/$', unfavourite_package, name="unfavourite_package"), url(r'^refresh$', "refresh_package", name="refresh_package"), url(r'^problem$', 'problem', name="problem"), + url(r'^(?P<version_tag>[^/]+)/ebuild$', "package_version_ebuild", + name="package_version_ebuild"), + url(r'^(?P<version_tag>[^/]+)/metadata$', "package_version_metadata", + name="package_version_metadata"), ) categories_patterns = patterns('djeuscan.views', diff --git a/euscanwww/djeuscan/views.py b/euscanwww/djeuscan/views.py index 7a7e489..7b51c28 100644 --- a/euscanwww/djeuscan/views.py +++ b/euscanwww/djeuscan/views.py @@ -3,13 +3,13 @@ import inspect from annoying.decorators import render_to, ajax_request -from django.http import Http404 +from django.http import Http404, HttpResponse from django.shortcuts import get_object_or_404 from django.contrib.auth.decorators import login_required from django.views.decorators.http import require_POST from djeuscan.helpers import version_key, packages_from_names, \ - get_maintainer_or_404, get_make_conf, get_layman_repos + get_maintainer_or_404, get_make_conf, get_layman_repos, versiontag_to_attrs from djeuscan.models import Version, Package, Herd, Maintainer, EuscanResult, \ VersionLog, RefreshPackageQuery, ProblemReport, Category, Overlay from djeuscan.forms import WorldForm, PackagesForm, ProblemReportForm @@ -223,6 +223,35 @@ def package(request, category, package): } +def package_version_metadata(request, category, package, version_tag): + package = get_object_or_404(Package, category=category, name=package) + try: + ver, rev, slot, over = versiontag_to_attrs(version_tag) + except TypeError: + raise Http404 + version = get_object_or_404(Version, package=package, version=ver, + revision=rev, slot=slot, overlay=over) + content = "" + if version.metadata_path: + with open(version.metadata_path) as meta_file: + content = meta_file.read() + return HttpResponse(content, content_type="text/plain") + + +def package_version_ebuild(request, category, package, version_tag): + package = get_object_or_404(Package, category=category, name=package) + try: + ver, rev, slot, over = versiontag_to_attrs(version_tag) + except TypeError: + raise Http404 + version = get_object_or_404(Version, package=package, version=ver, + revision=rev, slot=slot, overlay=over) + if version.ebuild_path: + with open(version.ebuild_path) as ebuild_file: + content = ebuild_file.read() + return HttpResponse(content, content_type="text/plain") + + @login_required @render_to('euscan/problem.html') def problem(request, category, package): diff --git a/euscanwww/htdocs/img/metadata.png b/euscanwww/htdocs/img/metadata.png Binary files differnew file mode 100644 index 0000000..363f51b --- /dev/null +++ b/euscanwww/htdocs/img/metadata.png |