Commit Graph

115 Commits

Author SHA1 Message Date
Lars Hjemli 04254fa903 Merge branch 'stable' 2012-01-03 16:06:58 +00:00
Tobias Grimm 7530d94f05 Add sort parameter to pager of repo list
When the repolist is paged, the page-links are missing the sort parameter,
causing the initial page to be custom sorted, but any clicked page will
then be with the default sort order again.
2012-01-03 15:20:17 +00:00
Lars Hjemli 5293c8b799 ui-repolist.c: fallback to "master" if no default branch is specified
When looking for the modtime of a repo we used to rely on repo.defbranch
having a value. This is no longer true so this patch provides a default
value when needed.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2011-07-19 09:34:18 +00:00
Lars Hjemli 3ec6b30950 cgit.c: always setup cgit repo environment variables
When cgit learned to setup environment variables for certain repo
settings before invoking a filter process, the setup occurred inside
cgit_open_filter().

This patch moves the setup out of cgit_open_filter() and into
prepare_repo_cmd() to prepare for additional uses of these variables.

Reviewed-by: Ferry Huberts <mailings@hupie.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2011-06-13 23:03:46 +00:00
Ferry Huberts 21e0e0bfac ui_repolist: get modtime from packed-refs as fallback
When no modtime could be determined then as a final
fallback try to get it from the packed-refs.

This will show an idle time when a repository has been packed
with all refs in the packed-refs.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2011-05-30 23:15:31 +02:00
Lars Hjemli ab350a77b1 Merge branch 'fh/filter-api'
Conflicts:
	cgit.c
2011-05-23 23:28:38 +02:00
Lars Hjemli c8ea73caab ui-repolist.c: do not return random/stale data from read_agefile
When git/date.c:parse_date() cannot parse its input it returns -1. But
read_agefile() checks if the result is different from zero, essentialy
returning random data from the date buffer when parsing fails. This
patch fixes the issue by verifying that the result from parse_date()
is positive.

Noticed-by: Julius Plenz <plenz@cis.fu-berlin.de>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2011-05-23 23:17:10 +02:00
Ferry Huberts d87bba846d cgit_open_filter: also take the repo as a parameter
To prepare for handing repo configuration to the
filter script that is executed.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2011-03-26 11:03:42 +01:00
Mark Lodato 25e8ba1996 ui-repolist: fix redefinition of _XOPEN_SOURCE
Previously, ui-repolist.c set _GNU_SOURCE and then included a standard
library before including <git-compat-util.h>.  This was a problem,
because <git-compat-util.h> redefined _XOPEN_SOURCE, which is set
automatically by glibc when _GNU_SOURCE is set.  However,
<git-compat-util.h> already sets _GNU_SOURCE and includes both
<string.h> and <time.h>, so there is no need to define _GNU_SOURCE or
include either header within ui-repolist.c.

Signed-off-by: Mark Lodato <lodatom@gmail.com>
2010-09-04 14:09:24 -04:00
Geoff Johnstone 9735835c0e Fix repolist search links with virtual root
Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-09-20 13:07:57 +02:00
Lars Hjemli e01229cf80 ui-repolist: handle empty sections similar to NULL sections
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-24 10:22:58 +02:00
Lars Hjemli 63816ec597 ui-repolist.c: sort by section name, repo name as default
When no sorting is requested by the client, cgit will now sort by
section name followed by repo name. This allows repos to be registered/
discovered independently of their display order.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-24 10:22:58 +02:00
Lars Hjemli e7af002d5c Introduce 'section' as canonical spelling for 'repo.group'
The 'repo.' prefix should be reserved for repo-specific options, but
the option 'repo.group' must still be honored to stay backwards
compatible.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-24 10:22:58 +02:00
Lars Hjemli e16f178334 Add and use a common readfile() function
This function is used to read the full content of a textfile into a
newly allocated buffer (with zerotermination).

It replaces the earlier readfile() in scan-tree.c (which was rather
error-prone[1]), and is reused by read_agefile() in ui-repolist.c.

1: No checks for EINTR and EAGAIN, fixed-size buffer

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-18 17:22:14 +02:00
Lars Hjemli 523c133e2e Merge branch 'stable' 2009-08-18 17:21:52 +02:00
Simon Arlott 011f2e9bdd truncate buffer before reading empty files
If readfile() reads an empty file, fgets() won't truncate the buffer
and it'll still contain the contents of the previously read file.

[lh: fixed similar issue in ui-repolist.c]

Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-18 14:27:41 +02:00
Lars Hjemli 537c05f138 Add 'about-filter' and 'repo.about-filter' options
These options can be used to execute a filter command on each about-page,
both top-level and for each repository (repo.about-filter can be used
to override the current about-filter).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-09 13:41:54 +02:00
Lars Hjemli 3c32fe0771 Merge branch 'full-log'
Conflicts:
	cgit.c
	cgit.h
