aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
Commit message (Expand)AuthorAgeFilesLines
* ui-shared: move about tab all the way to the left•••There were no objections (at the time of committing this): http://lists.zx2c4.com/pipermail/cgit/2013-May/001393.html http://lists.zx2c4.com/pipermail/cgit/2014-January/001904.html Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Jason A. Donenfeld2014-01-171-4/+4
* Switch to exclusively using global ctx•••Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_print_http_headers() * cgit_print_docstart() * cgit_print_pageheader() Remove context parameter from all commands Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_get_cmd() * All cgit command functions. * cgit_clone_info() * cgit_clone_objects() * cgit_clone_head() * cgit_print_plain() * cgit_show_stats() In initialization routines, use the global context variable instead of passing a pointer around locally. Remove callback data parameter for cache slots This is no longer needed since the context is always read from the global context variable. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2014-01-171-151/+150
* auth: have cgit calculate login address•••This way we're sure to use virtual root, or any other strangeness encountered. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Jason A. Donenfeld2014-01-161-0/+8
* auth: add basic authentication filter framework•••This leverages the new lua support. See filters/simple-authentication.lua for explaination of how this works. There is also additional documentation in cgitrc.5.txt. Though this is a cookie-based approach, cgit's caching mechanism is preserved for authenticated pages. Very plugable and extendable depending on user needs. The sample script uses an HMAC-SHA1 based cookie to store the currently logged in user, with an expiration date. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Jason A. Donenfeld2014-01-161-12/+16
* ui-shared: URL-escape script_name•••As far as I know, there is no requirement that $SCRIPT_NAME contain only URL-safe characters, so we need to make sure that any special characters are escaped. Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2014-01-121-2/+2
* Replace most uses of strncmp() with prefixcmp()•••This is a preparation for replacing all prefix checks with either strip_prefix() or starts_with() when Git 1.8.6 is released. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2014-01-101-1/+1
* Update copyright information•••* Name "cgit Development Team" as copyright holder to avoid listing every single developer. * Update copyright ranges. Signed-off-by: Lukas Fleischer <cgit@crytocrack.de> Lukas Fleischer2014-01-081-1/+1
* ui-shared: Drop filepair_cb_raw() and helper•••Remove filepair_cb_raw() and all related functions. These are no longer needed. We now use Git's internal functions for raw diff formatting everywhere. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-09-141-72/+0
* Extract filepair_cb from ui-patch.c•••Move filepair_cb() from ui-patch.c to ui-shared.c and rename it to filepair_cb_raw(). This callback will be used in ui-diff.c in a follow-up patch. Note that it is not straightforward to extract filepair_cb() from ui-diff.c which is why it is not done here as well. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-08-161-0/+72
* readme: use string_list instead of space deliminations•••Now this is possible in cgitrc - readme=:README.md readme=:readme.md readme=:README.mkd readme=:readme.mkd readme=:README.rst readme=:readme.rst readme=:README.html readme=:readme.html readme=:README.htm readme=:readme.htm readme=:README.txt readme=:readme.txt readme=:README readme=:readme readme=:INSTALL.txt readme=:install.txt readme=:INSTALL readme=:install Suggested-by: John Keeping <john@keeping.me.uk> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Jason A. Donenfeld2013-05-261-1/+1
* use struct strbuf instead of static buffers•••Use "struct strbuf" from Git to remove the limit on file path length. Notes on scan-tree: This is slightly involved since I decided to pass the strbuf into add_repo() and modify if whenever a new file name is required, which should avoid any extra allocations within that function. The pattern there is to append the filename, use it and then reset the buffer to its original length (retaining a trailing '/'). Notes on ui-snapshot: Since write_archive modifies the argv array passed to it we copy the argv_array values into a new array of char* and then free the original argv_array structure and the new array without worrying about what the values now look like. Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2013-04-081-28/+35
* Convert cgit_print_error to a variadic function•••This removes many uses of "fmt" which uses a fixed size static pool of fixed size buffers. Instead of relying on these, we now pass around argument lists for as long as possible before using a strbuf to render content of an arbitrary size. Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2013-04-081-2/+13
* Fix out-of-bounds memory accesses with virtual_root=""•••The CGit configuration variable virtual_root is normalized so that it does not have a trailing '/' character, but it is allowed to be empty (the empty string and NULL have different meanings here) and there is code that is insufficiently cautious when checking if it ends in a '/': if (virtual_root[strlen(virtual_root) - 1] != '/') Clearly this check is redundant, but rather than simply removing it we get a slight efficiency improvement by switching the normalization so that the virtual_root variable always ends in '/'. Do this with a new "ensure_end" helper. Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2013-04-081-9/+5
* Always #include corresponding .h in .c files•••While doing this, remove declarations from header files where the corresponding definition is declared "static" in order to avoid build errors. Also re-order existing headers in ui-*.c so that the file-specific header always comes immediately after "cgit.h", helping with future consistency. Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2013-04-081-0/+1
* Return const char * in cgit_{httpscheme, hosturl, rooturl}()•••The return values of these functions are essentially constant and should never be modified. Note that this will introduce a compiler warning when we try to free the return value of any of these functions. However, given that all of these currently return statically allocated strings in some cases, they need to be refactored before this can be done anyway. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-04-081-4/+4
* ui-shared: squelch compiler warning.•••Since tail is initialized to 0, we will never get a warning on the last if statement, but recent gcc complains anyway. So, we initialize len as well. Future gcc versions should be able to optimize this out anyway. Jason A. Donenfeld2013-03-201-0/+1
* Merge branch 'wip'Jason A. Donenfeld2013-03-201-57/+7
|\
| * cgit_print_snapshot_links(): Free prefix variable•••Fixes following memory leak seen with "PATH_INFO=/cgit/commit/": ==16894== 12 bytes in 1 blocks are definitely lost in loss record 9 of 92 ==16894== at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==16894== by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so) ==16894== by 0x46CAC8: xstrdup (wrapper.c:35) ==16894== by 0x414E34: cgit_print_snapshot_links (ui-shared.c:926) ==16894== by 0x40CFA1: cgit_print_commit (ui-commit.c:102) ==16894== by 0x407B06: commit_fn (cmd.c:54) ==16894== by 0x405E16: process_request (cgit.c:574) ==16894== by 0x4074C8: cache_process (cache.c:322) ==16894== by 0x406C4F: main (cgit.c:872) Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-03-041-0/+1
| * ui-shared.c: Remove unused function print_archive_ref()•••This is no longer used as of commit f135569b. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-03-041-39/+0
| * ui-shared.c: Remove unused function cgit_currurl()•••This is no longer used as of commit 0c8e184e. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-03-041-12/+0
| * Mark several functions/variables static•••Spotted by parsing the output of `gcc -Wmissing-prototypes [...]`. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-03-041-9/+9
* | ui-shared: fix return type of cgit_self_link•••cgit_self_link() is a void function but implements each case it handles by doing "return <another_void_function>" which is not valid C; section 6.8.6.4 of C11 says: A return statement with an expression shall not appear in a function whose return type is void. Fix this by removing the return keywords and converting the final code block into an "else". Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2013-03-201-41/+42
|/
* White space around control verbs.•••Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Jason A. Donenfeld2013-03-041-6/+6
* Fix several whitespace errors•••* Remove whitespace at the end of lines. * Replace space indentation by tabs. * Add whitespace before/after several operators ("+", "-", "*", ...) * Add whitespace to assignments ("foo = bar;"). * Fix whitespace in parameter lists ("foobar(foo, bar, 42)"). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-03-041-9/+9
* Print submodule revision next to submodule linkstfn2013-03-021-0/+1
* ui-shared: use placeholder for empty commit subject•••Display a placeholder when creating links to commits with empty subjects. This avoids the creation of links of the form <a></a>. Christian Franke2012-10-281-1/+4
* ui: Remember to print ampersand as proper html entities.William Bell2012-10-171-7/+7
* Merge branch 'lh/module-links'Lars Hjemli2012-03-181-0/+56
|\
| * ui-tree.c: add support for path-selected submodule links•••The current 'repo.module-link' option is sufficient when all gitlinks in a repository can be converted to commit links in a uniform way, but not when different submodules/paths needs different settings. This patch adds support for 'repo.module-link.<path>', which will be used for linking to submodules at paths matching one such entry. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Lars Hjemli2011-06-151-0/+56
* | segfault fix on some bogus requests•••ctx.qry.head can be NULL in some cases due to bad requests by weird bots. I managed to reproduce with: PATH_INFO=/repo.git/shop.php QUERY_STRING=id= Signed-off-by: Eric Wong <normalperson@yhbt.net> Eric Wong2012-03-181-2/+2
* | Fix segmentation fault in empty repository•••When a repository is empty, the ATOM feed link is written in the header, but this involves formatting ctx->qry.head which is NULL in this case. With glibc, vsnprintf formats "%s" with a NULL input as "(null)" but on Solaris this results in a segmentation fault. Since we don't have a meaningful head for the atom feed in an empty repository, it's simplest not to write out the link element at all. Signed-off-by: John Keeping <john@metanate.com> John Keeping2012-01-031-1/+1
* | 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. Tobias Grimm2012-01-031-9/+15
|/
* Merge branch 'stable'Lars Hjemli2011-03-051-1/+1
|\
| * ui-shared: silence warning•••warning: format ‘%ld’ expects type ‘long int’, but argument 2 has type ‘size_t’ Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Bernhard Reutner-Fischer2011-02-191-1/+1
* | implement repo.logo and repo.logo-link•••Allow for per repo logo and logo-link; Use global logo and logo-link per default. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Bernhard Reutner-Fischer2011-02-191-4/+14
* | Merge branch 'jh/ignorews'Lars Hjemli2010-07-181-0/+10
|\ \
| * | ui-diff: Add link to ignore/show whitespace changes in diffs•••Add a link to the "Diffstat" line to ignore/show whitespace changes in the generated diff. To support this, cgit_commit_link() and cgit_diff_link() has learned to preserve the ctx.qry.ignorews variable. Signed-off-by: Johan Herland <johan@herland.net> Johan Herland2010-07-181-0/+10
* | | Merge branch 'lh/range-search'Lars Hjemli2010-06-221-0/+1
|\ \ \ | |/ / |/| |
| * | ui-log.c: allow commit range as search expression•••Inspired-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Lars Hjemli2010-06-191-0/+1
* | | ui-diff: Add links to increase/decrease number of context lines in diffs•••Add two links to the "Diffstat" line to show more/less context lines in the generated diff. To support this, cgit_commit_link() and cgit_diff_link() has learned to preserve the ctx.qry.context variable. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-0/+14
* | | ui-shared: Preserve path limit in "tab bar" links•••When using the "tab bar" in the pageheader to navigate between pages, any path limit in effect on the current page is forgotten in the link to the target page, even if the target page can interpret and use the path limit constructively. Instead, preserve the current page's path limit in the "tab bar" links to other pages, where the path limit is useful to the target page. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-5/+6
* | | ui-commit: Preserve path limit in links to commit page•••This includes adding a path argument to cgit_commit_link() and updating all its callers. The callers from within the commit page (i.e. the "commit", "unidiff"/"side-by-side diff" and "parent" links) all preserve the path limit of the current commit page. All other callers pass NULL (i.e. no path limit). Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-4/+5
* | | ui-patch: Apply path limit to generated patch•••Also indicate in the comment section of the patch that a path limit was applied, too easily see when a generated patch is only partial. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-2/+2
* | | ui-shared: Teach "breadcrumb" navigation to path limit display beneath tab bar•••When a path limit is in effect, and displayed directly beneath the tab bar, it should offer breadcrumb navigation (like what the 'tree' page does), to allow changing the path limit easily. Implementing this requires a robust way to link back to the current page with a changed ctx->qry.path, but without losing track of the other query arguments. This is solved by adding the new cgit_self_link() function, which is then invoked repeatedly by the new cgit_print_path_crumbs() function while manipulating ctx->qry.path. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-1/+80
* | | ui-shared: Display path limit directly beneath tab bar in relevant pages•••Design-wise, the path is shown by "expanding" the grey border between the tab bar and the content area of the page to house the current path limit. This is only displayed on pages where the path limit is relevant, and only when a path limit is in effect. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-0/+6
* | | ui-shared: Replace ctx.qry.path with ctx.qry.vpath•••In all cases where ui-shared uses ctx.qry.path, it is done so in the context of a in-project path, and not in the context in which the 'refs' page or the 'clone'-related functionality uses ctx.qry.path. Make this explicit by using ctx.qry.vpath instead. This path introduces no fundamental difference in functionality except for fixing some minor bugs, for example the Atom feed reference from a "$repo/refs/heads/" page. Note that the usage of ctx.qry.path in the other ui-<page>.c files is ok, since that code presumably is only executed in the context of its own <page>, so the correct interpretation of ctx.qry.path is never in question. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-4/+4
* | | ui-shared: Remove needless cgit_get_cmd() call, and refactor hc() accordingly•••The call to cgit_get_cmd() and the following fallback handling (to "summary" or "repoindex") in cgit_print_pageheader() is unnecessary, since the same fallback handling was already done when ctx.qry.page was set when cgit_get_cmd() was called from process_request() in cgit.c. As such, hc() can also be rewritten to simply compare the given 'page' string against ctx.qry.page. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-19/+12
* | | ui-shared: Improve const-ness in API•••This is needed to prevent const-related warnings in later patches. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-36/+40
|/ /
* | Merge branch 'stable'Lars Hjemli2010-02-271-2/+2
|\|
| * ui-shared.c: fix segfault when repo is empty•••PATH_INFO="/$REPONAME/commit/?id=1" QUERY_STRING="id=1" ./cgit.cgi triggers segfault when the repository is empty and therefore ctx.qry.head is unset Signed-off-by: Florian Pritz <bluewind@xssn.at> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Florian Pritz2010-02-271-2/+2