Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Introducing the /fileedit page. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
1243bf39996b8a654bb4ab3c90d89bbc |
| User & Date: | stephan 2020-05-28 09:40:35.377 |
References
|
2022-02-09
| ||
| 19:29 | Fix a bug in the <tt>blob_reserve()</tt> function that was introduced by [1243bf39996b8a]. The <i>current</i> mainline is not affected because this function is not used anywhere. However it was causing memory corruption on the 'markdown-footnotes' branch since it was employed in [544df852b2d9a1]. check-in: 7283ae6e12 user: george tags: markdown-footnotes | |
Context
|
2020-05-28
| ||
| 09:47 | Added /fileedit to changes.wiki. check-in: 2c9aa1b939 user: stephan tags: trunk | |
| 09:40 | Introducing the /fileedit page. check-in: 1243bf3999 user: stephan tags: trunk | |
| 09:18 | Reworked how style.css is emitted: all default rules first, then page-specific rules (if passed name=PAGENAME and if builtin file style.PAGENAME.css exists), then the skin. This increases the default style.css output by only approx. 800 bytes before compression (approx. 300 after compression). Has no visual impact on existing built-in skins, and none is expected on 3rd-party skin edits. See [https://fossil-scm.org/forum/forumpost/d63ff33063|/forumpost/d63ff33063] for discussion. check-in: 064c1c9588 user: stephan tags: trunk | |
|
2020-05-27
| ||
| 07:56 | s/checkin/check-in/ in the help tab, per forum feedback. Closed-Leaf check-in: 91948d3afa user: stephan tags: fileedit-ajaxify | |
Changes
Changes to src/blob.c.
| ︙ | ︙ | |||
475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
** nByte in size. The blob is truncated if necessary.
*/
void blob_resize(Blob *pBlob, unsigned int newSize){
pBlob->xRealloc(pBlob, newSize+1);
pBlob->nUsed = newSize;
pBlob->aData[newSize] = 0;
}
/*
** Make sure a blob is nul-terminated and is not a pointer to unmanaged
** space. Return a pointer to the data.
*/
char *blob_materialize(Blob *pBlob){
blob_resize(pBlob, pBlob->nUsed);
| > > > > > > > > > > > > | 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 |
** nByte in size. The blob is truncated if necessary.
*/
void blob_resize(Blob *pBlob, unsigned int newSize){
pBlob->xRealloc(pBlob, newSize+1);
pBlob->nUsed = newSize;
pBlob->aData[newSize] = 0;
}
/*
** Ensures that the given blob has at least the given amount of memory
** allocated to it. Does not modify pBlob->nUsed nor will it reduce
** the currently-allocated amount of memory.
*/
void blob_reserve(Blob *pBlob, unsigned int newSize){
if(newSize>pBlob->nUsed){
pBlob->xRealloc(pBlob, newSize);
pBlob->aData[newSize] = 0;
}
}
/*
** Make sure a blob is nul-terminated and is not a pointer to unmanaged
** space. Return a pointer to the data.
*/
char *blob_materialize(Blob *pBlob){
blob_resize(pBlob, pBlob->nUsed);
|
| ︙ | ︙ | |||
1165 1166 1167 1168 1169 1170 1171 |
blob_reset(&b1);
blob_reset(&b2);
blob_reset(&b3);
}
fossil_print("ok\n");
}
| < | 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 |
blob_reset(&b1);
blob_reset(&b2);
blob_reset(&b3);
}
fossil_print("ok\n");
}
/*
** Convert every \n character in the given blob into \r\n.
*/
void blob_add_cr(Blob *p){
char *z = p->aData;
int j = p->nUsed;
int i, n;
|
| ︙ | ︙ | |||
1189 1190 1191 1192 1193 1194 1195 |
z[j] = 0;
while( j>i ){
if( (z[--j] = z[--i]) =='\n' ){
z[--j] = '\r';
}
}
}
| < | 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 |
z[j] = 0;
while( j>i ){
if( (z[--j] = z[--i]) =='\n' ){
z[--j] = '\r';
}
}
}
/*
** Remove every \r character from the given blob, replacing each one with
** a \n character if it was not already part of a \r\n pair.
*/
void blob_to_lf_only(Blob *p){
int i, j;
|
| ︙ | ︙ |
Changes to src/cgi.c.
| ︙ | ︙ | |||
62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #define PD(x,y) cgi_parameter((x),(y)) #define PT(x) cgi_parameter_trimmed((x),0) #define PDT(x,y) cgi_parameter_trimmed((x),(y)) #define PB(x) cgi_parameter_boolean(x) #define PCK(x) cgi_parameter_checked(x,1) #define PIF(x,y) cgi_parameter_checked(x,y) /* ** Destinations for output text. */ #define CGI_HEADER 0 #define CGI_BODY 1 | > > > > > > > > > > > | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #define PD(x,y) cgi_parameter((x),(y)) #define PT(x) cgi_parameter_trimmed((x),0) #define PDT(x,y) cgi_parameter_trimmed((x),(y)) #define PB(x) cgi_parameter_boolean(x) #define PCK(x) cgi_parameter_checked(x,1) #define PIF(x,y) cgi_parameter_checked(x,y) /* ** Shortcut for the cgi_printf() routine. Instead of using the ** ** @ ... ** ** notation provided by the translate.c utility, you can also ** optionally use: ** ** CX(...) */ #define CX cgi_printf /* ** Destinations for output text. */ #define CGI_HEADER 0 #define CGI_BODY 1 |
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 |
g.aCommitFile[jj++] = ii;
}
g.aCommitFile[jj] = 0;
bag_clear(&toCommit);
}
return result;
}
/*
** Make sure the current check-in with timestamp zDate is younger than its
** ancestor identified rid and zUuid. Throw a fatal error if not.
*/
static void checkin_verify_younger(
int rid, /* The record ID of the ancestor */
const char *zUuid, /* The artifact ID of the ancestor */
const char *zDate /* Date & time of the current check-in */
){
#ifndef FOSSIL_ALLOW_OUT_OF_ORDER_DATES
| > > > > > > > > > > > > > > > > > > < < < < < | < < > > | 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 |
g.aCommitFile[jj++] = ii;
}
g.aCommitFile[jj] = 0;
bag_clear(&toCommit);
}
return result;
}
/*
** Returns true if the checkin identified by the first parameter is
** older than the given (valid) date/time string, else returns false.
** Also returns true if rid does not refer to a checkin, but it is not
** intended to be used for that case.
*/
int checkin_is_younger(
int rid, /* The record ID of the ancestor */
const char *zDate /* Date & time of the current check-in */
){
return db_exists(
"SELECT 1 FROM event"
" WHERE datetime(mtime)>=%Q"
" AND type='ci' AND objid=%d",
zDate, rid
) ? 0 : 1;
}
/*
** Make sure the current check-in with timestamp zDate is younger than its
** ancestor identified rid and zUuid. Throw a fatal error if not.
*/
static void checkin_verify_younger(
int rid, /* The record ID of the ancestor */
const char *zUuid, /* The artifact ID of the ancestor */
const char *zDate /* Date & time of the current check-in */
){
#ifndef FOSSIL_ALLOW_OUT_OF_ORDER_DATES
if(checkin_is_younger(rid,zDate)==0){
fossil_fatal("ancestor check-in [%S] (%s) is not older (clock skew?)"
" Use --allow-older to override.", zUuid, zDate);
}
#endif
}
/*
** zDate should be a valid date string. Convert this string into the
** format YYYY-MM-DDTHH:MM:SS. If the string is not a valid date,
** print a fatal error and quit.
*/
char *date_in_standard_format(const char *zInputDate){
|
| ︙ | ︙ | |||
2327 2328 2329 2330 2331 2332 2333 |
/*
** Do not allow a commit against a closed leaf unless the commit
** ends up on a different branch.
*/
if(
/* parent check-in has the "closed" tag... */
| < < | | 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 |
/*
** Do not allow a commit against a closed leaf unless the commit
** ends up on a different branch.
*/
if(
/* parent check-in has the "closed" tag... */
leaf_is_closed(vid)
/* ... and the new check-in has no --branch option or the --branch
** option does not actually change the branch */
&& (sCiInfo.zBranch==0
|| db_exists("SELECT 1 FROM tagxref"
" WHERE tagid=%d AND rid=%d AND tagtype>0"
" AND value=%Q", TAG_BRANCH, vid, sCiInfo.zBranch))
){
|
| ︙ | ︙ |
Changes to src/configure.c.
| ︙ | ︙ | |||
146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
{ "dotfiles", CONFIGSET_PROJ },
{ "parent-project-code", CONFIGSET_PROJ },
{ "parent-project-name", CONFIGSET_PROJ },
{ "hash-policy", CONFIGSET_PROJ },
{ "comment-format", CONFIGSET_PROJ },
{ "mimetypes", CONFIGSET_PROJ },
{ "forbid-delta-manifests", CONFIGSET_PROJ },
#ifdef FOSSIL_ENABLE_LEGACY_MV_RM
{ "mv-rm-files", CONFIGSET_PROJ },
#endif
{ "ticket-table", CONFIGSET_TKT },
{ "ticket-common", CONFIGSET_TKT },
| > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
{ "dotfiles", CONFIGSET_PROJ },
{ "parent-project-code", CONFIGSET_PROJ },
{ "parent-project-name", CONFIGSET_PROJ },
{ "hash-policy", CONFIGSET_PROJ },
{ "comment-format", CONFIGSET_PROJ },
{ "mimetypes", CONFIGSET_PROJ },
{ "forbid-delta-manifests", CONFIGSET_PROJ },
{ "fileedit-glob", CONFIGSET_PROJ },
#ifdef FOSSIL_ENABLE_LEGACY_MV_RM
{ "mv-rm-files", CONFIGSET_PROJ },
#endif
{ "ticket-table", CONFIGSET_TKT },
{ "ticket-common", CONFIGSET_TKT },
|
| ︙ | ︙ |
Changes to src/db.c.
| ︙ | ︙ | |||
3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 | #if !defined(FOSSIL_ENABLE_EXEC_REL_PATHS) /* ** SETTING: exec-rel-paths boolean default=off ** When executing certain external commands (e.g. diff and ** gdiff), use relative paths. */ #endif /* ** SETTING: gdiff-command width=40 default=gdiff ** The value is an external command to run when performing a graphical ** diff. If undefined, text diff will be used. */ /* ** SETTING: gmerge-command width=40 | > > > > > > > > > | 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 | #if !defined(FOSSIL_ENABLE_EXEC_REL_PATHS) /* ** SETTING: exec-rel-paths boolean default=off ** When executing certain external commands (e.g. diff and ** gdiff), use relative paths. */ #endif /* ** SETTING: fileedit-glob width=40 block-text ** A comma- or newline-separated list of globs of filenames ** which are allowed to be edited using the /fileedit page. ** An empty list prohibits editing via that page. Note that ** it cannot edit binary files, so the list should not ** contain any globs for, e.g., images or PDFs. */ /* ** SETTING: gdiff-command width=40 default=gdiff ** The value is an external command to run when performing a graphical ** diff. If undefined, text diff will be used. */ /* ** SETTING: gmerge-command width=40 |
| ︙ | ︙ |
Changes to src/default_css.txt.
| ︙ | ︙ | |||
858 859 860 861 862 863 864 865 866 867 868 869 870 |
// border: 1px solid black;
// vertical-align: top;
// }
// #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div {
// max-width: 30em;
// overflow: auto;
// }
input {
max-width: 95%;
}
textarea {
max-width: 95%;
}
| > > > > > > > > > > > > > > > | 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 |
// border: 1px solid black;
// vertical-align: top;
// }
// #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div {
// max-width: 30em;
// overflow: auto;
// }
.error {
color: darkred;
background: yellow;
}
.warning {
color: darkred;
background: yellow;
opacity: 0.7;
}
.hidden {
position: absolute;
opacity: 0;
pointer-events: none;
display: none;
}
input {
max-width: 95%;
}
textarea {
max-width: 95%;
}
|
Changes to src/encode.c.
| ︙ | ︙ | |||
375 376 377 378 379 380 381 |
|| (c&0xFFFFF800)==0xD800
|| (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; }
}
return c;
}
/*
| | > | | > > > > > | > > > > > > > | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|| (c&0xFFFFF800)==0xD800
|| (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; }
}
return c;
}
/*
** Encode a UTF8 string as a JSON string literal (with or without the
** surrounding "...", depending on whether the 2nd argument is true or
** false) and return a pointer to the encoding. Space to hold the
** encoding is obtained from fossil_malloc() and must be freed by the
** caller.
**
** If nOut is not NULL then it is assigned to the length, in bytes, of
** the returned string (its strlen(), not counting the terminating
** NUL).
*/
char *encode_json_string_literal(const char *zStr, int fAddQuotes,
int * nOut){
const unsigned char *z;
char *zOut;
u32 c;
int n, i, j;
z = (const unsigned char*)zStr;
n = 0;
while( (c = fossil_utf8_read(&z))!=0 ){
if( c=='\\' || c=='"' ){
n += 2;
}else if( c<' ' || c>=0x7f ){
if( c=='\n' || c=='\r' ){
n += 2;
}else{
n += 6;
}
}else{
n++;
}
}
if(fAddQuotes){
n += 2;
}
zOut = fossil_malloc(n+1);
if( zOut==0 ) return 0;
z = (const unsigned char*)zStr;
i = 0;
if(fAddQuotes){
zOut[i++] = '"';
}
while( (c = fossil_utf8_read(&z))!=0 ){
if( c=='\\' ){
zOut[i++] = '\\';
zOut[i++] = c;
}else if( c<' ' || c>=0x7f ){
zOut[i++] = '\\';
if( c=='\n' ){
|
| ︙ | ︙ | |||
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
}
i += 4;
}
}else{
zOut[i++] = c;
}
}
zOut[i] = 0;
return zOut;
}
/*
** The characters used for HTTP base64 encoding.
*/
static unsigned char zBase[] =
| > > > > > > | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
}
i += 4;
}
}else{
zOut[i++] = c;
}
}
if(fAddQuotes){
zOut[i++] = '"';
}
zOut[i] = 0;
if(nOut!=0){
*nOut = i;
}
return zOut;
}
/*
** The characters used for HTTP base64 encoding.
*/
static unsigned char zBase[] =
|
| ︙ | ︙ |
Added src/fileedit.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 |
/*
** Copyright (c) 2020 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)
**
** This program is distributed in the hope that it will be useful,
** but without any warranty; without even the implied warranty of
** merchantability or fitness for a particular purpose.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This file contains code for the /fileedit page and related bits.
*/
#include "config.h"
#include "fileedit.h"
#include <assert.h>
#include <stdarg.h>
/*
** State for the "mini-checkin" infrastructure, which enables the
** ability to commit changes to a single file without a checkout
** db, e.g. for use via an HTTP request.
**
** Use CheckinMiniInfo_init() to cleanly initialize one to a known
** valid/empty default state.
**
** Memory for all non-const pointer members is owned by the
** CheckinMiniInfo instance, unless explicitly noted otherwise, and is
** freed by CheckinMiniInfo_cleanup(). Similarly, each instance owns
** any memory for its own Blob members, but NOT for its pointers to
** blobs.
*/
struct CheckinMiniInfo {
Manifest * pParent; /* parent checkin. Memory is owned by this
object. */
char *zParentUuid; /* Full UUID of pParent */
char *zFilename; /* Name of single file to commit. Must be
relative to the top of the repo. */
Blob fileContent; /* Content of file referred to by zFilename. */
Blob fileHash; /* Hash of this->fileContent, using the repo's
preferred hash method. */
Blob comment; /* Check-in comment text */
char *zCommentMimetype; /* Mimetype of comment. May be NULL */
char *zUser; /* User name */
char *zDate; /* Optionally force this date string (anything
supported by date_in_standard_format()).
Maybe be NULL. */
Blob *pMfOut; /* If not NULL, checkin_mini() will write a
copy of the generated manifest here. This
memory is NOT owned by CheckinMiniInfo. */
int filePerm; /* Permissions (via file_perm()) of the input
file. We need to store this before calling
checkin_mini() because the real input file
name may differ from the repo-centric
this->zFilename, and checkin_mini() requires
the permissions of the original file. For
web commits, set this to PERM_REG or (when
editing executable scripts) PERM_EXE before
calling checkin_mini(). */
int flags; /* Bitmask of fossil_cimini_flags. */
};
typedef struct CheckinMiniInfo CheckinMiniInfo;
/*
** CheckinMiniInfo::flags values.
*/
enum fossil_cimini_flags {
/*
** Must have a value of 0. All other flags have unspecified values.
*/
CIMINI_NONE = 0,
/*
** Tells checkin_mini() to use dry-run mode.
*/
CIMINI_DRY_RUN = 1,
/*
** Tells checkin_mini() to allow forking from a non-leaf commit.
*/
CIMINI_ALLOW_FORK = 1<<1,
/*
** Tells checkin_mini() to dump its generated manifest to stdout.
*/
CIMINI_DUMP_MANIFEST = 1<<2,
/*
** By default, content containing what appears to be a merge conflict
** marker is not permitted. This flag relaxes that requirement.
*/
CIMINI_ALLOW_MERGE_MARKER = 1<<3,
/*
** By default mini-checkins are not allowed to be "older"
** than their parent. i.e. they may not have a timestamp
** which predates their parent. This flag bypasses that
** check.
*/
CIMINI_ALLOW_OLDER = 1<<4,
/*
** Indicates that the content of the newly-checked-in file is
** converted, if needed, to use the same EOL style as the previous
** version of that file. Only the in-memory/in-repo copies are
** affected, not the original file (if any).
*/
CIMINI_CONVERT_EOL_INHERIT = 1<<5,
/*
** Indicates that the input's EOLs should be converted to Unix-style.
*/
CIMINI_CONVERT_EOL_UNIX = 1<<6,
/*
** Indicates that the input's EOLs should be converted to Windows-style.
*/
CIMINI_CONVERT_EOL_WINDOWS = 1<<7,
/*
** A hint to checkin_mini() to "prefer" creation of a delta manifest.
** It may decide not to for various reasons.
*/
CIMINI_PREFER_DELTA = 1<<8,
/*
** A "stronger hint" to checkin_mini() to prefer creation of a delta
** manifest if it at all can. It will decide not to only if creation
** of a delta is not a realistic option or if it's forbitted by the
** forbid-delta-manifests repo config option. For this to work, it
** must be set together with the CIMINI_PREFER_DELTA flag, but the two
** cannot be combined in this enum.
**
** This option is ONLY INTENDED FOR TESTING, used in bypassing
** heuristics which may otherwise disable generation of a delta on the
** grounds of efficiency (e.g. not generating a delta if the parent
** non-delta only has a few F-cards).
*/
CIMINI_STRONGLY_PREFER_DELTA = 1<<9,
/*
** Tells checkin_mini() to permit the addition of a new file. Normally
** this is disabled because there are hypothetically many cases where
** it could cause the inadvertent addition of a new file when an
** update to an existing was intended, as a side-effect of name-case
** differences.
*/
CIMINI_ALLOW_NEW_FILE = 1<<10
};
/*
** Initializes p to a known-valid default state.
*/
static void CheckinMiniInfo_init( CheckinMiniInfo * p ){
memset(p, 0, sizeof(CheckinMiniInfo));
p->flags = CIMINI_NONE;
p->filePerm = -1;
p->comment = p->fileContent = p->fileHash = empty_blob;
}
/*
** Frees all memory owned by p, but does not free p.
*/
static void CheckinMiniInfo_cleanup( CheckinMiniInfo * p ){
blob_reset(&p->comment);
blob_reset(&p->fileContent);
blob_reset(&p->fileHash);
if(p->pParent){
manifest_destroy(p->pParent);
}
fossil_free(p->zFilename);
fossil_free(p->zDate);
fossil_free(p->zParentUuid);
fossil_free(p->zCommentMimetype);
fossil_free(p->zUser);
CheckinMiniInfo_init(p);
}
/*
** Internal helper which returns an F-card perms string suitable for
** writing as-is into a manifest. If it's not empty, it includes a
** leading space to separate it from the F-card's hash field.
*/
static const char * mfile_permint_mstring(int perm){
switch(perm){
case PERM_EXE: return " x";
case PERM_LNK: return " l";
default: return "";
}
}
/*
** Given a ManifestFile permission string (or NULL), it returns one of
** PERM_REG, PERM_EXE, or PERM_LNK.
*/
static int mfile_permstr_int(const char *zPerm){
if(!zPerm || !*zPerm) return PERM_REG;
else if(strstr(zPerm,"x")) return PERM_EXE;
else if(strstr(zPerm,"l")) return PERM_LNK;
else return PERM_REG/*???*/;
}
/*
** Internal helper for checkin_mini() and friends. Appends an F-card
** for p to pOut.
*/
static void checkin_mini_append_fcard(Blob *pOut,
const ManifestFile *p){
if(p->zUuid){
assert(*p->zUuid);
blob_appendf(pOut, "F %F %s%s", p->zName,
p->zUuid,
mfile_permint_mstring(manifest_file_mperm(p)));
if(p->zPrior){
assert(*p->zPrior);
blob_appendf(pOut, " %F\n", p->zPrior);
}else{
blob_append(pOut, "\n", 1);
}
}else{
/* File was removed from parent delta. */
blob_appendf(pOut, "F %F\n", p->zName);
}
}
/*
** Handles the F-card parts for create_manifest_mini().
**
** If asDelta is true, F-cards will be handled as for a delta
** manifest, and the caller MUST have added a B-card to pOut before
** calling this.
**
** Returns 1 on success, 0 on error, and writes any error message to
** pErr (if it's not NULL). The only non-immediately-fatal/panic error
** is if pCI->filePerm is PERM_LNK or pCI would update a PERM_LNK
** in-repo file.
*/
static int create_manifest_mini_fcards( Blob * pOut,
CheckinMiniInfo * pCI,
int asDelta,
Blob * pErr){
int wroteThisCard = 0;
const ManifestFile * pFile;
int (*fncmp)(char const *, char const *) = /* filename comparator */
filenames_are_case_sensitive()
? fossil_strcmp
: fossil_stricmp;
#define mf_err(EXPR) if(pErr) blob_appendf EXPR; return 0
#define write_this_card(NAME) \
blob_appendf(pOut, "F %F %b%s\n", (NAME), &pCI->fileHash, \
mfile_permint_mstring(pCI->filePerm)); \
wroteThisCard = 1
assert(pCI->filePerm!=PERM_LNK && "This should have been validated before.");
assert(pCI->filePerm==PERM_REG || pCI->filePerm==PERM_EXE);
if(PERM_LNK==pCI->filePerm){
goto err_no_symlink;
}
manifest_file_rewind(pCI->pParent);
if(asDelta!=0 && (pCI->pParent->zBaseline==0
|| pCI->pParent->nFile==0)){
/* Parent is a baseline or a delta with no F-cards, so this is
** the simplest case: create a delta with a single F-card.
*/
pFile = manifest_file_find(pCI->pParent, pCI->zFilename);
if(pFile!=0 && manifest_file_mperm(pFile)==PERM_LNK){
goto err_no_symlink;
}
write_this_card(pFile ? pFile->zName : pCI->zFilename);
return 1;
}
while(1){
int cmp;
if(asDelta==0){
pFile = manifest_file_next(pCI->pParent, 0);
}else{
/* Parent is a delta manifest with F-cards. Traversal of delta
** manifest file entries is normally done via
** manifest_file_next(), which takes into account the
** differences between the delta and its parent and returns
** F-cards from both. Each successive delta from the same
** baseline includes all F-card changes from the previous
** deltas, so we instead clone the parent's F-cards except for
** the one (if any) which matches the new file.
*/
pFile = pCI->pParent->iFile < pCI->pParent->nFile
? &pCI->pParent->aFile[pCI->pParent->iFile++]
: 0;
}
if(0==pFile) break;
cmp = fncmp(pFile->zName, pCI->zFilename);
if(cmp<0){
checkin_mini_append_fcard(pOut,pFile);
}else{
if(cmp==0 || 0==wroteThisCard){
assert(0==wroteThisCard);
if(PERM_LNK==manifest_file_mperm(pFile)){
goto err_no_symlink;
}
write_this_card(cmp==0 ? pFile->zName : pCI->zFilename);
}
if(cmp>0){
assert(wroteThisCard!=0);
checkin_mini_append_fcard(pOut,pFile);
}
}
}
if(wroteThisCard==0){
write_this_card(pCI->zFilename);
}
return 1;
err_no_symlink:
mf_err((pErr,"Cannot commit or overwrite symlinks "
"via mini-checkin."));
return 0;
#undef write_this_card
#undef mf_err
}
/*
** Creates a manifest file, written to pOut, from the state in the
** fully-populated and semantically valid pCI argument. pCI is not
** *semantically* modified by this routine but cannot be const because
** blob_str() may need to NUL-terminate any given blob.
**
** Returns true on success. On error, returns 0 and, if pErr is not
** NULL, writes an error message there.
**
** Intended only to be called via checkin_mini() or routines which
** have already completely vetted pCI for semantic validity.
*/
static int create_manifest_mini( Blob * pOut, CheckinMiniInfo * pCI,
Blob * pErr){
Blob zCard = empty_blob; /* Z-card checksum */
int asDelta = 0;
#define mf_err(EXPR) if(pErr) blob_appendf EXPR; return 0
assert(blob_str(&pCI->fileHash));
assert(pCI->pParent);
assert(pCI->zFilename);
assert(pCI->zUser);
assert(pCI->zDate);
/* Potential TODOs include...
**
** - Maybe add support for tags. Those can be edited via /info page,
** and feel like YAGNI/feature creep for this purpose.
*/
blob_zero(pOut);
manifest_file_rewind(pCI->pParent) /* force load of baseline */;
/* Determine whether we want to create a delta manifest... */
if((CIMINI_PREFER_DELTA & pCI->flags)
&& ((CIMINI_STRONGLY_PREFER_DELTA & pCI->flags)
|| (pCI->pParent->pBaseline
? pCI->pParent->pBaseline
: pCI->pParent)->nFile > 15
/* 15 is arbitrary: don't create a delta when there is only a
** tiny gain for doing so. That heuristic is not *quite*
** right, in that when we're deriving from another delta, we
** really should compare the F-card count between it and its
** baseline, and create a delta if the baseline has (say)
** twice or more as many F-cards as the previous delta. */)
&& !db_get_boolean("forbid-delta-manifests",0)
){
asDelta = 1;
blob_appendf(pOut, "B %s\n",
pCI->pParent->zBaseline
? pCI->pParent->zBaseline
: pCI->zParentUuid);
}
blob_reserve(pOut, 1024 *
(asDelta ? 2 : pCI->pParent->nFile/11+1
/* In the fossil core repo, each 12-ish F-cards (on
** average) take up roughly 1kb */));
if(blob_size(&pCI->comment)!=0){
blob_appendf(pOut, "C %F\n", blob_str(&pCI->comment));
}else{
blob_append(pOut, "C (no\\scomment)\n", 16);
}
blob_appendf(pOut, "D %s\n", pCI->zDate);
if(create_manifest_mini_fcards(pOut,pCI,asDelta,pErr)==0){
return 0;
}
if(pCI->zCommentMimetype!=0 && pCI->zCommentMimetype[0]!=0){
blob_appendf(pOut, "N %F\n", pCI->zCommentMimetype);
}
blob_appendf(pOut, "P %s\n", pCI->zParentUuid);
blob_appendf(pOut, "U %F\n", pCI->zUser);
md5sum_blob(pOut, &zCard);
blob_appendf(pOut, "Z %b\n", &zCard);
blob_reset(&zCard);
return 1;
#undef mf_err
}
/*
** A so-called "single-file/mini/web checkin" is a slimmed-down form
** of the checkin command which accepts only a single file and is
** intended to accept edits to a file via the web interface or from
** the CLI from outside of a checkout.
**
** Being fully non-interactive is a requirement for this function,
** thus it cannot perform autosync or similar activities (which
** includes checking for repo locks).
**
** This routine uses the state from the given fully-populated pCI
** argument to add pCI->fileContent to the database, and create and
** save a manifest for that change. Ownership of pCI and its contents
** are unchanged.
**
** This function may may modify pCI as follows:
**
** - If one of Manifest pCI->pParent or pCI->zParentUuid are NULL,
** then the other will be assigned based on its counterpart. Both
** may not be NULL.
**
** - pCI->zDate is normalized to/replaced with a valid date/time
** string. If its original value cannot be validated then
** this function fails. If pCI->zDate is NULL, the current time
** is used.
**
** - If the CIMINI_CONVERT_EOL_INHERIT flag is set,
** pCI->fileContent appears to be plain text, and its line-ending
** style differs from its previous version, it is converted to the
** same EOL style as the previous version. If this is done, the
** pCI->fileHash is re-computed. Note that only pCI->fileContent,
** not the original file, is affected by the conversion.
**
** - Else if one of the CIMINI_CONVERT_EOL_WINDOWS or
** CIMINI_CONVERT_EOL_UNIX flags are set, pCI->fileContent is
** converted, if needed, to the corresponding EOL style.
**
** - If EOL conversion takes place, pCI->fileHash is re-calculated.
**
** - If pCI->fileHash is empty, this routine populates it with the
** repository's preferred hash algorithm (after any EOL conversion).
**
** - pCI->comment may be converted to Unix-style newlines.
**
** pCI's ownership is not modified.
**
** This function validates pCI's state and fails if any validation
** fails.
**
** On error, returns false (0) and, if pErr is not NULL, writes a
** diagnostic message there.
**
** Returns true on success. If pRid is not NULL, the RID of the
** resulting manifest is written to *pRid.
**
** The checkin process is largely influenced by pCI->flags, and that
** must be populated before calling this. See the fossil_cimini_flags
** enum for the docs for each flag.
*/
static int checkin_mini(CheckinMiniInfo * pCI, int *pRid, Blob * pErr){
Blob mf = empty_blob; /* output manifest */
int rid = 0, frid = 0; /* various RIDs */
int isPrivate; /* whether this is private content
or not */
ManifestFile * zFilePrev; /* file entry from pCI->pParent */
int prevFRid = 0; /* RID of file's prev. version */
#define ci_err(EXPR) if(pErr!=0){blob_appendf EXPR;} goto ci_error
db_begin_transaction();
if(pCI->pParent==0 && pCI->zParentUuid==0){
ci_err((pErr, "Cannot determine parent version."));
}
else if(pCI->pParent==0){
pCI->pParent = manifest_get_by_name(pCI->zParentUuid, 0);
if(pCI->pParent==0){
ci_err((pErr,"Cannot load manifest for [%S].", pCI->zParentUuid));
}
}else if(pCI->zParentUuid==0){
pCI->zParentUuid = rid_to_uuid(pCI->pParent->rid);
assert(pCI->zParentUuid);
}
assert(pCI->pParent->rid>0);
if(leaf_is_closed(pCI->pParent->rid)){
ci_err((pErr,"Cannot commit to a closed leaf."));
/* Remember that in order to override this we'd also need to
** cancel TAG_CLOSED on pCI->pParent. There would seem to be no
** reason we can't do that via the generated manifest, but the
** commit command does not offer that option, so mini-checkin
** probably shouldn't, either.
*/
}
if( !db_exists("SELECT 1 FROM user WHERE login=%Q", pCI->zUser) ){
ci_err((pErr,"No such user: %s", pCI->zUser));
}
if(!(CIMINI_ALLOW_FORK & pCI->flags)
&& !is_a_leaf(pCI->pParent->rid)){
ci_err((pErr,"Parent [%S] is not a leaf and forking is disabled.",
pCI->zParentUuid));
}
if(!(CIMINI_ALLOW_MERGE_MARKER & pCI->flags)
&& contains_merge_marker(&pCI->fileContent)){
ci_err((pErr,"Content appears to contain a merge conflict marker."));
}
if(!file_is_simple_pathname(pCI->zFilename, 1)){
ci_err((pErr,"Invalid filename for use in a repository: %s",
pCI->zFilename));
}
if(!(CIMINI_ALLOW_OLDER & pCI->flags)
&& !checkin_is_younger(pCI->pParent->rid, pCI->zDate)){
ci_err((pErr,"Checkin time (%s) may not be older "
"than its parent (%z).",
pCI->zDate,
db_text(0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%f',%lf)",
pCI->pParent->rDate)
));
}
{
/*
** Normalize the timestamp. We don't use date_in_standard_format()
** because that has side-effects we don't want to trigger here.
*/
char * zDVal = db_text(
0, "SELECT strftime('%%Y-%%m-%%dT%%H:%%M:%%f',%Q)",
pCI->zDate ? pCI->zDate : "now");
if(zDVal==0 || zDVal[0]==0){
fossil_free(zDVal);
ci_err((pErr,"Invalid timestamp string: %s", pCI->zDate));
}
fossil_free(pCI->zDate);
pCI->zDate = zDVal;
}
{ /* Confirm that only one EOL policy is in place. */
int n = 0;
if(CIMINI_CONVERT_EOL_INHERIT & pCI->flags) ++n;
if(CIMINI_CONVERT_EOL_UNIX & pCI->flags) ++n;
if(CIMINI_CONVERT_EOL_WINDOWS & pCI->flags) ++n;
if(n>1){
ci_err((pErr,"More than 1 EOL conversion policy was specified."));
}
}
/* Potential TODOs include:
**
** - Commit allows an empty checkin only with a flag, but we
** currently disallow an empty checkin entirely. Conform with
** commit?
**
** Non-TODOs:
**
** - Check for a commit lock would require auto-sync, which this
** code cannot do if it's going to be run via a web page.
*/
/*
** Confirm that pCI->zFilename can be found in pCI->pParent. If
** not, fail unless the CIMINI_ALLOW_NEW_FILE flag is set. This is
** admittedly an artificial limitation, not strictly necessary. We
** do it to hopefully reduce the chance of an "oops" where file
** X/Y/z gets committed as X/Y/Z or X/y/z due to a typo or
** case-sensitivity mismatch between the user/repo/filesystem, or
** some such.
*/
manifest_file_rewind(pCI->pParent);
zFilePrev = manifest_file_find(pCI->pParent, pCI->zFilename);
if(!(CIMINI_ALLOW_NEW_FILE & pCI->flags)
&& (!zFilePrev
|| !zFilePrev->zUuid/*was removed from parent delta manifest*/)
){
ci_err((pErr,"File [%s] not found in manifest [%S]. "
"Adding new files is currently not permitted.",
pCI->zFilename, pCI->zParentUuid));
}else if(zFilePrev
&& manifest_file_mperm(zFilePrev)==PERM_LNK){
ci_err((pErr,"Cannot save a symlink via a mini-checkin."));
}
if(zFilePrev){
prevFRid = fast_uuid_to_rid(zFilePrev->zUuid);
}
if(((CIMINI_CONVERT_EOL_INHERIT & pCI->flags)
|| (CIMINI_CONVERT_EOL_UNIX & pCI->flags)
|| (CIMINI_CONVERT_EOL_WINDOWS & pCI->flags))
&& blob_size(&pCI->fileContent)>0
){
/* Convert to the requested EOL style. Note that this inherently
** runs a risk of breaking content, e.g. string literals which
** contain embedded newlines. Note that HTML5 specifies that
** form-submitted TEXTAREA content gets normalized to CRLF-style:
**
** https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element
*/
const int pseudoBinary = LOOK_LONG | LOOK_NUL;
const int lookFlags = LOOK_CRLF | LOOK_LONE_LF | pseudoBinary;
const int lookNew = looks_like_utf8( &pCI->fileContent, lookFlags );
if(!(pseudoBinary & lookNew)){
int rehash = 0;
/*fossil_print("lookNew=%08x\n",lookNew);*/
if(CIMINI_CONVERT_EOL_INHERIT & pCI->flags){
Blob contentPrev = empty_blob;
int lookOrig, nOrig;
content_get(prevFRid, &contentPrev);
lookOrig = looks_like_utf8(&contentPrev, lookFlags);
nOrig = blob_size(&contentPrev);
blob_reset(&contentPrev);
/*fossil_print("lookOrig=%08x\n",lookOrig);*/
if(nOrig>0 && lookOrig!=lookNew){
/* If there is a newline-style mismatch, adjust the new
** content version to the previous style, then re-hash the
** content. Note that this means that what we insert is NOT
** what's in the filesystem.
*/
if(!(lookOrig & LOOK_CRLF) && (lookNew & LOOK_CRLF)){
/* Old has Unix-style, new has Windows-style. */
blob_to_lf_only(&pCI->fileContent);
rehash = 1;
}else if((lookOrig & LOOK_CRLF) && !(lookNew & LOOK_CRLF)){
/* Old has Windows-style, new has Unix-style. */
blob_add_cr(&pCI->fileContent);
rehash = 1;
}
}
}else{
const int oldSize = blob_size(&pCI->fileContent);
if(CIMINI_CONVERT_EOL_UNIX & pCI->flags){
if(LOOK_CRLF & lookNew){
blob_to_lf_only(&pCI->fileContent);
}
}else{
assert(CIMINI_CONVERT_EOL_WINDOWS & pCI->flags);
if(!(LOOK_CRLF & lookNew)){
blob_add_cr(&pCI->fileContent);
}
}
if(blob_size(&pCI->fileContent)!=oldSize){
rehash = 1;
}
}
if(rehash!=0){
hname_hash(&pCI->fileContent, 0, &pCI->fileHash);
}
}
}/* end EOL conversion */
if(blob_size(&pCI->fileHash)==0){
/* Hash the content if it's not done already... */
hname_hash(&pCI->fileContent, 0, &pCI->fileHash);
assert(blob_size(&pCI->fileHash)>0);
}
if(zFilePrev){
/* Has this file been changed since its previous commit? Note
** that we have to delay this check until after the potentially
** expensive EOL conversion. */
assert(blob_size(&pCI->fileHash));
if(0==fossil_strcmp(zFilePrev->zUuid, blob_str(&pCI->fileHash))
&& manifest_file_mperm(zFilePrev)==pCI->filePerm){
ci_err((pErr,"File is unchanged. Not committing."));
}
}
#if 1
/* Do we really want to normalize comment EOLs? Web-posting will
** submit them in CRLF or LF format, depending on how exactly the
** content is submitted (FORM (CRLF) or textarea-to-POST (LF, at
** least in theory)). */
blob_to_lf_only(&pCI->comment);
#endif
/* Create, save, deltify, and crosslink the manifest... */
if(create_manifest_mini(&mf, pCI, pErr)==0){
return 0;
}
isPrivate = content_is_private(pCI->pParent->rid);
rid = content_put_ex(&mf, 0, 0, 0, isPrivate);
if(pCI->flags & CIMINI_DUMP_MANIFEST){
fossil_print("%b", &mf);
}
if(pCI->pMfOut!=0){
/* Cross-linking clears mf, so we have to copy it,
** instead of taking over its memory. */
blob_reset(pCI->pMfOut);
blob_append(pCI->pMfOut, blob_buffer(&mf), blob_size(&mf));
}
content_deltify(rid, &pCI->pParent->rid, 1, 0);
manifest_crosslink(rid, &mf, 0);
blob_reset(&mf);
/* Save and deltify the file content... */
frid = content_put_ex(&pCI->fileContent, blob_str(&pCI->fileHash),
0, 0, isPrivate);
if(zFilePrev!=0){
assert(prevFRid>0);
content_deltify(frid, &prevFRid, 1, 0);
}
db_end_transaction((CIMINI_DRY_RUN & pCI->flags) ? 1 : 0);
if(pRid!=0){
*pRid = rid;
}
return 1;
ci_error:
assert(db_transaction_nesting_depth()>0);
db_end_transaction(1);
return 0;
#undef ci_err
}
/*
** COMMAND: test-ci-mini
**
** This is an on-going experiment, subject to change or removal at
** any time.
**
** Usage: %fossil test-ci-mini ?OPTIONS? FILENAME
**
** where FILENAME is a repo-relative name as it would appear in the
** vfile table.
**
** Options:
**
** --repository|-R REPO The repository file to commit to.
** --as FILENAME The repository-side name of the input
** file, relative to the top of the
** repository. Default is the same as the
** input file name.
** --comment|-m COMMENT Required checkin comment.
** --comment-file|-M FILE Reads checkin comment from the given file.
** --revision|-r VERSION Commit from this version. Default is
** the checkout version (if available) or
** trunk (if used without a checkout).
** --allow-fork Allows the commit to be made against a
** non-leaf parent. Note that no autosync
** is performed beforehand.
** --allow-merge-conflict Allows checkin of a file even if it
** appears to contain a fossil merge conflict
** marker.
** --user-override USER USER to use instead of the current
** default.
** --date-override DATETIME DATE to use instead of 'now'.
** --allow-older Allow a commit to be older than its
** ancestor.
** --convert-eol-inherit Convert EOL style of the checkin to match
** the previous version's content.
** --convert-eol-unix Convert the EOL style to Unix.
** --convert-eol-windows Convert the EOL style to Windows.
** (only one of the --convert-eol-X options may be used and they only
** modified the saved blob, not the input file.)
** --delta Prefer to generate a delta manifest, if
** able. The forbid-delta-manifests repo
** config option trumps this, as do certain
** heuristics.
** --allow-new-file Allow addition of a new file this way.
** Disabled by default to avoid that case-
** sensitivity errors inadvertently lead to
** adding a new file where an update is
** intended.
** --dump-manifest|-d Dumps the generated manifest to stdout
** immediately after it's generated.
** --save-manifest FILE Saves the generated manifest to a file
** after successfully processing it.
** --wet-run Disables the default dry-run mode.
**
** Example:
**
** %fossil test-ci-mini -R REPO -m ... -r foo --as src/myfile.c myfile.c
**
*/
void test_ci_mini_cmd(void){
CheckinMiniInfo cimi; /* checkin state */
int newRid = 0; /* RID of new version */
const char * zFilename; /* argv[2] */
const char * zComment; /* -m comment */
const char * zCommentFile; /* -M FILE */
const char * zAsFilename; /* --as filename */
const char * zRevision; /* --revision|-r [=trunk|checkout] */
const char * zUser; /* --user-override */
const char * zDate; /* --date-override */
char const * zManifestFile = 0;/* --save-manifest FILE */
/* This function should perform only the minimal "business logic" it
** needs in order to fully/properly populate the CheckinMiniInfo and
** then pass it on to checkin_mini() to do most of the validation
** and work. The point of this is to avoid duplicate code when a web
** front-end is added for checkin_mini().
*/
CheckinMiniInfo_init(&cimi);
zComment = find_option("comment","m",1);
zCommentFile = find_option("comment-file","M",1);
zAsFilename = find_option("as",0,1);
zRevision = find_option("revision","r",1);
zUser = find_option("user-override",0,1);
zDate = find_option("date-override",0,1);
zManifestFile = find_option("save-manifest",0,1);
if(find_option("wet-run",0,0)==0){
cimi.flags |= CIMINI_DRY_RUN;
}
if(find_option("allow-fork",0,0)!=0){
cimi.flags |= CIMINI_ALLOW_FORK;
}
if(find_option("dump-manifest","d",0)!=0){
cimi.flags |= CIMINI_DUMP_MANIFEST;
}
if(find_option("allow-merge-conflict",0,0)!=0){
cimi.flags |= CIMINI_ALLOW_MERGE_MARKER;
}
if(find_option("allow-older",0,0)!=0){
cimi.flags |= CIMINI_ALLOW_OLDER;
}
if(find_option("convert-eol-inherit",0,0)!=0){
cimi.flags |= CIMINI_CONVERT_EOL_INHERIT;
}else if(find_option("convert-eol-unix",0,0)!=0){
cimi.flags |= CIMINI_CONVERT_EOL_UNIX;
}else if(find_option("convert-eol-windows",0,0)!=0){
cimi.flags |= CIMINI_CONVERT_EOL_WINDOWS;
}
if(find_option("delta",0,0)!=0){
cimi.flags |= CIMINI_PREFER_DELTA;
}
if(find_option("delta2",0,0)!=0){
/* Undocumented. For testing only. */
cimi.flags |= CIMINI_PREFER_DELTA | CIMINI_STRONGLY_PREFER_DELTA;
}
if(find_option("allow-new-file",0,0)!=0){
cimi.flags |= CIMINI_ALLOW_NEW_FILE;
}
db_find_and_open_repository(0, 0);
verify_all_options();
user_select();
if(g.argc!=3){
usage("INFILE");
}
if(zComment && zCommentFile){
fossil_fatal("Only one of -m or -M, not both, may be used.");
}else{
if(zCommentFile && *zCommentFile){
blob_read_from_file(&cimi.comment, zCommentFile, ExtFILE);
}else if(zComment && *zComment){
blob_append(&cimi.comment, zComment, -1);
}
if(!blob_size(&cimi.comment)){
fossil_fatal("Non-empty checkin comment is required.");
}
}
db_begin_transaction();
zFilename = g.argv[2];
cimi.zFilename = mprintf("%/", zAsFilename ? zAsFilename : zFilename);
cimi.filePerm = file_perm(zFilename, ExtFILE);
cimi.zUser = mprintf("%s", zUser ? zUser : login_name());
if(zDate){
cimi.zDate = mprintf("%s", zDate);
}
if(zRevision==0 || zRevision[0]==0){
if(g.localOpen/*checkout*/){
zRevision = db_lget("checkout-hash", 0)/*leak*/;
}else{
zRevision = "trunk";
}
}
name_to_uuid2(zRevision, "ci", &cimi.zParentUuid);
if(cimi.zParentUuid==0){
fossil_fatal("Cannot determine version to commit to.");
}
blob_read_from_file(&cimi.fileContent, zFilename, ExtFILE);
{
Blob theManifest = empty_blob; /* --save-manifest target */
Blob errMsg = empty_blob;
int rc;
if(zManifestFile){
cimi.pMfOut = &theManifest;
}
rc = checkin_mini(&cimi, &newRid, &errMsg);
if(rc){
assert(blob_size(&errMsg)==0);
}else{
assert(blob_size(&errMsg));
fossil_fatal("%b", &errMsg);
}
if(zManifestFile){
fossil_print("Writing manifest to: %s\n", zManifestFile);
assert(blob_size(&theManifest)>0);
blob_write_to_file(&theManifest, zManifestFile);
blob_reset(&theManifest);
}
}
if(newRid!=0){
fossil_print("New version%s: %z\n",
(cimi.flags & CIMINI_DRY_RUN) ? " (dry run)" : "",
rid_to_uuid(newRid));
}
db_end_transaction(0/*checkin_mini() will have triggered it to roll
** back in dry-run mode, but we need access to
** the transaction-written db state in this
** routine.*/);
if(!(cimi.flags & CIMINI_DRY_RUN) && newRid!=0 && g.localOpen!=0){
fossil_warning("The checkout state is now out of sync "
"with regards to this commit. It needs to be "
"'update'd or 'close'd and re-'open'ed.");
}
CheckinMiniInfo_cleanup(&cimi);
}
/*
** If the fileedit-glob setting has a value, this returns its Glob
** object (in memory owned by this function), else it returns NULL.
*/
static Glob * fileedit_glob(void){
static Glob * pGlobs = 0;
static int once = 0;
if(0==pGlobs && once==0){
char * zGlobs = db_get("fileedit-glob",0);
once = 1;
if(0!=zGlobs && 0!=*zGlobs){
pGlobs = glob_create(zGlobs);
}
fossil_free(zGlobs);
}
return pGlobs;
}
/*
** Returns true if the given filename qualifies for online editing by
** the current user, else returns false.
**
** Editing requires that the user have the Write permission and that
** the filename match the glob defined by the fileedit-glob setting.
** A missing or empty value for that glob disables all editing.
*/
int fileedit_is_editable(const char *zFilename){
Glob * pGlobs = fileedit_glob();
if(pGlobs!=0 && zFilename!=0 && *zFilename!=0 && 0!=g.perm.Write){
return glob_match(pGlobs, zFilename);
}else{
return 0;
}
}
enum fileedit_render_preview_flags {
FE_PREVIEW_LINE_NUMBERS = 1
};
enum fileedit_render_modes {
/* GUESS must be 0. All others have unspecified values. */
FE_RENDER_GUESS = 0,
FE_RENDER_PLAIN_TEXT,
FE_RENDER_HTML_IFRAME,
FE_RENDER_HTML_INLINE,
FE_RENDER_WIKI
};
static int fileedit_render_mode_for_mimetype(const char * zMimetype){
int rc = FE_RENDER_PLAIN_TEXT;
if( zMimetype ){
if( fossil_strcmp(zMimetype, "text/html")==0 ){
rc = FE_RENDER_HTML_IFRAME;
}else if( fossil_strcmp(zMimetype, "text/x-fossil-wiki")==0
|| fossil_strcmp(zMimetype, "text/x-markdown")==0 ){
rc = FE_RENDER_WIKI;
}
}
return rc;
}
/*
** Performs the PREVIEW mode for /filepage.
**
** If *renderMode==FE_RENDER_GUESS then *renderMode gets set to the
** mode which is guessed at for the rendering.
*/
static void fileedit_render_preview(Blob * pContent,
const char *zFilename,
int flags, int * renderMode,
int nIframeHeightEm){
const char * zMime;
zMime = mimetype_from_name(zFilename);
if(FE_RENDER_GUESS==*renderMode){
*renderMode = fileedit_render_mode_for_mimetype(zMime);
}
switch(*renderMode){
case FE_RENDER_HTML_IFRAME:{
char * z64 = encode64(blob_str(pContent), blob_size(pContent));
CX("<iframe width='100%%' frameborder='0' "
"marginwidth='0' style='height:%dem' "
"marginheight='0' sandbox='allow-same-origin' "
"id='ifm1' src='data:text/html;base64,%z'"
"></iframe>",
nIframeHeightEm ? nIframeHeightEm : 40,
z64);
break;
}
case FE_RENDER_HTML_INLINE:{
CX("%b",pContent);
break;
}
case FE_RENDER_WIKI:
wiki_render_by_mimetype(pContent, zMime);
break;
default:{
const char *zExt = strrchr(zFilename,'.');
const char *zContent = blob_str(pContent);
if(FE_PREVIEW_LINE_NUMBERS & flags){
output_text_with_line_numbers(zContent, "on");
}else if(zExt && zExt[1]){
CX("<pre><code class='language-%s'>%h</code></pre>",
zExt+1, zContent);
}else{
CX("<pre>%h</pre>", zExt+1, zContent);
}
break;
}
}
}
/*
** Renders diffs for the /fileedit page. pContent is the
** locally-edited content. frid is the RID of the file's blob entry
** from which pContent is based. zManifestUuid is the checkin version
** to which RID belongs - it is purely informational, for labeling the
** diff view. isSbs is true for side-by-side diffs, false for unified.
*/
static void fileedit_render_diff(Blob * pContent, int frid,
const char * zManifestUuid,
u64 diffFlags){
Blob orig = empty_blob;
Blob out = empty_blob;
content_get(frid, &orig);
text_diff(&orig, pContent, &out, 0, diffFlags);
if(blob_size(&out)==0){
/* nothing to do */
}else if(DIFF_SIDEBYSIDE & diffFlags){
CX("%b",&out);
}else{
CX("<pre class='udiff'>%b</pre>",&out);
}
blob_reset(&orig);
blob_reset(&out);
}
/*
** Given a repo-relative filename and a manifest RID, returns the UUID
** of the corresponding file entry. Returns NULL if no match is
** found. If pFilePerm is not NULL, the file's permission flag value
** is written to *pFilePerm.
*/
static char *fileedit_file_uuid(char const *zFilename,
int vid, int *pFilePerm){
Stmt stmt = empty_Stmt;
char * zFileUuid = 0;
db_prepare(&stmt, "SELECT uuid, perm FROM files_of_checkin "
"WHERE filename=%Q %s AND checkinID=%d",
zFilename, filename_collation(), vid);
if(SQLITE_ROW==db_step(&stmt)){
zFileUuid = mprintf("%s",db_column_text(&stmt, 0));
if(pFilePerm){
*pFilePerm = mfile_permstr_int(db_column_text(&stmt, 1));
}
}
db_finalize(&stmt);
return zFileUuid;
}
/*
** Helper for /fileedit_xyz routes. Clears the CGI content buffer,
** sets an error status code, and queues up a JSON response in the
** form of an object:
**
** {error: formatted message}
**
** After calling this, the caller should immediately return.
*/
static void fileedit_ajax_error(int httpCode, const char * zFmt, ...){
Blob msg = empty_blob;
Blob content = empty_blob;
va_list vargs;
va_start(vargs,zFmt);
blob_vappendf(&msg, zFmt, vargs);
va_end(vargs);
blob_appendf(&content,"{\"error\":%!j}", blob_str(&msg));
blob_reset(&msg);
cgi_set_content(&content);
cgi_set_status(httpCode, "Error");
cgi_set_content_type("application/json");
}
/*
** Performs bootstrapping common to the /fileedit_xyz AJAX routes.
** Returns 0 if bootstrapping fails (wrong permissions), in which
** case it has reported the error and the route should immediately
** return. Returns true on success.
**
** Must be passed true if the request being set up requires POST,
** else false.
*/
static int fileedit_ajax_boostrap(int requirePost){
login_check_credentials();
if( !g.perm.Write ){
fileedit_ajax_error(403,"Write permissions required.");
return 0;
}else if(0==cgi_csrf_safe(requirePost)){
fileedit_ajax_error(403,
"CSRF violation (make sure sending of HTTP "
"Referer headers is enabled for XHR "
"connections).");
return 0;
}
return 1;
}
/*
** Returns true if the current user is allowed to edit the given
** filename, as determined by fileedit_is_editable(), else false,
** in which case it queues up an error response and the caller
** must return immediately.
*/
static int fileedit_ajax_check_filename(const char * zFilename){
if(0==fileedit_is_editable(zFilename)){
fileedit_ajax_error(403, "File is disallowed by the "
"fileedit-glob setting.");
return 0;
}
return 1;
}
/*
** If zFn is not NULL, it is assigned the value of the first one of
** the "filename" or "fn" CGI parameters which is set.
**
** If zCi is not NULL, it is assigned the value of the first one of
** the "checkin" or "ci" CGI parameters which is set.
**
** If a parameter is not NULL, it will be assigned NULL if the
** corresponding parameter is not set.
**
** Returns the number of non-NULL values it assigns to arguments. Thus
** if passed (&x, NULL), it returns 1 if it assigns non-NULL to *x and
** 0 if it assigns NULL to *x.
*/
static int fileedit_get_fnci_args( const char **zFn, const char **zCi ){
int rc = 0;
if(zCi!=0){
*zCi = PD("checkin",P("ci"));
if( *zCi ) ++rc;
}
if(zFn!=0){
*zFn = PD("filename",P("fn"));
if (*zFn) ++rc;
}
return rc;
}
/*
** Passed the values of the "checkin" and "filename" request
** properties, this function verifies that they are valid and
** populates:
**
** - *zRevUuid = the fully-expanded value of zRev (owned by the
** caller). zRevUuid may be NULL.
**
** - *vid = the RID of zRevUuid. May not be NULL.
**
** - *frid = the RID of zFilename's blob content. May not be NULL
** unless zFilename is also NULL. If BOTH of zFilename and frid are
** NULL then no confirmation is done on the filename argument - only
** zRev is checked.
**
** Returns 0 if the given file is not in the given checkin or if
** fileedit_ajax_check_filename() fails, else returns true. If it
** returns false, it queues up an error response and the caller must
** return immediately.
*/
static int fileedit_ajax_setup_filerev(const char * zRev,
char ** zRevUuid,
int * vid,
const char * zFilename,
int * frid){
char * zFileUuid; /* file UUID */
const int checkFile = zFilename!=0 || frid!=0;
if(checkFile && !fileedit_ajax_check_filename(zFilename)){
return 0;
}
*vid = symbolic_name_to_rid(zRev, "ci");
if(0==*vid){
fileedit_ajax_error(404,"Cannot resolve name as a checkin: %s",
zRev);
return 0;
}else if(*vid<0){
fileedit_ajax_error(400,"Checkin name is ambiguous: %s",
zRev);
return 0;
}
if(checkFile){
zFileUuid = fileedit_file_uuid(zFilename, *vid, 0);
if(zFileUuid==0){
fileedit_ajax_error(404,"Checkin does not contain file.");
return 0;
}
}
if(zRevUuid!=0){
*zRevUuid = rid_to_uuid(*vid);
}
if(checkFile){
assert(zFileUuid!=0);
if(frid!=0){
*frid = fast_uuid_to_rid(zFileUuid);
}
fossil_free(zFileUuid);
}
return 1;
}
/*
** AJAX route /fileedit?ajax=content
**
** Query parameters:
**
** filename=FILENAME
** checkin=CHECKIN_NAME
**
** User must have Write access to use this page.
**
** Responds with the raw content of the given page. On error it
** produces a JSON response as documented for fileedit_ajax_error().
**
** Extra response headers:
**
** x-fileedit-file-perm: empty or "x" or "l", representing PERM_REG,
** PERM_EXE, or PERM_LINK, respectively.
**
** x-fileedit-checkin-branch: branch name for the passed-in checkin.
*/
static void fileedit_ajax_content(void){
const char * zFilename = 0;
const char * zRev = 0;
int vid, frid;
Blob content = empty_blob;
const char * zMime;
fileedit_get_fnci_args( &zFilename, &zRev );
if(!fileedit_ajax_boostrap(0)
|| !fileedit_ajax_setup_filerev(zRev, 0, &vid,
zFilename, &frid)){
return;
}
zMime = mimetype_from_name(zFilename);
content_get(frid, &content);
if(0==zMime){
if(looks_like_binary(&content)){
zMime = "application/octet-stream";
}else{
zMime = "text/plain";
}
}
{ /* Send the is-exec bit via response header so that the UI can be
** updated to account for that. */
int fperm = 0;
char * zFuuid = fileedit_file_uuid(zFilename, vid, &fperm);
const char * zPerm = mfile_permint_mstring(fperm);
assert(zFuuid);
cgi_printf_header("x-fileedit-file-perm:%s\r\n", zPerm);
fossil_free(zFuuid);
}
{ /* Send branch name via response header for UI usability reasons */
char * zBranch = branch_of_rid(vid);
if(zBranch!=0 && zBranch[0]!=0){
cgi_printf_header("x-fileedit-checkin-branch: %s\r\n", zBranch);
}
fossil_free(zBranch);
}
cgi_set_content_type(zMime);
cgi_set_content(&content);
}
/*
** AJAX route /fileedit?ajax=preview
**
** Required query parameters:
**
** filename=FILENAME
** content=text
**
** Optional query parameters:
**
** render_mode=integer (FE_RENDER_xxx) (default=FE_RENDER_GUESS)
**
** ln=0 or 1 to disable/enable line number mode in
** FE_RENDER_PLAIN_TEXT mode.
**
** iframe_height=integer (default=40) Height, in EMs of HTML preview
** iframe.
**
** User must have Write access to use this page.
**
** Responds with the HTML content of the preview. On error it produces
** a JSON response as documented for fileedit_ajax_error().
**
** Extra response headers:
**
** x-fileedit-render-mode: string representing the rendering mode
** which was really used (which will differ from the requested mode
** only if mode 0 (guess) was requested). The names are documented
** below in code and match those in the emitted JS object
** fossil.page.previewModes.
*/
static void fileedit_ajax_preview(void){
const char * zFilename = 0;
const char * zContent = P("content");
int renderMode = atoi(PD("render_mode","0"));
int ln = atoi(PD("ln","0"));
int iframeHeight = atoi(PD("iframe_height","40"));
Blob content = empty_blob;
const char * zRenderMode = 0;
fileedit_get_fnci_args( &zFilename, 0 );
if(!fileedit_ajax_boostrap(1)
|| !fileedit_ajax_check_filename(zFilename)){
return;
}
cgi_set_content_type("text/html");
blob_init(&content, zContent, -1);
fileedit_render_preview(&content, zFilename,
ln ? FE_PREVIEW_LINE_NUMBERS : 0,
&renderMode, iframeHeight);
/*
** Now tell the caller if we did indeed use FE_RENDER_WIKI, so that
** they can re-set the <base href> to an appropriate value (which
** requires knowing the content's current checkin version, which we
** don't have here).
*/
switch(renderMode){
/* The strings used here MUST correspond to those used in the JS-side
** fossil.page.previewModes map.
*/
case FE_RENDER_WIKI: zRenderMode = "wiki"; break;
case FE_RENDER_HTML_INLINE: zRenderMode = "htmlInline"; break;
case FE_RENDER_HTML_IFRAME: zRenderMode = "htmlIframe"; break;
case FE_RENDER_PLAIN_TEXT: zRenderMode = "text"; break;
case FE_RENDER_GUESS:
assert(!"cannot happen");
}
if(zRenderMode!=0){
cgi_printf_header("x-fileedit-render-mode: %s\r\n", zRenderMode);
}
}
/*
** AJAX route /fileedit?ajax=diff
**
** Required query parameters:
**
** filename=FILENAME
** content=text
** checkin=checkin version
**
** Optional parameters:
**
** sbs=integer (1=side-by-side or 0=unified, default=0)
**
** ws=integer (0=diff whitespace, 1=ignore EOL ws, 2=ignore all ws)
**
** Reminder to self: search info.c for isPatch to see how a
** patch-style siff can be produced.
**
** User must have Write access to use this page.
**
** Responds with the HTML content of the diff. On error it produces a
** JSON response as documented for fileedit_ajax_error().
*/
static void fileedit_ajax_diff(void){
/*
** Reminder: we only need the filename to perform valdiation
** against fileedit_is_editable(), else this route could be
** abused to get diffs against content disallowed by the
** whitelist.
*/
const char * zFilename = 0;
const char * zRev = 0;
const char * zContent = P("content");
char * zRevUuid = 0;
int vid, frid, iFlag;
u64 diffFlags = DIFF_HTML | DIFF_NOTTOOBIG;
Blob content = empty_blob;
iFlag = atoi(PD("sbs","0"));
if(0==iFlag){
diffFlags |= DIFF_LINENO;
}else{
diffFlags |= DIFF_SIDEBYSIDE;
}
iFlag = atoi(PD("ws","2"));
if(2==iFlag){
diffFlags |= DIFF_IGNORE_ALLWS;
}else if(1==iFlag){
diffFlags |= DIFF_IGNORE_EOLWS;
}
diffFlags |= DIFF_STRIP_EOLCR;
fileedit_get_fnci_args( &zFilename, &zRev );
if(!fileedit_ajax_boostrap(1)
|| !fileedit_ajax_setup_filerev(zRev, &zRevUuid, &vid,
zFilename, &frid)){
return;
}
if(!zContent){
zContent = "";
}
cgi_set_content_type("text/html");
blob_init(&content, zContent, -1);
fileedit_render_diff(&content, frid, zRevUuid, diffFlags);
fossil_free(zRevUuid);
blob_reset(&content);
}
/*
** Sets up and validates most, but not all, of p's checkin-related
** state from the CGI environment. Returns 0 on success or a suggested
** HTTP result code on error, in which case a message will have been
** written to pErr.
**
** It always fails if it cannot completely resolve the 'file' and 'r'
** parameters, including verifying that the refer to a real
** file/version combination and editable by the current user. All
** others are optional (at this level, anyway, but upstream code might
** require them).
**
** If the 3rd argument is not NULL and an error is related to a
** missing arg then *bIsMissingArg is set to true. This is
** intended to allow /fileedit to squelch certain initialization
** errors.
**
** Intended to be used only by /filepage and /filepage_commit.
*/
static int fileedit_setup_cimi_from_p(CheckinMiniInfo * p, Blob * pErr,
int * bIsMissingArg){
char * zFileUuid = 0; /* UUID of file content */
const char * zFlag; /* generic flag */
int rc = 0, vid = 0, frid = 0; /* result code, checkin/file rids */
#define fail(EXPR) blob_appendf EXPR; goto end_fail
zFlag = PD("filename",P("fn"));
if(zFlag==0 || !*zFlag){
rc = 400;
if(bIsMissingArg){
*bIsMissingArg = 1;
}
fail((pErr,"Missing required 'filename' parameter."));
}
p->zFilename = mprintf("%s",zFlag);
if(0==fileedit_is_editable(p->zFilename)){
rc = 403;
fail((pErr,"Filename [%h] is disallowed "
"by the [fileedit-glob] repository "
"setting.",
p->zFilename));
}
zFlag = PD("checkin",P("ci"));
if(!zFlag){
rc = 400;
if(bIsMissingArg){
*bIsMissingArg = 1;
}
fail((pErr,"Missing required 'checkin' parameter."));
}
vid = symbolic_name_to_rid(zFlag, "ci");
if(0==vid){
rc = 404;
fail((pErr,"Could not resolve checkin version."));
}else if(vid<0){
rc = 400;
fail((pErr,"Checkin name is ambiguous."));
}
p->zParentUuid = rid_to_uuid(vid)/*fully expand it*/;
zFileUuid = fileedit_file_uuid(p->zFilename, vid, &p->filePerm);
if(!zFileUuid){
rc = 404;
fail((pErr,"Checkin [%S] does not contain file: "
"[%h]", p->zParentUuid, p->zFilename));
}else if(PERM_LNK==p->filePerm){
rc = 400;
fail((pErr,"Editing symlinks is not permitted."));
}
/* Find the repo-side file entry or fail... */
frid = fast_uuid_to_rid(zFileUuid);
assert(frid);
/* Read file content from submit request or repo... */
zFlag = P("content");
if(zFlag==0){
content_get(frid, &p->fileContent);
}else{
blob_init(&p->fileContent,zFlag,-1);
}
if(looks_like_binary(&p->fileContent)){
rc = 400;
fail((pErr,"File appears to be binary. Cannot edit: "
"[%h]",p->zFilename));
}
zFlag = PT("comment");
if(zFlag!=0 && *zFlag!=0){
blob_append(&p->comment, zFlag, -1);
}
zFlag = P("comment_mimetype");
if(zFlag){
p->zCommentMimetype = mprintf("%s",zFlag);
zFlag = 0;
}
#define p_int(K) atoi(PD(K,"0"))
if(p_int("dry_run")!=0){
p->flags |= CIMINI_DRY_RUN;
}
if(p_int("allow_fork")!=0){
p->flags |= CIMINI_ALLOW_FORK;
}
if(p_int("allow_older")!=0){
p->flags |= CIMINI_ALLOW_OLDER;
}
if(0==p_int("exec_bit")){
p->filePerm = PERM_REG;
}else{
p->filePerm = PERM_EXE;
}
if(p_int("allow_merge_conflict")!=0){
p->flags |= CIMINI_ALLOW_MERGE_MARKER;
}
if(p_int("prefer_delta")!=0){
p->flags |= CIMINI_PREFER_DELTA;
}
/* EOL conversion policy... */
switch(p_int("eol")){
case 1: p->flags |= CIMINI_CONVERT_EOL_UNIX; break;
case 2: p->flags |= CIMINI_CONVERT_EOL_WINDOWS; break;
default: p->flags |= CIMINI_CONVERT_EOL_INHERIT; break;
}
#undef p_int
/*
** TODO?: date-override date selection field. Maybe use
** an input[type=datetime-local].
*/
p->zUser = mprintf("%s",g.zLogin);
return 0;
end_fail:
#undef fail
fossil_free(zFileUuid);
return rc ? rc : 500;
}
/*
** AJAX route /fileedit?ajax=filelist
**
** Fetches a JSON-format list of leaves and/or filenames for use in
** creating a file selection list in /fileedit. It has different modes
** of operation depending on its arguments:
**
** 'leaves': just fetch a list of open leaf versions, in this
** format:
**
** [
** {checkin: UUID, branch: branchName, timestamp: string}
** ]
**
** The entries are ordered newest first.
**
** 'checkin=CHECKIN_NAME': fetch the current list of is-editable files
** for the current user and given checkin name:
**
** {
** checkin: UUID,
** editableFiles: [ filename1, ... filenameN ] // sorted by name
** }
**
** On error it produces a JSON response as documented for
** fileedit_ajax_error().
*/
static void fileedit_ajax_filelist(void){
const char * zCi = PD("checkin",P("ci"));
Blob sql = empty_blob;
Stmt q = empty_Stmt;
int i = 0;
if(!fileedit_ajax_boostrap(0)){
return;
}
cgi_set_content_type("application/json");
if(zCi!=0){
char * zCiFull = 0;
int vid = 0;
if(0==fileedit_ajax_setup_filerev(zCi, &zCiFull, &vid, 0, 0)){
/* Error already reported */
return;
}
CX("{\"checkin\":%!j,"
"\"editableFiles\":[", zCiFull);
blob_append_sql(&sql, "SELECT filename FROM files_of_checkin(%Q) "
"ORDER BY filename %s",
zCiFull, filename_collation());
db_prepare_blob(&q, &sql);
while( SQLITE_ROW==db_step(&q) ){
const char * zFilename = db_column_text(&q, 0);
if(fileedit_is_editable(zFilename)){
if(i++){
CX(",");
}
CX("%!j", zFilename);
}
}
db_finalize(&q);
CX("]}");
}else if(P("leaves")!=0){
blob_append(&sql, timeline_query_for_tty(), -1);
blob_append_sql(&sql, " AND blob.rid IN (SElECT rid FROM leaf "
"WHERE NOT EXISTS("
"SELECT 1 from tagxref WHERE tagid=%d AND "
"tagtype>0 AND rid=leaf.rid"
")) "
"ORDER BY mtime DESC", TAG_CLOSED);
db_prepare_blob(&q, &sql);
CX("[");
while( SQLITE_ROW==db_step(&q) ){
if(i++){
CX(",");
}
CX("{");
CX("\"checkin\":%!j,", db_column_text(&q, 1));
CX("\"branch\":%!j,", db_column_text(&q, 7));
CX("\"timestamp\":%!j", db_column_text(&q, 2));
CX("}");
}
CX("]");
db_finalize(&q);
}else{
fileedit_ajax_error(500, "Unhandled URL argument.");
}
}
/*
** AJAX route /fileedit?ajax=commit
**
** Required query parameters:
**
** filename=FILENAME
** checkin=Parent checkin UUID
** content=text
** comment=non-empty text
**
** Optional query parameters:
**
** comment_mimetype=text (NOT currently honored)
**
** dry_run=int (1 or 0)
**
** include_manifest=int (1 or 0), whether to include
** the generated manifest in the response.
**
**
** User must have Write permissions to use this page.
**
** Responds with JSON (with some state repeated
** from the input in order to avoid certain race conditions
** client-side):
**
** {
** checkin: newUUID,
** filename: theFilename,
** mimetype: string,
** branch: name of the checkin's branch,
** isExe: bool,
** dryRun: bool,
** manifest: text of manifest,
** }
**
** On error it produces a JSON response as documented for
** fileedit_ajax_error().
*/
static void fileedit_ajax_commit(void){
Blob err = empty_blob; /* Error messages */
Blob manifest = empty_blob; /* raw new manifest */
CheckinMiniInfo cimi; /* checkin state */
int rc; /* generic result code */
int newVid = 0; /* new version's RID */
char * zNewUuid = 0; /* newVid's UUID */
char const * zMimetype;
char * zBranch = 0;
if(!fileedit_ajax_boostrap(1)){
return;
}
db_begin_transaction();
CheckinMiniInfo_init(&cimi);
rc = fileedit_setup_cimi_from_p(&cimi, &err, 0);
if(0!=rc){
fileedit_ajax_error(rc,"%b",&err);
goto end_cleanup;
}
if(blob_size(&cimi.comment)==0){
fileedit_ajax_error(400,"Empty checkin comment is not permitted.");
goto end_cleanup;
}
if(0!=atoi(PD("include_manifest","0"))){
cimi.pMfOut = &manifest;
}
checkin_mini(&cimi, &newVid, &err);
if(blob_size(&err)){
fileedit_ajax_error(500,"%b",&err);
goto end_cleanup;
}
assert(newVid>0);
zNewUuid = rid_to_uuid(newVid);
cgi_set_content_type("application/json");
CX("{");
CX("\"checkin\":%!j,", zNewUuid);
CX("\"filename\":%!j,", cimi.zFilename);
CX("\"isExe\": %s,", cimi.filePerm==PERM_EXE ? "true" : "false");
zMimetype = mimetype_from_name(cimi.zFilename);
if(zMimetype!=0){
CX("\"mimetype\": %!j,", zMimetype);
}
zBranch = branch_of_rid(newVid);
if(zBranch!=0){
CX("\"branch\": %!j,", zBranch);
fossil_free(zBranch);
}
CX("\"dryRun\": %s",
(CIMINI_DRY_RUN & cimi.flags) ? "true" : "false");
if(blob_size(&manifest)>0){
CX(",\"manifest\": %!j", blob_str(&manifest));
}
CX("}");
db_end_transaction(0/*noting that dry-run mode will have already
** set this to rollback mode. */);
end_cleanup:
fossil_free(zNewUuid);
blob_reset(&err);
blob_reset(&manifest);
CheckinMiniInfo_cleanup(&cimi);
}
/*
** WEBPAGE: fileedit
**
** Enables the online editing and committing of individual text files.
** Requires that the user have Write permissions.
**
** Optional query parameters:
**
** filename=FILENAME Repo-relative path to the file.
** checkin=VERSION Checkin version, using any unambiguous
** supported symbolic version name.
**
** Internal-use parameters:
**
** name=string The name of a page-specific AJAX operation.
**
** Noting that fossil internally stores all URL path components after
** the first as the "name" value. Thus /fileedit?name=blah is
** equivalent to /fileedit/blah. The latter is the preferred
** form. This means, however, that no fileedit ajax routes may make
** use of the name parameter.
**
** Which additional parameters are used by each distinct ajax value is
** an internal implementation detail and may change with any given
** build of this code. An unknown "name" value triggers an error, as
** documented for fileedit_ajax_error().
*/
void fileedit_page(void){
const char * zFilename = 0; /* filename. We'll accept 'name'
because that param is handled
specially by the core. */
const char * zRev = 0; /* checkin version */
const char * zFileMime = 0; /* File mime type guess */
CheckinMiniInfo cimi; /* Checkin state */
int previewHtmlHeight = 0; /* iframe height (EMs) */
int previewRenderMode = FE_RENDER_GUESS; /* preview mode */
Blob err = empty_blob; /* Error report */
Blob endScript = empty_blob; /* Script code to run at the
end. This content will be
combined into a single JS
function call, thus each
entry must end with a
semicolon. */
const char *zAjax = P("name");
if(0!=zAjax){
if(0==strcmp("content",zAjax)){
fileedit_ajax_content();
}else if(0==strcmp("preview",zAjax)){
fileedit_ajax_preview();
}else if(0==strcmp("filelist",zAjax)){
fileedit_ajax_filelist();
}else if(0==strcmp("diff",zAjax)){
fileedit_ajax_diff();
}else if(0==strcmp("commit",zAjax)){
fileedit_ajax_commit();
}else{
fileedit_ajax_error(500, "Unhandled ajax route name.");
}
return;
}
login_check_credentials();
if( !g.perm.Write ){
login_needed(g.anon.Write);
return;
}
db_begin_transaction();
CheckinMiniInfo_init(&cimi);
style_header("File Editor");
/* As of this point, don't use return or fossil_fatal(). Write any
** error in (&err) and goto end_footer instead so that we can be
** sure to do any cleanup and end the transaction cleanly.
*/
{
int isMissingArg = 0;
if(fileedit_setup_cimi_from_p(&cimi, &err, &isMissingArg)==0){
zFilename = cimi.zFilename;
zRev = cimi.zParentUuid;
assert(zRev);
assert(zFilename);
zFileMime = mimetype_from_name(cimi.zFilename);
}else if(isMissingArg!=0){
/* Squelch these startup warnings - they're non-fatal now but
** used to be. */
blob_reset(&err);
}
}
/********************************************************************
** All errors which "could" have happened up to this point are of a
** degree which keep us from rendering the rest of the page, and
** thus have already caused us to skipped to the end of the page to
** render the errors. Any up-coming errors, barring malloc failure
** or similar, are not "that" fatal. We can/should continue
** rendering the page, then output the error message at the end.
********************************************************************/
{
/* The CSS for this page lives in a common file but much of it we
** don't want inadvertently being used by other pages. We don't
** have a common, page-specific container we can filter our CSS
** selectors, but we do have the BODY, which we can decorate with
** whatever CSS we wish...
*/
style_emit_script_tag(0,0);
CX("document.body.classList.add('fileedit');\n");
style_emit_script_tag(1,0);
}
if(fileedit_glob()==0){
CX("<div class='error'>To enable online editing, the "
"<code>fileedit-glob</code> repository setting must be set to a "
"comma- or newine-delimited list of glob values matching files "
"which may be edited online."
"</div>");
}
/* Status bar */
CX("<div id='fossil-status-bar' "
"title='Status message area. Double-click to clear them.'>"
"Status messages will go here.</div>\n"
/* will be moved into the tab container via JS */);
/* Main tab container... */
CX("<div id='fileedit-tabs' class='tab-container'></div>");
/***** File/version info tab *****/
{
CX("<div id='fileedit-tab-fileselect' "
"data-tab-parent='fileedit-tabs' "
"data-tab-label='File Info & Selection'"
">");
CX("<fieldset id='file-version-details'>"
"<legend>File/Version</legend>"
"<div>No file loaded.</div>"
"</fieldset>");
CX("<h1>Select a file to edit:</h1>");
CX("<div id='fileedit-file-selector'></div>");
CX("</div>"/*#fileedit-tab-fileselect*/);
}
/******* Content tab *******/
{
CX("<div id='fileedit-tab-content' "
"data-tab-parent='fileedit-tabs' "
"data-tab-label='File Content'"
">");
CX("<div class='flex-container flex-row child-gap-small'>");
CX("<button class='fileedit-content-reload confirmer' "
"title='Reload the file from the server, discarding "
"any local edits. To help avoid accidental loss of "
"edits, it requires confirmation (a second click) within "
"a few seconds or it will not reload.'"
">Discard & Reload</button>");
style_select_list_int("select-font-size",
"editor_font_size", "Editor font size",
NULL/*tooltip*/,
100,
"100%", 100, "125%", 125,
"150%", 150, "175%", 175,
"200%", 200, NULL);
CX("</div>");
CX("<div class='flex-container flex-column stretch'>");
CX("<textarea name='content' id='fileedit-content-editor' "
"class='fileedit' "
"rows='20' cols='80'>");
CX("</textarea>");
CX("</div>"/*textarea wrapper*/);
CX("</div>"/*#tab-file-content*/);
}
/****** Preview tab ******/
{
CX("<div id='fileedit-tab-preview' "
"data-tab-parent='fileedit-tabs' "
"data-tab-label='Preview'"
">");
CX("<div class='fileedit-options flex-container flex-row'>");
CX("<button id='btn-preview-refresh' "
"data-f-preview-from='fileContent' "
/* ^^^ fossil.page[methodName]() OR text source elem ID,
** but we need a method in order to support clients swapping out
** the text editor with their own. */
"data-f-preview-via='_postPreview' "
/* ^^^ fossil.page[methodName](content, callback) */
"data-f-preview-to='#fileedit-tab-preview-wrapper' "
/* ^^^ dest elem ID */
">Refresh</button>");
/* Toggle auto-update of preview when the Preview tab is selected. */
style_labeled_checkbox("cb-preview-autoupdate",
NULL,
"Auto-refresh?",
"1", 1,
"If on, the preview will automatically "
"refresh when this tab is selected.");
/* Default preview rendering mode selection... */
previewRenderMode = zFileMime
? fileedit_render_mode_for_mimetype(zFileMime)
: FE_RENDER_GUESS;
style_select_list_int("select-preview-mode",
"preview_render_mode",
"Preview Mode",
"Preview mode format.",
previewRenderMode,
"Guess", FE_RENDER_GUESS,
"Wiki/Markdown", FE_RENDER_WIKI,
"HTML (iframe)", FE_RENDER_HTML_IFRAME,
"HTML (inline)", FE_RENDER_HTML_INLINE,
"Plain Text", FE_RENDER_PLAIN_TEXT,
NULL);
/*
** Set up a JS-side mapping of the FE_RENDER_xyz values. This is
** used for dynamically toggling certain UI components on and off.
*/
blob_appendf(&endScript, "fossil.page.previewModes={"
"guess: %d, %d: 'guess', wiki: %d, %d: 'wiki',"
"htmlIframe: %d, %d: 'htmlIframe', "
"htmlInline: %d, %d: 'htmlInline', "
"text: %d, %d: 'text'"
"};\n",
FE_RENDER_GUESS, FE_RENDER_GUESS,
FE_RENDER_WIKI, FE_RENDER_WIKI,
FE_RENDER_HTML_IFRAME, FE_RENDER_HTML_IFRAME,
FE_RENDER_HTML_INLINE, FE_RENDER_HTML_INLINE,
FE_RENDER_PLAIN_TEXT, FE_RENDER_PLAIN_TEXT);
/* Allow selection of HTML preview iframe height */
previewHtmlHeight = 40;
style_select_list_int("select-preview-html-ems",
"preview_html_ems",
"HTML Preview IFrame Height (EMs)",
"Height (in EMs) of the iframe used for "
"HTML preview",
previewHtmlHeight,
"", 20, "", 40,
"", 60, "", 80,
"", 100, NULL);
/* Selection of line numbers for text preview */
style_labeled_checkbox("cb-line-numbers",
"preview_ln",
"Add line numbers to plain-text previews?",
"1", P("preview_ln")!=0,
"If on, plain-text files (only) will get "
"line numbers added to the preview.");
CX("</div>"/*.fileedit-options*/);
CX("<div id='fileedit-tab-preview-wrapper'></div>");
CX("</div>"/*#fileedit-tab-preview*/);
}
/****** Diff tab ******/
{
CX("<div id='fileedit-tab-diff' "
"data-tab-parent='fileedit-tabs' "
"data-tab-label='Diff'"
">");
CX("<div class='fileedit-options flex-container flex-row' "
"id='fileedit-tab-diff-buttons'>");
CX("<button class='sbs'>Side-by-side</button>"
"<button class='unified'>Unified</button>");
if(0){
/* For the time being let's just ignore all whitespace
** changes, as files with Windows-style EOLs always show
** more diffs than we want then they're submitted to
** ?ajax=diff because JS normalizes them to Unix EOLs.
** We can revisit this decision later. */
style_select_list_int("diff-ws-policy",
"diff_ws", "Whitespace",
"Whitespace handling policy.",
2,
"Diff all whitespace", 0,
"Ignore EOL whitespace", 1,
"Ignore all whitespace", 2,
NULL);
}
CX("</div>");
CX("<div id='fileedit-tab-diff-wrapper'>"
"Diffs will be shown here."
"</div>");
CX("</div>"/*#fileedit-tab-diff*/);
}
/****** Commit ******/
CX("<div id='fileedit-tab-commit' "
"data-tab-parent='fileedit-tabs' "
"data-tab-label='Commit'"
">");
{
/******* Commit flags/options *******/
CX("<div class='fileedit-options flex-container flex-row'>");
style_labeled_checkbox("cb-dry-run",
"dry_run", "Dry-run?", "1",
0,
"In dry-run mode, the Commit button performs"
"all work needed for committing changes but "
"then rolls back the transaction, and thus "
"does not really commit.");
style_labeled_checkbox("cb-allow-fork",
"allow_fork", "Allow fork?", "1",
cimi.flags & CIMINI_ALLOW_FORK,
"Allow committing to create a fork?");
style_labeled_checkbox("cb-allow-older",
"allow_older", "Allow older?", "1",
cimi.flags & CIMINI_ALLOW_OLDER,
"Allow saving against a parent version "
"which has a newer timestamp?");
style_labeled_checkbox("cb-exec-bit",
"exec_bit", "Executable?", "1",
PERM_EXE==cimi.filePerm,
"Set the executable bit?");
style_labeled_checkbox("cb-allow-merge-conflict",
"allow_merge_conflict",
"Allow merge conflict markers?", "1",
cimi.flags & CIMINI_ALLOW_MERGE_MARKER,
"Allow saving even if the content contains "
"what appear to be fossil merge conflict "
"markers?");
style_labeled_checkbox("cb-prefer-delta",
"prefer_delta",
"Prefer delta manifest?", "1",
db_get_boolean("forbid-delta-manifests",0)
? 0
: (db_get_boolean("seen-delta-manifest",0)
|| cimi.flags & CIMINI_PREFER_DELTA),
"Will create a delta manifest, instead of "
"baseline, if conditions are favorable to "
"do so. This option is only a suggestion.");
style_labeled_checkbox("cb-include-manifest",
"include_manifest",
"Response manifest?", "1",
0,
"Include the manifest in the response? "
"It's generally only useful for debug "
"purposes.");
style_select_list_int("select-eol-style",
"eol", "EOL Style",
"EOL conversion policy, noting that "
"webpage-side processing may implicitly change "
"the line endings of the input.",
(cimi.flags & CIMINI_CONVERT_EOL_UNIX)
? 1 : (cimi.flags & CIMINI_CONVERT_EOL_WINDOWS
? 2 : 0),
"Inherit", 0,
"Unix", 1,
"Windows", 2,
NULL);
CX("</div>"/*checkboxes*/);
}
{ /******* Commit comment, button, and result manifest *******/
CX("<fieldset class='fileedit-options commit-message'>"
"<legend>Message (required)</legend><div>\n");
/* We have two comment input fields, defaulting to single-line
** mode. JS code sets up the ability to toggle between single-
** and multi-line modes. */
CX("<input type='text' name='comment' "
"id='fileedit-comment'></input>");
CX("<textarea name='commentBig' class='hidden' "
"rows='5' id='fileedit-comment-big'></textarea>\n");
{ /* comment options... */
CX("<div class='flex-container flex-column child-gap-small'>");
CX("<button id='comment-toggle' "
"title='Toggle between single- and multi-line comment mode, "
"noting that switching from multi- to single-line will cause "
"newlines to get stripped.'"
">Toggle single-/multi-line</button> ");
if(0){
/* Manifests support an N-card (comment mime type) but it has
** yet to be honored where comments are rendered, so we don't
** currently offer it as an option here:
** https://fossil-scm.org/forum/forumpost/662da045a1
**
** If/when it's ever implemented, simply enable this block and
** adjust the container's layout accordingly (as of this
** writing, that means changing the CSS class from
** 'flex-container flex-column' to 'flex-container flex-row').
*/
style_select_list_str("comment-mimetype", "comment_mimetype",
"Comment style:",
"Specify how fossil will interpret the "
"comment string.",
NULL,
"Fossil", "text/x-fossil-wiki",
"Markdown", "text/x-markdown",
"Plain text", "text/plain",
NULL);
CX("</div>\n");
}
CX("<div class='fileedit-hint flex-container flex-row'>"
"(Warning: switching from multi- to single-line mode will "
"strip out all newlines!)</div>");
}
CX("</div></fieldset>\n"/*commit comment options*/);
CX("<div class='flex-container flex-column' "
"id='fileedit-commit-button-wrapper'>"
"<button id='fileedit-btn-commit'>Commit</button>"
"</div>\n");
CX("<div id='fileedit-manifest'></div>\n"
/* Manifest gets rendered here after a commit. */);
}
CX("</div>"/*#fileedit-tab-commit*/);
/****** Help/Tips ******/
CX("<div id='fileedit-tab-help' "
"data-tab-parent='fileedit-tabs' "
"data-tab-label='Help'"
">");
{
CX("<h1>Help & Tips</h1>");
CX("<ul>");
CX("<li><strong>Only files matching the <code>fileedit-glob</code> "
"repository setting</strong> can be edited online. That setting "
"must be a comma- or newline-delimited list of glob patterns "
"for files which may be edited online.</li>");
CX("<li>Committing edits creates a new commit record with a single "
"modified file.</li>");
CX("<li>\"Delta manifests\" (see the checkbox on the Commit tab) "
"make for smaller commit records, especially in repositories "
"with many files.</li>");
CX("<li>The file selector allows, for usability's sake, only files "
"in leaf check-ins to be selected, but files may be edited via "
"non-leaf check-ins by passing them as the <code>filename</code> "
"and <code>checkin</code> URL arguments to this page.</li>");
CX("<li>The editor stores some number of local edits in one of "
"<code>window.fileStorage</code> or "
"<code>window.sessionStorage</code>, if able, but which storage "
"is unspecified and may differ across environments. When "
"committing or force-reloading a file, local edits to that "
"file/check-in combination are discarded.</li>");
CX("</ul>");
}
CX("</div>"/*#fileedit-tab-help*/);
{
/* Dynamically populate the editor, display any error in the err
** blob, and/or switch to tab #0, where the file selector
** lives... */
blob_appendf(&endScript,
"window.addEventListener('load',");
if(zRev && zFilename){
assert(0==blob_size(&err));
blob_appendf(&endScript,
"()=>fossil.page.loadFile(%!j,%!j)",
zFilename, cimi.zParentUuid);
}else{
blob_appendf(&endScript,"function(){");
if(blob_size(&err)>0){
blob_appendf(&endScript,
"fossil.error(%!j);\n",
blob_str(&err));
}
blob_appendf(&endScript,
"fossil.page.tabs.switchToTab(0);\n");
blob_appendf(&endScript,"}");
}
blob_appendf(&endScript,", false);\n");
}
blob_reset(&err);
CheckinMiniInfo_cleanup(&cimi);
style_emit_script_fossil_bootstrap(0);
append_diff_javascript(1);
style_emit_script_fetch(0);
style_emit_script_tabs(0)/*also emits fossil.dom*/;
style_emit_script_confirmer(0);
style_emit_script_builtin(0, "fossil.storage.js");
style_emit_script_builtin(0, "fossil.page.fileedit.js");
if(blob_size(&endScript)>0){
style_emit_script_tag(0,0);
CX("(function(){\n");
CX("try{\n%b\n}"
"catch(e){"
"fossil.error(e);\n"
"console.error('Exception:',e);\n"
"}\n",
&endScript);
CX("})();");
style_emit_script_tag(1,0);
}
db_end_transaction(0);
style_footer();
}
|
Changes to src/finfo.c.
| ︙ | ︙ | |||
623 624 625 626 627 628 629 630 631 632 633 634 635 636 |
@ [annotate]</a>
@ %z(href("%R/blame?filename=%h&checkin=%s",z,zCkin))
@ [blame]</a>
@ %z(href("%R/timeline?n=all&uf=%!S",zUuid))[check-ins using]</a>
if( fpid>0 ){
@ %z(href("%R/fdiff?v1=%!S&v2=%!S",zPUuid,zUuid))[diff]</a>
}
@ </span></span>
}
if( fDebug & FINFO_DEBUG_MLINK ){
int ii;
char *zAncLink;
@ <br />fid=%d(frid) pid=%d(fpid) mid=%d(fmid)
if( nParent>0 ){
| > > > | 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
@ [annotate]</a>
@ %z(href("%R/blame?filename=%h&checkin=%s",z,zCkin))
@ [blame]</a>
@ %z(href("%R/timeline?n=all&uf=%!S",zUuid))[check-ins using]</a>
if( fpid>0 ){
@ %z(href("%R/fdiff?v1=%!S&v2=%!S",zPUuid,zUuid))[diff]</a>
}
if( fileedit_is_editable(zFilename) ){
@ %z(href("%R/fileedit?filename=%T&checkin=%!S",zFilename,zCkin))[edit]</a>
}
@ </span></span>
}
if( fDebug & FINFO_DEBUG_MLINK ){
int ii;
char *zAncLink;
@ <br />fid=%d(frid) pid=%d(fpid) mid=%d(fmid)
if( nParent>0 ){
|
| ︙ | ︙ |
Added src/fossil.bootstrap.js.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
"use strict";
(function(global){
/* Bootstrapping bits for the global.fossil object. Must be
loaded after style.c:style_emit_script_tag() has initialized
that object.
*/
const F = global.fossil;
/**
Returns the current time in something approximating
ISO-8601 format.
*/
const timestring = function f(){
if(!f.rx1){
f.rx1 = /\.\d+Z$/;
}
const d = new Date();
return d.toISOString().replace(f.rx1,'').split('T').join(' ');
};
/*
** By default fossil.message() sends its arguments console.debug(). If
** fossil.message.targetElement is set, it is assumed to be a DOM
** element, its innerText gets assigned to the concatenation of all
** arguments (with a space between each), and the CSS 'error' class is
** removed from the object. Pass it a falsy value to clear the target
** element.
**
** Returns this object.
*/
F.message = function f(msg){
const args = Array.prototype.slice.call(arguments,0);
const tgt = f.targetElement;
if(args.length) args.unshift(timestring(),'UTC:');
if(tgt){
tgt.classList.remove('error');
tgt.innerText = args.join(' ');
}
else{
if(args.length){
args.unshift('Fossil status:');
console.debug.apply(console,args);
}
}
return this;
};
/*
** Set default message.targetElement to #fossil-status-bar, if found.
*/
F.message.targetElement =
document.querySelector('#fossil-status-bar');
if(F.message.targetElement){
F.message.targetElement.addEventListener(
'dblclick', ()=>F.message(), false
);
}
/*
** By default fossil.error() sends its first argument to
** console.error(). If fossil.message.targetElement (yes,
** fossil.message) is set, it adds the 'error' CSS class to
** that element and sets its content as defined for message().
**
** Returns this object.
*/
F.error = function f(msg){
const args = Array.prototype.slice.call(arguments,0);
const tgt = F.message.targetElement;
args.unshift(timestring(),'UTC:');
if(tgt){
tgt.classList.add('error');
tgt.innerText = args.join(' ');
}
else{
args.unshift('Fossil error:');
console.error.apply(console,args);
}
return this;
};
/**
For each property in the given object, its key/value are encoded
for use as URL parameters and the combined string is
returned. e.g. {a:1,b:2} encodes to "a=1&b=2".
If the 2nd argument is an array, each encoded element is appended
to that array and tgtArray is returned. The above object would be
appended as ['a','=','1','&','b','=','2']. This form is used for
building up parameter lists before join('')ing the array to create
the result string.
If passed a truthy 3rd argument, it does not really encode each
component - it simply concatenates them together.
*/
F.encodeUrlArgs = function(obj,tgtArray,fakeEncode){
if(!obj) return '';
const a = (tgtArray instanceof Array) ? tgtArray : [],
enc = fakeEncode ? (x)=>x : encodeURIComponent;
let k, i = 0;
for( k in obj ){
if(i++) a.push('&');
a.push(enc(k),'=',enc(obj[k]));
}
return a===tgtArray ? a : a.join('');
};
/**
repoUrl( repoRelativePath [,urlParams] )
Creates a URL by prepending this.rootPath to the given path
(which must be relative from the top of the site, without a
leading slash). If urlParams is a string, it must be
paramters encoded in the form "key=val&key2=val2...", WITHOUT
a leading '?'. If it's an object, all of its properties get
appended to the URL in that form.
*/
F.repoUrl = function(path,urlParams){
if(!urlParams) return this.rootPath+path;
const url=[this.rootPath,path];
url.push('?');
if('string'===typeof urlParams) url.push(urlParams);
else if('object'===typeof urlParams){
this.encodeUrlArgs(urlParams, url);
}
return url.join('');
};
/**
Returns true if v appears to be a plain object.
*/
F.isObject = function(v){
return v &&
(v instanceof Object) &&
('[object Object]' === Object.prototype.toString.apply(v) );
};
/**
For each object argument, this function combines their properties,
using a last-one-wins policy, and returns a new object with the
combined properties. If passed a single object, it effectively
shallowly clones that object.
*/
F.mergeLastWins = function(){
var k, o, i;
const n = arguments.length, rc={};
for(i = 0; i < n; ++i){
if(!F.isObject(o = arguments[i])) continue;
for( k in o ){
if(o.hasOwnProperty(k)) rc[k] = o[k];
}
}
return rc;
};
/**
Expects to be passed as hash code as its first argument. It
returns a "shortened" form of hash, with a length which depends
on the 2nd argument: truthy = fossil.config.hashDigitsUrl, falsy
= fossil.config.hashDigits, number == that many digits. The
fossil.config values are derived from the 'hash-digits'
repo-level config setting or the
FOSSIL_HASH_DIGITS_URL/FOSSIL_HASH_DIGITS compile-time options.
If its first arugment is a non-string, that value is returned
as-is.
*/
F.hashDigits = function(hash,forUrl){
const n = ('number'===typeof forUrl)
? forUrl : F.config[forUrl ? 'hashDigitsUrl' : 'hashDigits'];
return ('string'==typeof hash ? hash.substr(
0, n
) : hash);
};
/**
Sets up pseudo-automatic content preview handling between a
source element (typically a TEXTAREA) and a target rendering
element (typically a DIV). The selector argument must be one of:
- A single DOM element
- A collection of DOM elements with a forEach method.
- A CSS selector
Each element in the collection must have the following data
attributes:
- data-f-preview-from: is either a DOM element id, WITH a leading
'#' prefix, or the name of a method (see below). If it's an ID,
the DOM element must support .value to get the content.
- data-f-preview-to: the DOM element id of the target "previewer"
element, WITH a leading '#', or the name of a method (see below).
- data-f-preview-via: the name of a method (see below).
- OPTIONAL data-f-preview-as-text: a numeric value. Explained below.
Each element gets a click handler added to it which does the
following:
1) Reads the content from its data-f-preview-from element or, if
that property refers to a method, calls the method without
arguments and uses its result as the content.
2) Passes the content to
methodNamespace[f-data-post-via](content,callback). f-data-post-via
is responsible for submitting the preview HTTP request, including
any parameters the request might require. When the response
arrives, it must pass the content of the response to its 2nd
argument, an auto-generated callback installed by this mechanism
which...
3) Assigns the response text to the data-f-preview-to element or
passes it to the function methodNamespace[f-data-preview-to](content), as
appropriate. If data-f-preview-to is a DOM element and
data-f-preview-as-text is '0' (the default) then the content is
assigned to the target element's innerHTML property, else it is
assigned to the element's textContent property.
The methodNamespace (2nd argument) defaults to fossil.page, and
any method-name data properties, e.g. data-f-preview-via and
potentially data-f-preview-from/to, must be a single method name,
not a property-access-style string. e.g. "myPreview" is legal but
"foo.myPreview" is not (unless, of course, the method is actually
named "foo.myPreview" (which is legal but would be
unconventional)).
An example...
First an input button:
<button id='test-preview-connector'
data-f-preview-from='#fileedit-content-editor' // elem ID or method name
data-f-preview-via='myPreview' // method name
data-f-preview-to='#fileedit-tab-preview-wrapper' // elem ID or method name
>Preview update</button>
And a sample data-f-preview-via method:
fossil.page.myPreview = function(content,callback){
const fd = new FormData();
fd.append('foo', ...);
fossil.fetch('preview_forumpost',{
payload: fd,
onload: callback,
onerror: (e)=>{ // only if app-specific handling is needed
fossil.fetch.onerror(e); // default impl
... any app-specific error reporting ...
}
});
};
Then connect the parts with:
fossil.connectPagePreviewers('#test-preview-connector');
Note that the data-f-preview-from, data-f-preview-via, and
data-f-preview-to selector are not resolved until the button is
actually clicked, so they need not exist in the DOM at the
instant when the connection is set up, so long as they can be
resolved when the preview-refreshing element is clicked.
*/
F.connectPagePreviewers = function f(selector,methodNamespace){
if('string'===typeof selector){
selector = document.querySelectorAll(selector);
}else if(!selector.forEach){
selector = [selector];
}
if(!methodNamespace){
methodNamespace = F.page;
}
selector.forEach(function(e){
e.addEventListener(
'click', function(r){
const eTo = '#'===e.dataset.fPreviewTo[0]
? document.querySelector(e.dataset.fPreviewTo)
: methodNamespace[e.dataset.fPreviewTo],
eFrom = '#'===e.dataset.fPreviewFrom[0]
? document.querySelector(e.dataset.fPreviewFrom)
: methodNamespace[e.dataset.fPreviewFrom],
asText = +(e.dataset.fPreviewAsText || 0);
eTo.textContent = "Fetching preview...";
methodNamespace[e.dataset.fPreviewVia](
(eFrom instanceof Function ? eFrom() : eFrom.value),
(r)=>{
if(eTo instanceof Function) eTo(r||'');
else eTo[asText ? 'textContent' : 'innerHTML'] = r||'';
}
);
}, false
);
});
return this;
};
/**
Convenience wrapper which adds an onload event listener to the
window object. Returns this.
*/
F.onPageLoad = function(callback){
window.addEventListener('load', callback, false);
return this;
};
/**
Assuming name is a repo-style filename, this function returns
a shortened form of that name:
.../LastDirectoryPart/FilenamePart
If the name has 0-1 directory parts, it is returned as-is.
Design note: in practice it is generally not helpful to elide the
*last* directory part because embedded docs (in particular) often
include x/y/index.md and x/z/index.md, both of which would be
shortened to something like x/.../index.md.
*/
F.shortenFilename = function(name){
const a = name.split('/');
if(a.length<=2) return name;
while(a.length>2) a.shift();
return '.../'+a.join('/');
};
/**
Adds a listener for fossil-level custom events. Events are
delivered to their callbacks as CustomEvent objects with a
'detail' property holding the event's app-level data.
The exact events fired differ by page, and not all pages trigger
events.
Pedantic sidebar: the custom event's 'target' property is an
unspecified DOM element. Clients must not rely on its value being
anything specific or useful.
Returns this object.
*/
F.page.addEventListener = function f(eventName, callback){
if(!f.proxy){
f.proxy = document.createElement('span');
}
f.proxy.addEventListener(eventName, callback, false);
return this;
};
/**
Internal. Dispatches a new CustomEvent to all listeners
registered for the given eventName via
fossil.page.addEventListener(), passing on a new CustomEvent with
a 'detail' property equal to the 2nd argument. Returns this
object.
*/
F.page.dispatchEvent = function(eventName, eventDetail){
if(this.addEventListener.proxy){
try{
this.addEventListener.proxy.dispatchEvent(
new CustomEvent(eventName,{detail: eventDetail})
);
}catch(e){
console.error(eventName,"event listener threw:",e);
}
}
return this;
};
/**
Sets the innerText of the page's TITLE tag to
the given text and returns this object.
*/
F.page.setPageTitle = function(title){
const t = document.querySelector('title');
if(t) t.innerText = title;
return this;
};
})(window);
|
Added src/fossil.confirmer.js.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
"use strict";
/**************************************************************
Confirmer is a utility which provides an alternative to confirmation
dialog boxes and "check this checkbox to confirm action" widgets. It
acts by modifying a button to require two clicks within a certain
time, with the second click acting as a confirmation of the first. If
the second click does not come within a specified timeout then the
action is not confirmed.
Usage:
fossil.confirmer(domElement, options);
Usually:
fossil.confirmer(element, {
onconfirm: function(){
// this === the element.
// Do whatever the element would normally do when
// clicked.
}
});
Options:
.initialText = initial text of the element. Defaults to the result
of the element's .value (for INPUT tags) or innerHTML (for
everything else). After the timeout/tick count expires, or if the
user confirms the operation, the element's text is re-set to this
value.
.confirmText = text to show when in "confirm mode".
Default=("Confirm: "+initialText), or something similar.
.timeout = Number of milliseconds to wait for confirmation.
Default=3000. Alternately, use a combination of .ticks and
.ticktime.
.onconfirm = function to call when clicked in confirm mode. Default
= undefined. The function's "this" is the the DOM element to which
the countdown applies.
.ontimeout = function to call when confirm is not issued. Default =
undefined. The function's "this" is the DOM element to which the
countdown applies.
.onactivate = function to call when item is clicked, but only if the
item is not currently in countdown mode. This is called (and must
return) before the countdown starts. The function's "this" is the
DOM element to which the countdown applies. This can be used, e.g.,
to change the element's text or CSS classes.
.classInitial = optional CSS class string (default='') which is
added to the element during its "initial" state (the state it is in
when it is not waiting on a timeout). When the target is activated
(waiting on a timeout) this class is removed. In the case of a
timeout, this class is added *before* the .ontimeout handler is
called.
.classWaiting = optional CSS class string (default='') which is
added to the target when it is waiting on a timeout. When the target
leaves timeout-wait mode, this class is removed. When timeout-wait
mode is entered, this class is added *before* the .onactivate
handler is called.
.ticktime = a number of ms to wait per tick (see the next item).
Default = 1000.
.ticks = a number of "ticks" to wait, as an alternative to .timeout.
When this mode is active, the ontick callback will be triggered
immediately before each tick, including the first one. If both
.ticks and .timeout are set, only one will be used, but which one is
unspecified. If passed a ticks value with a truncated integer value
of 0 or less, it will throw an exception (e.g. that also applies if
it's passed 0.5).
.ontick = when using .ticks, this callback is passed the current
tick number before each tick, and its "this" is the target
element. On each subsequent call, the tick count will be reduced by
1, and it is passed 0 after the final tick expires or when the
action has been confirmed, immediately before the onconfirm or
ontimeout callback. The intention of the callback is to update the
label of the target element. If .ticks is set but .ontick is not
then a default implementation is used which updates the element with
the .confirmText, prepending a countdown to it.
.debug = boolean. If truthy, it sends some debug output to the dev
console to track what it's doing.
Various notes:
- To change the default option values, modify the
fossil.confirmer.defaultOpts object.
- Exceptions triggered via the callbacks are caught and emitted to the
dev console if the debug option is enabled, but are otherwise
ignored.
- Due to the nature of multi-threaded code, it is potentially possible
that confirmation and timeout actions BOTH happen if the user
triggers the associated action at "just the right millisecond"
before the timeout is triggered.
TODO: add an invert option which activates if the timeout is reached
and "times out" if the element is clicked again. e.g. a button which
says "Saving..." and cancels the op if it's clicked again, else it
saves after X time/ticks.
Terse Change history:
- 20200507:
- Add a tick-based countdown in order to more easily support
updating the target element with the countdown.
- 20200506:
- Ported from jQuery to plain JS.
- 20181112:
- extended to support certain INPUT elements.
- made default opts configurable.
- 20070717: initial jQuery-based impl.
*/
(function(F/*the fossil object*/){
F.confirmer = function f(elem,opt){
const dbg = opt.debug
? function(){console.debug.apply(console,arguments)}
: function(){};
dbg("confirmer opt =",opt);
if(!f.Holder){
f.isInput = (e)=>/^(input|textarea)$/i.test(e.nodeName);
f.Holder = function(target,opt){
const self = this;
this.target = target;
this.opt = opt;
this.timerID = undefined;
this.state = this.states.initial;
const isInput = f.isInput(target);
const updateText = function(msg){
if(isInput) target.value = msg;
else target.innerHTML = msg;
}
updateText(this.opt.initialText);
if(this.opt.ticks && !this.opt.ontick){
this.opt.ontick = function(tick){
updateText("("+tick+") "+self.opt.confirmText);
};
}
this.setClasses(false);
this.doTimeout = function() {
if(this.timerID){
clearTimeout( this.timerID );
delete this.timerID;
}
if( this.state != this.states.waiting ) {
// it was already confirmed
return;
}
this.setClasses( false );
this.state = this.states.initial;
dbg("Timeout triggered.");
if( this.opt.ontick ){
try{this.opt.ontick.call(this.target, 0)}
catch(e){dbg("ontick EXCEPTION:",e)}
}
if( this.opt.ontimeout ) {
try{this.opt.ontimeout.call(this.target)}
catch(e){dbg("ontimeout EXCEPTION:",e)}
}
updateText(this.opt.initialText);
};
target.addEventListener(
'click', function(){
switch( self.state ) {
case( self.states.waiting ):
/* Cancel the wait on confirmation */
if( undefined !== self.timerID ){
clearTimeout( self.timerID );
delete self.timerID;
}
self.state = self.states.initial;
self.setClasses( false );
dbg("Confirmed");
if( self.opt.ontick ){
try{self.opt.ontick.call(self.target,0)}
catch(e){dbg("ontick EXCEPTION:",e)}
}
if( self.opt.onconfirm ){
try{self.opt.onconfirm.call(self.target)}
catch(e){dbg("onconfirm EXCEPTION:",e)}
}
updateText(self.opt.initialText);
break;
case( self.states.initial ):
/* Enter the waiting-on-confirmation state... */
if(self.opt.ticks) self.opt.currentTick = self.opt.ticks;
self.setClasses( true );
self.state = self.states.waiting;
updateText( self.opt.confirmText );
if( self.opt.onactivate ) self.opt.onactivate.call( self.target );
if( self.opt.ontick ) self.opt.ontick.call(self.target, self.opt.currentTick);
if(self.opt.timeout){
dbg("Waiting "+self.opt.timeout+"ms on confirmation...");
self.timerID =
setTimeout(()=>self.doTimeout(),self.opt.timeout );
}else if(self.opt.ticks){
dbg("Waiting on confirmation for "+self.opt.ticks
+" ticks of "+self.opt.ticktime+"ms each...");
self.timerID =
setInterval(function(){
if(0===--self.opt.currentTick) self.doTimeout();
else{
try{self.opt.ontick.call(self.target,
self.opt.currentTick)}
catch(e){dbg("ontick EXCEPTION:",e)}
}
},self.opt.ticktime);
}
break;
default: // can't happen.
break;
}
}, false
);
};
f.Holder.prototype = {
states:{initial: 0, waiting: 1},
setClasses: function(activated) {
if(activated) {
if( this.opt.classWaiting ) {
this.target.classList.add( this.opt.classWaiting );
}
if( this.opt.classInitial ) {
this.target.classList.remove( this.opt.classInitial );
}
}else{
if( this.opt.classInitial ) {
this.target.classList.add( this.opt.classInitial );
}
if( this.opt.classWaiting ) {
this.target.classList.remove( this.opt.classWaiting );
}
}
}
};
}/*static init*/
opt = F.mergeLastWins(f.defaultOpts,{
initialText: (
f.isInput(elem) ? elem.value : elem.innerHTML
) || "PLEASE SET .initialText"
},opt);
if(!opt.confirmText){
opt.confirmText = "Confirm: "+opt.initialText;
}
if(opt.ticks){
delete opt.timeout;
opt.ticks = 0 | opt.ticks /* ensure it's an integer */;
if(opt.ticks<=0){
throw new Error("ticks must be >0");
}
if(opt.ticktime <= 0) opt.ticktime = 1000;
}else{
delete opt.ontick;
delete opt.ticks;
}
new f.Holder(elem,opt);
return this;
};
/**
The default options for initConfirmer(). Tweak them to set the
defaults. A couple of them (initialText and confirmText) are
dynamically-generated, and can't reasonably be set in the
defaults.
*/
F.confirmer.defaultOpts = {
timeout:3000,
ticks: undefined,
ticktime: 998/*not *quite* 1000*/,
onconfirm: undefined,
ontimeout: undefined,
onactivate: undefined,
classInitial: '',
classWaiting: '',
debug: false
};
})(window.fossil);
|
Added src/fossil.dom.js.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
"use strict";
(function(F/*fossil object*/){
/**
A collection of HTML DOM utilities to simplify, a bit, using the
DOM API. It is focused on manipulation of the DOM, but one of its
core mantras is "No innerHTML." Using innerHTML in this code, in
particular assigning to it, is absolutely verboten.
*/
const argsToArray = (a)=>Array.prototype.slice.call(a,0);
const isArray = (v)=>v instanceof Array;
const dom = {
create: function(elemType){
return document.createElement(elemType);
},
createElemFactory: function(eType){
return function(){
return document.createElement(eType);
};
},
remove: function(e){
if(e.forEach){
e.forEach(
(x)=>x.parentNode.removeChild(x)
);
}else{
e.parentNode.removeChild(e);
}
return e;
},
/**
Removes all child DOM elements from the given element
and returns that element.
If e has a forEach method (is an array or DOM element
collection), this function instead clears each element in the
collection. May be passed any number of arguments, each of
which must be a DOM element or a container of DOM elements with
a forEach() method. Returns its first argument.
*/
clearElement: function f(e){
if(!f.each){
f.each = function(e){
if(e.forEach){
e.forEach((x)=>f(x));
return e;
}
while(e.firstChild) e.removeChild(e.firstChild);
};
}
argsToArray(arguments).forEach(f.each);
return arguments[0];
},
}/* dom object */;
/**
Returns the result of splitting the given str on
a run of spaces of (\s*,\s*).
*/
dom.splitClassList = function f(str){
if(!f.rx){
f.rx = /(\s+|\s*,\s*)/;
}
return str ? str.split(f.rx) : [str];
};
dom.div = dom.createElemFactory('div');
dom.p = dom.createElemFactory('p');
dom.code = dom.createElemFactory('code');
dom.pre = dom.createElemFactory('pre');
dom.header = dom.createElemFactory('header');
dom.footer = dom.createElemFactory('footer');
dom.section = dom.createElemFactory('section');
dom.span = dom.createElemFactory('span');
dom.strong = dom.createElemFactory('strong');
dom.em = dom.createElemFactory('em');
dom.img = function(src){
const e = dom.create('img');
if(src) e.setAttribute('src',src);
return e;
};
/**
Creates and returns a new anchor element with the given
optional href and label. If label===true then href is used
as the label.
*/
dom.a = function(href,label){
const e = dom.create('a');
if(href) e.setAttribute('href',href);
if(label) e.appendChild(dom.text(true===label ? href : label));
return e;
};
dom.hr = dom.createElemFactory('hr');
dom.br = dom.createElemFactory('br');
dom.text = (t)=>document.createTextNode(t||'');
dom.button = function(label){
const b = this.create('button');
if(label) b.appendChild(this.text(label));
return b;
};
dom.select = dom.createElemFactory('select');
/**
Returns an OPTION element with the given value and label
text (which defaults to the value).
May be called as (value), (selectElement), (selectElement,
value), (value, label) or (selectElement, value,
label). The latter appends the new element to the given
SELECT element.
If the value has the undefined value then it is NOT
assigned as the option element's value.
*/
dom.option = function(value,label){
const a = arguments;
var sel;
if(1==a.length){
if(a[0] instanceof HTMLElement){
sel = a[0];
}else{
value = a[0];
}
}else if(2==a.length){
if(a[0] instanceof HTMLElement){
sel = a[0];
value = a[1];
}else{
value = a[0];
label = a[1];
}
}
else if(3===a.length){
sel = a[0];
value = a[1];
label = a[2];
}
const o = this.create('option');
if(undefined !== value){
o.value = value;
this.append(o, this.text(label || value));
}
if(sel) this.append(sel, o);
return o;
};
dom.h = function(level){
return this.create('h'+level);
};
dom.ul = dom.createElemFactory('ul');
/**
Creates and returns a new LI element, appending it to the
given parent argument if it is provided.
*/
dom.li = function(parent){
const li = this.create('li');
if(parent) parent.appendChild(li);
return li;
};
/**
Returns a function which creates a new DOM element of the
given type and accepts an optional parent DOM element
argument. If the function's argument is truthy, the new
child element is appended to the given parent element.
Returns the new child element.
*/
dom.createElemFactoryWithOptionalParent = function(childType){
return function(parent){
const e = this.create(childType);
if(parent) parent.appendChild(e);
return e;
};
};
dom.table = dom.createElemFactory('table');
dom.thead = dom.createElemFactoryWithOptionalParent('thead');
dom.tbody = dom.createElemFactoryWithOptionalParent('tbody');
dom.tfoot = dom.createElemFactoryWithOptionalParent('tfoot');
dom.tr = dom.createElemFactoryWithOptionalParent('tr');
dom.td = dom.createElemFactoryWithOptionalParent('td');
dom.th = dom.createElemFactoryWithOptionalParent('th');
/**
Creates and returns a FIELDSET element, optionaly with a
LEGEND element added to it.
*/
dom.fieldset = function(legendText){
const fs = this.create('fieldset');
if(legendText){
this.append(
fs,
this.append(
this.create('legend'),
legendText
)
);
}
return fs;
};
/**
Appends each argument after the first to the first argument
(a DOM node) and returns the first argument.
- If an argument is a string or number, it is transformed
into a text node.
- If an argument is an array or has a forEach member, this
function appends each element in that list to the target
by calling its forEach() method to pass it (recursively)
to this function.
- Else the argument assumed to be of a type legal
to pass to parent.appendChild().
*/
dom.append = function f(parent/*,...*/){
const a = argsToArray(arguments);
a.shift();
for(let i in a) {
var e = a[i];
if(isArray(e) || e.forEach){
e.forEach((x)=>f.call(this, parent,e));
continue;
}
if('string'===typeof e || 'number'===typeof e) e = this.text(e);
parent.appendChild(e);
}
return parent;
};
dom.input = function(type){
return this.attr(this.create('input'), 'type', type);
};
/**
Internal impl for addClass(), removeClass().
*/
const domAddRemoveClass = function f(action,e){
if(!f.rxSPlus){
f.rxSPlus = /\s+/;
f.applyAction = function(e,a,v){
if(!e || !v
/*silently skip empty strings/flasy
values, for user convenience*/) return;
else if(e.forEach){
e.forEach((E)=>E.classList[a](v));
}else{
e.classList[a](v);
}
};
}
var i = 2, n = arguments.length;
for( ; i < n; ++i ){
let c = arguments[i];
if(!c) continue;
else if(isArray(c) ||
('string'===typeof c
&& c.indexOf(' ')>=0
&& (c = c.split(f.rxSPlus)))
|| c.forEach
){
c.forEach((k)=>k ? f.applyAction(e, action, k) : false);
// ^^^ we could arguably call f(action,e,k) to recursively
// apply constructs like ['foo bar'] or [['foo'],['bar baz']].
}else if(c){
f.applyAction(e, action, c);
}
}
return e;
};
/**
Adds one or more CSS classes to one or more DOM elements.
The first argument is a target DOM element or a list type of such elements
which has a forEach() method. Each argument
after the first may be a string or array of strings. Each
string may contain spaces, in which case it is treated as a
list of CSS classes.
Returns e.
*/
dom.addClass = function(e,c){
const a = argsToArray(arguments);
a.unshift('add');
return domAddRemoveClass.apply(this, a);
};
/**
The 'remove' counterpart of the addClass() method, taking
the same arguments and returning the same thing.
*/
dom.removeClass = function(e,c){
const a = argsToArray(arguments);
a.unshift('remove');
return domAddRemoveClass.apply(this, a);
};
dom.hasClass = function(e,c){
return (e && e.classList) ? e.classList.contains(c) : false;
};
/**
Each argument after the first may be a single DOM element
or a container of them with a forEach() method. All such
elements are appended, in the given order, to the dest
element.
Returns dest.
*/
dom.moveTo = function(dest,e){
const n = arguments.length;
var i = 1;
for( ; i < n; ++i ){
e = arguments[i];
if(e.forEach){
e.forEach((x)=>dest.appendChild(x));
}else{
dest.appendChild(e);
}
}
return dest;
};
/**
Each argument after the first may be a single DOM element
or a container of them with a forEach() method. For each
DOM element argument, all children of that DOM element
are moved to dest (via appendChild()). For each list argument,
each entry in the list is assumed to be a DOM element and is
appended to dest.
dest may be an Array, in which case each child is pushed
into the array and removed from its current parent element.
All children are appended in the given order.
Returns dest.
*/
dom.moveChildrenTo = function f(dest,e){
if(!f.mv){
f.mv = function(d,v){
if(d instanceof Array){
d.push(v);
if(v.parentNode) v.parentNode.removeChild(v);
}
else d.appendChild(v);
};
}
const n = arguments.length;
var i = 1;
for( ; i < n; ++i ){
e = arguments[i];
if(!e){
console.warn("Achtung: dom.moveChildrenTo() passed a falsy value at argment",i,"of",
arguments,arguments[i]);
continue;
}
if(e.forEach){
e.forEach((x)=>f.mv(dest, x));
}else{
while(e.firstChild){
f.mv(dest, e.firstChild);
}
}
}
return dest;
};
/**
Adds each argument (DOM Elements) after the first to the
DOM immediately before the first argument (in the order
provided), then removes the first argument from the DOM.
Returns void.
If any argument beyond the first has a forEach method, that
method is used to recursively insert the collection's
contents before removing the first argument from the DOM.
*/
dom.replaceNode = function f(old,nu){
var i = 1, n = arguments.length;
++f.counter;
try {
for( ; i < n; ++i ){
const e = arguments[i];
if(e.forEach){
e.forEach((x)=>f.call(this,old,e));
continue;
}
old.parentNode.insertBefore(e, old);
}
}
finally{
--f.counter;
}
if(!f.counter){
old.parentNode.removeChild(old);
}
};
dom.replaceNode.counter = 0;
/**
Two args == getter: (e,key), returns value
Three == setter: (e,key,val), returns e. If val===null
or val===undefined then the attribute is removed. If (e)
has a forEach method then this routine is applied to each
element of that collection via that method.
*/
dom.attr = function f(e){
if(2===arguments.length) return e.getAttribute(arguments[1]);
if(e.forEach){
e.forEach((x)=>f(x,arguments[1],arguments[2]));
return e;
}
const key = arguments[1], val = arguments[2];
if(null===val || undefined===val){
e.removeAttribute(key);
}else{
e.setAttribute(key,val);
}
return e;
};
const enableDisable = function f(enable){
var i = 1, n = arguments.length;
for( ; i < n; ++i ){
let e = arguments[i];
if(e.forEach){
e.forEach((x)=>f(enable,x));
}else{
e.disabled = !enable;
}
}
return arguments[1];
};
/**
Enables (by removing the "disabled" attribute) each element
(HTML DOM element or a collection with a forEach method)
and returns the first argument.
*/
dom.enable = function(e){
const args = argsToArray(arguments);
args.unshift(true);
return enableDisable.apply(this,args);
};
/**
Disables (by setting the "disabled" attribute) each element
(HTML DOM element or a collection with a forEach method)
and returns the first argument.
*/
dom.disable = function(e){
const args = argsToArray(arguments);
args.unshift(false);
return enableDisable.apply(this,args);
};
/**
A proxy for document.querySelector() which throws if
selection x is not found. It may optionally be passed an
"origin" object as its 2nd argument, which restricts the
search to that branch of the tree.
*/
dom.selectOne = function(x,origin){
var src = origin || document,
e = src.querySelector(x);
if(!e){
e = new Error("Cannot find DOM element: "+x);
console.error(e, src);
throw e;
}
return e;
};
return F.dom = dom;
})(window.fossil);
|
Added src/fossil.fetch.js.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
"use strict";
/**
Requires that window.fossil has already been set up.
window.fossil.fetch() is an HTTP request/response mini-framework
similar (but not identical) to the not-quite-ubiquitous
window.fetch().
JS usages:
fossil.fetch( URI [, onLoadCallback] );
fossil.fetch( URI [, optionsObject = {}] );
Noting that URI must be relative to the top of the repository and
should not start with a slash (if it does, it is stripped). It gets
the equivalent of "%R/" prepended to it.
The optionsObject may be an onload callback or an object with any
of these properties:
- onload: callback(responseData) (default = output response to the
console). In the context of the callback, the options object is
"this", noting that this call may have amended the options object
with state other than what the caller provided.
- onerror: callback(XHR onload event | exception) (default = event
or exception to the console). Triggered if the request generates
any response other than HTTP 200. In the context of the callback,
the options object is "this".
- method: 'POST' | 'GET' (default = 'GET'). CASE SENSITIVE!
- payload: anything acceptable by XHR2.send(ARG) (DOMString,
Document, FormData, Blob, File, ArrayBuffer), or a plain object or
array, either of which gets JSON.stringify()'d. If payload is set
then the method is automatically set to 'POST'. By default XHR2
will set the content type based on the payload type. If an
object/array is converted to JSON, the contentType option is
automatically set to 'application/json', and if JSON.stringify() of
that value fails then the exception is propagated to this
function's caller.
- contentType: Optional request content type when POSTing. Ignored
if the method is not 'POST'.
- responseType: optional string. One of ("text", "arraybuffer",
"blob", or "document") (as specified by XHR2). Default = "text".
As an extension, it supports "json", which tells it that the
response is expected to be text and that it should be JSON.parse()d
before passing it on to the onload() callback. If parsing of such
an object fails, the onload callback is not called, and the
onerror() callback is passed the exception from the parsing error.
- urlParams: string|object. If a string, it is assumed to be a
URI-encoded list of params in the form "key1=val1&key2=val2...",
with NO leading '?'. If it is an object, all of its properties get
converted to that form. Either way, the parameters get appended to
the URL before submitting the request.
- responseHeaders: If true, the onload() callback is passed an
additional argument: a map of all of the response headers. If it's
a string value, the 2nd argument passed to onload() is instead the
value of that single header. If it's an array, it's treated as a
list of headers to return, and the 2nd argument is a map of those
header values. When a map is passed on, all of its keys are
lower-cased. When a given header is requested and that header is
set multiple times, their values are (per the XHR docs)
concatenated together with ", " between them.
- beforesend/aftersend: optional callbacks which are called without
arguments immediately before the request is submitted and
immediately after it is received, regardless of success or
error. In the context of the callback, the options object is the
"this". These can be used to, e.g., keep track of in-flight
requests and update the UI accordingly, e.g. disabling/enabling DOM
elements. Any exceptions triggered by beforesend/aftersend are
caught and silently ignored.
When an options object does not provide
onload/onerror/beforesend/aftersend handlers of its own, this
function falls to defaults which are member properties of this
function with the same name, e.g. fossil.fetch.onload(). The
default onload/onerror implementations route the data through the
dev console and (for onerror()) through fossil.error(). The default
beforesend/aftersend are no-ops. Individual pages may overwrite
those members to provide default implementations suitable for the
page's use, e.g. keeping track of how many in-flight
Returns this object, noting that the XHR request is asynchronous,
and still in transit (or has yet to be sent) when that happens.
*/
window.fossil.fetch = function f(uri,opt){
const F = fossil;
if(!f.onload){
f.onload = (r)=>console.debug('ajax response:',r);
}
if(!f.onerror){
f.onerror = function(e/*event or exception*/){
console.error("Ajax error:",e);
if(e instanceof Error){
F.error('Exception:',e);
}
else if(e.originalTarget && e.originalTarget.responseType==='text'){
const txt = e.originalTarget.responseText;
try{
/* The convention from the /filepage_xyz routes is to
return error responses in JSON form if possible:
{error: "..."}
*/
const j = JSON.parse(txt);
console.error("Error JSON:",j);
if(j.error){ F.error(j.error) };
}catch(e){/* Try harder */
F.error(txt)
}
}
};
}/*f.onerror()*/
if(!f.parseResponseHeaders){
f.parseResponseHeaders = function(h){
const rc = {};
if(!h) return rc;
const ar = h.trim().split(/[\r\n]+/);
ar.forEach(function(line) {
const parts = line.split(': ');
const header = parts.shift();
const value = parts.join(': ');
rc[header.toLowerCase()] = value;
});
return rc;
};
}
if('/'===uri[0]) uri = uri.substr(1);
if(!opt) opt = {};
else if('function'===typeof opt) opt={onload:opt};
if(!opt.onload) opt.onload = f.onload;
if(!opt.onerror) opt.onerror = f.onerror;
if(!opt.beforesend) opt.beforesend = f.beforesend;
if(!opt.aftersend) opt.aftersend = f.aftersend;
let payload = opt.payload, jsonResponse = false;
if(undefined!==payload){
opt.method = 'POST';
if(!(payload instanceof FormData)
&& !(payload instanceof Document)
&& !(payload instanceof Blob)
&& !(payload instanceof File)
&& !(payload instanceof ArrayBuffer)
&& ('object'===typeof payload
|| payload instanceof Array)){
payload = JSON.stringify(payload);
opt.contentType = 'application/json';
}
}
const url=[F.repoUrl(uri,opt.urlParams)],
x=new XMLHttpRequest();
if('POST'===opt.method && 'string'===typeof opt.contentType){
x.setRequestHeader('Content-Type',opt.contentType);
}
x.open(opt.method||'GET', url.join(''), true);
if('json'===opt.responseType){
/* 'json' is an extension to the supported XHR.responseType
list. We use it as a flag to tell us to JSON.parse()
the response. */
jsonResponse = true;
x.responseType = 'text';
}else{
x.responseType = opt.responseType||'text';
}
x.onload = function(e){
try{opt.aftersend()}catch(e){/*ignore*/}
if(200!==this.status){
opt.onerror(e);
return;
}
const orh = opt.responseHeaders;
let head;
if(true===orh){
head = f.parseResponseHeaders(this.getAllResponseHeaders());
}else if('string'===typeof orh){
head = this.getResponseHeader(orh);
}else if(orh instanceof Array){
head = {};
orh.forEach((s)=>{
if('string' === typeof s) head[s.toLowerCase()] = x.getResponseHeader(s);
});
}
try{
const args = [(jsonResponse && this.response)
? JSON.parse(this.response) : this.response];
if(head) args.push(head);
opt.onload.apply(opt, args);
}catch(e){
opt.onerror(e);
}
};
try{opt.beforesend()}catch(e){/*ignore*/}
if(undefined!==payload) x.send(payload);
else x.send();
return this;
};
window.fossil.fetch.beforesend = function(){};
window.fossil.fetch.aftersend = function(){};
|
Added src/fossil.page.fileedit.js.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 |
(function(F/*the fossil object*/){
"use strict";
/**
Client-side implementation of the /filepage app. Requires that
the fossil JS bootstrapping is complete and that several fossil
JS APIs have been installed: fossil.fetch, fossil.dom,
fossil.tabs, fossil.storage, fossil.confirmer.
Custom events which can be listened for via
fossil.page.addEventListener():
- Event 'fileedit-file-loaded': passes on information when it
loads a file (whether from the network or its internal local-edit
cache), in the form of an "finfo" object:
{
filename: string,
checkin: UUID string,
branch: branch name of UUID,
isExe: bool, true only for executable files
mimetype: mimetype string, as determined by the fossil server.
}
The internal docs and code frequently use the term "finfo", and such
references refer to an object with that form.
The fossil.page.fileContent() method gets or sets the current file
content for the page.
- Event 'fileedit-committed': is fired when a commit completes,
passing on the same info as fileedit-file-loaded.
- Event 'fileedit-content-replaced': when the editor's content is
replaced, as opposed to it being edited via user
interaction. This normally happens via selecting a file to
load. The event detail is the fossil.page object, not the current
file content.
- Event 'fileedit-preview-updated': when the preview is refreshed
from the server, this event passes on information about the preview
change in the form of an object:
{
element: the DOM element which contains the content preview.
mimetype: the fossil-reported content mimetype.
previewMode: a string describing the preview mode: see
the fossil.page.previewModes map for the values. This can
be used to determine whether, e.g., the content is suitable
for applying a 3rd-party code highlighting API to.
}
Here's an example which can be used with the highlightjs code
highlighter to update the highlighting when the preview is
refreshed in "wiki" mode (which includes fossil-native wiki and
markdown):
fossil.page.addEventListener(
'fileedit-preview-updated',
(ev)=>{
if(ev.detail.previewMode==='wiki'){
ev.detail.element.querySelectorAll(
'code[class^=language-]'
).forEach((e)=>hljs.highlightBlock(e));
}
}
);
*/
const E = (s)=>document.querySelector(s),
D = F.dom,
P = F.page;
P.config = {
defaultMaxStashSize: 7
};
/**
$stash is an internal-use-only object for managing "stashed"
local edits, to help avoid that users accidentally lose content
by switching tabs or following links or some such. The basic
theory of operation is...
All "stashed" state is stored using fossil.storage.
- When the current file content is modified by the user, the
current stathe of the current P.finfo and its the content
is stashed. For the built-in editor widget, "changes" is
notified via a 'change' event. For a client-side custom
widget, the client needs to call P.stashContentChange() when
their widget triggers the equivalent of a 'change' event.
- For certain non-content updates (as of this writing, only the
is-executable checkbox), only the P.finfo stash entry is
updated, not the content (unless the content has not yet been
stashed, in which case it is also stashed so that the stash
always has matching pairs of finfo/content).
- When saving, the stashed entry for the previous version is removed
from the stash.
- When "loading", we use any stashed state for the given
checkin/file combination. When forcing a re-load of content,
any stashed entry for that combination is removed from the
stash.
- Every time P.stashContentChange() updates the stash, it is
pruned to $stash.prune.defaultMaxCount most-recently-updated
entries.
- This API often refers to "finfo objects." Those are objects
with a minimum of {checkin,filename} properties (which must be
valid), and a combination of those two properties is used as
basis for the stash keys for any given checkin/filename
combination.
The structure of the stash is a bit convoluted for efficiency's
sake: we store a map of file info (finfo) objects separately from
those files' contents because otherwise we would be required to
JSONize/de-JSONize the file content when stashing/restoring it,
and that would be horribly inefficient (meaning "battery-consuming"
on mobile devices).
*/
const $stash = {
keys: {
index: F.page.name+'/index'
},
/**
index: {
"CHECKIN_HASH:FILENAME": {file info w/o content}
...
}
In F.storage we...
- Store this.index under the key this.keys.index.
- Store each file's content under the key
(P.name+'/CHECKIN_HASH:FILENAME'). These are stored separately
from the index entries to avoid having to JSONize/de-JSONize
the content. The assumption/hope is that the browser can store
those records "directly," without any intermediary
encoding/decoding going on.
*/
indexKey: function(finfo){return finfo.checkin+':'+finfo.filename},
/** Returns the key for storing content for the given key suffix,
by prepending P.name to suffix. */
contentKey: function(suffix){return P.name+'/'+suffix},
/** Returns the index object, fetching it from the stash or creating
it anew on the first call. */
getIndex: function(){
if(!this.index){
this.index = F.storage.getJSON(
this.keys.index, undefined
);
if(!this.index){
/*check for and remove/replace older name. This whole block
can be removed once the test phase is done (don't want to
invalidate the testers' edits on the test server). When
doing so, be sure to replace undefined in the above
getJSON() call with {}. */
const oldName = F.page.name+':index';
this.index = F.storage.getJSON(oldName,undefined);
if(this.index){
F.storage.remove(oldName);
this.storeIndex();
}else{
this.index = {};
}
}
}
return this.index;
},
_fireStashEvent: function(){
if(this._disableNextEvent) delete this._disableNextEvent;
else F.page.dispatchEvent('fileedit-stash-updated', this);
},
/**
Returns the stashed version, if any, for the given finfo object.
*/
getFinfo: function(finfo){
const ndx = this.getIndex();
return ndx[this.indexKey(finfo)];
},
/** Serializes this object's index to F.storage. Returns this. */
storeIndex: function(){
if(this.index) F.storage.setJSON(this.keys.index,this.index);
return this;
},
/** Updates the stash record for the given finfo
and (optionally) content. If passed 1 arg, only
the finfo stash is updated, else both the finfo
and its contents are (re-)stashed. Returns this.
*/
updateFile: function(finfo,content){
const ndx = this.getIndex(),
key = this.indexKey(finfo),
old = ndx[key];
const record = old || (ndx[key]={
checkin: finfo.checkin,
filename: finfo.filename,
mimetype: finfo.mimetype
});
record.isExe = !!finfo.isExe;
record.stashTime = new Date().getTime();
if(!record.branch) record.branch=finfo.branch;
this.storeIndex();
if(arguments.length>1){
F.storage.set(this.contentKey(key), content);
}
this._fireStashEvent();
return this;
},
/**
Returns the stashed content, if any, for the given finfo
object.
*/
stashedContent: function(finfo){
return F.storage.get(this.contentKey(this.indexKey(finfo)));
},
/** Returns true if we have stashed content for the given finfo
record. */
hasStashedContent: function(finfo){
return F.storage.contains(this.contentKey(this.indexKey(finfo)));
},
/** Unstashes the given finfo record and its content.
Returns this. */
unstash: function(finfo){
const ndx = this.getIndex(),
key = this.indexKey(finfo);
delete finfo.stashTime;
delete ndx[key];
F.storage.remove(this.contentKey(key));
this.storeIndex();
this._fireStashEvent();
return this;
},
/**
Clears all $stash entries from F.storage. Returns this.
*/
clear: function(){
const ndx = this.getIndex(),
self = this;
let count = 0;
Object.keys(ndx).forEach(function(k){
++count;
const e = ndx[k];
delete ndx[k];
F.storage.remove(self.contentKey(k));
});
F.storage.remove(this.keys.index);
delete this.index;
if(count) this._fireStashEvent();
return this;
},
/**
Removes all but the maxCount most-recently-updated stash
entries, where maxCount defaults to this.prune.defaultMaxCount.
*/
prune: function f(maxCount){
const ndx = this.getIndex();
const li = [];
if(!maxCount || maxCount<0) maxCount = f.defaultMaxCount;
Object.keys(ndx).forEach((k)=>li.push(ndx[k]));
li.sort((l,r)=>l.stashTime - r.stashTime);
let n = 0;
while(li.length>maxCount){
++n;
const e = li.shift();
this._disableNextEvent = true;
this.unstash(e);
console.warn("Pruned oldest local file edit entry:",e);
}
if(n) this._fireStashEvent();
}
};
$stash.prune.defaultMaxCount = P.config.defaultMaxStashSize;
/**
Widget for the checkin/file selection list.
*/
P.fileSelectWidget = {
e:{
container: E('#fileedit-file-selector')
},
finfo: {},
cache: {
checkins: undefined,
files:{},
branchKey: 'fileedit/uuid-branches',
branchNames: {}
},
/**
Fetches the list of leaf checkins from the server and updates
the UI with that list.
*/
loadLeaves: function(){
D.append(D.clearElement(
this.e.ciListLabel,
this.e.selectCi,
this.e.selectFiles
),"Loading leaves...");
D.disable(this.e.btnLoadFile, this.e.selectFiles, this.e.selectCi);
const self = this;
F.fetch('fileedit/filelist',{
urlParams:'leaves',
responseType: 'json',
onload: function(list){
D.append(D.clearElement(self.e.ciListLabel),
"Open leaves (newest first):");
self.cache.checkins = list;
D.clearElement(D.enable(self.e.selectCi));
let loadThisOne;
list.forEach(function(o,n){
if(!n) loadThisOne = o;
self.cache.branchNames[F.hashDigits(o.checkin,true)] = o.branch;
D.option(self.e.selectCi, o.checkin,
o.timestamp+' ['+o.branch+']: '
+F.hashDigits(o.checkin));
});
F.storage.setJSON(self.cache.branchKey, self.cache.branchNames);
self.loadFiles(loadThisOne ? loadThisOne.checkin : false);
}
});
},
/**
Loads the file list for the given checkin UUID. It uses a
cached copy on subsequent calls for the same UUID. If passed a
falsy value, it instead clears and disables the file selection
list.
*/
loadFiles: function(ciUuid){
delete this.finfo.filename;
this.finfo.checkin = ciUuid;
const selFiles = this.e.selectFiles;
if(!ciUuid){
D.clearElement(D.disable(selFiles, this.e.btnLoadFile));
return this;
}
const onload = (response)=>{
D.clearElement(selFiles);
D.append(
D.clearElement(this.e.fileListLabel),
"Editable files for ",
D.append(
D.code(), "[",
D.a(F.repoUrl('timeline',{
c: ciUuid
}), F.hashDigits(ciUuid)),"]"
), ":"
);
this.cache.files[response.checkin] = response;
response.editableFiles.forEach(function(fn,n){
D.option(selFiles, fn);
});
if(selFiles.options.length){
D.enable(selFiles, this.e.btnLoadFile);
}
};
const got = this.cache.files[ciUuid];
if(got){
onload(got);
return this;
}
D.disable(selFiles,this.e.btnLoadFile);
D.clearElement(selFiles);
D.append(D.clearElement(this.e.fileListLabel),
"Loading files for "+F.hashDigits(ciUuid)+"...");
F.fetch('fileedit/filelist',{
urlParams:{checkin: ciUuid},
responseType: 'json',
onload
});
return this;
},
/**
If this object has ever loaded the given checkin version via
loadLeaves(), this returns the branch name associated with that
version, else returns undefined;
*/
checkinBranchName: function(uuid){
return this.cache.branchNames[F.hashDigits(uuid,true)];
},
/**
Initializes the checkin/file selector widget. Must only be
called once.
*/
init: function(){
this.cache.branchNames = F.storage.getJSON(this.cache.branchKey, {});
const selCi = this.e.selectCi = D.select(),
selFiles = this.e.selectFiles
= D.addClass(D.select(), 'file-list'),
btnLoad = this.e.btnLoadFile =
D.addClass(D.button("Load file"), "flex-shrink"),
filesLabel = this.e.fileListLabel =
D.addClass(D.div(),'flex-shrink','file-list-label'),
ciLabelWrapper = D.addClass(
D.div(), 'flex-container','flex-row', 'flex-shrink',
'stretch'
),
btnReload = D.addClass(
D.button('Reload'), 'flex-shrink'
),
ciLabel = this.e.ciListLabel =
D.addClass(D.span(),'flex-shrink','checkin-list-label')
;
D.attr(selCi, 'title',"The list of opened leaves.");
D.attr(selFiles, 'title',
"The list of editable files for the selected checkin.");
D.attr(btnLoad, 'title',
"Load the selected file into the editor.");
D.disable(selCi, selFiles, btnLoad);
D.attr(selFiles, 'size', 10);
D.append(
this.e.container,
D.append(ciLabelWrapper,
btnReload, ciLabel),
selCi,
filesLabel,
selFiles,
btnLoad
);
this.loadLeaves();
selCi.addEventListener(
'change', (e)=>this.loadFiles(e.target.value), false
);
btnLoad.addEventListener(
'click', (e)=>{
this.finfo.filename = selFiles.value;
if(this.finfo.filename){
P.loadFile(this.finfo.filename, this.finfo.checkin);
}
}, false
);
btnReload.addEventListener(
'click', (e)=>this.loadLeaves(), false
);
delete this.init;
}
}/*P.fileSelectWidget*/;
/**
Widget for listing and selecting $stash entries.
*/
P.stashWidget = {
e:{/*DOM element(s)*/},
init: function(domInsertPoint/*insert widget BEFORE this element*/){
const wrapper = D.addClass(
D.attr(D.div(),'id','fileedit-stash-selector'),
'input-with-label'
);
const sel = this.e.select = D.select();
const btnClear = this.e.btnClear
= D.addClass(D.button("Clear"),'hidden');
D.append(wrapper, "Local edits (",
D.append(D.code(),
F.storage.storageImplName()),
"):",
sel, btnClear);
D.attr(wrapper, "title", [
'Locally-edited files. Timestamps are the last local edit time.',
'Only the',P.config.defaultMaxStashSize,'most recent checkin/file',
'combinations are retained.',
'Committing or reloading a file removes it from this list.'
].join(' '));
D.option(D.disable(sel), "(empty)");
F.page.addEventListener('fileedit-stash-updated',(e)=>this.updateList(e.detail));
F.page.addEventListener('fileedit-file-loaded',(e)=>this.updateList($stash, e.detail));
sel.addEventListener('change',function(e){
const opt = this.selectedOptions[0];
if(opt && opt._finfo) P.loadFile(opt._finfo);
});
F.confirmer(btnClear, {
confirmText: "REALLY delete ALL local edits?",
onconfirm: (e)=>P.clearStash().loadFile(/*in case P.finfo() was in the stash*/),
ticks: 3
});
if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/
D.append(wrapper, D.append(
D.addClass(D.span(),'warning'),
"Warning: persistent storage is not available, "+
"so uncomitted edits will not survive a page reload."
));
}
domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
$stash._fireStashEvent(/*read the page-load-time stash*/);
delete this.init;
},
/**
Regenerates the edit selection list.
*/
updateList: function f(stasher,theFinfo){
if(!f.compare){
const cmpBase = (l,r)=>l<r ? -1 : (l===r ? 0 : 1);
f.compare = function(l,r){
const cmp = cmpBase(l.filename, r.filename);
return cmp ? cmp : cmpBase(l.checkin, r.checkin);
};
f.rxZ = /\.\d+Z$/ /* ms and 'Z' part of date string */;
const pad=(x)=>(''+x).length>1 ? x : '0'+x;
f.timestring = function ff(d){
return [
d.getFullYear(),'-',pad(d.getMonth()+1/*sigh*/),'-',pad(d.getDate()),
'@',pad(d.getHours()),':',pad(d.getMinutes())
].join('');
};
}
const index = stasher.getIndex(), ilist = [];
Object.keys(index).forEach((finfo)=>{
ilist.push(index[finfo]);
});
const self = this;
D.clearElement(this.e.select);
if(0===ilist.length){
D.addClass(this.e.btnClear, 'hidden');
D.option(D.disable(this.e.select),"No local edits");
return;
}
D.enable(this.e.select);
D.removeClass(this.e.btnClear, 'hidden');
D.disable(D.option(this.e.select,0,"Select a local edit..."));
const currentFinfo = theFinfo || P.finfo || {};
ilist.sort(f.compare).forEach(function(finfo,n){
const key = stasher.indexKey(finfo),
branch = finfo.branch
|| P.fileSelectWidget.checkinBranchName(finfo.checkin)||'';
/* Remember that we don't know the branch name for non-leaf versions
which P.fileSelectWidget() has never seen/cached. */
const opt = D.option(
self.e.select, n+1/*value is (almost) irrelevant*/,
[F.hashDigits(finfo.checkin, 6), ' [',branch||'?branch?','] ',
f.timestring(new Date(finfo.stashTime)),' ',
false ? finfo.filename : F.shortenFilename(finfo.filename)
].join('')
);
opt._finfo = finfo;
if(0===f.compare(currentFinfo, finfo)){
D.attr(opt, 'selected', true);
}
});
}
}/*P.stashWidget*/;
/**
Internal workaround to select the current preview mode
and fire a change event if the value actually changes
or if forceEvent is truthy.
*/
P.selectPreviewMode = function(modeValue, forceEvent){
const s = this.e.selectPreviewMode;
if(!modeValue) modeValue = s.value;
else if(s.value != modeValue){
s.value = modeValue;
forceEvent = true;
}
if(forceEvent){
// Force UI update
s.dispatchEvent(new Event('change',{target:s}));
}
};
/**
Keep track of how many in-flight AJAX requests there are so we
can disable input elements while any are pending. For
simplicity's sake we simply disable ALL OF IT while any AJAX is
pending, rather than disabling operation-specific UI elements,
which would be a huge maintenance hassle.
Noting, however, that this global on/off is not *quite*
pedantically correct. Pedantically speaking. If an element is
disabled before an XHR starts, this code "should" notice that and
not include it in the to-re-enable list. That would be annoying
to do, and becomes impossible to do properly once multiple XHRs
are in transit and an element is disabled seprately between two
of those in-transit requests (that would be an unlikely, but
possible, corner case). As of this writing, the only elements
which are ever normally programmatically toggled between
enabled/disabled...
1) Belong to the file selection list and remain disabled until
the list of leaves and files are loaded. i.e. they would be
disabled *anyway* during their own XHR requests.
2) The stashWidget's SELECT list when no local edits are
stashed. Curiously, the all-or-nothing re-enabling implemented
here does not re-enable that particular selection list. That's
because of timing, though: that widget is "manually" disabled
when the list is empty, and that list is normally emptied in
conjunction with an XHR request.
*/
const ajaxState = {
count: 0 /* in-flight F.fetch() requests */,
toDisable: undefined /* elements to disable during ajax activity */
};
F.fetch.beforesend = function f(){
if(!ajaxState.toDisable){
ajaxState.toDisable = document.querySelectorAll(
'button, input, select, textarea'
);
}
if(1===++ajaxState.count){
D.addClass(document.body, 'waiting');
D.disable(ajaxState.toDisable);
}
};
F.fetch.aftersend = function(){
if(0===--ajaxState.count){
D.removeClass(document.body, 'waiting');
D.enable(ajaxState.toDisable);
}
};
F.onPageLoad(function() {
P.base = {tag: E('base')};
P.base.originalHref = P.base.tag.href;
P.tabs = new fossil.TabManager('#fileedit-tabs');
P.e = { /* various DOM elements we work with... */
taEditor: E('#fileedit-content-editor'),
taCommentSmall: E('#fileedit-comment'),
taCommentBig: E('#fileedit-comment-big'),
taComment: undefined/*gets set to one of taComment{Big,Small}*/,
ajaxContentTarget: E('#ajax-target'),
btnCommit: E("#fileedit-btn-commit"),
btnReload: E("#fileedit-tab-content button.fileedit-content-reload"),
selectPreviewMode: E('#select-preview-mode select'),
selectHtmlEmsWrap: E('#select-preview-html-ems'),
selectEolWrap: E('#select-eol-style'),
selectEol: E('#select-eol-style select[name=eol]'),
selectFontSizeWrap: E('#select-font-size'),
selectDiffWS: E('select[name=diff_ws]'),
cbLineNumbersWrap: E('#cb-line-numbers'),
cbAutoPreview: E('#cb-preview-autoupdate > input[type=checkbox]'),
previewTarget: E('#fileedit-tab-preview-wrapper'),
manifestTarget: E('#fileedit-manifest'),
diffTarget: E('#fileedit-tab-diff-wrapper'),
cbIsExe: E('input[type=checkbox][name=exec_bit]'),
cbManifest: E('input[type=checkbox][name=include_manifest]'),
fsFileVersionDetails: E('#file-version-details'),
tabs:{
content: E('#fileedit-tab-content'),
preview: E('#fileedit-tab-preview'),
diff: E('#fileedit-tab-diff'),
commit: E('#fileedit-tab-commit'),
fileSelect: E('#fileedit-tab-fileselect')
}
};
/* Figure out which comment editor to show by default and
hide the other one. By default we take the one which does
not have the 'hidden' CSS class. If neither do, we default
to single-line mode. */
if(D.hasClass(P.e.taCommentSmall, 'hidden')){
P.e.taComment = P.e.taCommentBig;
}else if(D.hasClass(P.e.taCommentBig,'hidden')){
P.e.taComment = P.e.taCommentSmall;
}else{
P.e.taComment = P.e.taCommentSmall;
D.addClass(P.e.taCommentBig, 'hidden');
}
D.removeClass(P.e.taComment, 'hidden');
P.tabs.e.container.insertBefore(
/* Move the status bar between the tab buttons and
tab panels. Seems to be the best fit in terms of
functionality and visibility. */
E('#fossil-status-bar'), P.tabs.e.tabs
);
P.tabs.addEventListener(
/* Set up auto-refresh of the preview tab... */
'before-switch-to', function(ev){
if(ev.detail===P.e.tabs.preview){
P.baseHrefForFile();
if(P.e.cbAutoPreview.checked) P.preview();
}else if(ev.detail===P.e.tabs.diff){
/* Work around a weird bug where the page gets wider than
the window when the diff tab is NOT in view and the
current SBS diff widget is wider than the window. When
the diff IS in view then CSS overflow magically reduces
the page size again. Weird. Maybe FF-specific. Note that
this weirdness happens even though P.e.diffTarget's parent
is hidden (and therefore P.e.diffTarget is also hidden).
*/
D.removeClass(P.e.diffTarget, 'hidden');
}
}
);
P.tabs.addEventListener(
/* Set up auto-refresh of the preview tab... */
'before-switch-from', function(ev){
if(ev.detail===P.e.tabs.preview){
P.baseHrefRestore();
}else if(ev.detail===P.e.tabs.diff){
/* See notes in the before-switch-to handler. */
D.addClass(P.e.diffTarget, 'hidden');
}
}
);
F.connectPagePreviewers(
P.e.tabs.preview.querySelector(
'#btn-preview-refresh'
)
);
const diffButtons = E('#fileedit-tab-diff-buttons');
diffButtons.querySelector('button.sbs').addEventListener(
"click",(e)=>P.diff(true), false
);
diffButtons.querySelector('button.unified').addEventListener(
"click",(e)=>P.diff(false), false
);
P.e.btnCommit.addEventListener(
"click",(e)=>P.commit(), false
);
F.confirmer(P.e.btnReload, {
confirmText: "Really reload, losing edits?",
onconfirm: (e)=>P.unstashContent().loadFile(),
ticks: 3
});
E('#comment-toggle').addEventListener(
"click",(e)=>P.toggleCommentMode(), false
);
P.e.taEditor.addEventListener(
'change', ()=>P.stashContentChange(), false
);
P.e.cbIsExe.addEventListener(
'change', ()=>P.stashContentChange(true), false
);
/**
Cosmetic: jump through some hoops to enable/disable
certain preview options depending on the current
preview mode...
*/
P.e.selectPreviewMode.addEventListener(
"change", function(e){
const mode = e.target.value,
name = P.previewModes[mode],
hide = [], unhide = [];
P.previewModes.current = name;
if('guess'===name){
unhide.push(P.e.cbLineNumbersWrap,
P.e.selectHtmlEmsWrap);
}else{
if('text'===name) unhide.push(P.e.cbLineNumbersWrap);
else hide.push(P.e.cbLineNumbersWrap);
if('htmlIframe'===name) unhide.push(P.e.selectHtmlEmsWrap);
else hide.push(P.e.selectHtmlEmsWrap);
}
hide.forEach((e)=>e.classList.add('hidden'));
unhide.forEach((e)=>e.classList.remove('hidden'));
}, false
);
P.selectPreviewMode(false, true);
const selectFontSize = E('select[name=editor_font_size]');
if(selectFontSize){
selectFontSize.addEventListener(
"change",function(e){
const ed = P.e.taEditor;
ed.className = ed.className.replace(
/\bfont-size-\d+/g, '' );
ed.classList.add('font-size-'+e.target.value);
}, false
);
selectFontSize.dispatchEvent(
// Force UI update
new Event('change',{target:selectFontSize})
);
}
P.addEventListener(
// Clear certain views when new content is loaded/set
'fileedit-content-replaced',
()=>D.clearElement(P.e.diffTarget, P.e.previewTarget, P.e.manifestTarget)
);
P.addEventListener(
// Clear certain views after a non-dry-run commit
'fileedit-committed',
(e)=>{
if(!e.detail.dryRun){
D.clearElement(P.e.diffTarget, P.e.previewTarget);
}
}
);
P.fileSelectWidget.init();
P.stashWidget.init(
P.e.tabs.content.lastElementChild
//P.e.tabs.fileSelect.querySelector("h1")
);
}/*F.onPageLoad()*/);
/**
Getter (if called with no args) or setter (if passed an arg) for
the current file content.
The setter form sets the content, dispatches a
'fileedit-content-replaced' event, and returns this object.
*/
P.fileContent = function f(){
if(0===arguments.length){
return f.get();
}else{
f.set(arguments[0] || '');
this.dispatchEvent('fileedit-content-replaced', this);
return this;
}
};
/* Default get/set impls for file content */
P.fileContent.get = function(){return P.e.taEditor.value};
P.fileContent.set = function(content){P.e.taEditor.value = content};
/**
For use when installing a custom editor widget. Pass it the
getter and setter callbacks to fetch resp. set the content of the
custom widget. They will be triggered via
P.fileContent(). Returns this object.
*/
P.setFileContentMethods = function(getter, setter){
this.fileContent.get = getter;
this.fileContent.set = setter;
return this;
};
/**
Removes the default editor widget (and any dependent elements)
from the DOM, adds the given element in its place, removes this
method from this object, and returns this object.
*/
P.replaceEditorElement = function(newEditor){
P.e.taEditor.parentNode.insertBefore(newEditor, P.e.taEditor);
P.e.taEditor.remove();
P.e.selectFontSizeWrap.remove();
delete this.replaceEditorElement;
return P;
};
/**
If either of...
- P.previewModes.current==='wiki'
- P.previewModes.current==='guess' AND the currently-loaded file
has a mimetype of "text/x-fossil-wiki" or "text/x-markdown".
... then this function updates the document's base.href to a
repo-relative /doc/{{this.finfo.checkin}}/{{directory part of
this.finfo.filename}}/
If neither of those conditions applies, this is a no-op.
*/
P.baseHrefForFile = function f(){
const fn = this.finfo ? this.finfo.filename : undefined;
if(!fn) return this;
if(!f.wikiMimeTypes){
f.wikiMimeTypes = ["text/x-fossil-wiki", "text/x-markdown"];
}
if('wiki'===P.previewModes.current
|| ('guess'===P.previewModes.current
&& f.wikiMimeTypes.indexOf(this.finfo.mimetype)>=0)){
const a = fn.split('/');
a.pop();
this.base.tag.href = F.repoUrl(
'doc/'+F.hashDigits(this.finfo.checkin)
+'/'+(a.length ? a.join('/')+'/' : '')
);
}
return this;
};
/**
Sets the document's base.href value to its page-load-time
setting.
*/
P.baseHrefRestore = function(){
P.base.tag.href = P.base.originalHref;
};
/**
Toggles between single- and multi-line comment
mode.
*/
P.toggleCommentMode = function(){
var s, h, c = this.e.taComment.value;
if(this.e.taComment === this.e.taCommentSmall){
s = this.e.taCommentBig;
h = this.e.taCommentSmall;
}else{
s = this.e.taCommentSmall;
h = this.e.taCommentBig;
/*
Doing (input[type=text].value = textarea.value) unfortunately
strips all newlines. To compensate we'll replace each EOL with
a space. Not ideal. If we were to instead escape them as \n,
and do the reverse when toggling again, then they would get
committed as escaped newlines if the user did not first switch
back to multi-line mode. We cannot blindly unescape the
newlines, in the off chance that the user actually enters \n
in the comment.
*/
c = c.replace(/\r?\n/g,' ');
}
s.value = c;
this.e.taComment = s;
D.addClass(h, 'hidden');
D.removeClass(s, 'hidden');
};
/**
Returns true if fossil.page.finfo is set, indicating that a file
has been loaded, else it reports an error and returns false.
If passed a truthy value any error message about not having
a file loaded is suppressed.
*/
const affirmHasFile = function(quiet){
if(!P.finfo){
if(!quiet) F.error("No file is loaded.");
}
return !!P.finfo;
};
/**
updateVersion() updates the filename and version in various UI
elements...
Returns this object.
*/
P.updateVersion = function(file,rev){
if(1===arguments.length){/*assume object*/
this.finfo = arguments[0];
file = this.finfo.filename;
rev = this.finfo.checkin;
}else if(0===arguments.length){
if(!affirmHasFile()) return this;
file = this.finfo.filename;
rev = this.finfo.checkin;
}else{
this.finfo = {filename:file,checkin:rev};
}
const eTgt = this.e.fsFileVersionDetails.querySelector('div'),
rHuman = F.hashDigits(rev),
rUrl = F.hashDigits(rev,true);
D.clearElement(eTgt);
D.append(
eTgt, "File: ",
D.append(D.code(),
D.a(F.repoUrl('finfo',{name:file, m:rUrl}), file)),
D.br()
);
D.append(
eTgt, "Checkin: ",
D.append(D.code(), D.a(F.repoUrl('info/'+rUrl), rHuman)),
" [",D.a(F.repoUrl('timeline',{m:rUrl}), "timeline"),"]",
D.br()
);
D.append(
eTgt, "Mimetype: ",
D.append(D.code(), this.finfo.mimetype||'???'),
D.br()
);
D.append(
eTgt,
D.append(D.code(), "[",
D.a(F.repoUrl('annotate',{filename:file, checkin:rUrl}),
'annotate'), "]"),
D.append(D.code(), "[",
D.a(F.repoUrl('blame',{filename:file, checkin:rUrl}),
'blame'), "]")
);
const purlArgs = F.encodeUrlArgs({
filename: this.finfo.filename,
checkin: rUrl
},false,true);
const purl = F.repoUrl('fileedit',purlArgs);
D.append(
eTgt,
D.append(D.code(),
"[",D.a(purl,"Editor permalink"),"]")
);
this.setPageTitle("Edit: "+this.finfo.filename);
return this;
};
/**
loadFile() loads (file,checkinVersion) and updates the relevant
UI elements to reflect the loaded state. If passed no arguments
then it re-uses the values from the currently-loaded file, reloading
it (emitting an error message if no file is loaded).
Returns this object, noting that the load is async. After loading
it triggers a 'fileedit-file-loaded' event, passing it
this.finfo.
If a locally-edited copy of the given file/rev is found, that
copy is used instead of one fetched from the server, but it is
still treated as a load event.
Alternate call forms:
- no arguments: re-loads from this.finfo.
- 1 argument: assumed to be an finfo-style object. Must have at
least {filename, checkin} properties, but need not have other
finfo state.
*/
P.loadFile = function(file,rev){
if(0===arguments.length){
/* Reload from this.finfo */
if(!affirmHasFile()) return this;
file = this.finfo.filename;
rev = this.finfo.checkin;
}else if(1===arguments.length){
/* Assume finfo-like object */
const arg = arguments[0];
file = arg.filename;
rev = arg.checkin;
}
const self = this;
const onload = (r,headers)=>{
delete self.finfo;
self.updateVersion({
filename: file,
checkin: rev,
branch: headers['x-fileedit-checkin-branch'],
isExe: ('x'===headers['x-fileedit-file-perm']),
mimetype: headers['content-type'].split(';').shift()
});
self.tabs.switchToTab(self.e.tabs.content);
self.e.cbIsExe.checked = self.finfo.isExe;
self.fileContent(r);
self.dispatchEvent('fileedit-file-loaded', self.finfo);
};
const semiFinfo = {filename: file, checkin: rev};
const stashFinfo = this.getStashedFinfo(semiFinfo);
if(stashFinfo){ // fake a response from the stash...
this.finfo = stashFinfo;
this.e.cbIsExe.checked = !!stashFinfo.isExe;
onload(this.contentFromStash()||'',{
'x-fileedit-file-perm': stashFinfo.isExe ? 'x' : undefined,
'content-type': stashFinfo.mimetype,
'x-fileedit-checkin-branch': stashFinfo.branch
});
F.message("Fetched from the local-edit storage:",
F.hashDigits(stashFinfo.checkin),
stashFinfo.filename);
return this;
}
F.message(
"Loading content..."
).fetch('fileedit/content',{
urlParams: {
filename:file,
checkin:rev
},
responseHeaders: [
'x-fileedit-file-perm',
'x-fileedit-checkin-branch',
'content-type'],
onload:(r,headers)=>{
onload(r,headers);
F.message('Loaded content for',
F.hashDigits(self.finfo.checkin),
self.finfo.filename);
}
});
return this;
};
/**
Fetches the page preview based on the contents and settings of
this page's input fields, and updates the UI with with the
preview.
Returns this object, noting that the operation is async.
*/
P.preview = function f(switchToTab){
if(!affirmHasFile()) return this;
const target = this.e.previewTarget,
self = this;
const updateView = function(c){
D.clearElement(target);
if('string'===typeof c) target.innerHTML = c;
if(switchToTab) self.tabs.switchToTab(self.e.tabs.preview);
};
return this._postPreview(this.fileContent(), updateView);
};
/**
Callback for use with F.connectPagePreviewers()
*/
P._postPreview = function(content,callback){
if(!affirmHasFile()) return this;
if(!content){
callback(content);
return this;
}
const fd = new FormData();
fd.append('render_mode',this.e.selectPreviewMode.value);
fd.append('filename',this.finfo.filename);
fd.append('ln',E('[name=preview_ln]').checked ? 1 : 0);
fd.append('iframe_height', E('[name=preview_html_ems]').value);
fd.append('content',content || '');
F.message(
"Fetching preview..."
).fetch('fileedit/preview',{
payload: fd,
responseHeaders: 'x-fileedit-render-mode',
onload: (r,header)=>{
P.selectPreviewMode(P.previewModes[header]);
if('wiki'===header) P.baseHrefForFile();
else P.baseHrefRestore();
callback(r);
F.message('Updated preview.');
P.dispatchEvent('fileedit-preview-updated',{
previewMode: P.previewModes.current,
mimetype: P.finfo.mimetype,
element: P.e.previewTarget
});
},
onerror: (e)=>{
fossil.fetch.onerror(e);
callback("Error fetching preview: "+e);
}
});
return this;
};
/**
Undo some of the SBS diff-rendering bits which hurt us more than
they help...
*/
P.tweakSbsDiffs2 = function(){
if(1){
const dt = this.e.diffTarget;
dt.querySelectorAll('.sbsdiffcols .difftxtcol').forEach(
(dtc)=>{
const pre = dtc.querySelector('pre');
pre.style.width = 'initial';
//pre.removeAttribute('style');
//console.debug("pre width =",pre.style.width);
}
);
}
this.tweakSbsDiffs();
};
/**
Fetches the content diff based on the contents and settings of
this page's input fields, and updates the UI with the diff view.
Returns this object, noting that the operation is async.
*/
P.diff = function f(sbs){
if(!affirmHasFile()) return this;
const content = this.fileContent(),
self = this,
target = this.e.diffTarget;
const fd = new FormData();
fd.append('filename',this.finfo.filename);
fd.append('checkin', this.finfo.checkin);
fd.append('sbs', sbs ? 1 : 0);
fd.append('content',content);
if(this.e.selectDiffWS) fd.append('ws',this.e.selectDiffWS.value);
F.message(
"Fetching diff..."
).fetch('fileedit/diff',{
payload: fd,
onload: function(c){
target.innerHTML = [
"<div>Diff <code>[",
self.finfo.checkin,
"]</code> → Local Edits</div>",
c||'No changes.'
].join('');
if(sbs) P.tweakSbsDiffs2();
F.message('Updated diff.');
self.tabs.switchToTab(self.e.tabs.diff);
}
});
return this;
};
/**
Performs an async commit based on the form contents and updates
the UI.
Returns this object.
*/
P.commit = function f(){
if(!affirmHasFile()) return this;
const self = this;
const content = this.fileContent(),
target = D.clearElement(P.e.manifestTarget),
cbDryRun = E('[name=dry_run]'),
isDryRun = cbDryRun.checked,
filename = this.finfo.filename;
if(!f.onload){
f.onload = function(c){
const oldFinfo = JSON.parse(JSON.stringify(self.finfo))
if(c.manifest){
target.innerHTML = [
"<h3>Manifest",
(c.dryRun?" (dry run)":""),
": ", F.hashDigits(c.checkin),"</h3>",
"<code class='fileedit-manifest'>",
c.manifest,
"</code></pre>"
].join('');
delete c.manifest/*so we don't stash this with finfo*/;
}
const msg = [
'Committed',
c.dryRun ? '(dry run)' : '',
'[', F.hashDigits(c.checkin) ,'].'
];
if(!c.dryRun){
self.unstashContent(oldFinfo);
self.finfo = c;
self.e.taComment.value = '';
self.updateVersion();
self.fileSelectWidget.loadLeaves();
}
self.dispatchEvent('fileedit-committed', c);
F.message.apply(F, msg);
self.tabs.switchToTab(self.e.tabs.commit);
};
}
const fd = new FormData();
fd.append('filename',filename);
fd.append('checkin', this.finfo.checkin);
fd.append('content',content);
fd.append('dry_run',isDryRun ? 1 : 0);
fd.append('eol', this.e.selectEol.value || 0);
/* Text fields or select lists... */
fd.append('comment', this.e.taComment.value);
if(0){
// Comment mimetype is currently not supported by the UI...
['comment_mimetype'
].forEach(function(name){
var e = E('[name='+name+']');
if(e) fd.append(name,e.value);
});
}
/* Checkboxes: */
['allow_fork',
'allow_older',
'exec_bit',
'allow_merge_conflict',
'include_manifest',
'prefer_delta'
].forEach(function(name){
var e = E('[name='+name+']');
if(e){
fd.append(name, e.checked ? 1 : 0);
}else{
console.error("Missing checkbox? name =",name);
}
});
F.message(
"Checking in..."
).fetch('fileedit/commit',{
payload: fd,
responseType: 'json',
onload: f.onload
});
return this;
};
/**
Updates P.finfo for certain state and stashes P.finfo, with the
current content fetched via P.fileContent().
If passed truthy AND the stash already has stashed content for
the current file, only the stashed finfo record is updated, else
both the finfo and content are updated.
*/
P.stashContentChange = function(onlyFinfo){
if(affirmHasFile(true)){
const fi = this.finfo;
fi.isExe = this.e.cbIsExe.checked;
if(!fi.branch) fi.branch = this.fileSelectWidget.checkinBranchName(fi.checkin);
if(onlyFinfo && $stash.hasStashedContent(fi)){
$stash.updateFile(fi);
}else{
$stash.updateFile(fi, P.fileContent());
}
F.message("Stashed change to",F.hashDigits(fi.checkin),fi.filename);
$stash.prune();
}
return this;
};
/**
Removes any stashed state for the current P.finfo (if set) from
F.storage. Returns this.
*/
P.unstashContent = function(){
const finfo = arguments[0] || this.finfo;
if(finfo){
$stash.unstash(finfo);
//console.debug("Unstashed",finfo);
F.message("Unstashed",F.hashDigits(finfo.checkin),finfo.filename);
}
return this;
};
/**
Clears all stashed file state from F.storage. Returns this.
*/
P.clearStash = function(){
$stash.clear();
return this;
};
/**
If stashed content for P.finfo exists, it is returned, else
undefined is returned.
*/
P.contentFromStash = function(){
return affirmHasFile(true) ? $stash.stashedContent(this.finfo) : undefined;
};
/**
If a stashed version of the given finfo object exists (same
filename/checkin values), return it, else return undefined.
*/
P.getStashedFinfo = function(finfo){
return $stash.getFinfo(finfo);
};
P.$stash = $stash /*only for testing/debugging - not part of the API.*/;
})(window.fossil);
|
Added src/fossil.storage.js.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
(function(F){
/**
fossil.store is a basic wrapper around localStorage
or sessionStorage or a dummy proxy object if neither
of those are available.
*/
const tryStorage = function f(obj){
if(!f.key) f.key = 'fossil.access.check';
try{
obj.setItem(f.key, 'f');
const x = obj.getItem(f.key);
obj.removeItem(f.key);
if(x!=='f') throw new Error(f.key+" failed")
return obj;
}catch(e){
return undefined;
}
};
/** Internal storage impl for fossil.storage. */
const $storage =
tryStorage(window.localStorage)
|| tryStorage(window.sessionStorage)
|| tryStorage({
// A basic dummy xyzStorage stand-in
$:{},
setItem: function(k,v){this.$[k]=v},
getItem: function(k){
return this.$.hasOwnProperty(k) ? this.$[k] : undefined;
},
removeItem: function(k){delete this.$[k]},
clear: function(){this.$={}}
});
/**
For the dummy storage we need to differentiate between
$storage and its real property storage for hasOwnProperty()
to work properly...
*/
const $storageHolder = $storage.hasOwnProperty('$') ? $storage.$ : $storage;
/**
A proxy for localStorage or sessionStorage or a
page-instance-local proxy, if neither one is availble.
Which exact storage implementation is uses is unspecified, and
apps must not rely on it.
*/
fossil.storage = {
/** Sets the storage key k to value v, implicitly converting
it to a string. */
set: (k,v)=>$storage.setItem(k,v),
/** Sets storage key k to JSON.stringify(v). */
setJSON: (k,v)=>$storage.setItem(k,JSON.stringify(v)),
/** Returns the value for the given storage key, or
dflt if the key is not found in the storage. */
get: (k,dflt)=>$storageHolder.hasOwnProperty(k) ? $storage.getItem(k) : dflt,
/** Returns the JSON.parse()'d value of the given
storage key's value, or dflt is the key is not
found or JSON.parse() fails. */
getJSON: function f(k,dflt){
try {
const x = this.get(k,f);
return x===f ? dflt : JSON.parse(x);
}
catch(e){return dflt}
},
/** Returns true if the storage contains the given key,
else false. */
contains: (k)=>$storageHolder.hasOwnProperty(k),
/** Removes the given key from the storage. Returns this. */
remove: function(k){
$storage.removeItem(k);
return this;
},
/** Clears ALL keys from the storage. Returns this. */
clear: function(){
$storage.clear();
return this;
},
/** Returns an array of all keys currently in the storage. */
keys: ()=>Object.keys($storageHolder),
/** Returns true if this storage is transient (only available
until the page is reloaded), indicating that fileStorage
and sessionStorage are unavailable. */
isTransient: ()=>$storageHolder!==$storage,
/** Returns a symbolic name for the current storage mechanism. */
storageImplName: function(){
if($storage===window.localStorage) return 'localStorage';
else if($storage===window.sessionStorage) return 'sessionStorage';
else return 'transient';
}
};
})(window.fossil);
|
Added src/fossil.tabs.js.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
"use strict";
(function(F/*fossil object*/){
const E = (s)=>document.querySelector(s),
EA = (s)=>document.querySelectorAll(s),
D = F.dom;
/**
Creates a TabManager. If passed an argument, it is
passed to init().
*/
const TabManager = function(domElem){
this.e = {};
if(domElem) this.init(domElem);
};
/**
Internal helper to normalize a method argument
to a tab element.
*/
const tabArg = function(arg,tabMgr){
if('string'===typeof arg) arg = E(arg);
else if(tabMgr && 'number'===typeof arg && arg>=0){
arg = tabMgr.e.tabs.childNodes[arg];
}
return arg;
};
const setVisible = function(e,yes){
D[yes ? 'removeClass' : 'addClass'](e, 'hidden');
};
TabManager.prototype = {
/**
Initializes the tabs associated with the given tab container
(DOM element or selector for a single element). This must be
called once before using any other member functions of a given
instance, noting that the constructor will call this if it is
passed an argument.
The tab container must have an 'id' attribute. This function
looks through the DOM for all elements which have
data-tab-parent=thatId. For each one it creates a button to
switch to that tab and moves the element into this.e.tabs.
The label for each tab is set by the data-tab-label attribute
of each element, defaulting to something not terribly useful.
When it's done, it auto-selects the first tab unless a tab has
a truthy numeric value in its data-tab-select attribute, in
which case the last tab to have such a property is selected.
This method must only be called once per instance. TabManagers
may be nested but must not share any tabs instances.
Returns this object.
DOM elements of potential interest to users:
this.e.container = the outermost container element.
this.e.tabBar = the button bar. Each "button" (whether it's a
buttor not is unspecified) has a class of .tab-button.
this.e.tabs = the parent for all of the tab elements.
It is legal, within reason, to manipulate these a bit, in
particular this.e.container, e.g. by adding more children to
it. Do not remove elements from the tabs or tabBar, however, or
the tab state may get sorely out of sync.
CSS classes: the container element has whatever class(es) the
client sets on. this.e.tabBar gets the 'tab-bar' class and
this.e.tabs gets the 'tabs' class. It's hypothetically possible
to move the tabs to either side or the bottom using only CSS,
but it's never been tested.
*/
init: function(container){
container = tabArg(container);
const cID = container.getAttribute('id');
if(!cID){
throw new Error("Tab container element is missing 'id' attribute.");
}
const c = this.e.container = container;
this.e.tabBar = D.addClass(D.div(),'tab-bar');
this.e.tabs = D.addClass(D.div(),'tabs');
D.append(c, this.e.tabBar, this.e.tabs);
let selectIndex = 0;
EA('[data-tab-parent='+cID+']').forEach((c,n)=>{
if(+c.dataset.tabSelect) selectIndex=n;
this.addTab(c);
});
return this.switchToTab(selectIndex);
},
/**
For the given tab element, unique selector string, or integer
(0-based tab number), returns the button associated with that
tab, or undefined if the argument does not match any current
tab.
*/
getButtonForTab: function(tab){
tab = tabArg(tab,this);
var i = -1;
this.e.tabs.childNodes.forEach(function(e,n){
if(e===tab) i = n;
});
return i>=0 ? this.e.tabBar.childNodes[i] : undefined;
},
/**
Adds the given DOM element or unique selector as the next
tab in the tab container, adding a button to switch to
the tab. Returns this object.
*/
addTab: function f(tab){
if(!f.click){
f.click = function(e){
e.target.$manager.switchToTab(e.target.$tab);
};
}
tab = tabArg(tab);
tab.remove();
D.append(this.e.tabs, D.addClass(tab,'tab-panel'));
const lbl = tab.dataset.tabLabel || 'Tab #'+(this.e.tabs.childNodes.length-1);
const btn = D.addClass(D.append(D.span(), lbl), 'tab-button');
D.append(this.e.tabBar,btn);
btn.$manager = this;
btn.$tab = tab;
btn.addEventListener('click', f.click, false);
return this;
},
/**
Internal. Fires a new CustomEvent to all listeners which have
registered via this.addEventListener().
*/
_dispatchEvent: function(name, detail){
try{
this.e.container.dispatchEvent(
new CustomEvent(name, {detail: detail})
);
}catch(e){
/* ignore */
}
return this;
},
/**
Registers an event listener for this object's custom events.
The callback gets a CustomEvent object with a 'detail'
propertly holding any tab-related state for the event. The events
are:
- 'before-switch-from' is emitted immediately before a new tab
is switched away from. detail = the tab element being switched
away from.
- 'before-switch-to' is emitted immediately before a new tab is
switched to. detail = the tab element.
- 'after-switch-to' is emitted immediately after a new tab is
switched to. detail = the tab element.
Any exceptions thrown by listeners are caught and ignored, to
avoid that they knock the tab state out of sync.
Returns this object.
*/
addEventListener: function(eventName, callback){
this.e.container.addEventListener(eventName, callback, false);
return this;
},
/**
If the given DOM element, unique selector, or integer (0-based
tab number) is one of this object's tabs, the UI makes that tab
the currently-visible one, firing any relevant events. Returns
this object. If the argument is the current tab, this is a
no-op, and no events are fired.
*/
switchToTab: function(tab){
tab = tabArg(tab,this);
const self = this;
if(tab===this._currentTab) return this;
else if(this._currentTab){
this._dispatchEvent('before-switch-from', this._currentTab);
}
delete this._currentTab;
this.e.tabs.childNodes.forEach((e,ndx)=>{
const btn = this.e.tabBar.childNodes[ndx];
if(e===tab){
if(D.hasClass(e,'selected')){
return;
}
self._dispatchEvent('before-switch-to',tab);
setVisible(e, true);
this._currentTab = e;
D.addClass(btn,'selected');
self._dispatchEvent('after-switch-to',tab);
}else{
if(D.hasClass(e,'selected')){
return;
}
setVisible(e, false);
D.removeClass(btn,'selected');
}
});
return this;
}
};
F.TabManager = TabManager;
})(window.fossil);
|
Changes to src/info.c.
| ︙ | ︙ | |||
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 |
@ size: %d(szFile))
if( g.perm.Hyperlink ){
@ %z(href("%R/annotate?filename=%T&checkin=%!S",zName,zVers))
@ [annotate]</a>
@ %z(href("%R/blame?filename=%T&checkin=%!S",zName,zVers))
@ [blame]</a>
@ %z(href("%R/timeline?n=all&uf=%!S",zUuid))[check-ins using]</a>
}
cnt++;
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_append(pDownloadName, zName, -1);
}
}
if( prevName && showDetail ){
| > > > | 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 |
@ size: %d(szFile))
if( g.perm.Hyperlink ){
@ %z(href("%R/annotate?filename=%T&checkin=%!S",zName,zVers))
@ [annotate]</a>
@ %z(href("%R/blame?filename=%T&checkin=%!S",zName,zVers))
@ [blame]</a>
@ %z(href("%R/timeline?n=all&uf=%!S",zUuid))[check-ins using]</a>
if( fileedit_is_editable(zName) ){
@ %z(href("%R/fileedit?filename=%T&checkin=%!S",zName,zVers))[edit]</a>
}
}
cnt++;
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_append(pDownloadName, zName, -1);
}
}
if( prevName && showDetail ){
|
| ︙ | ︙ | |||
2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 |
if( asText ){
style_submenu_element("Wiki", "%s", url_render(&url, "txt", 0, 0, 0));
}else{
renderAsWiki = 1;
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
}
}
}
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){
style_submenu_element("Parsed", "%R/info/%s", zUuid);
}
if( descOnly ){
style_submenu_element("Content", "%R/artifact/%s", zUuid);
}else{
| > > > > > | 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 |
if( asText ){
style_submenu_element("Wiki", "%s", url_render(&url, "txt", 0, 0, 0));
}else{
renderAsWiki = 1;
style_submenu_element("Text", "%s", url_render(&url, "txt", "1", 0, 0));
}
}
if( fileedit_is_editable(zName) ){
style_submenu_element("Edit",
"%R/fileedit?filename=%T&checkin=%!S",
zName, zCI);
}
}
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){
style_submenu_element("Parsed", "%R/info/%s", zUuid);
}
if( descOnly ){
style_submenu_element("Content", "%R/artifact/%s", zUuid);
}else{
|
| ︙ | ︙ |
Changes to src/leaf.c.
| ︙ | ︙ | |||
150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
"EXISTS(SELECT 1 FROM tagxref AS tx"
" WHERE tx.rid=%s"
" AND tx.tagid=%d"
" AND tx.tagtype>0)",
zVar, TAG_CLOSED
);
}
/*
** Schedule a leaf check for "rid" and its parents.
*/
void leaf_eventually_check(int rid){
static Stmt parentsOf;
| > > > > > > > > > > > | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
"EXISTS(SELECT 1 FROM tagxref AS tx"
" WHERE tx.rid=%s"
" AND tx.tagid=%d"
" AND tx.tagtype>0)",
zVar, TAG_CLOSED
);
}
/*
** Returns true if vid refers to a closed leaf, else false. vid is
** assumed to refer to a manifest, but this function does not verify
** that.
*/
int leaf_is_closed(int vid){
return db_exists("SELECT 1 FROM tagxref"
" WHERE tagid=%d AND rid=%d AND tagtype>0",
TAG_CLOSED, vid);
}
/*
** Schedule a leaf check for "rid" and its parents.
*/
void leaf_eventually_check(int rid){
static Stmt parentsOf;
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
2810 2811 2812 2813 2814 2815 2816 |
}
}
}
#else
zBrowser = db_get("web-browser", "open");
#endif
if( zIpAddr==0 ){
| | | | | 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 |
}
}
}
#else
zBrowser = db_get("web-browser", "open");
#endif
if( zIpAddr==0 ){
zBrowserCmd = mprintf("%s \"http://localhost:%%d/%s\" &",
zBrowser, zInitPage);
}else if( strchr(zIpAddr,':') ){
zBrowserCmd = mprintf("%s \"http://[%s]:%%d/%s\" &",
zBrowser, zIpAddr, zInitPage);
}else{
zBrowserCmd = mprintf("%s \"http://%s:%%d/%s\" &",
zBrowser, zIpAddr, zInitPage);
}
}
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
db_close(1);
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
|
| ︙ | ︙ |
Changes to src/main.mk.
| ︙ | ︙ | |||
52 53 54 55 56 57 58 59 60 61 62 63 64 65 | $(SRCDIR)/doc.c \ $(SRCDIR)/encode.c \ $(SRCDIR)/etag.c \ $(SRCDIR)/event.c \ $(SRCDIR)/export.c \ $(SRCDIR)/extcgi.c \ $(SRCDIR)/file.c \ $(SRCDIR)/finfo.c \ $(SRCDIR)/foci.c \ $(SRCDIR)/forum.c \ $(SRCDIR)/fshell.c \ $(SRCDIR)/fusefs.c \ $(SRCDIR)/fuzz.c \ $(SRCDIR)/glob.c \ | > | 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | $(SRCDIR)/doc.c \ $(SRCDIR)/encode.c \ $(SRCDIR)/etag.c \ $(SRCDIR)/event.c \ $(SRCDIR)/export.c \ $(SRCDIR)/extcgi.c \ $(SRCDIR)/file.c \ $(SRCDIR)/fileedit.c \ $(SRCDIR)/finfo.c \ $(SRCDIR)/foci.c \ $(SRCDIR)/forum.c \ $(SRCDIR)/fshell.c \ $(SRCDIR)/fusefs.c \ $(SRCDIR)/fuzz.c \ $(SRCDIR)/glob.c \ |
| ︙ | ︙ | |||
216 217 218 219 220 221 222 223 224 225 226 227 228 229 | $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/accordion.js \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/copybtn.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ $(SRCDIR)/sbsdiff.js \ $(SRCDIR)/scroll.js \ | > > > > > > > | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/accordion.js \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/copybtn.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/fossil.bootstrap.js \ $(SRCDIR)/fossil.confirmer.js \ $(SRCDIR)/fossil.dom.js \ $(SRCDIR)/fossil.fetch.js \ $(SRCDIR)/fossil.page.fileedit.js \ $(SRCDIR)/fossil.storage.js \ $(SRCDIR)/fossil.tabs.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ $(SRCDIR)/sbsdiff.js \ $(SRCDIR)/scroll.js \ |
| ︙ | ︙ | |||
242 243 244 245 246 247 248 249 250 251 252 253 254 255 | $(SRCDIR)/sounds/a.wav \ $(SRCDIR)/sounds/b.wav \ $(SRCDIR)/sounds/c.wav \ $(SRCDIR)/sounds/d.wav \ $(SRCDIR)/sounds/e.wav \ $(SRCDIR)/sounds/f.wav \ $(SRCDIR)/style.admin_log.css \ $(SRCDIR)/tree.js \ $(SRCDIR)/useredit.js \ $(SRCDIR)/wiki.wiki TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/alerts_.c \ | > | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | $(SRCDIR)/sounds/a.wav \ $(SRCDIR)/sounds/b.wav \ $(SRCDIR)/sounds/c.wav \ $(SRCDIR)/sounds/d.wav \ $(SRCDIR)/sounds/e.wav \ $(SRCDIR)/sounds/f.wav \ $(SRCDIR)/style.admin_log.css \ $(SRCDIR)/style.fileedit.css \ $(SRCDIR)/tree.js \ $(SRCDIR)/useredit.js \ $(SRCDIR)/wiki.wiki TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/alerts_.c \ |
| ︙ | ︙ | |||
287 288 289 290 291 292 293 294 295 296 297 298 299 300 | $(OBJDIR)/doc_.c \ $(OBJDIR)/encode_.c \ $(OBJDIR)/etag_.c \ $(OBJDIR)/event_.c \ $(OBJDIR)/export_.c \ $(OBJDIR)/extcgi_.c \ $(OBJDIR)/file_.c \ $(OBJDIR)/finfo_.c \ $(OBJDIR)/foci_.c \ $(OBJDIR)/forum_.c \ $(OBJDIR)/fshell_.c \ $(OBJDIR)/fusefs_.c \ $(OBJDIR)/fuzz_.c \ $(OBJDIR)/glob_.c \ | > | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | $(OBJDIR)/doc_.c \ $(OBJDIR)/encode_.c \ $(OBJDIR)/etag_.c \ $(OBJDIR)/event_.c \ $(OBJDIR)/export_.c \ $(OBJDIR)/extcgi_.c \ $(OBJDIR)/file_.c \ $(OBJDIR)/fileedit_.c \ $(OBJDIR)/finfo_.c \ $(OBJDIR)/foci_.c \ $(OBJDIR)/forum_.c \ $(OBJDIR)/fshell_.c \ $(OBJDIR)/fusefs_.c \ $(OBJDIR)/fuzz_.c \ $(OBJDIR)/glob_.c \ |
| ︙ | ︙ | |||
430 431 432 433 434 435 436 437 438 439 440 441 442 443 | $(OBJDIR)/doc.o \ $(OBJDIR)/encode.o \ $(OBJDIR)/etag.o \ $(OBJDIR)/event.o \ $(OBJDIR)/export.o \ $(OBJDIR)/extcgi.o \ $(OBJDIR)/file.o \ $(OBJDIR)/finfo.o \ $(OBJDIR)/foci.o \ $(OBJDIR)/forum.o \ $(OBJDIR)/fshell.o \ $(OBJDIR)/fusefs.o \ $(OBJDIR)/fuzz.o \ $(OBJDIR)/glob.o \ | > | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | $(OBJDIR)/doc.o \ $(OBJDIR)/encode.o \ $(OBJDIR)/etag.o \ $(OBJDIR)/event.o \ $(OBJDIR)/export.o \ $(OBJDIR)/extcgi.o \ $(OBJDIR)/file.o \ $(OBJDIR)/fileedit.o \ $(OBJDIR)/finfo.o \ $(OBJDIR)/foci.o \ $(OBJDIR)/forum.o \ $(OBJDIR)/fshell.o \ $(OBJDIR)/fusefs.o \ $(OBJDIR)/fuzz.o \ $(OBJDIR)/glob.o \ |
| ︙ | ︙ | |||
768 769 770 771 772 773 774 775 776 777 778 779 780 781 | $(OBJDIR)/doc_.c:$(OBJDIR)/doc.h \ $(OBJDIR)/encode_.c:$(OBJDIR)/encode.h \ $(OBJDIR)/etag_.c:$(OBJDIR)/etag.h \ $(OBJDIR)/event_.c:$(OBJDIR)/event.h \ $(OBJDIR)/export_.c:$(OBJDIR)/export.h \ $(OBJDIR)/extcgi_.c:$(OBJDIR)/extcgi.h \ $(OBJDIR)/file_.c:$(OBJDIR)/file.h \ $(OBJDIR)/finfo_.c:$(OBJDIR)/finfo.h \ $(OBJDIR)/foci_.c:$(OBJDIR)/foci.h \ $(OBJDIR)/forum_.c:$(OBJDIR)/forum.h \ $(OBJDIR)/fshell_.c:$(OBJDIR)/fshell.h \ $(OBJDIR)/fusefs_.c:$(OBJDIR)/fusefs.h \ $(OBJDIR)/fuzz_.c:$(OBJDIR)/fuzz.h \ $(OBJDIR)/glob_.c:$(OBJDIR)/glob.h \ | > | 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | $(OBJDIR)/doc_.c:$(OBJDIR)/doc.h \ $(OBJDIR)/encode_.c:$(OBJDIR)/encode.h \ $(OBJDIR)/etag_.c:$(OBJDIR)/etag.h \ $(OBJDIR)/event_.c:$(OBJDIR)/event.h \ $(OBJDIR)/export_.c:$(OBJDIR)/export.h \ $(OBJDIR)/extcgi_.c:$(OBJDIR)/extcgi.h \ $(OBJDIR)/file_.c:$(OBJDIR)/file.h \ $(OBJDIR)/fileedit_.c:$(OBJDIR)/fileedit.h \ $(OBJDIR)/finfo_.c:$(OBJDIR)/finfo.h \ $(OBJDIR)/foci_.c:$(OBJDIR)/foci.h \ $(OBJDIR)/forum_.c:$(OBJDIR)/forum.h \ $(OBJDIR)/fshell_.c:$(OBJDIR)/fshell.h \ $(OBJDIR)/fusefs_.c:$(OBJDIR)/fusefs.h \ $(OBJDIR)/fuzz_.c:$(OBJDIR)/fuzz.h \ $(OBJDIR)/glob_.c:$(OBJDIR)/glob.h \ |
| ︙ | ︙ | |||
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 | $(OBJDIR)/file_.c: $(SRCDIR)/file.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/file.c >$@ $(OBJDIR)/file.o: $(OBJDIR)/file_.c $(OBJDIR)/file.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/file.o -c $(OBJDIR)/file_.c $(OBJDIR)/file.h: $(OBJDIR)/headers $(OBJDIR)/finfo_.c: $(SRCDIR)/finfo.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/finfo.c >$@ $(OBJDIR)/finfo.o: $(OBJDIR)/finfo_.c $(OBJDIR)/finfo.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/finfo.o -c $(OBJDIR)/finfo_.c | > > > > > > > > | 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 | $(OBJDIR)/file_.c: $(SRCDIR)/file.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/file.c >$@ $(OBJDIR)/file.o: $(OBJDIR)/file_.c $(OBJDIR)/file.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/file.o -c $(OBJDIR)/file_.c $(OBJDIR)/file.h: $(OBJDIR)/headers $(OBJDIR)/fileedit_.c: $(SRCDIR)/fileedit.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/fileedit.c >$@ $(OBJDIR)/fileedit.o: $(OBJDIR)/fileedit_.c $(OBJDIR)/fileedit.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/fileedit.o -c $(OBJDIR)/fileedit_.c $(OBJDIR)/fileedit.h: $(OBJDIR)/headers $(OBJDIR)/finfo_.c: $(SRCDIR)/finfo.c $(OBJDIR)/translate $(OBJDIR)/translate $(SRCDIR)/finfo.c >$@ $(OBJDIR)/finfo.o: $(OBJDIR)/finfo_.c $(OBJDIR)/finfo.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/finfo.o -c $(OBJDIR)/finfo_.c |
| ︙ | ︙ |
Changes to src/makemake.tcl.
| ︙ | ︙ | |||
63 64 65 66 67 68 69 70 71 72 73 74 75 76 | doc encode etag event extcgi export file finfo foci forum fshell fusefs fuzz glob | > | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | doc encode etag event extcgi export file fileedit finfo foci forum fshell fusefs fuzz glob |
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
1062 1063 1064 1065 1066 1067 1068 |
md5sum_init();
if( !isRepeat ) g.parseCnt[p->type]++;
return p;
manifest_syntax_error:
{
| | | 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 |
md5sum_init();
if( !isRepeat ) g.parseCnt[p->type]++;
return p;
manifest_syntax_error:
{
char *zUuid = rid_to_uuid(rid);
if( zUuid ){
blob_appendf(pErr, "artifact [%s] ", zUuid);
fossil_free(zUuid);
}
}
if( zErr ){
blob_appendf(pErr, "line %d: %s", lineNo, zErr);
|
| ︙ | ︙ | |||
1325 1326 1327 1328 1329 1330 1331 | return fnid; } /* ** Compute an appropriate mlink.mperm integer for the permission string ** of a file. */ | | | 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 |
return fnid;
}
/*
** Compute an appropriate mlink.mperm integer for the permission string
** of a file.
*/
int manifest_file_mperm(const ManifestFile *pFile){
int mperm = PERM_REG;
if( pFile && pFile->zPerm){
if( strstr(pFile->zPerm,"x")!=0 ){
mperm = PERM_EXE;
}else if( strstr(pFile->zPerm,"l")!=0 ){
mperm = PERM_LNK;
}
|
| ︙ | ︙ |
Changes to src/printf.c.
| ︙ | ︙ | |||
97 98 99 100 101 102 103 | #define etHTTPIZE 18 /* Make text safe for HTTP. "/" encoded as %2f */ #define etURLIZE 19 /* Make text safe for HTTP. "/" not encoded */ #define etFOSSILIZE 20 /* The fossil header encoding format. */ #define etPATH 21 /* Path type */ #define etWIKISTR 22 /* Timeline comment text rendered from a char*: %W */ #define etSTRINGID 23 /* String with length limit for a UUID prefix: %S */ #define etROOT 24 /* String value of g.zTop: %R */ | | > | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
#define etHTTPIZE 18 /* Make text safe for HTTP. "/" encoded as %2f */
#define etURLIZE 19 /* Make text safe for HTTP. "/" not encoded */
#define etFOSSILIZE 20 /* The fossil header encoding format. */
#define etPATH 21 /* Path type */
#define etWIKISTR 22 /* Timeline comment text rendered from a char*: %W */
#define etSTRINGID 23 /* String with length limit for a UUID prefix: %S */
#define etROOT 24 /* String value of g.zTop: %R */
#define etJSONSTR 25 /* String encoded as a JSON string literal: %j
Use %!j to include double-quotes around it. */
/*
** An "etByte" is an 8-bit unsigned value.
*/
typedef unsigned char etByte;
|
| ︙ | ︙ | |||
796 797 798 799 800 801 802 |
char *zMem = va_arg(ap,char*);
if( limit!=0 ){
/* Ignore the limit flag, if set, for JSON string
** output. This block exists to squelch the associated
** "unused variable" compiler warning. */
}
if( zMem==0 ) zMem = "";
| | | | 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 |
char *zMem = va_arg(ap,char*);
if( limit!=0 ){
/* Ignore the limit flag, if set, for JSON string
** output. This block exists to squelch the associated
** "unused variable" compiler warning. */
}
if( zMem==0 ) zMem = "";
zExtra = bufpt =
encode_json_string_literal(zMem, flag_altform2, &length);
if( precision>=0 && precision<length ) length = precision;
break;
}
case etWIKISTR: {
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char *zWiki = va_arg(ap, char*);
Blob wiki;
|
| ︙ | ︙ |
Changes to src/sbsdiff.js.
1 2 3 4 5 6 7 8 9 10 |
/* The javascript in this file was added by Joel Bruick on 2013-07-06,
** originally as in-line javascript. It does some kind of setup for
** side-by-side diff display, but I'm not really sure what.
*/
(function(){
var SCROLL_LEN = 25;
function initSbsDiff(diff){
var txtCols = diff.querySelectorAll('.difftxtcol');
var txtPres = diff.querySelectorAll('.difftxtcol pre');
var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);
| > | | | > | > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
/* The javascript in this file was added by Joel Bruick on 2013-07-06,
** originally as in-line javascript. It does some kind of setup for
** side-by-side diff display, but I'm not really sure what.
*/
(function(){
var SCROLL_LEN = 25;
function initSbsDiff(diff){
var txtCols = diff.querySelectorAll('.difftxtcol');
var txtPres = diff.querySelectorAll('.difftxtcol pre');
var width = Math.max(txtPres[0].scrollWidth, txtPres[1].scrollWidth);
var i;
for(i=0; i<2; i++){
txtPres[i].style.width = width + 'px';
txtCols[i].onscroll = function(e){
txtCols[0].scrollLeft = txtCols[1].scrollLeft = this.scrollLeft;
};
}
diff.tabIndex = 0;
diff.onkeydown = function(e){
e = e || event;
var len = {37: -SCROLL_LEN, 39: SCROLL_LEN}[e.keyCode];
if( !len ) return;
txtCols[0].scrollLeft += len;
return false;
};
}
document.querySelectorAll('.sbsdiffcols').forEach(initSbsDiff);
if(window.fossil && fossil.page){
fossil.page.tweakSbsDiffs = function(){
document.querySelectorAll('.sbsdiffcols').forEach(initSbsDiff);
};
}
})();
|
Changes to src/style.c.
| ︙ | ︙ | |||
1329 1330 1331 1332 1333 1334 1335 |
cgi_reset_content();
webpage_error("assertion fault at %s:%d - %s", zFile, iLine, zExpr);
}
#if INTERFACE
# define webpage_assert(T) if(!(T)){webpage_assert_page(__FILE__,__LINE__,#T);}
#endif
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 |
cgi_reset_content();
webpage_error("assertion fault at %s:%d - %s", zFile, iLine, zExpr);
}
#if INTERFACE
# define webpage_assert(T) if(!(T)){webpage_assert_page(__FILE__,__LINE__,#T);}
#endif
/*
** Returns a pseudo-random input field ID, for use in associating an
** ID-less input field with a label. The memory is owned by the
** caller.
*/
static char * style_next_input_id(){
static int inputID = 0;
++inputID;
return mprintf("input-id-%d", inputID);
}
/*
** Outputs a labeled checkbox element. zWrapperId is an optional ID
** value for the containing element (see below). zFieldName is the
** form element name. zLabel is the label for the checkbox. zValue is
** the optional value for the checkbox. zTip is an optional tooltip,
** which gets set as the "title" attribute of the outermost
** element. If isChecked is true, the checkbox gets the "checked"
** attribute set, else it is not.
**
** Resulting structure:
**
** <span class='input-with-label' title={{zTip}} id={{zWrapperId}}>
** <input type='checkbox' name={{zFieldName}} value={{zValue}}
** id='A RANDOM VALUE'
** {{isChecked ? " checked : ""}}/>
** <label for='ID OF THE INPUT FIELD'>{{zLabel}}</label>
** </span>
**
** zLabel, and zValue are required. zFieldName, zWrapperId, and zTip
** are may be NULL or empty.
**
** Be sure that the input-with-label CSS class is defined sensibly, in
** particular, having its display:inline-block is useful for alignment
** purposes.
*/
void style_labeled_checkbox(const char * zWrapperId,
const char *zFieldName, const char * zLabel,
const char * zValue, int isChecked,
const char * zTip){
char * zLabelID = style_next_input_id();
CX("<span class='input-with-label'");
if(zTip && *zTip){
CX(" title='%h'", zTip);
}
if(zWrapperId && *zWrapperId){
CX(" id='%s'",zWrapperId);
}
CX("><input type='checkbox' id='%s' ", zLabelID);
if(zFieldName && *zFieldName){
CX("name='%s' ",zFieldName);
}
CX("value='%T'%s/>",
zValue ? zValue : "", isChecked ? " checked" : "");
CX("<label for='%s'>%h</label></span>", zLabelID, zLabel);
fossil_free(zLabelID);
}
/*
** Outputs a SELECT list from a compile-time list of integers.
** The vargs must be a list of (const char *, int) pairs, terminated
** with a single NULL. Each pair is interpreted as...
**
** If the (const char *) is NULL, it is the end of the list, else
** a new OPTION entry is created. If the string is empty, the
** label and value of the OPTION is the integer part of the pair.
** If the string is not empty, it becomes the label and the integer
** the value. If that value == selectedValue then that OPTION
** element gets the 'selected' attribute.
**
** Note that the pairs are not in (int, const char *) order because
** there is no well-known integer value which we can definitively use
** as a list terminator.
**
** zWrapperId is an optional ID value for the containing element (see
** below).
**
** zFieldName is the value of the form element's name attribute. Note
** that fossil prefers underscores over '-' for separators in form
** element names.
**
** zLabel is an optional string to use as a "label" for the element
** (see below).
**
** zTooltip is an optional value for the SELECT's title attribute.
**
** The structure of the emitted HTML is:
**
** <span class='input-with-label' title={{zToolTip}} id={{zWrapperId}}>
** <label for='SELECT ELEMENT ID'>{{zLabel}}</label>
** <select id='RANDOM ID' name={{zFieldName}}>...</select>
** </span>
**
** Example:
**
** style_select_list_int("my-grapes", "my_grapes", "Grapes",
** "Select the number of grapes",
** atoi(PD("my_field","0")),
** "", 1, "2", 2, "Three", 3,
** NULL);
**
*/
void style_select_list_int(const char * zWrapperId,
const char *zFieldName, const char * zLabel,
const char * zToolTip, int selectedVal,
... ){
char * zLabelID = style_next_input_id();
va_list vargs;
va_start(vargs,selectedVal);
CX("<span class='input-with-label'");
if(zToolTip && *zToolTip){
CX(" title='%h'",zToolTip);
}
if(zWrapperId && *zWrapperId){
CX(" id='%s'",zWrapperId);
}
CX(">");
if(zLabel && *zLabel){
CX("<label label='%s'>%h</label>", zLabelID, zLabel);
}
CX("<select name='%s' id='%s'>",zFieldName, zLabelID);
while(1){
const char * zOption = va_arg(vargs,char *);
int v;
if(NULL==zOption){
break;
}
v = va_arg(vargs,int);
CX("<option value='%d'%s>",
v, v==selectedVal ? " selected" : "");
if(*zOption){
CX("%s", zOption);
}else{
CX("%d",v);
}
CX("</option>\n");
}
CX("</select>\n");
CX("</span>\n");
va_end(vargs);
fossil_free(zLabelID);
}
/*
** The C-string counterpart of style_select_list_int(), this variant
** differs only in that its variadic arguments are C-strings in pairs
** of (optionLabel, optionValue). If a given optionLabel is an empty
** string, the corresponding optionValue is used as its label. If any
** given value matches zSelectedVal, that option gets preselected. If
** no options match zSelectedVal then the first entry is selected by
** default.
**
** Any of (zWrapperId, zTooltip, zSelectedVal) may be NULL or empty.
**
** Example:
**
** style_select_list_str("my-grapes", "my_grapes", "Grapes",
** "Select the number of grapes",
** P("my_field"),
** "1", "One", "2", "Two", "", "3",
** NULL);
*/
void style_select_list_str(const char * zWrapperId,
const char *zFieldName, const char * zLabel,
const char * zToolTip, char const * zSelectedVal,
... ){
char * zLabelID = style_next_input_id();
va_list vargs;
va_start(vargs,zSelectedVal);
if(!zSelectedVal){
zSelectedVal = __FILE__/*some string we'll never match*/;
}
CX("<span class='input-with-label'");
if(zToolTip && *zToolTip){
CX(" title='%h'",zToolTip);
}
if(zWrapperId && *zWrapperId){
CX(" id='%s'",zWrapperId);
}
CX(">");
if(zLabel && *zLabel){
CX("<label for='%s'>%h</label>", zLabelID, zLabel);
}
CX("<select name='%s' id='%s'>",zFieldName, zLabelID);
while(1){
const char * zLabel = va_arg(vargs,char *);
const char * zVal;
if(NULL==zLabel){
break;
}
zVal = va_arg(vargs,char *);
CX("<option value='%T'%s>",
zVal, 0==fossil_strcmp(zVal, zSelectedVal) ? " selected" : "");
if(*zLabel){
CX("%s", zLabel);
}else{
CX("%h",zVal);
}
CX("</option>\n");
}
CX("</select>\n");
CX("</span>\n");
va_end(vargs);
fossil_free(zLabelID);
}
/*
** The first time this is called, it emits code to install and
** bootstrap the window.fossil object, using the built-in file
** fossil.bootstrap.js (not to be confused with bootstrap.js).
**
** Subsequent calls are no-ops.
**
** If passed a true value, it emits the contents directly to the page
** output, else it emits a script tag with a src=builtin/... to load
** the script. It always outputs a small pre-bootstrap element in its
** own script tag to initialize parts which need C-runtime-level
** information, before loading the main fossil.bootstrap.js either
** inline or via a <script src=...>, as specified by the first
** argument.
*/
void style_emit_script_fossil_bootstrap(int asInline){
static int once = 0;
if(0==once++){
/* Set up the generic/app-agnostic parts of window.fossil
** which require C-level state... */
style_emit_script_tag(0,0);
CX("(function(){\n"
"if(!window.fossil) window.fossil={};\n"
"window.fossil.version = %!j;\n"
/* fossil.rootPath is the top-most CGI/server path,
** including a trailing slash. */
"window.fossil.rootPath = %!j+'/';\n",
get_version(), g.zTop);
/* fossil.config = {...various config-level options...} */
CX("window.fossil.config = {"
"hashDigits: %d, hashDigitsUrl: %d"
"};\n", hash_digits(0), hash_digits(1));
#if 0
/* Is it safe to emit the CSRF token here? Some pages add it
** as a hidden form field. */
if(g.zCsrfToken[0]!=0){
CX("window.fossil.csrfToken = %!j;\n",
g.zCsrfToken);
}
#endif
/*
** fossil.page holds info about the current page. This is also
** where the current page "should" store any of its own
** page-specific state, and it is reserved for that purpose.
*/
CX("window.fossil.page = {"
"name:\"%T\""
"};\n", g.zPath);
CX("})();\n");
/* The remaining fossil object bootstrap code is not dependent on
** C-runtime state... */
if(asInline){
CX("%s\n", builtin_text("fossil.bootstrap.js"));
}
style_emit_script_tag(1,0);
if(asInline==0){
style_emit_script_builtin(0, "fossil.bootstrap.js");
}
}
}
/*
** If passed 0 as its first argument, it emits a script opener tag
** with this request's nonce. If passed non-0 it emits a script
** closing tag. Mnemonic for remembering the order in which to pass 0
** or 1 as the first argument to this function: 0 comes before 1.
**
** If passed 0 as its first argument and a non-NULL/non-empty zSrc,
** then it instead emits:
**
** <script src='%R/{{zSrc}}'></script>
**
** zSrc is always assumed to be a repository-relative path without
** a leading slash, and has %R/ prepended to it.
**
** Meaning that no follow-up call to pass a non-0 first argument
** to close the tag. zSrc is ignored if the first argument is not
** 0.
**
*/
void style_emit_script_tag(int isCloser, const char * zSrc){
if(0==isCloser){
if(zSrc!=0 && zSrc[0]!=0){
CX("<script src='%R/%T'></script>\n", zSrc);
}else{
CX("<script nonce='%s'>", style_nonce());
}
}else{
CX("</script>\n");
}
}
/*
** Emits a script tag which uses content from a builtin script file.
**
** If asInline is true, it is emitted directly as an opening tag, the
** content of the zName builtin file, and a closing tag.
**
** If it is false, a script tag loading it via
** src=builtin/{{zName}}?cache=XYZ is emitted, where XYZ is a
** build-time-dependent cache-buster value.
*/
void style_emit_script_builtin(int asInline, char const * zName){
if(asInline){
style_emit_script_tag(0,0);
CX("%s", builtin_text(zName));
style_emit_script_tag(1,0);
}else{
char * zFullName = mprintf("builtin/%s",zName);
const char * zHash = fossil_exe_id();
CX("<script src='%R/%T?cache=%.8s'></script>\n",
zFullName, zHash);
fossil_free(zFullName);
}
}
/*
** The first time this is called it emits the JS code from the
** built-in file fossil.fossil.js. Subsequent calls are no-ops.
**
** If passed a true value, it emits the contents directly
** to the page output, else it emits a script tag with a
** src=builtin/... to load the script.
**
** Note that this code relies on that loaded via
** style_emit_script_fossil_bootstrap() but it does not call that
** routine.
*/
void style_emit_script_fetch(int asInline){
static int once = 0;
if(0==once++){
style_emit_script_builtin(asInline, "fossil.fetch.js");
}
}
/*
** The first time this is called it emits the JS code from the
** built-in file fossil.dom.js. Subsequent calls are no-ops.
**
** If passed a true value, it emits the contents directly
** to the page output, else it emits a script tag with a
** src=builtin/... to load the script.
**
** Note that this code relies on that loaded via
** style_emit_script_fossil_bootstrap(), but it does not call that
** routine.
*/
void style_emit_script_dom(int asInline){
static int once = 0;
if(0==once++){
style_emit_script_builtin(asInline, "fossil.dom.js");
}
}
/*
** The first time this is called, it calls style_emit_script_dom(),
** passing it the given asInline value, and emits the JS code from the
** built-in file fossil.tabs.js. Subsequent calls are no-ops.
**
** If passed a true value, it emits the contents directly
** to the page output, else it emits a script tag with a
** src=builtin/... to load the script.
*/
void style_emit_script_tabs(int asInline){
static int once = 0;
if(0==once++){
style_emit_script_dom(asInline);
style_emit_script_builtin(asInline, "fossil.tabs.js");
}
}
/*
** The first time this is called it emits the JS code from the
** built-in file fossil.confirmer.js. Subsequent calls are no-ops.
**
** If passed a true value, it emits the contents directly
** to the page output, else it emits a script tag with a
** src=builtin/... to load the script.
*/
void style_emit_script_confirmer(int asInline){
static int once = 0;
if(0==once++){
style_emit_script_builtin(asInline, "fossil.confirmer.js");
}
}
|
Added src/style.fileedit.css.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
/** Styles specific to /fileedit... */
body.fileedit.waiting * {
/* Triggered during AJAX requests. */
cursor: wait;
}
body.fileedit .error {
padding: 0.25em;
}
body.fileedit .warning {
padding: 0.25em;
}
body.fileedit textarea {
font-family: monospace;
flex: 10 1 auto;
height: initial/*undo damage from some skins*/;
}
body.fileedit textarea:focus,
body.fileedit input:focus{
/* The sudden appearance of a border (as in the Ardoise skin)
shifts the layout in unsightly ways */
border: initial;
}
body.fileedit fieldset {
margin: 0.5em 0 0.5em 0;
padding: 0.25em 0;
border-radius: 0.5em;
border-color: inherit;
border-width: 1px;
font-size: 90%;
overflow: auto;
}
body.fileedit fieldset > legend {
margin: 0 0 0 1em;
padding: 0 0.5em 0 0.5em;
}
body.fileedit fieldset > div {
margin: 0 0.25em 0 0.25em;
padding: 0;
overflow: auto;
}
body.fileedit fieldset > div > .input-with-label {
margin: 0.25em 0.5em;
}
body.fileedit fieldset > div > button {
margin: 0.25em 0.5em;
}
body.fileedit .fileedit-hint {
font-size: 80%;
opacity: 0.75;
}
body.fileedit .fileedit-error-report {
background: yellow;
color: darkred;
margin: 1em 0;
padding: 0.5em;
border-radius: 0.5em;
}
body.fileedit code.fileedit-manifest {
display: block;
height: 16em;
overflow: auto;
white-space: pre;
}
body.fileedit div.fileedit-preview {
margin: 0;
padding: 0;
}
body.fileedit #fileedit-tabs {
margin: 1em 0 0 0;
}
body.fileedit #fileedit-tab-preview-wrapper {
overflow: auto;
}
body.fileedit #fileedit-tab-fileselect > h1 {
margin: 0;
}
body.fileedit .fileedit-options.commit-message > div {
display: flex;
flex-direction: column;
align-items: stretch;
font-family: monospace;
}
body.fileedit .fileedit-options.commit-message > div > * {
margin: 0.25em;
}
body.fileedit #fileedit-commit-button-wrapper {
margin: 0.25em;
}
body.fileedit .tab-container > .tabs > .tab-panel > .fileedit-options {
margin-top: 0;
border: none;
border-radius: 0;
border-bottom-width: 1px;
border-bottom-style: dotted;
}
body.fileedit .tab-container > .tabs > .tab-panel > .fileedit-options > button {
vertical-align: middle;
margin: 0.5em;
}
body.fileedit .tab-container > .tabs > .tab-panel > .fileedit-options > input {
vertical-align: middle;
margin: 0.5em;
}
body.fileedit .tab-container > .tabs > .tab-panel > .fileedit-options > .input-with-label {
vertical-align: middle;
margin: 0.5em;
}
body.fileedit .fileedit-options > div > * {
margin: 0.25em;
}
body.fileedit .fileedit-options.flex-container.flex-row {
align-items: first baseline;
}
body.fileedit #fileedit-file-selector {
display: flex;
flex-direction: column;
align-content: flex-start;
border-color: inherit;
border-width: 1px;
border-style: inset;
border-radius: 0.5em;
padding: 0 0.25em;
margin: 0;
min-height: 12em;
}
body.fileedit #fileedit-file-selector select {
margin: 0 0 0.5em 0;
height: initial;
font-family: monospace;
}
body.fileedit select:focus {
border: none;
}
body.fileedit option:focus {
border: none;
}
body.fileedit #fileedit-file-selector > div {
padding: 0;
margin: 0;
}
body.fileedit #fileedit-file-selector > div > * {
margin: 0.25em 0.5em 0.25em 0;
}
body.fileedit #fileedit-stash-selector {
margin: 0.25em;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: baseline;
}
body.fileedit #fileedit-stash-selector select {
margin: 0;
height: initial;
font-family: monospace;
flex: 10 1 auto;
}
body.fileedit .tab-container > .tabs > .tab-panel {
display: flex;
flex-direction: column;
}
body.fileedit #fileedit-tab-diff-wrapper {
margin: 0;
padding: 0;
overflow: auto;
display: flex;
flex-direction: column;
align-items: stretch;
}
body.fileedit #fileedit-tab-diff-wrapper > div {
margin: 0.5em 0 0.5em 0;
}
body.fileedit table.sbsdiffcols {
/*width: initial;*/
}
body.fileedit #fileedit-tab-diff-wrapper > pre.udiff {
margin-top: 0;
}
body.fileedit .sbsdiffcols div.difftxtcol {
display: flex;
flex-direction: column;
align-items: stretch;
width: initial;
}
body.fileedit .sbsdiffcols div.difftxtcol pre {
max-width: 44em;
}
/**
Styles for fossil.tabs.js. As of this writing, currently
only used by /fileedit, but it is anticipated that these
will eventually need to migrate to default_css.txt for use
in the wiki and/or forum pages when implementing tabbed
ajax-based previews.
*/
.tab-container {
width: 100%;
display: flex;
flex-direction: column;
align-items: stretch;
}
.tab-container > #fossil-status-bar {
margin-top: 0;
}
.tab-container > .tabs {
padding: 0.25em;
margin: 0;
display: flex;
flex-direction: column;
border-width: 1px;
border-style: outset;
border-color: inherit;
}
.tab-container > .tabs > .tab-panel {
align-self: stretch;
flex: 10 1 auto;
display: block;
}
.tab-container > .tab-bar {
display: flex;
flex-direction: row;
flex: 1 10 auto;
align-self: stretch;
flex-wrap: wrap;
}
.tab-container > .tab-bar > .tab-button {
display: inline-block;
border-radius: 0.5em 0.5em 0 0;
margin: 0 0.1em;
padding: 0.25em 0.75em;
align-self: baseline;
border-color: inherit;
border-width: 1px;
border-bottom: none;
border-top-style: inset;
border-left-style: inset;
border-right-style: inset;
cursor: pointer;
opacity: 0.6;
}
.tab-container > .tab-bar > .tab-button.selected {
text-decoration: underline;
opacity: 1.0;
border-top-style: outset;
border-left-style: outset;
border-right-style: outset;
}
/**
Styles developed for /fileedit but which have wider
applicability...
As of this writing, these are only used by /fileedit, but it is
anticipated that they will eventually need to be migrated over to
default_css.txt for use in other pages (specifically wiki and forum
page/post editors).
*/
.flex-container {
display: flex;
}
.flex-container.flex-row {
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
.flex-container .flex-grow {
flex-grow: 10;
flex-shrink: 0;
}
.flex-container .flex-shrink {
flex-grow: 0;
flex-shrink: 10;
}
.flex-container.flex-row.stretch {
flex-wrap: wrap;
align-items: baseline;
justify-content: stretch;
margin: 0;
}
.flex-container.flex-column {
flex-direction: column;
flex-wrap: wrap;
justify-content: center;
align-items: center;
}
.flex-container.flex-column.stretch {
align-items: stretch;
margin: 0;
}
.flex-container.child-gap-small > * {
margin: 0.25em;
}
#fossil-status-bar {
display: block;
font-family: monospace;
border-width: 1px;
border-style: inset;
border-color: inherit;
min-height: 1.5em;
font-size: 1.2em;
padding: 0.2em;
margin: 0.25em 0;
flex: 0 0 auto;
}
.font-size-100 {
font-size: 100%;
}
.font-size-125 {
font-size: 125%;
}
.font-size-150 {
font-size: 150%;
}
.font-size-175 {
font-size: 175%;
}
.font-size-200 {
font-size: 200%;
}
/**
.input-with-label is intended to be a wrapper element which
contain both a LABEL tag and an INPUT or SELECT control.
The wrapper is "necessary", as opposed to placing the INPUT
in the LABEL, so that we can include multiple INPUT
elements (e.g. a set of radio buttons).
*/
.input-with-label {
border: 1px inset #808080;
border-radius: 0.5em;
padding: 0.25em 0.4em;
margin: 0 0.5em;
display: inline-block;
cursor: default;
}
.input-with-label > * {
vertical-align: middle;
}
.input-with-label > label {
display: inline; /* some skins set label display to block! */
}
.input-with-label > input {
margin: 0;
}
.input-with-label > button {
margin: 0;
}
.input-with-label > select {
margin: 0;
}
.input-with-label > input[type=text] {
margin: 0;
}
.input-with-label > textarea {
margin: 0;
}
.input-with-label > input[type=checkbox] {
vertical-align: sub;
}
.input-with-label > input[type=radio] {
vertical-align: sub;
}
.input-with-label > label {
font-weight: initial;
margin: 0 0.25em 0 0.25em;
vertical-align: middle;
}
|
Changes to win/Makefile.dmc.
| ︙ | ︙ | |||
26 27 28 29 30 31 32 | TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL) LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 dnsapi SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen | | | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL) LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 dnsapi SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_GET_TABLE -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_USE_ALLOCA -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_INTROSPECTION_PRAGMAS -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen SRC = add_.c alerts_.c allrepo_.c attach_.c backlink_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c deltafunc_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c extcgi_.c file_.c fileedit_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c fuzz_.c glob_.c graph_.c gzip_.c hname_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c terminal_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c webmail_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c OBJ = $(OBJDIR)\add$O $(OBJDIR)\alerts$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\backlink$O $(OBJDIR)\backoffice$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\capabilities$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\deltafunc$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\extcgi$O $(OBJDIR)\file$O $(OBJDIR)\fileedit$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\forum$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\fuzz$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\repolist$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\setupuser$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\smtp$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\terminal$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\webmail$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O RC=$(DMDIR)\bin\rcc RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__ APPNAME = $(OBJDIR)\fossil$(E) all: $(APPNAME) $(APPNAME) : translate$E mkindex$E codecheck1$E headers $(OBJ) $(OBJDIR)\link cd $(OBJDIR) codecheck1$E $(SRC) $(DMDIR)\bin\link @link $(OBJDIR)\fossil.res: $B\win\fossil.rc $(RC) $(RCFLAGS) -o$@ $** $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res +echo add alerts allrepo attach backlink backoffice bag bisect blob branch browse builtin bundle cache capabilities captcha cgi checkin checkout clearsign clone comformat configure content cookies db delta deltacmd deltafunc descendants diff diffcmd dispatch doc encode etag event export extcgi file fileedit finfo foci forum fshell fusefs fuzz glob graph gzip hname http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path piechart pivot popen pqueue printf publish purge rebuild regexp repolist report rss schema search security_audit setup setupuser sha1 sha1hard sha3 shun sitemap skins smtp sqlcmd stash stat statrep style sync tag tar terminal th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile webmail wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@ +echo fossil >> $@ +echo fossil >> $@ +echo $(LIBS) >> $@ +echo. >> $@ +echo fossil >> $@ translate$E: $(SRCDIR)\translate.c |
| ︙ | ︙ | |||
366 367 368 369 370 371 372 373 374 375 376 377 378 379 | +translate$E $** > $@ $(OBJDIR)\file$O : file_.c file.h $(TCC) -o$@ -c file_.c file_.c : $(SRCDIR)\file.c +translate$E $** > $@ $(OBJDIR)\finfo$O : finfo_.c finfo.h $(TCC) -o$@ -c finfo_.c finfo_.c : $(SRCDIR)\finfo.c +translate$E $** > $@ | > > > > > > | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | +translate$E $** > $@ $(OBJDIR)\file$O : file_.c file.h $(TCC) -o$@ -c file_.c file_.c : $(SRCDIR)\file.c +translate$E $** > $@ $(OBJDIR)\fileedit$O : fileedit_.c fileedit.h $(TCC) -o$@ -c fileedit_.c fileedit_.c : $(SRCDIR)\fileedit.c +translate$E $** > $@ $(OBJDIR)\finfo$O : finfo_.c finfo.h $(TCC) -o$@ -c finfo_.c finfo_.c : $(SRCDIR)\finfo.c +translate$E $** > $@ |
| ︙ | ︙ | |||
974 975 976 977 978 979 980 | $(OBJDIR)\zip$O : zip_.c zip.h $(TCC) -o$@ -c zip_.c zip_.c : $(SRCDIR)\zip.c +translate$E $** > $@ headers: makeheaders$E page_index.h builtin_data.h default_css.h VERSION.h | | | 980 981 982 983 984 985 986 987 988 | $(OBJDIR)\zip$O : zip_.c zip.h $(TCC) -o$@ -c zip_.c zip_.c : $(SRCDIR)\zip.c +translate$E $** > $@ headers: makeheaders$E page_index.h builtin_data.h default_css.h VERSION.h +makeheaders$E add_.c:add.h alerts_.c:alerts.h allrepo_.c:allrepo.h attach_.c:attach.h backlink_.c:backlink.h backoffice_.c:backoffice.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h capabilities_.c:capabilities.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h cookies_.c:cookies.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h deltafunc_.c:deltafunc.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h etag_.c:etag.h event_.c:event.h export_.c:export.h extcgi_.c:extcgi.h file_.c:file.h fileedit_.c:fileedit.h finfo_.c:finfo.h foci_.c:foci.h forum_.c:forum.h fshell_.c:fshell.h fusefs_.c:fusefs.h fuzz_.c:fuzz.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h piechart_.c:piechart.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h repolist_.c:repolist.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h setupuser_.c:setupuser.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h smtp_.c:smtp.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h terminal_.c:terminal.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h webmail_.c:webmail.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h @copy /Y nul: headers |
Changes to win/Makefile.mingw.
| ︙ | ︙ | |||
474 475 476 477 478 479 480 481 482 483 484 485 486 487 | $(SRCDIR)/doc.c \ $(SRCDIR)/encode.c \ $(SRCDIR)/etag.c \ $(SRCDIR)/event.c \ $(SRCDIR)/export.c \ $(SRCDIR)/extcgi.c \ $(SRCDIR)/file.c \ $(SRCDIR)/finfo.c \ $(SRCDIR)/foci.c \ $(SRCDIR)/forum.c \ $(SRCDIR)/fshell.c \ $(SRCDIR)/fusefs.c \ $(SRCDIR)/fuzz.c \ $(SRCDIR)/glob.c \ | > | 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | $(SRCDIR)/doc.c \ $(SRCDIR)/encode.c \ $(SRCDIR)/etag.c \ $(SRCDIR)/event.c \ $(SRCDIR)/export.c \ $(SRCDIR)/extcgi.c \ $(SRCDIR)/file.c \ $(SRCDIR)/fileedit.c \ $(SRCDIR)/finfo.c \ $(SRCDIR)/foci.c \ $(SRCDIR)/forum.c \ $(SRCDIR)/fshell.c \ $(SRCDIR)/fusefs.c \ $(SRCDIR)/fuzz.c \ $(SRCDIR)/glob.c \ |
| ︙ | ︙ | |||
638 639 640 641 642 643 644 645 646 647 648 649 650 651 | $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/accordion.js \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/copybtn.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ $(SRCDIR)/sbsdiff.js \ $(SRCDIR)/scroll.js \ | > > > > > > > | 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 | $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/accordion.js \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/copybtn.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/fossil.bootstrap.js \ $(SRCDIR)/fossil.confirmer.js \ $(SRCDIR)/fossil.dom.js \ $(SRCDIR)/fossil.fetch.js \ $(SRCDIR)/fossil.page.fileedit.js \ $(SRCDIR)/fossil.storage.js \ $(SRCDIR)/fossil.tabs.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ $(SRCDIR)/sbsdiff.js \ $(SRCDIR)/scroll.js \ |
| ︙ | ︙ | |||
664 665 666 667 668 669 670 671 672 673 674 675 676 677 | $(SRCDIR)/sounds/a.wav \ $(SRCDIR)/sounds/b.wav \ $(SRCDIR)/sounds/c.wav \ $(SRCDIR)/sounds/d.wav \ $(SRCDIR)/sounds/e.wav \ $(SRCDIR)/sounds/f.wav \ $(SRCDIR)/style.admin_log.css \ $(SRCDIR)/tree.js \ $(SRCDIR)/useredit.js \ $(SRCDIR)/wiki.wiki TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/alerts_.c \ | > | 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 | $(SRCDIR)/sounds/a.wav \ $(SRCDIR)/sounds/b.wav \ $(SRCDIR)/sounds/c.wav \ $(SRCDIR)/sounds/d.wav \ $(SRCDIR)/sounds/e.wav \ $(SRCDIR)/sounds/f.wav \ $(SRCDIR)/style.admin_log.css \ $(SRCDIR)/style.fileedit.css \ $(SRCDIR)/tree.js \ $(SRCDIR)/useredit.js \ $(SRCDIR)/wiki.wiki TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/alerts_.c \ |
| ︙ | ︙ | |||
709 710 711 712 713 714 715 716 717 718 719 720 721 722 | $(OBJDIR)/doc_.c \ $(OBJDIR)/encode_.c \ $(OBJDIR)/etag_.c \ $(OBJDIR)/event_.c \ $(OBJDIR)/export_.c \ $(OBJDIR)/extcgi_.c \ $(OBJDIR)/file_.c \ $(OBJDIR)/finfo_.c \ $(OBJDIR)/foci_.c \ $(OBJDIR)/forum_.c \ $(OBJDIR)/fshell_.c \ $(OBJDIR)/fusefs_.c \ $(OBJDIR)/fuzz_.c \ $(OBJDIR)/glob_.c \ | > | 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 | $(OBJDIR)/doc_.c \ $(OBJDIR)/encode_.c \ $(OBJDIR)/etag_.c \ $(OBJDIR)/event_.c \ $(OBJDIR)/export_.c \ $(OBJDIR)/extcgi_.c \ $(OBJDIR)/file_.c \ $(OBJDIR)/fileedit_.c \ $(OBJDIR)/finfo_.c \ $(OBJDIR)/foci_.c \ $(OBJDIR)/forum_.c \ $(OBJDIR)/fshell_.c \ $(OBJDIR)/fusefs_.c \ $(OBJDIR)/fuzz_.c \ $(OBJDIR)/glob_.c \ |
| ︙ | ︙ | |||
852 853 854 855 856 857 858 859 860 861 862 863 864 865 | $(OBJDIR)/doc.o \ $(OBJDIR)/encode.o \ $(OBJDIR)/etag.o \ $(OBJDIR)/event.o \ $(OBJDIR)/export.o \ $(OBJDIR)/extcgi.o \ $(OBJDIR)/file.o \ $(OBJDIR)/finfo.o \ $(OBJDIR)/foci.o \ $(OBJDIR)/forum.o \ $(OBJDIR)/fshell.o \ $(OBJDIR)/fusefs.o \ $(OBJDIR)/fuzz.o \ $(OBJDIR)/glob.o \ | > | 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | $(OBJDIR)/doc.o \ $(OBJDIR)/encode.o \ $(OBJDIR)/etag.o \ $(OBJDIR)/event.o \ $(OBJDIR)/export.o \ $(OBJDIR)/extcgi.o \ $(OBJDIR)/file.o \ $(OBJDIR)/fileedit.o \ $(OBJDIR)/finfo.o \ $(OBJDIR)/foci.o \ $(OBJDIR)/forum.o \ $(OBJDIR)/fshell.o \ $(OBJDIR)/fusefs.o \ $(OBJDIR)/fuzz.o \ $(OBJDIR)/glob.o \ |
| ︙ | ︙ | |||
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 | $(OBJDIR)/doc_.c:$(OBJDIR)/doc.h \ $(OBJDIR)/encode_.c:$(OBJDIR)/encode.h \ $(OBJDIR)/etag_.c:$(OBJDIR)/etag.h \ $(OBJDIR)/event_.c:$(OBJDIR)/event.h \ $(OBJDIR)/export_.c:$(OBJDIR)/export.h \ $(OBJDIR)/extcgi_.c:$(OBJDIR)/extcgi.h \ $(OBJDIR)/file_.c:$(OBJDIR)/file.h \ $(OBJDIR)/finfo_.c:$(OBJDIR)/finfo.h \ $(OBJDIR)/foci_.c:$(OBJDIR)/foci.h \ $(OBJDIR)/forum_.c:$(OBJDIR)/forum.h \ $(OBJDIR)/fshell_.c:$(OBJDIR)/fshell.h \ $(OBJDIR)/fusefs_.c:$(OBJDIR)/fusefs.h \ $(OBJDIR)/fuzz_.c:$(OBJDIR)/fuzz.h \ $(OBJDIR)/glob_.c:$(OBJDIR)/glob.h \ | > | 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | $(OBJDIR)/doc_.c:$(OBJDIR)/doc.h \ $(OBJDIR)/encode_.c:$(OBJDIR)/encode.h \ $(OBJDIR)/etag_.c:$(OBJDIR)/etag.h \ $(OBJDIR)/event_.c:$(OBJDIR)/event.h \ $(OBJDIR)/export_.c:$(OBJDIR)/export.h \ $(OBJDIR)/extcgi_.c:$(OBJDIR)/extcgi.h \ $(OBJDIR)/file_.c:$(OBJDIR)/file.h \ $(OBJDIR)/fileedit_.c:$(OBJDIR)/fileedit.h \ $(OBJDIR)/finfo_.c:$(OBJDIR)/finfo.h \ $(OBJDIR)/foci_.c:$(OBJDIR)/foci.h \ $(OBJDIR)/forum_.c:$(OBJDIR)/forum.h \ $(OBJDIR)/fshell_.c:$(OBJDIR)/fshell.h \ $(OBJDIR)/fusefs_.c:$(OBJDIR)/fusefs.h \ $(OBJDIR)/fuzz_.c:$(OBJDIR)/fuzz.h \ $(OBJDIR)/glob_.c:$(OBJDIR)/glob.h \ |
| ︙ | ︙ | |||
1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 | $(OBJDIR)/file_.c: $(SRCDIR)/file.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/file.c >$@ $(OBJDIR)/file.o: $(OBJDIR)/file_.c $(OBJDIR)/file.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/file.o -c $(OBJDIR)/file_.c $(OBJDIR)/file.h: $(OBJDIR)/headers $(OBJDIR)/finfo_.c: $(SRCDIR)/finfo.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/finfo.c >$@ $(OBJDIR)/finfo.o: $(OBJDIR)/finfo_.c $(OBJDIR)/finfo.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/finfo.o -c $(OBJDIR)/finfo_.c | > > > > > > > > | 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 | $(OBJDIR)/file_.c: $(SRCDIR)/file.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/file.c >$@ $(OBJDIR)/file.o: $(OBJDIR)/file_.c $(OBJDIR)/file.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/file.o -c $(OBJDIR)/file_.c $(OBJDIR)/file.h: $(OBJDIR)/headers $(OBJDIR)/fileedit_.c: $(SRCDIR)/fileedit.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/fileedit.c >$@ $(OBJDIR)/fileedit.o: $(OBJDIR)/fileedit_.c $(OBJDIR)/fileedit.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/fileedit.o -c $(OBJDIR)/fileedit_.c $(OBJDIR)/fileedit.h: $(OBJDIR)/headers $(OBJDIR)/finfo_.c: $(SRCDIR)/finfo.c $(TRANSLATE) $(TRANSLATE) $(SRCDIR)/finfo.c >$@ $(OBJDIR)/finfo.o: $(OBJDIR)/finfo_.c $(OBJDIR)/finfo.h $(SRCDIR)/config.h $(XTCC) -o $(OBJDIR)/finfo.o -c $(OBJDIR)/finfo_.c |
| ︙ | ︙ |
Changes to win/Makefile.msc.
| ︙ | ︙ | |||
382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
doc_.c \
encode_.c \
etag_.c \
event_.c \
export_.c \
extcgi_.c \
file_.c \
finfo_.c \
foci_.c \
forum_.c \
fshell_.c \
fusefs_.c \
fuzz_.c \
glob_.c \
| > | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
doc_.c \
encode_.c \
etag_.c \
event_.c \
export_.c \
extcgi_.c \
file_.c \
fileedit_.c \
finfo_.c \
foci_.c \
forum_.c \
fshell_.c \
fusefs_.c \
fuzz_.c \
glob_.c \
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 552 553 554 555 556 557 558 |
$(SRCDIR)\..\skins\xekri\footer.txt \
$(SRCDIR)\..\skins\xekri\header.txt \
$(SRCDIR)\accordion.js \
$(SRCDIR)\ci_edit.js \
$(SRCDIR)\copybtn.js \
$(SRCDIR)\diff.tcl \
$(SRCDIR)\forum.js \
$(SRCDIR)\graph.js \
$(SRCDIR)\href.js \
$(SRCDIR)\login.js \
$(SRCDIR)\markdown.md \
$(SRCDIR)\menu.js \
$(SRCDIR)\sbsdiff.js \
$(SRCDIR)\scroll.js \
| > > > > > > > | 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
$(SRCDIR)\..\skins\xekri\footer.txt \
$(SRCDIR)\..\skins\xekri\header.txt \
$(SRCDIR)\accordion.js \
$(SRCDIR)\ci_edit.js \
$(SRCDIR)\copybtn.js \
$(SRCDIR)\diff.tcl \
$(SRCDIR)\forum.js \
$(SRCDIR)\fossil.bootstrap.js \
$(SRCDIR)\fossil.confirmer.js \
$(SRCDIR)\fossil.dom.js \
$(SRCDIR)\fossil.fetch.js \
$(SRCDIR)\fossil.page.fileedit.js \
$(SRCDIR)\fossil.storage.js \
$(SRCDIR)\fossil.tabs.js \
$(SRCDIR)\graph.js \
$(SRCDIR)\href.js \
$(SRCDIR)\login.js \
$(SRCDIR)\markdown.md \
$(SRCDIR)\menu.js \
$(SRCDIR)\sbsdiff.js \
$(SRCDIR)\scroll.js \
|
| ︙ | ︙ | |||
571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
$(SRCDIR)\sounds\a.wav \
$(SRCDIR)\sounds\b.wav \
$(SRCDIR)\sounds\c.wav \
$(SRCDIR)\sounds\d.wav \
$(SRCDIR)\sounds\e.wav \
$(SRCDIR)\sounds\f.wav \
$(SRCDIR)\style.admin_log.css \
$(SRCDIR)\tree.js \
$(SRCDIR)\useredit.js \
$(SRCDIR)\wiki.wiki
OBJ = $(OX)\add$O \
$(OX)\alerts$O \
$(OX)\allrepo$O \
| > | 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 |
$(SRCDIR)\sounds\a.wav \
$(SRCDIR)\sounds\b.wav \
$(SRCDIR)\sounds\c.wav \
$(SRCDIR)\sounds\d.wav \
$(SRCDIR)\sounds\e.wav \
$(SRCDIR)\sounds\f.wav \
$(SRCDIR)\style.admin_log.css \
$(SRCDIR)\style.fileedit.css \
$(SRCDIR)\tree.js \
$(SRCDIR)\useredit.js \
$(SRCDIR)\wiki.wiki
OBJ = $(OX)\add$O \
$(OX)\alerts$O \
$(OX)\allrepo$O \
|
| ︙ | ︙ | |||
616 617 618 619 620 621 622 623 624 625 626 627 628 629 |
$(OX)\doc$O \
$(OX)\encode$O \
$(OX)\etag$O \
$(OX)\event$O \
$(OX)\export$O \
$(OX)\extcgi$O \
$(OX)\file$O \
$(OX)\finfo$O \
$(OX)\foci$O \
$(OX)\forum$O \
$(OX)\fshell$O \
$(OX)\fusefs$O \
$(OX)\fuzz$O \
$(OX)\glob$O \
| > | 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 |
$(OX)\doc$O \
$(OX)\encode$O \
$(OX)\etag$O \
$(OX)\event$O \
$(OX)\export$O \
$(OX)\extcgi$O \
$(OX)\file$O \
$(OX)\fileedit$O \
$(OX)\finfo$O \
$(OX)\foci$O \
$(OX)\forum$O \
$(OX)\fshell$O \
$(OX)\fusefs$O \
$(OX)\fuzz$O \
$(OX)\glob$O \
|
| ︙ | ︙ | |||
821 822 823 824 825 826 827 828 829 830 831 832 833 834 | echo $(OX)\doc.obj >> $@ echo $(OX)\encode.obj >> $@ echo $(OX)\etag.obj >> $@ echo $(OX)\event.obj >> $@ echo $(OX)\export.obj >> $@ echo $(OX)\extcgi.obj >> $@ echo $(OX)\file.obj >> $@ echo $(OX)\finfo.obj >> $@ echo $(OX)\foci.obj >> $@ echo $(OX)\forum.obj >> $@ echo $(OX)\fshell.obj >> $@ echo $(OX)\fusefs.obj >> $@ echo $(OX)\fuzz.obj >> $@ echo $(OX)\glob.obj >> $@ | > | 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 | echo $(OX)\doc.obj >> $@ echo $(OX)\encode.obj >> $@ echo $(OX)\etag.obj >> $@ echo $(OX)\event.obj >> $@ echo $(OX)\export.obj >> $@ echo $(OX)\extcgi.obj >> $@ echo $(OX)\file.obj >> $@ echo $(OX)\fileedit.obj >> $@ echo $(OX)\finfo.obj >> $@ echo $(OX)\foci.obj >> $@ echo $(OX)\forum.obj >> $@ echo $(OX)\fshell.obj >> $@ echo $(OX)\fusefs.obj >> $@ echo $(OX)\fuzz.obj >> $@ echo $(OX)\glob.obj >> $@ |
| ︙ | ︙ | |||
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 | translate$E $** > $@ $(OX)\file$O : file_.c file.h $(TCC) /Fo$@ -c file_.c file_.c : $(SRCDIR)\file.c translate$E $** > $@ $(OX)\finfo$O : finfo_.c finfo.h $(TCC) /Fo$@ -c finfo_.c finfo_.c : $(SRCDIR)\finfo.c translate$E $** > $@ | > > > > > > | 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 | translate$E $** > $@ $(OX)\file$O : file_.c file.h $(TCC) /Fo$@ -c file_.c file_.c : $(SRCDIR)\file.c translate$E $** > $@ $(OX)\fileedit$O : fileedit_.c fileedit.h $(TCC) /Fo$@ -c fileedit_.c fileedit_.c : $(SRCDIR)\fileedit.c translate$E $** > $@ $(OX)\finfo$O : finfo_.c finfo.h $(TCC) /Fo$@ -c finfo_.c finfo_.c : $(SRCDIR)\finfo.c translate$E $** > $@ |
| ︙ | ︙ | |||
1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 | doc_.c:doc.h \ encode_.c:encode.h \ etag_.c:etag.h \ event_.c:event.h \ export_.c:export.h \ extcgi_.c:extcgi.h \ file_.c:file.h \ finfo_.c:finfo.h \ foci_.c:foci.h \ forum_.c:forum.h \ fshell_.c:fshell.h \ fusefs_.c:fusefs.h \ fuzz_.c:fuzz.h \ glob_.c:glob.h \ | > | 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 | doc_.c:doc.h \ encode_.c:encode.h \ etag_.c:etag.h \ event_.c:event.h \ export_.c:export.h \ extcgi_.c:extcgi.h \ file_.c:file.h \ fileedit_.c:fileedit.h \ finfo_.c:finfo.h \ foci_.c:foci.h \ forum_.c:forum.h \ fshell_.c:fshell.h \ fusefs_.c:fusefs.h \ fuzz_.c:fuzz.h \ glob_.c:glob.h \ |
| ︙ | ︙ |
Added www/fileedit-page.md.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# The fileedit Page
This document describes the limitations of, caveats for, and
disclaimers for the [](/fileedit) page, which provides users with
[checkin privileges](./caps/index.md) basic editing features for files
via the web interface.
# Important Caveats and Disclaimers
Predictably, the ability to edit files in a repository from a web
browser halfway around the world comes with several obligatory caveats
and disclaimers...
## `/fileedit` Does *Nothing* by Default.
In order to "activate" it, a user with [the "setup"
permission](./caps/index.md) must set the
[fileedit-glob](/help?cmd=fileedit-glob) repository setting to a
comma- or newline-delimited list of globs representing a whitelist of
files which may be edited online. Any user with commit access may then
edit files matching one of those globs. Certain pages within the UI
get an "edit" link added to them when the current user's permissions
and the whitelist both permit editing of that file.
## CSRF & HTTP Referrer Headers
In order to protect against [Cross-site Request Forgery (CSRF)][csrf]
attacks, Fossil UI features which write to the database require that
the browser send the so-called [HTTP `Referer` header][referer]
(noting that the misspelling of "referrer" is a historical accident
which has long-since been standardized!). Modern browsers, by default,
include such information automatically for *interactive* actions which
lead to a request, e.g. clicking on a link back to the same
server. However, `/fileedit` uses asynchronous ["XHR"][xhr]
connections, which browsers *may* treat differently than strictly
interactive elements.
- **Firefox**: configuration option `network.http.sendRefererHeader`
specifies whether the `Referer` header is sent. It must have a value
of 2 (which is the default) for XHR requests to get the `Referer`
header. Purely interactive Fossil features, in which users directly
activate links or forms, work with a level of 1 or higher.
- **Chrome**: apparently requires an add-on in order to change this
policy, so Chrome without such an add-on will not suppress this
header.
- **Safari**: ???
- **Other browsers**: ???
If `/filepage` shows an error message saying "CSRF violation," the
problem is that the browser is not sending a `Referer` header to XHR
connections. Fossil does not offer a way to disable its CSRF
protections.
[referer]: https://en.wikipedia.org/wiki/HTTP_referer
[csrf]: https://en.wikipedia.org/wiki/Cross-site_request_forgery
[xhr]: https://en.wikipedia.org/wiki/XMLHttpRequest
## `/fileedit` **Works by Creating Commits**
Thus any edits made via that page become a normal part of the
repository's blockchain.
## `/fileedit` is *Intended* for use with Embedded Docs
... and similar text files, and is most certainly
**not intended for editing code**.
Editing files with unusual syntax requirements, e.g. hard tabs in
makefiles, may break them. *You Have Been Warned.*
Similarly, though every effort is made to retain the end-of-line
style used by being-edited files, the round-trip through an HTML
textarea element may change the EOLs. The Commit section of the page
offers three different options for how to treat newlines when saving
changes. **Files with mixed EOL styles** *will be normalized to a single
EOL style* when modified using `/fileedit`. When "inheriting" the EOL
style from a previous version which has mixed styles, the first EOL
style detected in the previous version of the file is used.
## `/fileedit` **is Not a Replacement for a Checkout**
A full-featured checkout allows far more possibilities than this basic
online editor permits, and the feature scope of `/fileedit` is
intentionally kept small, implementing only the bare necessities
needed for performing basic edits online. It *is not, and will never
be, a replacement for a checkout.*
It is to be expected that users will want to do "more" with this
page, and we generally encourage feature requests, but be aware that
certain types of ostensibly sensible feature requests *will be
rejected* for `/fileedit`. These include, but are not limited to:
- Features which are already provided by other pages, e.g.
the ability to create a new named branch or add tags.
- Features which would require re-implementing significant
capabilities provided only within a checkout (e.g. merging files).
- The ability to edit/manipulate files which are in a local
checkout. (If you have a checkout, use your local editor, not
`/fileedit`.)
- Editing of non-text files, e.g. images. Use a checkout and your
preferred graphics editor.
- Support for syncing/pulling/pushing of a repository before and/or
after edits. Those features cannot be *reliably* provided via a web
interface for several reasons.
Similarly, some *potential* features have significant downsides,
abuses, and/or implementation hurdles which make the decision of
whether or not to implement them subject to notable contributor
debate. e.g. the ability to add new files or remove/rename older
files.
## `/fileedit` **Stores Only Limited Local Edits While Working**
When changes are made to a given checkin/file combination,
`/fileedit` will, if possible, store them in [`window.localStorage`
or `window.sessionStorage`][html5storage], if available, but...
- Which storage is used is unspecified and may differ across
environments.
- If neither of those is available, the storage is transient and
will not survive a page reload. In this case, the UI issues a clear
warning in the editor tab.
- It stores only the most recent checkin/file combinations which have
been modified (exactly how many may differ - the number will be
noted somewhere in the UI). Note that changing the "executable bit"
is counted as a modification, but the checkin *comment* is *not*
and is reset after a commit.
- If its internal limit on the number of modified files is exceeded,
it silently discards the oldest edits to keep the list at its limit.
Edits are saved whenever the editor component fires its "change"
event, which essentially means as soon as it loses input focus. Thus
to force the browser to save any pending changes, simply click
somwhere on the page outside of the editor.
Exactly how long `localStorage` will survive, and how much it or
`sessionStorage` can hold, is environment-dependent. `sessionStorage`
will survive until the current browser tab is closed, but it survives
across reloads of the same tab.
If `/filepage` determines that no peristent storage is available a
warning is displayed on the editor page.
[html5storage]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API
## The Power is Yours, but...
> "With great power comes great responsibility."
**Use this feature judiciously, *if at all*.**
Now, with those warnings and caveats out of the way...
-----
# Tips and Tricks
## `fossil` Global-scope JS Object
`/fileedit` is largely implemented in JavaScript, and makes heavy use
of the global-scope `fossil` object, which provides
infrastructure-level features intended for use by Fossil UI pages.
(That said, that infrastructure was introduced with `/fileedit`, and
most pages do not use it.)
The `fossil.page` object represents the UI's current page (on pages
which make use of this API - most do not). That object supports
listening to page-specific events so that JS code installed via
[client-side edits to the site skin's footer](customskin.md) may react
to those changes somehow. The next section describes one such use for
such events...
## Integrating Syntax Highlighting
Assuming a repository has integrated a 3rd-party syntax highlighting
solution, it can probably (depending on its API) be told how to
highlight `/fileedit`'s wiki/markdown-format previews. Here are
instructions for doing so with [highlightjs](https://highlightjs.org/):
At the very bottom of the [site skin's footer](customskin.md), add a
script tag similar to the following:
```javascript
<script nonce="$<nonce>">
if(window.fossil && fossil.page && fossil.page.name==='fileedit'){
fossil.page.addEventListener(
'fileedit-preview-updated',
(ev)=>{
if(ev.detail.previewMode==='wiki'){
ev.detail.element.querySelectorAll(
'code[class^=language-]'
).forEach((e)=>hljs.highlightBlock(e));
}
}
);
}
</script>
```
Note that the `nonce="$<nonce>"` part is intended to be entered
literally as shown above. It will be expanded to contain the current
request's nonce value when the page is rendered.
The first line of the script just ensures that the expected JS-level
infrastructure is loaded. It's only loaded in the `/fileedit` page and
possibly pages added or "upgraded" since `/fileedit`'s introduction.
The part in the `if` block adds an event listener to the `/filepage`
app which gets called when the preview is refreshed. That event
contains 3 properties:
- `previewMode`: a string describing the current preview mode: `wiki`
(which includes Fossil-native wiki and markdown), `text`,
`htmlInline`, `htmlIframe`. We should "probably" only highlight wiki
text, and thus the example above limits its work to that type of
preview. It won't work with `htmlIframe`, as that represents an
iframe element which contains a complete HTML document.
- `element`: the DOM element in which the preview is rendered.
- `mimetype`: the mimetype of the being-previewed content, as determined
by Fossil (by its file extension).
The event listener callback shown above doesn't use the `mimetype`,
but makes used of the other two. It fishes all `code` blocks out of
the preview which explicitly have a CSS class named
`language-`something, and then asks highlightjs to highlight them.
## Integrating a Custom Editor Widget
*Hypothetically*, though this is currently unproven "in the wild," it
is possible to replace `/filepage`'s basic text-editing widget (a
`textarea` element) with a fancy 3rd-party editor widget by following
these instructions...
All JavaScript code which follows is assumed to be in a script tag
similar to the one shown in the previous section:
```javascript
<script nonce="$<nonce>">
if(window.fossil && fossil.page && fossil.page.name==='fileedit'){
// code specific to the fileedit page goes here
}
</script>
```
First, install proxy functions so that `fossil.page.fileContent()`
can get and set your content:
```
fossil.page.setFileContentMethods(
function(){ return text-form content of your widget },
function(content){ set text-form content of your widget }
};
```
Secondly, inject the custom editor widget into the UI, replacing
the default editor widget:
```javascript
fossil.page.replaceEditorWidget(yourNewWidgetElement);
```
That method must be passed a DOM element and may only be called once:
it *removes itself* the first time it is called.
That "should" be all there is to it. When `fossil.page` needs to get
the being-edited content, it will call `fossil.page.fileContent()`
with no arguments, and when it sets the content (immediately after
(re)loading a file), it will pass that content to
`fossil.page.fileContent()`. Those, in turn will trigger the installed
proxies and fire any relevant events.
|
Changes to www/mkindex.tcl.
| ︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
delta_encoder_algorithm.wiki {Fossil Delta Encoding Algorithm}
delta_format.wiki {Fossil Delta Format}
embeddeddoc.wiki {Embedded Project Documentation}
encryptedrepos.wiki {How To Use Encrypted Repositories}
env-opts.md {Environment Variables and Global Options}
event.wiki {Events}
faq.wiki {Frequently Asked Questions}
fileformat.wiki {Fossil File Format}
fiveminutes.wiki {Up and Running in 5 Minutes as a Single User}
forum.wiki {Fossil Forums}
foss-cklist.wiki {Checklist For Successful Open-Source Projects}
fossil-from-msvc.wiki {Integrating Fossil in the Microsoft Express 2010 IDE}
fossil_prompt.wiki {Fossilized Bash Prompt}
fossil-v-git.wiki {Fossil Versus Git}
| > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
delta_encoder_algorithm.wiki {Fossil Delta Encoding Algorithm}
delta_format.wiki {Fossil Delta Format}
embeddeddoc.wiki {Embedded Project Documentation}
encryptedrepos.wiki {How To Use Encrypted Repositories}
env-opts.md {Environment Variables and Global Options}
event.wiki {Events}
faq.wiki {Frequently Asked Questions}
fileedit-page.md {The fileedit Page}
fileformat.wiki {Fossil File Format}
fiveminutes.wiki {Up and Running in 5 Minutes as a Single User}
forum.wiki {Fossil Forums}
foss-cklist.wiki {Checklist For Successful Open-Source Projects}
fossil-from-msvc.wiki {Integrating Fossil in the Microsoft Express 2010 IDE}
fossil_prompt.wiki {Fossilized Bash Prompt}
fossil-v-git.wiki {Fossil Versus Git}
|
| ︙ | ︙ |
Changes to www/permutedindex.html.
| ︙ | ︙ | |||
9 10 11 12 13 14 15 | <h2>Primary Documents:</h2> <ul> <li> <a href='quickstart.wiki'>Quick-start Guide</a> <li> <a href='history.md'>Purpose and History of Fossil</a> <li> <a href='build.wiki'>Compiling and installing Fossil</a> <li> <a href='../COPYRIGHT-BSD2.txt'>License</a> <li> <a href='$ROOT/help'>List of commands, web-pages, and settings</a> | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <h2>Primary Documents:</h2> <ul> <li> <a href='quickstart.wiki'>Quick-start Guide</a> <li> <a href='history.md'>Purpose and History of Fossil</a> <li> <a href='build.wiki'>Compiling and installing Fossil</a> <li> <a href='../COPYRIGHT-BSD2.txt'>License</a> <li> <a href='$ROOT/help'>List of commands, web-pages, and settings</a> <li> <a href='userlinks.wiki'>Miscellaneous Docs for Fossil Users</a> <li> <a href='hacker-howto.wiki'>Fossil Developer's Guide</a> <li> <a href='http://www.fossil-scm.org/schimpf-book/home'>Jim Schimpf's book</a> </ul> <a name="pindex"></a> <h2>Permuted Index:</h2> <ul> |
| ︙ | ︙ | |||
111 112 113 114 115 116 117 118 119 120 121 122 123 124 | <li><a href="inout.wiki">Export To And From Git — Import And</a></li> <li><a href="fossil-from-msvc.wiki">Express 2010 IDE — Integrating Fossil in the Microsoft</a></li> <li><a href="serverext.wiki">Extensions — CGI Server</a></li> <li><a href="serverext.wiki">Extensions To A Fossil Server Using CGI Scripts — Adding</a></li> <li><a href="adding_code.wiki">Features To Fossil — Adding New</a></li> <li><a href="fileformat.wiki">File Format — Fossil</a></li> <li><a href="globs.md"><b>File Name Glob Patterns</b></a></li> <li><a href="unvers.wiki">Files — Unversioned</a></li> <li><a href="branching.wiki">Forking, Merging, and Tagging — Branching,</a></li> <li><a href="delta_format.wiki">Format — Fossil Delta</a></li> <li><a href="fileformat.wiki">Format — Fossil File</a></li> <li><a href="image-format-vs-repo-size.md">Format vs Fossil Repo Size — Image</a></li> <li><a href="../../../md_rules">Formatting Rules — Markdown</a></li> <li><a href="../../../wiki_rules">Formatting Rules — Wiki</a></li> | > | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | <li><a href="inout.wiki">Export To And From Git — Import And</a></li> <li><a href="fossil-from-msvc.wiki">Express 2010 IDE — Integrating Fossil in the Microsoft</a></li> <li><a href="serverext.wiki">Extensions — CGI Server</a></li> <li><a href="serverext.wiki">Extensions To A Fossil Server Using CGI Scripts — Adding</a></li> <li><a href="adding_code.wiki">Features To Fossil — Adding New</a></li> <li><a href="fileformat.wiki">File Format — Fossil</a></li> <li><a href="globs.md"><b>File Name Glob Patterns</b></a></li> <li><a href="fileedit-page.md">fileedit Page — The</a></li> <li><a href="unvers.wiki">Files — Unversioned</a></li> <li><a href="branching.wiki">Forking, Merging, and Tagging — Branching,</a></li> <li><a href="delta_format.wiki">Format — Fossil Delta</a></li> <li><a href="fileformat.wiki">Format — Fossil File</a></li> <li><a href="image-format-vs-repo-size.md">Format vs Fossil Repo Size — Image</a></li> <li><a href="../../../md_rules">Formatting Rules — Markdown</a></li> <li><a href="../../../wiki_rules">Formatting Rules — Wiki</a></li> |
| ︙ | ︙ | |||
204 205 206 207 208 209 210 211 212 213 214 215 216 217 | <li><a href="alerts.md">Notifications — Email Alerts And</a></li> <li><a href="foss-cklist.wiki">Open-Source Projects — Checklist For Successful</a></li> <li><a href="pop.wiki">Operation — Principles Of</a></li> <li><a href="cgi.wiki">Options — CGI Script Configuration</a></li> <li><a href="env-opts.md">Options — Environment Variables and Global</a></li> <li><a href="tech_overview.wiki">Overview Of The Design And Implementation Of Fossil — A Technical</a></li> <li><a href="index.wiki">Page — Home</a></li> <li><a href="aboutdownload.wiki">Page Works — How The Download</a></li> <li><a href="customskin.md">Pages — Theming: Customizing The Appearance of Web</a></li> <li><a href="password.wiki"><b>Password Management And Authentication</b></a></li> <li><a href="globs.md">Patterns — File Name Glob</a></li> <li><a href="quotes.wiki">People Are Saying About Fossil, Git, and DVCSes in General — Quotes: What</a></li> <li><a href="stats.wiki"><b>Performance Statistics</b></a></li> <li><a href="defcsp.md">Policy — The Default Content Security</a></li> | > | 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | <li><a href="alerts.md">Notifications — Email Alerts And</a></li> <li><a href="foss-cklist.wiki">Open-Source Projects — Checklist For Successful</a></li> <li><a href="pop.wiki">Operation — Principles Of</a></li> <li><a href="cgi.wiki">Options — CGI Script Configuration</a></li> <li><a href="env-opts.md">Options — Environment Variables and Global</a></li> <li><a href="tech_overview.wiki">Overview Of The Design And Implementation Of Fossil — A Technical</a></li> <li><a href="index.wiki">Page — Home</a></li> <li><a href="fileedit-page.md">Page — The fileedit</a></li> <li><a href="aboutdownload.wiki">Page Works — How The Download</a></li> <li><a href="customskin.md">Pages — Theming: Customizing The Appearance of Web</a></li> <li><a href="password.wiki"><b>Password Management And Authentication</b></a></li> <li><a href="globs.md">Patterns — File Name Glob</a></li> <li><a href="quotes.wiki">People Are Saying About Fossil, Git, and DVCSes in General — Quotes: What</a></li> <li><a href="stats.wiki"><b>Performance Statistics</b></a></li> <li><a href="defcsp.md">Policy — The Default Content Security</a></li> |
| ︙ | ︙ | |||
279 280 281 282 283 284 285 286 287 288 289 290 291 292 | <li><a href="branching.wiki">Tagging — Branching, Forking, Merging, and</a></li> <li><a href="tech_overview.wiki">Technical Overview Of The Design And Implementation Of Fossil — A</a></li> <li><a href="../test/release-checklist.wiki">Testing Checklist — Pre-Release</a></li> <li><a href="th1.md">TH1 Scripting Language — The</a></li> <li><a href="backoffice.md"><b>The "Backoffice" mechanism of Fossil</b></a></li> <li><a href="blame.wiki"><b>The Annotate/Blame Algorithm Of Fossil</b></a></li> <li><a href="defcsp.md"><b>The Default Content Security Policy</b></a></li> <li><a href="makefile.wiki"><b>The Fossil Build Process</b></a></li> <li><a href="sync.wiki"><b>The Fossil Sync Protocol</b></a></li> <li><a href="tickets.wiki"><b>The Fossil Ticket System</b></a></li> <li><a href="webui.wiki"><b>The Fossil Web Interface</b></a></li> <li><a href="history.md"><b>The Purpose And History Of Fossil</b></a></li> <li><a href="th1.md"><b>The TH1 Scripting Language</b></a></li> <li><a href="customskin.md"><b>Theming: Customizing The Appearance of Web Pages</b></a></li> | > | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | <li><a href="branching.wiki">Tagging — Branching, Forking, Merging, and</a></li> <li><a href="tech_overview.wiki">Technical Overview Of The Design And Implementation Of Fossil — A</a></li> <li><a href="../test/release-checklist.wiki">Testing Checklist — Pre-Release</a></li> <li><a href="th1.md">TH1 Scripting Language — The</a></li> <li><a href="backoffice.md"><b>The "Backoffice" mechanism of Fossil</b></a></li> <li><a href="blame.wiki"><b>The Annotate/Blame Algorithm Of Fossil</b></a></li> <li><a href="defcsp.md"><b>The Default Content Security Policy</b></a></li> <li><a href="fileedit-page.md"><b>The fileedit Page</b></a></li> <li><a href="makefile.wiki"><b>The Fossil Build Process</b></a></li> <li><a href="sync.wiki"><b>The Fossil Sync Protocol</b></a></li> <li><a href="tickets.wiki"><b>The Fossil Ticket System</b></a></li> <li><a href="webui.wiki"><b>The Fossil Web Interface</b></a></li> <li><a href="history.md"><b>The Purpose And History Of Fossil</b></a></li> <li><a href="th1.md"><b>The TH1 Scripting Language</b></a></li> <li><a href="customskin.md"><b>Theming: Customizing The Appearance of Web Pages</b></a></li> |
| ︙ | ︙ |