Commit Graph

83 Commits

Author SHA1 Message Date
Eric Sunshine
7f2f67629f views: branch/paginate: teach "next" link to respect 'max_pages'
Pagination link "next" does not respect 'max_pages', thus it incorrectly
remains enabled on the final page capped by 'max_pages'. When clicked,
the user is taken to a "404 Page not found" error page, which makes for
a poor user experience.

Fix this problem by teaching the "next" link to respect 'max_pages'.

(As a side-effect, this also causes 'serve' mode to respect 'max_pages',
which was not previously the case. This change of behavior is
appropriate since it brings 'serve' mode, which is intended primarily
for testing, more in line with 'generate' mode.)

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
Eric Sunshine
ac105c8383 views: branch/paginate: fix incorrectly enabled "next" link
When the number of commits on a branch page is less than
'commits_per_page', the pagination "next" link is disabled, indicating
correctly that this is the final page. However, if the number of commits
on the branch page is exactly 'commits_per_page', then the "next" link
is incorrectly enabled, even on the final page. When clicked, the user
is taken to a "404 Page not found" error page, which makes for a poor
user experience.

Fix this problem by reliably detecting when the branch page is the final
one. Do so by asking for (but not displaying) one commit more than
actually needed by the page. If the additional commit is successfully
retrieved, then another page definitely follows this one. If not
retrieved, then this is definitely the final page.

(Unfortunately, the seemingly more expedient approach of checking if the
final commit on the current page is a root commit -- has no parents --
is not a reliable indicator that this the final page since a branch may
have multiple root commits due to merging.)

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
Eric Sunshine
bebc7fa3f0 repo: diff: add option to show "creation event" diff for root commit
At its inception, Git did not show a "creation event" diff for a
project's root commit since early projects, such as the Linux kernel,
were already well established, and a large root diff was considered
uninteresting noise.

On the other hand, new projects adopting Git typically have small root
commits, and such a "creation event" is likely to have meaning, rather
than being pure noise. Consequently, git-diff-tree gained a --root flag
in dc26bd89 (diff-tree: add "--root" flag to show a root commit as a big
creation event, 2005-05-19), though it was disabled by default.

Displaying the root "creation event" diff, however, became the default
behavior when configuration option 'log.showroot' was added to git-log
in 0f03ca94 (config option log.showroot to show the diff of root
commits; 2006-11-23). And, gitk (belatedly) followed suit when it
learned to respect 'log.showroot' in b2b76d10 (gitk: Teach gitk to
respect log.showroot; 2011-10-04).

By default, these tools now all show the root diff as a "creation
event", however, git-arr suppresses it unconditionally. Resolve this
shortcoming by adding a new git-arr configuration option "rootdiff" to
control the behavior (enabled by default).

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
Eric Sunshine
9ef78aaffd git-arr: interpret 'max_pages = 0' as unlimited
By default, git-arr limits the number of pages of commits to 5, however,
it is reasonable to expect that some projects will want all commits to
be shown. Rather than forcing such projects to choose an arbitrarily
large number as the value of 'max_pages', provide a formal mechanism to
specify unlimited commit pages.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-11 21:18:18 +00:00
Eric Sunshine
d7604dab4d write_tree: suppress double-slash in blob HTML filename
When emitting a blob in the root tree of a commit, write_tree() composes
the blob's HTML filename with an extra slash before the "f=", like this:

    output/r/repo/b/master/t//f=README.txt.html

Although the double-slash is not harmful on Unix, it is unsightly, and
may be problematic for other platforms or filesystems which interpret
double-slash specially or disallow it. Therefore, suppress the extra
slash for blobs in the root tree.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-11 21:18:14 +00:00
Eric Sunshine
aaf2968538 route: commit: match only hexadecimal rather than digits + full alphabet
A human-readable representation of a Git SHA1 commit ID is composed
only of hexadecimal digits, thus there is no need to match against
the full alphabet.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-11 21:18:10 +00:00
Eric Sunshine
420afd3206 views: summary: suppress extra horizontal rule when no "master" branch
When a repository has a "master" branch, a short summary of its most
recent commits is shown, followed by a horizontal rule. If there is no
"master" branch, then the commit summary is suppressed, however, the
rule is shown unconditionally, which is ugly, particularly when there
is already a rule following the web_url/git_url block. Therefore,
suppress the "master" branch horizontal rule when not needed. (This is
analogous to how the rule following the web_url/git_url block is
suppressed when that information is not shown).

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-11 21:18:06 +00:00
Eric Sunshine
605421f2d6 sample.conf: document embed_markdown and embed_images
These repo-specific options were added in 54026b75 (Make embedding
markdown and images configurable per-repo, 2013-11-02) but not
documented.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2015-01-11 21:18:00 +00:00
Alberto Bertogli
df00293a7c git: Add '--' to "git rev-list" runs to avoid ambiguous arguments
If there is a branch and a file with the same name, git-arr will fail to
generate, as git will complain when running git rev-list.

For example, if there is both a file and a branch called "hooks" in the
repository, git-arr would fail as follows:

