-// Activate Google Prettify for pretty-printing code.
-addEventListener('load', prettyPrint, false);
-
$(document).ready(function() {
+ // Activate Google Prettify for pretty-printing code.
+ window.prettyPrint && prettyPrint()
});
function getCookie(name) {
<td>
<div class="btn-group">
{% if file.viewable %}
- <a class="btn btn-mini" href="#">
+ <a class="btn btn-mini" href="/package/{{ pkg.uuid }}/view{{ file.name }}">
<i class="icon-file"></i>
</a>
{% end %}
--- /dev/null
+{% extends "../base.html" %}
+
+{% block title %}{{ _("View %(filename)s from %(pkg)s") % { "filename" : filename, "pkg" : pkg.friendly_name } }}{% end block %}
+
+{% block body %}
+ <ul class="breadcrumb">
+ <li>
+ <a href="/">{{ _("Home") }}</a>
+ <span class="divider">/</span>
+ </li>
+ <li>
+ <a href="/packages">{{ _("Packages") }}</a>
+ <span class="divider">/</span>
+ </li>
+ <li>
+ <a href="/package/{{ pkg.name }}">{{ pkg.name }}</a>
+ <span class="divider">/</span>
+ </li>
+ {% if pkg.build %}
+ <li>
+ <a href="/build/{{ pkg.build.uuid }}">{{ pkg.build.name }}</a>
+ <span class="divider">/</span>
+ </li>
+ {% end %}
+ {% if pkg.job %}
+ <li>
+ <a href="/job/{{ pkg.job.uuid }}">{{ pkg.job.arch.name }}</a>
+ <span class="divider">/</span>
+ </li>
+ {% end %}
+ <li>
+ <a href="/package/{{ pkg.uuid }}">{{ pkg.friendly_name }}</a>
+ <span class="divider">/</span>
+ </li>
+ <li class="active">
+ {{ _("View file") }}
+ </li>
+ </ul>
+
+ <div class="page-header">
+ <h2>
+ {{ filename }}<br>
+ <small><a href="/package/{{ pkg.uuid }}">{{ pkg.friendly_name }}</a> - {{ pkg.summary }}</small>
+ </h2>
+ </div>
+
+ <pre {% if not filesize >= 1024 ** 2 %}class="prettyprint linenums"{% end %}>{{ content }}</pre>
+
+ <p class="muted ac">
+ {{ _("Mimetype: %s") % mimetype }} - {{ _("Size: %s") % format_size(filesize) }} -
+ <a href="/package/{{ pkg.uuid }}/download{{ filename }}">{{ _("Download file") }}</a>
+ </p>
+{% end block %}
(r"/package/([\w\-\+]+)", PackageNameHandler),
(r"/package/([\w\-\+]+)/changelog", PackageChangelogHandler),
(r"/package/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/download(.*)", PackageFileDownloadHandler),
+ (r"/package/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})/view(.*)", PackageFileViewHandler),
# Files
(r"/file/([\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12})", FileDetailHandler),
class PackageFileDownloadHandler(BaseHandler):
- def get(self, pkg_uuid, filename):
+ def get_file(self, pkg_uuid, filename):
# Fetch package.
pkg = self.pakfire.packages.get_by_uuid(pkg_uuid)
if not pkg:
if not f:
raise tornado.web.HTTPError(404, "Package %s does not contain file %s" % (pkg_file, filename))
- # Send the filename in header.
- self.set_header("Content-Disposition", "attachment; filename=%s" % os.path.basename(filename))
-
# Guess the MIME type of the file.
(type, encoding) = mimetypes.guess_type(filename)
if not type:
type = "text/plain"
- self.set_header("Content-Type", type)
+
+ return (pkg, f, type)
+
+ def get(self, pkg_uuid, filename):
+ pkg, f, mimetype = self.get_file(pkg_uuid, filename)
+
+ # Send the filename and mimetype in header.
+ self.set_header("Content-Disposition", "attachment; filename=%s" % os.path.basename(filename))
+ self.set_header("Content-Type", mimetype)
# Transfer the content chunk by chunk.
while True:
# Done.
self.finish()
+
+
+class PackageFileViewHandler(PackageFileDownloadHandler):
+ def get(self, pkg_uuid, filename):
+ pkg, f, mimetype = self.get_file(pkg_uuid, filename)
+
+ # Read in the data.
+ content = f.read()
+ f.close()
+
+ self.render("packages/view_file.html", pkg=pkg, filename=filename,
+ mimetype=mimetype, content=content, filesize=f.size)