Commit Graph

118 Commits (46b7abed99e957008c01c02cf612aa526ba92f04)

Author SHA1 Message Date
Lars Hjemli 46b7abed99 ui-tree: add support for source-filter option
This new option is used to specify an external command which will be
executed when displaying blob content in the tree view. Blob content
will be written to STDIN of the filter and STDOUT from the filter
will be included verbatim in the html output from cgit. The file name
of the blob will be passed as the only argument to the filter command.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli d6f6072560 Add generic filter/plugin infrastructure
The functions cgit_open_filter() and cgit_close_filter() can be used to
execute filters on the output stream from cgit.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli 286a905842 Merge branch 'lh/embedded'
Conflicts:
	cgitrc.5.txt
	ui-shared.c
15 years ago
Lars Hjemli ef0c6aadf7 Add support for 'noheader' option
This option can be used to disable the standard cgit page header, which
might be useful in combination with the 'embedded' option.

Suggested-by: Mark Constable <markc@renta.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli 542f6a4330 Merge branch 'ml/head-include' 15 years ago
Lars Hjemli 681fdc4547 Merge branch 'plain-etag'
Conflicts:
	ui-shared.c
15 years ago
Lars Hjemli e429fb0cca Return http statuscode 404 on unknown branch
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Mark Lodato b5a3a20496 Add head-include configuration option.
This patch adds an option to the configuration file, "head-include",
which works just like "header" or "footer", except the content is put
into the HTML's <head> tag.
15 years ago
Lars Hjemli 3ff58ddd51 Add support for HEAD requests
This is a quick 'n dirty hack which makes cgit honor HEAD requests.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli 488a214a81 Add support for ETag in 'plain' view
When downloading a blob identified by its path, the client might want
to know if the blob has been modified since a previous download of the
same path. To this end, an ETag containing the blob SHA1 seems to be
ideal.

Todo: add support for HEAD requests...

Suggested-by: Owen Taylor <otaylor@redhat.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli 0cbb50841a Add support for an 'embedded' option in cgitrc
When activated, cgit will neither generate http headers nor any 'framing'
html elements (like <html> and <body>). Also, all page content is now
wrapped in a <div id='cgit'> element to make it easier to select the
correct cgit classes when embedded/themed.

Suggested-by: Matt Sealey <matt@genesi-usa.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli b115955d71 Add support for a custom header
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 7710178e45 Merge branch 'lh/stats'
Conflicts:
	cgit.c
	cgit.css
	cgit.h
	ui-tree.c

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 31665579c2 Merge branch 'stable' 16 years ago
Lars Hjemli eb14609dc4 Avoid SEGFAULT on invalid requests
When an unknown page is requested, either on the querystring or via
PATH_INFO, we end up with a null-referencing cgit_cmd. This null-
pointer is then used as argument to the hc() function (which decides
what tab to render as 'active'), but this function failed to check if a
valid cmd was specified and a SEGFAULT would occur. This patch fixes the
issue by introducing a 'fallback-cmd' which specifies what tab to render
as 'active' when no valid cmd is requested.

While at it, we now also keep track of the active repository even if an
invalid cmd was requested since we want to show the error message about
the invalid request in the correct context.

Noticed-by: Robin Redeker <elmex@ta-sa.org>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 377a1c8ced Untie logic for SCRIPT_NAME and PATH_INFO
SCRIPT_NAME is used as fallback for virtual-root when virtual-root is
unspecified in cgitrc and PATH_INFO is used as fallback for the query-
string parameter 'url' when the latter is unspecified. But until now,
the use of PATH_INFO depended on virtual-root also being unspecified,
i.e. it was impossible to use PATH_INFO when virtual-root was specified.

This commit makes the fallback on SCRIPT_NAME and PATH_INFO independent
code paths, i.e. it is now possible to specify virtual-root in cgitrc
while still using PATH_INFO (instead of rewrite rules) to get 'pretty
urls'.