=== git-arr running: ['git', '--git-dir=/some/repo', 'rev-list', '--max-count=1', '--header', u'hooks'])
fatal: ambiguous argument 'hooks': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Traceback (most recent call last):
  File "./git-arr", line 457, in <module>
    main()
  File "./git-arr", line 452, in main
    skip_index = len(opts.only) > 0)
  File "./git-arr", line 388, in generate
    branch_mtime = r.commit(bn).committer_date.epoch
AttributeError: 'NoneType' object has no attribute 'committer_date'

To fix that, this patch appends a "--" as the last argument to rev-list, which
indicates that it has completed the revision list, which disambiguates the
argument.

While at it, a minor typo in a comment is also fixed.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2014-12-31 17:07:38 +00:00
Alberto Bertogli
7898b2becd git.py: Parse timestamps from UTC, not from local time
The current parsing of dates from git incorrectly uses
datetime.fromtimestamp(), which returns the *local* date and time
corresponding to the given timestamp.

Instead, it should be using datetime.utcfromtimestamp() which returns the UTC
date and time, as the rest of the code expects.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2014-10-05 22:15:54 +01:00
Alberto Bertogli
47d500715a views/tree.html: Fix lambda syntax
Some versions of bottle.py don't deal well with the "if" inside the lambda, so
work around it by just using comparison and simplifying the function.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
0.13
2014-07-28 23:46:50 +01:00
Vanya Sergeev
eb7cadd64f Enable line number anchors when using pygments HtmlFormatter
Signed-off-by: Vanya Sergeev <vsergeev@gmail.com>
2014-07-03 00:56:19 +01: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
2f65291ef1 Fix committer field in the commit view
The commit view shows the author information in the committer field; this
patch fixes it by showing the appropriate fields.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
0.12
2013-11-03 10:57:54 +00:00
Alberto Bertogli
f6a75820e8 Work around HTTPError status code issues
It turned out that bottle.py is not backwards-compatible with the status code
change: older versions encode the status in e.status; newer ones use
e.status_code (and e.status became a string).

This patch works around that by trying to pick up which of the two variants we
have, and deciding accordingly.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2013-11-02 23:32:43 +00:00
Alberto Bertogli
e49c69da2e Show the age of a repository in the index, via javascript
This patch adds the age of the repository to the index view, using javascript
to give a nice human string for the age.

When javascript is not available, the element remains hidden.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2013-11-02 22:18:33 +00:00
Alberto Bertogli
6764bfcfd6 Use the status_code attribute to tell 404s appart
Newer versions of bottle have a string in the e.status attribute, and the
status code can be found in e.status_code, which should be backwards
compatible.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2013-11-02 21:15:23 +00: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
Alberto Bertogli
a42d7da6a4 utils: Make the embedded image code use mimetypes
This patch makes minor changes to the code that handles embedded images,
mostly to make it use mimetypes, and to remove SVG support (at least for now)
due to security concerns.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2013-11-02 19:14:36 +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
Vanya Sergeev
d3bf98ea00 Fix parsing of empty commit messages 2013-10-12 01:19:57 +01:00
Alberto Bertogli
6f5f3c4aa5 Add a post-receive hook
This patch adds a post-receive hook that can be used to trigger a git-arr
update when there is a push to a repository.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
0.11
2013-03-12 22:09:25 +00:00
Alberto Bertogli
c72278c97c Allow calling the executable from any directory
When the tool is invoked like /path/to/git-arr, it currently fails because
both the serving of static files and bottle templates assume they're on the
current working directory.

This patch fixes that by computing the directories based on the executable
location.

Note this is assuming the static directory and the templates live next to the
executable, which will not always be the case, and eventually it should be
configurable; but it's ok for the time being.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2013-03-10 00:55:56 +00:00
Alberto Bertogli
18e8599bfa Use "cloneurl" as a default for git_url
This patch makes git_url have the same default as gitweb.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2013-03-09 23:23:52 +00:00
Alberto Bertogli
c303c30755 Fix the "--only" option
This patch fixes the --only option, and makes it avoid generating the
top-level index so we don't get a broken one with only the specified
repositories.

The intention is that this option is used in hooks to update the views after a
commit or push.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2013-03-09 23:23:52 +00:00
Alberto Bertogli
9ec2bde5c4 Only guess the lexer if the file starts with "#!"
The lexer guesser based on content is often wrong; to minimize the chances of
that happening, we only use it on files that start with "#!", for which it
usually has smarter rules.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2012-11-27 02:57:31 +00:00
Alberto Bertogli
36db9cc0ee Add a note about pygments in the README
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
0.10
2012-11-21 00:29:43 +00:00
Alberto Bertogli
bad8c52ef2 Fall back to guess the lexer by content
If we can't guess the lexer by the file name, try to guess based on the
content.

This allows pygments to colorize extension-less files, usually scripts.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2012-11-18 14:55:27 +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
ba3b2132f5 Improve the way we find repo paths
This patch improves the way we find the path to the repositories, both in the
recursive and in the non-recursive cases.

We now support specifying non-bare repositories directly, and also recursing
on them.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2012-11-11 13:43:02 +00:00
Alberto Bertogli
1c729578b2 Add dependencies and improve contact information to README
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
2012-11-11 12:53:39 +00:00
Alberto Bertogli
80ef0017d4 Initial commit
Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
0.01
2012-11-10 17:49:54 +00:00