summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
authorLars Hjemli <hjemli@gmail.com>2007-06-17 12:53:02 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2007-06-17 12:53:02 (UTC)
commit42a7eb9c73457319a3fd5441ff26046fc9b31dad (patch) (side-by-side diff)
tree4771b955e031005e7c222ef0cbabb719f7cd003a /ui-shared.c
parent48c487d72daef7e71683a85f775db8d36ab20341 (diff)
downloadcgit-42a7eb9c73457319a3fd5441ff26046fc9b31dad.zip
cgit-42a7eb9c73457319a3fd5441ff26046fc9b31dad.tar.gz
cgit-42a7eb9c73457319a3fd5441ff26046fc9b31dad.tar.bz2
Add cgit_commit_link() + support for id=sha1 to commit view
This adds a function to generate links to the commit page and extends said page to use id from querystring as primary revision specified (fallback to h). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 64ee79c..71c899a 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -131,18 +131,18 @@ static char *repolink(char *title, char *class, char *page, char *head,
html(delim);
html("h=");
html_attr(head);
delim = "&amp;";
}
return fmt("%s", delim);
}
-static char *reporevlink(char *page, char *name, char *title, char *class,
- char *head, char *rev, char *path)
+static void reporevlink(char *page, char *name, char *title, char *class,
+ char *head, char *rev, char *path)
{
char *delim;
delim = repolink(title, class, page, head, path);
if (rev && strcmp(rev, cgit_query_head)) {
html(delim);
html("id=");
html_attr(rev);
@@ -159,16 +159,28 @@ void cgit_tree_link(char *name, char *title, char *class, char *head,
}
void cgit_log_link(char *name, char *title, char *class, char *head,
char *rev, char *path)
{
reporevlink("log", name, title, class, head, rev, path);
}
+void cgit_commit_link(char *name, char *title, char *class, char *head,
+ char *rev)
+{
+ if (strlen(name) > cgit_max_msg_len && cgit_max_msg_len >= 15) {
+ name[cgit_max_msg_len] = '\0';
+ name[cgit_max_msg_len - 1] = '.';
+ name[cgit_max_msg_len - 2] = '.';
+ name[cgit_max_msg_len - 3] = '.';
+ }
+ reporevlink("commit", name, title, class, head, rev, NULL);
+}
+
void cgit_print_date(time_t secs, char *format)
{
char buf[64];
struct tm *time;
time = gmtime(&secs);
strftime(buf, sizeof(buf)-1, format, time);
html_txt(buf);