Noticed-by: Jack Moffitt <jack@chesspark.com>
Noticed-by: LiKai Liu <liulk@cs.bu.edu>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli fb2f3f6c29 ui-stats: replace 'enable-stats' setting with 'max-stats'
The new 'max-stats' and 'repo.max-stats' settings makes it possible to
define the maximum statistics period, both globally and per repo. Hence,
it is now feasible to allow statistics on repositories with a high commit
frequency, like linux-2.6, by setting repo.max-stats to e.g. 'month'.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli f86a23ff53 Add a 'stats' page to each repo
This new page, which is disabled by default, can be used to print some
statistics about the number of commits per period in the repository,
where period can be either weeks, months, quarters or years.

The function can be activated globally by setting 'enable-stats=1' in
cgitrc and disabled for individual repos by setting 'repo.enable-stats=0'.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 3c32fe0771 Merge branch 'full-log'
Conflicts:
	cgit.c
	cgit.h
16 years ago
Lars Hjemli 0274b57d55 ui-log: add support for showing the full commit message
Some users prefer to see the full message, so to make these users happy
the new querystring parameter "showmsg" can be used to print the full
commit message per log entry.

A link is provided in the log heading to make this function accessible,
and all links and forms tries to preserve the users preference.

Note: the new link is not displayed on the summary page since the point
of the summary page is to be a summary, but it is still obeyed if specified
manually.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Benjamin Close d71c0c725d Add support for sorting by Age in the repolist
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 5632ba35d1 Add cgit_query.nohead flag
This flag is set when no HEAD is specified in the querystring. Currently
it has no users, but it will be used by ui-snapshot to invoke a DWIM-mode
where the revision is extracted from the snapshot name.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 93397a765b Add support for --scan-tree=<path> option to cgit
This option makes cgit scan a directory tree looking for git repositories,
generating suitable definitions for a cgitrc file on stdout.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli e154edd807 Teach cgit how to use PATH_INFO
This commit makes cgit use the cgi variables SCRIPT_NAME and PATH_INFO
when virtual-root is unspecified in cgitrc and no url-parameter is
specified on the querystring. This has two nice effects:

* Virtual urls works out of the box, no more need for rewrite-rules in httpd.
* Virtual urls with special querystring characters are handled correctly.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli e5da4bca54 Implement plain view
This implements a way to access plain blobs by path (similar to the
tree view) instead of by sha1.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Stefan Naewe 0f0ab148c6 Added `local-time` option to cgitrc
When `local-time` is set, commit, tag and patch timestamps will be printed
in the servers timezone. Also, regardless of the value of `local-time`,
these timestamps will now always show the timezone.

Signed-off-by: Stefan Naewe <stefan.naewe@atlas-elektronik.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 952f4ece29 Modify default value for a few cgitrc options
The default max-length used when printing commit messages and repo
descriptions can be increased due to the new layout (no sidebar).

Also, on the repo summary page I believe it makes sense to only show the
ten most recent branches and tags by default, just as it makes sense to
show the ten most recent commit messages for the active branch.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 25c84326de Be prepared for empty repositories
Before this patch, cgit would segfault on repositories with no refs.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 502865a5ec Add a favicon option to cgitrc
This option is used to specify a shortcut icon on all cgit pages.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli de5e928171 Add support for including a footer on all pages
The new cgitrc option `footer` can be used to include a html-file which
replaces the standard 'generated by cgit' message at the bottom of each
page.

Suggested-by: Peter Danenberg <pcd@wikitex.org>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Michael Krelin 42effc9390 allow specification of directly linked blobs mimetypes
Signed-off-by: Michael Krelin <hacker@klever.net>
16 years ago
Lars Hjemli af2e75616d cache.c: do not ignore errors from print_slot()
If print_slot() fails, the client will be served an inferior response.
This patch makes sure that such an error will be returned to main(), which
in turn will try to inform about the error in the response itself.

The error is also printed to the cache_log, i.e. stderr, which will make
the error message appear in error_log (atleast when httpd==apache).

Noticed-by: Jim Meyering <jim@meyering.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli c6078b8b00 Add a pager on the repolist
This enables a pager on the repolist which restricts the number of entries
displayed per page, controlled by the new option `max-repo-count` (default
value 50).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli e19683bede Merge branch 'lh/cache'
* lh/cache:
  Add page 'ls_cache'
  Redesign the caching layer