2008-12-06 11:37:37 +01:00
Lars Hjemli 9c8be943f7 Merge branch 'lh/sort-repolist' 2008-12-06 11:35:49 +01:00
Lars Hjemli 7115f7d257 ui-repolist: avoid build warning for strcasestr(3)
The non-standard function strcasestr is only defined if _GNU_SOURCE has
also been defined.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-12-05 19:04:17 +01:00
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>
2008-11-29 18:39:41 +01:00
Lars Hjemli 8813170390 ui-repolist: implement lazy caching of repo->mtime
When sorting the list of repositories by their last modification time,
cgit would (in the worst case) invoke fstat(3) four times and open(3)
twice for each callback from qsort(3). This obviously scales very badly.

Now, the calculated modtime for each repo is saved in repo->mtime, thus
keeping the number of stat/open invocations identical for sorted and
unsorted repo-listings.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-11-29 16:46:37 +01:00
Lars Hjemli 54272e6096 ui-repolist: sort null values last
When sorting on e.g. owner, it's not interesting to get all repos
without owner at the top of the list.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-11-29 14:27:35 +01:00
Lars Hjemli f250c1ca2e ui-repolist: add support for sorting any column
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-11-29 14:08:51 +01:00
Lars Hjemli cbac02c8b0 ui-repolist: extract get_repo_modtime() from print_modtime()
The new function is then used by both print_modtime() and
cgit_reposort_modtime().

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-11-29 13:33:02 +01:00
Benjamin Close d71c0c725d Add support for sorting by Age in the repolist
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-11-29 13:25:54 +01:00
Lars Hjemli c7d1402b17 ui-repolist: handle empty agefiles
When the agefile was empty the old code would happily reuse the static
buffer filled by a previous call to read_agefile().

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-11-14 09:29:22 +01:00
Lars Hjemli 49ecbbddf0 ui-repolist + ui-shared: Use cgit_summary_link()
This makes is possible to use cgit with repository urls containing special
url characters like '#' and '?'.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-10-05 17:16:36 +02:00
Lars Hjemli dd80ef59e7 ui-repolist: enable filtering of repos by path
If a repo url is specified but no exact match is found in the list of
repos the url will now be used as a prefix-filter.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-09-15 23:35:34 +02:00
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>
2008-05-03 10:54:39 +02:00
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>
2008-04-29 01:06:30 +02:00
Lars Hjemli 8062817885 Move included header-file out of repolist table
When the 'index-header' option is specified in cgitrc we used to print
the included file content inside the repolist table, which is bad style.

This commit makes the included file be printed before the table.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-04-29 00:35:49 +02:00
Lars Hjemli e9a7042b5b Make a few more columns in repolist and log view clickable
Less mouse movement is nice.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-04-14 22:23:48 +02:00
Lars Hjemli 28d781f34b Make repository search case insensitive
This reuses the strcasestr() compiled or linked by libgit.a to implement a
case insensitive variation of the repository search.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-04-13 12:46:54 +02:00
Lars Hjemli 536b0541fc Implement minimal freetext search in the repolist
This makes the repolist much more usable when there's a lot of repositories
registered in cgitrc.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-04-13 12:10:03 +02:00
Lars Hjemli 931fc6d1e4 More layout fixes
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-04-13 10:57:11 +02:00
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>
2008-03-24 16:50:57 +01:00
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>
2008-03-24 01:01:28 +01:00
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>
2008-03-24 00:51:19 +01:00
Lars Hjemli b1f9b9c145 Introduce html.h
All html-functions can be quite easily separated from the rest of cgit, so
lets do it; the only issue was html_filemode which uses some git-defined
macros so the function is moved into ui-shared.c::cgit_print_filemode().

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-03-18 08:13:10 +01:00
Lars Hjemli d1f3bbe9d2 Move cgit_repo into cgit_context
This removes the global variable which is used to keep track of the
currently selected repository, and adds a new variable in the cgit_context
structure.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-02-16 13:56:09 +01:00
Lars Hjemli b228d4ff82 Add all config variables into struct cgit_context
This removes another big set of global variables, and introduces the
cgit_prepare_context() function which populates a context-variable with
compile-time default values.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-02-16 13:10:50 +01:00
Lars Hjemli 2915483ef6 Fix html error detected by test-suite
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-11-11 13:04:28 +01:00
Lars Hjemli 51140311bb Add search parameters to cgit_log_link
This makes the [prev] and [next] links work correctly on search results.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-11-03 10:42:37 +01:00
Lars Hjemli 103940fe6b Add ofs argument to cgit_log_link and use it in ui-log.c
This fixes a bug in the prev/next links on the log page: when on the default
branch the links to prev/next page would contain h=(null).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-06-29 20:31:00 +02:00
Lars Hjemli 0d05bca502 Add setting to enable/disable extra links on index page
The summary/log/tree links displayed for each repository on the index
page lost some of their purpose when the header menu was added, so this
commit introduces the parameter 'enable-index-links' which must be set
to 1 to enable these links.

Suggested-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-06-19 00:56:40 +02:00
Lars Hjemli a215bf4620 Change S/L/T to summary/log/tree
In yet another attempt at better usability, the cryptic S/L/T links are
changed to show their full name.

Suggested-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-06-18 22:14:17 +02:00
Lars Hjemli 1f34fb9d4f Change "files" to "tree"
This renames the menu link and the shortcut on the repo index page from
the strange "files" to the more gittish "tree".

