summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2007-07-21 11:13:40 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-21 11:13:40 (UTC)
commit0df096f6e146187e55e2203ea1c017442cc2c8c6 (patch) (unidiff)
treec3daea456db5424bbddee326c1479a2b759d551a
parent86ca02231fc42a629c50abebcae3ea9d4d692979 (diff)
downloadcgit-0df096f6e146187e55e2203ea1c017442cc2c8c6.zip
cgit-0df096f6e146187e55e2203ea1c017442cc2c8c6.tar.gz
cgit-0df096f6e146187e55e2203ea1c017442cc2c8c6.tar.bz2
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>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.h2
-rw-r--r--ui-shared.c17
-rw-r--r--ui-snapshot.c2
3 files changed, 16 insertions, 5 deletions
diff --git a/cgit.h b/cgit.h
index 6937c42..aabf725 100644
--- a/cgit.h
+++ b/cgit.h
@@ -198,12 +198,14 @@ extern int cache_lock(struct cacheitem *item);
198extern int cache_unlock(struct cacheitem *item); 198extern int cache_unlock(struct cacheitem *item);
199extern int cache_cancel_lock(struct cacheitem *item); 199extern int cache_cancel_lock(struct cacheitem *item);
200extern int cache_exist(struct cacheitem *item); 200extern int cache_exist(struct cacheitem *item);
201extern int cache_expired(struct cacheitem *item); 201extern int cache_expired(struct cacheitem *item);
202 202
203extern char *cgit_repourl(const char *reponame); 203extern char *cgit_repourl(const char *reponame);
204extern char *cgit_fileurl(const char *reponame, const char *pagename,
205 const char *filename, const char *query);
204extern char *cgit_pageurl(const char *reponame, const char *pagename, 206extern char *cgit_pageurl(const char *reponame, const char *pagename,
205 const char *query); 207 const char *query);
206 208
207extern void cgit_tree_link(char *name, char *title, char *class, char *head, 209extern void cgit_tree_link(char *name, char *title, char *class, char *head,
208 char *rev, char *path); 210 char *rev, char *path);
209extern void cgit_log_link(char *name, char *title, char *class, char *head, 211extern void cgit_log_link(char *name, char *title, char *class, char *head,
diff --git a/ui-shared.c b/ui-shared.c
index d4376ce..1c1415e 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -54,30 +54,37 @@ char *cgit_repourl(const char *reponame)
54 return fmt("%s/%s/", cgit_virtual_root, reponame); 54 return fmt("%s/%s/", cgit_virtual_root, reponame);
55 } else { 55 } else {
56 return fmt("?r=%s", reponame); 56 return fmt("?r=%s", reponame);
57 } 57 }
58} 58}
59 59
60char *cgit_pageurl(const char *reponame, const char *pagename, 60char *cgit_fileurl(const char *reponame, const char *pagename,
61 const char *query) 61 const char *filename, const char *query)
62{ 62{
63 if (cgit_virtual_root) { 63 if (cgit_virtual_root) {
64 if (query) 64 if (query)
65 return fmt("%s/%s/%s/?%s", cgit_virtual_root, reponame, 65 return fmt("%s/%s/%s/%s?%s", cgit_virtual_root, reponame,
66 pagename, query); 66 pagename, filename?filename:"", query);
67 else 67 else
68 return fmt("%s/%s/%s/", cgit_virtual_root, reponame, 68 return fmt("%s/%s/%s/", cgit_virtual_root, reponame,
69 pagename); 69 pagename);
70 } else { 70 } else {
71 if (query) 71 if (query)
72 return fmt("?r=%s&amp;p=%s&amp;%s", reponame, pagename, query); 72 return fmt("?r=%s&amp;p=%s&amp;%s", reponame, pagename, query);
73 else 73 else
74 return fmt("?r=%s&amp;p=%s", reponame, pagename); 74 return fmt("?r=%s&amp;p=%s", reponame, pagename);
75 } 75 }
76} 76}
77 77
78char *cgit_pageurl(const char *reponame, const char *pagename,
79 const char *query)
80{
81 return cgit_fileurl(reponame,pagename,0,query);
82}
83
84
78char *cgit_currurl() 85char *cgit_currurl()
79{ 86{
80 if (!cgit_virtual_root) 87 if (!cgit_virtual_root)
81 return cgit_script_name; 88 return cgit_script_name;
82 else if (cgit_query_page) 89 else if (cgit_query_page)
83 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page); 90 return fmt("%s/%s/%s/", cgit_virtual_root, cgit_query_repo, cgit_query_page);
@@ -365,6 +372,8 @@ void cgit_print_snapshot_start(const char *mimetype, const char *filename,
365 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename); 372 htmlf("Content-Disposition: inline; filename=\"%s\"\n", filename);
366 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); 373 htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime));
367 htmlf("Expires: %s\n", http_date(item->st.st_mtime + 374 htmlf("Expires: %s\n", http_date(item->st.st_mtime +
368 ttl_seconds(item->ttl))); 375 ttl_seconds(item->ttl)));
369 html("\n"); 376 html("\n");
370} 377}
378
379/* vim:set sw=8: */
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 84bf8f7..7076b50 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -106,11 +106,11 @@ void cgit_print_snapshot_links(const char *repo,const char *hex)
106 char *filename; 106 char *filename;
107 int f; 107 int f;
108 for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) { 108 for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) {
109 const struct snapshot_archive_t* sat = &snapshot_archives[f]; 109 const struct snapshot_archive_t* sat = &snapshot_archives[f];
110 filename = fmt("%s-%s%s",repo,hex,sat->suffix); 110 filename = fmt("%s-%s%s",repo,hex,sat->suffix);
111 htmlf("<a href='%s'>%s</a><br/>", 111 htmlf("<a href='%s'>%s</a><br/>",
112 cgit_pageurl(repo,"snapshot", 112 cgit_fileurl(repo,"snapshot",filename,
113 fmt("id=%s&amp;name=%s",hex,filename)), filename); 113 fmt("id=%s&amp;name=%s",hex,filename)), filename);
114 } 114 }
115} 115}
116/* vim:set sw=8: */ 116/* vim:set sw=8: */