16 years ago
Lars Hjemli c6431a7150 Prepare for 'about site' page / add 'root-readme' option to cgitrc
The new option names a file which will be included on a new page, next
to the current 'index' page.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 651ef79768 Make it possible for a single cmd to work both with and without a repo
When cgit_cmd.want_repo was 0, we used to assume that the cmd would never
be invoked for a repo. But soon this will become untrue (the 'about' cmd
is rapidly approching), so from now on we will initialize any requested
repo even if want_repo==0 (and return an error if want_repo==1 but no repo
is specified).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 4c9916043d Re-enable 'index-info' and add support for 'root-desc' in cgitrc
The 'index-info' option got lost when the layout was converted from
sidebar to old-fashioned header (noticed by Harley Laue, thanks!), and
this commit re-enables it.

But there is now also an alternative in the 'root-desc' option; where
'index-info' specifies a file to include, 'root-desc' specifies the text
literally. This might be nicer for the one-liner descriptions which these
options typically provides.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 939d32fda7 Redesign the caching layer
The original caching layer in cgit has no upper bound on the number of
concurrent cache entries, so when cgit is traversed by a spider (like the
googlebot), the cache might end up filling your disk. Also, if any error
occurs in the cache layer, no content is returned to the client.

This patch redesigns the caching layer to avoid these flaws by
* giving the cache a bound number of slots
* disabling the cache for the current request when errors occur

The cache size limit is implemented by hashing the querystring (the cache
lookup key) and generating a cache filename based on this hash modulo the
cache size. In order to detect hash collisions, the full lookup key (i.e.
the querystring) is stored in the cache file (separated from its associated
content by ascii 0).

The cache filename is the reversed 8-digit hexadecimal representation of

  hash(key) % cache_size

which should make the filesystem lookup pretty fast (if directory content
is indexed/sorted); reversing the representation avoids the problem where
all keys have equal prefix.

There is a new config option, cache-size, which sets the upper bound for
the cache. Default value for this option is 0, which has the same effect
as setting nocache=1 (hence nocache is now deprecated).

Included in this patch is also a new testfile which verifies that the
new option works as intended.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 78031f92b0 Fix search in repo index even if caching is enabled
The repository index page needed to include the querystring in the cache
filename.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli c6f747649a Reset ctx.repo to NULL when the config parser is finished
This global variable is used by the config parsing callback to keep track
of the currently configured repository. If it is not reset to NULL when
the config parser is finished, and neither `url` or `r` is specified on the
querystring, cgit will wrongly consider the last configured repo as
selected.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli e87e896333 Move cgit_parse_query() from parsing.c to html.c as http_parse_querystring()
This is a generic http-function.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 20a33548b9 Move function for configfile parsing into configfile.[ch]
This is a generic function which wanted its own little object file.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli ee4056bd2c Add cache.h
The functions found in cache.c are only used by cgit.c, so there's no
point in rebuilding all object files when the cache interface is changed.


Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli dc3282f0ba Remove global and obsolete cgit_cmd
This variable was obsoleted by cmd.c.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 92908af455 Move cgit_version from shared.c to cgit.c
With the matching Makefile change, this makes sure that only cgit.o and cgit
proper needs to be rebuildt when VERSION has been modified.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 163037e79c Move non-generic functions from shared.c to cgit.c
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli a4d1ca1dc6 Add ui-shared.h
This is finally a proper headerfile for the shared ui-functions which
used to reside in cgit.h

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli e0e4478e7b Add command dispatcher
This simplifies the code in cgit.c and makes it easier to extend cgit with
new pages/commands.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli b608e88adb Remove obsolete cacheitem parameter to ui-functions
This parameter hasn't been used for a very long time...

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli f3c1a187fe Add struct cgit_page to cgit_context
This struct is used when generating http headers, and as such is another
small step towards the goal of the whole cleanup series; to invoke each
page/view function with a function pointer.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago