aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
AgeCommit message (Collapse)AuthorFilesLines
2015-03-13Remove no-op link from submodule entriesLukas Fleischer1-17/+24
Instead of linking to the current page ("href='#'"), do not add a link to a submodule entry at all if the module-link setting is not used. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2015-03-09ui-shared: currenturl should take into account leading slashJason A. Donenfeld1-1/+5
2015-03-09ui-shared: don't use an integer as a NULL pointerJohn Keeping1-1/+1
Signed-off-by: John Keeping <john@keeping.me.uk>
2015-03-09ui-shared: avoid initializing static variable to zeroJohn Keeping1-1/+1
Sparse complains that we are using a plain integer as a NULL pointer here, but in fact we do not have to specify a value for this variable at all since it has static storage duration and thus will be initialized to NULL by the compiler. Signed-off-by: John Keeping <john@keeping.me.uk>
2015-03-09ui-shared: make cgit_doctype 'static'John Keeping1-1/+1
This is not used outside this file and is not declared. Signed-off-by: John Keeping <john@keeping.me.uk>
2015-03-09Avoid non-ANSI function declarationsJohn Keeping1-6/+6
Sparse says things like: warning: non-ANSI function declaration of function 'calc_ttl' Signed-off-by: John Keeping <john@keeping.me.uk>
2015-03-03Make root handling sane again.Jason A. Donenfeld1-12/+12
2015-03-03ui-shared: Add current url helper function.Jason A. Donenfeld1-2/+9
2015-03-03ui-shared: keep filter repolist page in paginationJason A. Donenfeld1-3/+3
2015-03-03ui-repolist: use ctx.qry.url instead of rooturl, in case we're filteringJason A. Donenfeld1-1/+1
2015-02-05ui-shared.c: Refactor add_clone_urls()Lukas Fleischer1-22/+10
Make use of strbuf_split_str() and strbuf lists to split clone URLs. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2015-01-19tag: reference with "h" instead of "id"masterJohn Keeping1-4/+4
When clicking on "log" from a tag we end up showing the log of whatever branch we used to reach the tag. If the tag doesn't point onto a branch then the tagged commit won't appear in this output. By linking to tags with the head parameter instead of the "id" parameter the log link will show the log of the tag. This is clearly desirable when the tag has been reached from the refs UI and changing the behaviour for tag decorations makes them match branch decorations where log -> decoration -> log shows the log of the decoration. Reported-by: Ferry Huberts <mailings@hupie.com> Signed-off-by: John Keeping <john@keeping.me.uk>
2014-12-24footer: link back to cgit home pageJason A. Donenfeld1-1/+1
The footer has always been overrideable using the footer= in cgitrc, so this won't anger anybody who cares about their footer.
2014-12-24ui-shared: show absolute time in tooltip for relative datesJohn Keeping1-12/+23
Signed-off-by: John Keeping <john@keeping.me.uk>
2014-12-24ui-shared: add rel-vcs microformat links to HTML headerJohn Keeping1-0/+11
As described at https://joeyh.name/rfc/rel-vcs/. Signed-off-by: John Keeping <john@keeping.me.uk>
2014-12-24Extract clone URL printing to ui-shared.cJohn Keeping1-0/+37
This will allow us to reuse the same logic to add clone URL <link/> elements to the header of all repo-specific pages in order to support the rel-vcs microformat. Signed-off-by: John Keeping <john@keeping.me.uk>
2014-12-13Change "ss" diff flag to an enumJohn Keeping1-4/+4
This will allow us to introduce a new "stat only" diff mode without needing an explosion of mutually incompatible flags. The old "ss" query parameter is still accepted in order to avoid breaking saved links, but we no longer generate any URIs using it; instead the new "dt" (diff type) parameter is used. Signed-off-by: John Keeping <john@keeping.me.uk>
2014-12-13ui-shared: remove toggle_ssdiff arg to cgit_diff_link()John Keeping1-4/+4
This argument is never used with a value other than zero, so remove it and simplify the code. Signed-off-by: John Keeping <john@keeping.me.uk>
2014-12-13ui-shared: remove toggle_ssdiff arg to cgit_commit_link()John Keeping1-6/+5
This argument is never used with a value other than zero, so remove it and simplify the code. Signed-off-by: John Keeping <john@keeping.me.uk>
2014-06-28git: update for git 2.0Christian Hesse1-1/+1
prefixcmp() and suffixcmp() have been remove, functionality is now provided by starts_with() and ends_with(). Retrurn values have been changed, so instead of just renaming we have to fix logic. Everything else looks just fine.
2014-01-17ui-shared: do not allow negative minutesJason A. Donenfeld1-0/+2
Do to timestamp differences, sometimes cgit would should "-0 min", which doesn't make any sense. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2014-01-17ui-shared: move about tab all the way to the leftJason A. Donenfeld1-4/+4
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>
2014-01-17Switch to exclusively using global ctxLukas Fleischer1-152/+151
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>
2014-01-16auth: have cgit calculate login addressJason A. Donenfeld1-0/+8
This way we're sure to use virtual root, or any other strangeness encountered. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2014-01-16auth: add basic authentication filter frameworkJason A. Donenfeld1-12/+16
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>
2014-01-12ui-shared: URL-escape script_nameJohn Keeping1-2/+2
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>
2014-01-10Replace most uses of strncmp() with prefixcmp()Lukas Fleischer1-1/+1
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>
2014-01-08Update copyright informationLukas Fleischer1-1/+1
* Name "cgit Development Team" as copyright holder to avoid listing every single developer. * Update copyright ranges. Signed-off-by: Lukas Fleischer <cgit@crytocrack.de>
2013-09-14ui-shared: Drop filepair_cb_raw() and helperLukas Fleischer1-72/+0
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>
2013-08-16Extract filepair_cb from ui-patch.cLukas Fleischer1-0/+72
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>
2013-05-26readme: use string_list instead of space deliminationsJason A. Donenfeld1-1/+1
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>
2013-04-08use struct strbuf instead of static buffersJohn Keeping1-28/+35
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>
2013-04-08Convert cgit_print_error to a variadic functionJohn Keeping1-2/+13
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>
2013-04-08Fix out-of-bounds memory accesses with virtual_root=""John Keeping1-9/+5
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>
2013-04-08Always #include corresponding .h in .c filesJohn Keeping1-0/+1
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>
2013-04-08Return const char * in cgit_{httpscheme, hosturl, rooturl}()Lukas Fleischer1-4/+4
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>
2013-03-20ui-shared: squelch compiler warning.Jason A. Donenfeld1-0/+1
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.
2013-03-20Merge branch 'wip'Jason A. Donenfeld1-57/+7
2013-03-20ui-shared: fix return type of cgit_self_linkJohn Keeping1-41/+42
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>
2013-03-05cgit_print_snapshot_links(): Free prefix variableLukas Fleischer1-0/+1
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>
2013-03-05ui-shared.c: Remove unused function print_archive_ref()Lukas Fleischer1-39/+0
This is no longer used as of commit f135569b. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-05ui-shared.c: Remove unused function cgit_currurl()Lukas Fleischer1-12/+0
This is no longer used as of commit 0c8e184e. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-05Mark several functions/variables staticLukas Fleischer1-9/+9
Spotted by parsing the output of `gcc -Wmissing-prototypes [...]`. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04White space around control verbs.Jason A. Donenfeld1-6/+6
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2013-03-04Fix several whitespace errorsLukas Fleischer1-9/+9
* 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>
2013-03-02Print submodule revision next to submodule linkstfn1-0/+1
2012-10-28ui-shared: use placeholder for empty commit subjectChristian Franke1-1/+4
Display a placeholder when creating links to commits with empty subjects. This avoids the creation of links of the form <a></a>.
2012-10-17ui: Remember to print ampersand as proper html entities.William Bell1-7/+7
2012-03-18Merge branch 'lh/module-links'Lars Hjemli1-0/+56
2012-03-18segfault fix on some bogus requestsEric Wong1-2/+2
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>