Commit Graph

18 Commits

Author SHA1 Message Date
Alberto Bertogli
aee18d0edd Simplify smstr
With the Python 2 to 3 migration and the type checking, we can be
fairly confident that smstr are always constructed from strings, not
bytes.

This allows the code to be simplified, as we no longer need to carry
the dual raw/unicode representation.
2020-05-24 16:05:18 +01:00
Alberto Bertogli
5e75a1e7a1 Tune markdown CSS to increase readability
The default CSS is not very comfortable for markdown, as for example the
links are hidden.

This patch makes the markdown CSS tunable by wrapping it into a div, and
then adjusting the default styles to increase readability.
2018-03-04 19:14:49 +00:00
Alberto Bertogli
c648cfb593 views: Improve display on mobile browsers
This patch moves the pages to HTML5, and adds some simple meta tags and CSS media
constraints so things render better on mobile browsers, while leaving the
desktop unaffected.

It's still not ideal, though.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-11-18 00:29:34 +00:00
Eric Sunshine
84d628c690 views/blob: suppress double-slash in page title
For blobs in subdirectories, the page title always includes a double
slash between the final directory component and the filename (for
example, "git >> repo >> branch >> doc//readme.txt"). This is unsightly.

git-arr:blob() ensures that the directory passed to views/blob always
has a trailing slash, so we can drop the slash inserted by views/blob
between the directory and the filename.

As a side-effect, this also changes the page title for blobs in the root
directory. Instead of "git >> repo >> branch >> /readme.txt", the title
becomes "git >> repo >> branch >> readme.txt", which is slightly more
aesthetically pleasing.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-24 19:23:18 +00:00
Eric Sunshine
37e731fc2e blob: pass branch name to view explicitly
Passing the branch name into the view indirectly via
Repo.new_in_branch() increases cognitive burden, thus outweighing
whatever minor convenience (if any) is gained by doing so. The code is
easier to reason about when the branch name is passed to the view
directly.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-17 13:11:39 +00:00
Eric Sunshine
46640c68b9 views: blob: render empty blobs specially
Empty (zero-length) blobs are currently rendered by 'pygments'
misleadingly as a single empty line, or, when 'pygments' is unavailable,
as "nothingness" preceding a horizontal rule. In either case, it is
somewhat difficult to glean concrete information about the blob.

Address this by instead rendering summary information about the blob: in
particular, its classification ("empty") and its size ("0 bytes"). This
is analogous to the summary information rendered for binary blobs
("binary" and size).

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-13 19:51:45 +00:00
Eric Sunshine
c91beccdb0 blob: cap amount of rendered binary blob content
Although hexdump(1)-style rendering of binary blob content may reveal
some meaningful information about the data, it wastes even more storage
space than embedding the raw data itself. However, many binary files
have a "magic number" or other signature near the beginning of the file,
so it is often possible to glean useful information from just the
initial chunk of the file without having the entire content available.

Thus, limiting the rendered data to just an initial chunk saves storage
space while still potentially presenting useful information about the
binary content.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-13 19:51:45 +00:00
Eric Sunshine
6f3942ce38 blob: render hexdump(1)-style binary blob content
Raw binary blob content tends to look like "line noise" and is rarely,
if ever, meaningful. A hexdump(1)-style rendering (specifically,
"hexdump -C"), on the other hand, showing runs of hexadecimal byte
values along with an ASCII representation of those bytes can sometimes
reveal useful information about the data.

(A subsequent patch will add the ability to cap the amount of data
rendered in order to reduce storage space requirements.)

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-13 19:51:44 +00:00
Eric Sunshine
09c2f33f5a blob: render binary blob summary information rather than raw content
Binary blobs are currently rendered as raw data directly into the HTML
output, looking much like "line noise". This is rarely, if ever,
meaningful, and consumes considerable storage space since the entire raw
blob content is embedded in the generated HTML file.

Address this issue by instead emitting summary information about the
blob, such as its classification ("binary") and its size. Other
information can be added as needed.

As in Git itself, a blob is considered binary if a NUL is present in the
first ~8KB.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-13 19:51:44 +00:00
Eric Sunshine
50c004f8a5 embed_image_blob: retire reload of image blob
Historically, the 'blob' view was unconditionally handed cooked
(utf8-encoded) blob content, so embed_image_blob(), which requires raw
blob content, has been forced to reload the blob in raw form, which is
ugly and expensive. However, now that the Blob returned by Repo.blob()
is able to vend raw or cooked content, it is no longer necessary for
embed_image_blob() to reload the blob to gain access to the raw content.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-13 19:51:44 +00:00
Eric Sunshine
0ba89d75e6 git.py: introduce Blob abstraction
Some blob representations (such as embedded images) require raw blob
content, however, the 'blob' view is unconditionally handed cooked
(utf8-encoded) content, thus representations which need raw content are
forced to reload the blob in raw form, which is ugly and expensive (due
to shelling out to git-cat-file a second time).

The ultimate goal is to eliminate the wasteful blob reloading when raw
content is needed. As a first step, introduce a Blob abstraction to be
returned by Repo.blob() rather than the cooked content. A subsequent
change will flesh out Blob, allowing it to return raw or cooked content
on demand without the client having to specify one or the other when
invoking Repo.blob().

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-13 19:51:44 +00:00
Eric Sunshine
93b161c23e views: fix broken URLs involving hierarchical branch names
Git branch names can be hierarchical (for example, "wip/parser/fix"),
however, git-arr does not take this into account when formulating URLs
on branch, tree, and blobs pages. These URLs are dysfunctional because
it is assumed incorrectly that a single "../" is sufficient to climb
over the branch name when computing relative paths to resources higher
in the hierarchy. This problem manifests as failure to load static
resources (stylesheet, etc.), broken links to commits on branch pages,
and malfunctioning breadcrumb trails.

Fix this problem by computing the the proper number of "../" based upon
the branch name, rather than assuming that a single "../" will work
unconditionally. (This is analogous to the treatment already given to
hierarchical pathnames in tree and blob views.)

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-11 21:18:22 +00:00
Vanya Sergeev
48a00cb460 Fix one-line 'if' termination in tree, blob templates
The missing '% end' template keyword to these one-line if statements was
causing bottle 0.12.7 to incorrectly indent the following line, leading to an
IndentationError at runtime when the blob and tree templates are compiled.

Signed-off-by: Vanya Sergeev <vsergeev@gmail.com>
2014-06-30 08:45:36 +01:00
Alberto Bertogli
54026b7585 Make embedding markdown and images configurable per-repo
This patch introduces the embed_markdown and embed_images configuration
options, so users can enable and disable those features on a per-repository
basis.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2013-11-02 21:12:50 +00:00
Vanya Sergeev
21522f8a3a Add embed data URI image blob support 2013-11-02 19:07:59 +00:00
Vanya Sergeev
f62ca211eb Add markdown blob support 2013-11-02 19:03:59 +00:00
Alberto Bertogli
62da3ebc08 Use heuristics to decide what to colorize
In practise pygments seems to have a very hard time processing large files and
files with long lines, so try to avoid using it in those cases.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2012-11-18 14:55:22 +00:00
Alberto Bertogli
80ef0017d4 Initial commit
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2012-11-10 17:49:54 +00:00