euscanwww: Showing ebuild and metadata in package details page
Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
parent
effab2015b
commit
c648d7e756
@ -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>
|
||||
|
@ -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',
|
||||
|
@ -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):
|
||||
|
BIN
euscanwww/htdocs/img/metadata.png
Normal file
BIN
euscanwww/htdocs/img/metadata.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 798 B |
Loading…
Reference in New Issue
Block a user