staticdir = $(datadir)/static
static_css_DATA = \
- src/static/css/highlight.css \
src/static/css/site.css
static_cssdir = $(staticdir)/css
self.package = package
self.data = data
+ def __str__(self):
+ return self.path
+
@property
def path(self):
return self.data.path
color: $danger-invert;
}
}
+
+/*
+ Code Highlighting
+*/
+.highlight {
+ .hll {
+ background-color: $grey;
+ }
+
+ // Keywords
+ .k, .kc, .kd, .kn, .kp, .kr, .kt {
+ color: $grey-dark;
+ font-weight: bold;
+ }
+
+ // Literals
+ .l, .ld {
+ color: $blue;
+ }
+
+ // Literal Number
+ .m, .mb, .mf, .mh, .mi, .mo, .il {
+ color: $red;
+ }
+
+ // Literal Strings
+ .s, .sa, .sb, .sc, .dl, .sd, .s2, .se, .sh, .si, .sx, .sr, .s1, .ss {
+ color: $blue;
+ }
+
+ // Names
+ .n, .na, .nb, .nc, .no, .nd, .ni, .ne, .nf, .nl, .nn, .nx, .py, .nt, .nv, .bp,
+ .fm, .vc, .vg, .vi, .vm {
+ color: $text;
+ }
+
+ // Operators
+ .o, .ow {
+ color: $text;
+ }
+
+ // Comments
+ .c, .ch, .cm, .cp, .cpf, .c1, .cs {
+ color: $grey;
+ }
+}
{% extends "../base.html" %}
-{% block title %}{{ _("Package") }} - {{ package }} - {{ file }}{% end block %}
+{% block title %}{{ package }} - {{ file }}{% end block %}
{% block container %}
- <nav aria-label="{{ _("You are here:") }}" role="navigation">
- <ul class="breadcrumbs">
- <li>
- <a href="/">{{ _("Home") }}</a>
- </li>
+ <nav class="breadcrumb" aria-label="breadcrumbs">
+ <ul>
<li>
<a href="/packages">{{ _("Packages") }}</a>
</li>
<li>
<a href="/packages/{{ package.uuid }}">{{ package }}</a>
</li>
- <li>
- <span class="show-for-sr">{{ _("Current") }}: </span> {{ file.path }}
+ <li class="is-active">
+ <a href="#" aria-current="page">{{ _("File %s") % file }}</a>
</li>
</ul>
</nav>
- {% module Highlight(payload) %}
+ <section class="section">
+ <h1 class="title">{{ file }}</h1>
+
+ <div class="block">
+ {% module Highlight(payload, filename=file.path) %}
+ </div>
- <a class="expanded primary button" href="/package/{{ package.uuid }}/download{{ file.path }}">
- {{ _("Download (%s)") % format_size(file.size) }}
- </a>
+ <div class="block">
+ <a class="button" href="/package/{{ package.uuid }}/download{{ file.path }}">
+ {{ _("Download (%s)") % format_size(file.size) }}
+ </a>
+ </div>
+ </section>
{% end block %}
class HighlightModule(UIModule):
- def render(self, text):
+ def render(self, text, filename=None):
# Find a lexer
try:
- lexer = pygments.lexers.guess_lexer(text)
+ if filename:
+ lexer = pygments.lexers.guess_lexer_for_filename(filename, text)
+ else:
+ lexer = pygments.lexers.guess_lexer(text)
except pygments.util.ClassNotFound as e:
lexer = pygments.lexers.special.TextLexer()
# Find a formatter
- formatter = pygments.formatters.HtmlFormatter(linenos="table")
+ formatter = pygments.formatters.HtmlFormatter()
return pygments.highlight(text, lexer, formatter)
- def css_files(self):
- return (
- "css/highlight.css",
- )
-
class CommitMessageModule(UIModule):
def render(self, commit):