Author: Michael Krelin <hacker@klever.net>
added snapshot filename to the link - changed cgit_pageurl into cgit_fileurl with the filename parameter - rewritten cgit_pageurl as a wrapper around cgit_fileurl Signed-off-by: Michael Krelin <hacker@klever.net>
cgit.h | 2 ++ ui-shared.c | 17 +++++++++++++---- ui-snapshot.c | 2 +-
diff --git a/cgit.h b/cgit.h index 6937c42900eea20c5e9824974aa9eccbb68f814b..aabf7252af6bff743e18de9e028b9b5e23bf81e8 100644 --- a/cgit.h +++ b/cgit.h @@ -201,6 +201,8 @@ extern int cache_exist(struct cacheitem *item); extern int cache_expired(struct cacheitem *item); extern char *cgit_repourl(const char *reponame); +extern char *cgit_fileurl(const char *reponame, const char *pagename, + const char *filename, const char *query); extern char *cgit_pageurl(const char *reponame, const char *pagename, const char *query); diff --git a/ui-shared.c b/ui-shared.c index d4376cef5823f403ccd30707abc985ef76c2e6fb..1c1415e4f4d9934d60c6237be7105f58852eb73b 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -57,13 +57,13 @@ return fmt("?r=%s", reponame); } } -char *cgit_pageurl(const char *reponame, const char *pagename, - const char *query) +char *cgit_fileurl(const char *reponame, const char *pagename, + const char *filename, const char *query) { if (cgit_virtual_root) { if (query) - return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame, - pagename, query); + return fmt("%s/%s/%s/%s?%s", cgit_virtual_root, reponame, + pagename, filename?filename:"", query); else return fmt("%s/%s/%s/", cgit_virtual_root, reponame, pagename); @@ -74,6 +74,13 @@ else return fmt("?r=%s&p=%s", reponame, pagename); } } + +char *cgit_pageurl(const char *reponame, const char *pagename, + const char *query) +{ + return cgit_fileurl(reponame,pagename,0,query); +} + char *cgit_currurl() { @@ -368,3 +375,5 @@ htmlf("Expires: %s\n", http_date(item->st.st_mtime + ttl_seconds(item->ttl))); html("\n"); } + +/* vim:set sw=8: */ diff --git a/ui-snapshot.c b/ui-snapshot.c index 84bf8f7c1a9f9c87a8c84668ee33a5c685842128..7076b500fdc52581e573cd70b665e9cafa879a66 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -109,7 +109,7 @@ for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) { const struct snapshot_archive_t* sat = &snapshot_archives[f]; filename = fmt("%s-%s%s",repo,hex,sat->suffix); htmlf("<a href='%s'>%s</a><br/>", - cgit_pageurl(repo,"snapshot", + cgit_fileurl(repo,"snapshot",filename, fmt("id=%s&name=%s",hex,filename)), filename); } }