Suggested-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-06-18 22:06:00 +02:00
Lars Hjemli 48c487d72d Add git_log_link() and fix bug in generic repolink function
The generic repolink function compared head with cgit_query_head, which
almost always would be the same pointer. The test now compares with
repo.defbranch, which is the wanted behavour.

Bug discovered while adding cgit_log_link(), so this commit also contain
that change.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-06-17 13:57:51 +02:00
Lars Hjemli 44947bfcdc Add and use cgit_tree_link()
This creates a new function used to generate links to 'tree' page and uses
the function everywhere a link to the 'tree' page is generated.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-06-17 01:39:05 +02:00
Lars Hjemli 25da3f7625 Remove unused variable from ui-repolist.c:read_agefile()
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-05-23 19:22:20 +02:00
Lars Hjemli 57f6a8bf0d Show time since last change on index page
When creating the index page, an optional file can be scanned per repository
to obtain a timestamp for last modification within the repo. If such a file
cannot be found, st_mtime for repo.defbranch is used instead.

This information is then printed in a new column, "Idle", using the new
function cgit_print_age().

The new parameter "repo.agefile" can be used to specify (globally) a relative
path to scan (default value is "info/web/last-modified").

The content of the "last-modified" file can be generated by the post-receive
hook with a command like this:

	git-for-each-ref --format="%(committerdate)" --sort=-committerdate \
	--count=1 > $GIT_DIR/info/web/last-modified

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-05-22 23:25:25 +02:00
Lars Hjemli 0b8b6a3176 Make frontpage friendlier
This is an attempt to make the index page more usable by changing how
repo groups and repo links are displayed.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-05-21 00:14:28 +02:00
Lars Hjemli 271ac5a7e6 Merge branch 'repogroups'
* repogroups:
  Adjust apperance of repogroup headers
  Don't highlight repogroup headings
  Teach cgit how to group repositories by category
2007-05-20 22:13:17 +02:00
Lars Hjemli de69ce020c Teach cgit howto include an external file on index page.
The new parameter index-header can be used to name an external file
which will be included verbatim at the top of the index page.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-05-19 00:00:25 +02:00
Lars Hjemli 2aef89e5da Don't highlight repogroup headings
Specify class='nohover' to avoid highlighting this row.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-05-18 23:17:09 +02:00
Lars Hjemli 5877c49f68 Teach cgit how to group repositories by category
The new parameter 'repo.group' is used to set the repository group
for the following repositores. Whenever this parameter changes value,
a subheading is generated in the index page (printing the current value
of repo.group).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-05-18 22:51:18 +02:00
Lars Hjemli c1ad6cb778 Restrict length of repo description on repolist page
If any repo has a very long description, all repos suffer since the
repo-links in the right-most column gets pushed out of sight.

Fix it by introducing max-repodesc-length parameter in cgitrc, and default
to 60 chars.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-05-16 10:46:59 +02:00
Lars Hjemli 8f6f8c3406 Add C D L and T links to index page
These are of course Commit, Diff, Log and Tree pages, all accessed w.o.
specifying refname or sha1.

Sadly, the layout is neither pretty nor accessible.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-05-16 02:16:55 +02:00
Lars Hjemli 66cacd053b Layout update 2007-02-21 00:24:36 +01:00
Lars Hjemli ce1c7336e5 Read repo-info from /etc/cgitrc
This makes cgit read all repo-info from the configfile, instead of scanning for
possible git-dirs below a common root path. This is primarily done to get
better security (separate physical path from logical repo-name).

In /etc/cgitrc each repo is registered with the following keys:

repo.url
repo.name
repo.path
repo.desc
repo.owner

Note:

*Required keys are repo.url and repo.path, all others are optional
*Each occurrence of repo.url starts a new repository registration
*Default value for repo.name is taken from repo.url
*The value of repo.url cannot contain characters with special meaning for
 urls (i.e. one of /?%&), while repo.name can contain anything.

Example:

repo.url=cgit-pub
repo.name=cgit/public
repo.path=/pub/git/cgit
repo.desc=My public cgit repo
repo.owner=Lars Hjemli

repo.url=cgit-priv
repo.name=cgit/private
repo.path=/home/larsh/src/cgit/.git
repo.desc=My private cgit repo
repo.owner=Lars Hjemli

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-02-04 21:47:46 +01:00
Lars Hjemli 777faf7e50 Cleanup table listings
Make the output for <table class='list'> a bit nicer

Signed-off-by: Lars Hjemli <larsh@slaptop.hjemli.net>
2007-01-28 00:52:41 +01:00
Lars Hjemli e39d738c39 Add generic support for search box in page header
This adds the ability to show a search box in any pageheader with correct href and
hidden form data, but does not enable the box on any pages.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2006-12-28 02:01:49 +01:00
Lars Hjemli c43f1246cb Minor style fixes
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2006-12-22 01:44:32 +01:00
Lars Hjemli 74620f12e4 Move functions for repolist output into ui-repolist.c
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2006-12-11 16:49:18 +01:00