Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Use an HTML5 color chooser dialog in the check-in comment editor. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
f8bc3ce8c71424352b507fcc2e93ff0e |
| User & Date: | drh 2017-12-06 15:37:44.223 |
Context
|
2017-12-06
| ||
| 16:50 | Reorganize the elements of the "Overview" section of a check-in view, to give more prominence to the "Download" links. ... (check-in: 4290984dd3 user: drh tags: trunk) | |
| 15:37 | Use an HTML5 color chooser dialog in the check-in comment editor. ... (check-in: f8bc3ce8c7 user: drh tags: trunk) | |
| 13:48 | Remove the last bits of in-line javascript from the timelines. ... (check-in: b799891b82 user: drh tags: trunk) | |
Changes
Changes to src/event.c.
| ︙ | ︙ | |||
341 342 343 344 345 346 347 | /* ** WEBPAGE: technoteedit ** WEBPAGE: eventedit ** ** Revise or create a technical note (formerly called an "event"). ** | | | > > > > > > > > > > | | | | | > | | 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 |
/*
** WEBPAGE: technoteedit
** WEBPAGE: eventedit
**
** Revise or create a technical note (formerly called an "event").
**
** Required query parameter:
**
** name=ID Hex hash ID of the technote. If omitted, a new
** tech-note is created.
**
** POST parameters from the "Cancel", "Preview", or "Submit" buttons:
**
** w=TEXT Complete text of the technote.
** t=TEXT Time of the technote on the timeline (ISO 8601)
** c=TEXT Timeline comment
** g=TEXT Tags associated with this technote
** mimetype=TEXT Mimetype for w= text
** newclr Use a background color
** clr=TEXT Background color to use if newclr
*/
void eventedit_page(void){
char *zTag;
int rid = 0;
Blob event;
const char *zId;
int n;
const char *z;
char *zBody = (char*)P("w"); /* Text of the technote */
char *zETime = (char*)P("t"); /* Date this technote appears */
const char *zComment = P("c"); /* Timeline comment */
const char *zTags = P("g"); /* Tags added to this technote */
const char *zClrFlag = ""; /* "checked" for bg color */
const char *zClr; /* Name of the background color */
const char *zMimetype = P("mimetype"); /* Mimetype of zBody */
int isNew = 0;
if( zBody ){
zBody = mprintf("%s", zBody);
}
login_check_credentials();
zId = P("name");
|
| ︙ | ︙ | |||
405 406 407 408 409 410 411 |
/* Figure out the color */
if( rid ){
zClr = db_text("", "SELECT bgcolor FROM event WHERE objid=%d", rid);
}else{
zClr = "";
isNew = 1;
}
| > | | | | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
/* Figure out the color */
if( rid ){
zClr = db_text("", "SELECT bgcolor FROM event WHERE objid=%d", rid);
}else{
zClr = "";
isNew = 1;
}
if( P("newclr") ){
zClr = PD("clr",zClr);
if( zClr[0] ) zClrFlag = " checked";
}
/* If editing an existing event, extract the key fields to use as
** a starting point for the edit.
*/
if( rid
&& (zBody==0 || zETime==0 || zComment==0 || zTags==0 || zMimetype==0)
){
|
| ︙ | ︙ | |||
440 441 442 443 444 445 446 |
);
}
}
zETime = db_text(0, "SELECT coalesce(datetime(%Q),datetime('now'))", zETime);
if( P("submit")!=0 && (zBody!=0 && zComment!=0) ){
login_verify_csrf_secret();
if ( !event_commit_common(rid, zId, zBody, zETime,
| | > | | | | 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 |
);
}
}
zETime = db_text(0, "SELECT coalesce(datetime(%Q),datetime('now'))", zETime);
if( P("submit")!=0 && (zBody!=0 && zComment!=0) ){
login_verify_csrf_secret();
if ( !event_commit_common(rid, zId, zBody, zETime,
zMimetype, zComment, zTags,
zClrFlag[0] ? zClr : 0) ){
style_header("Error");
@ Internal error: Fossil tried to make an invalid artifact for
@ the edited technote.
style_footer();
return;
}
cgi_redirectf("%R/technote?name=%T", zId);
}
if( P("cancel")!=0 ){
cgi_redirectf("%R/technote?name=%T", zId);
return;
}
if( zBody==0 ){
zBody = mprintf("Insert new content here...");
}
if( isNew ){
style_header("New Tech-note %S", zId);
}else{
style_header("Edit Tech-note %S", zId);
}
if( P("preview")!=0 ){
Blob com;
@ <p><b>Timeline comment preview:</b></p>
@ <blockquote>
@ <table border="0">
if( zClrFlag[0] && zClr && zClr[0] ){
@ <tr><td style="background-color: %h(zClr);">
}else{
@ <tr><td>
}
blob_zero(&com);
blob_append(&com, zComment, -1);
wiki_convert(&com, 0, WIKI_INLINE|WIKI_NOBADLINKS);
|
| ︙ | ︙ | |||
507 508 509 510 511 512 513 | @ <td valign="top"> @ <textarea name="c" class="technoteedit" cols="80" @ rows="3" wrap="virtual">%h(zComment)</textarea> @ </td></tr> @ <tr><th align="right" valign="top">Timeline Background Color:</th> @ <td valign="top"> | > | > | | > | > | 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 |
@ <td valign="top">
@ <textarea name="c" class="technoteedit" cols="80"
@ rows="3" wrap="virtual">%h(zComment)</textarea>
@ </td></tr>
@ <tr><th align="right" valign="top">Timeline Background Color:</th>
@ <td valign="top">
@ <input type='checkbox' name='newclr'%s(zClrFlag) />
@ Use custom color: \
@ <input type='color' name='clr' value='%s(zClr[0]?zClr:"#c0f0ff")'>
@ </td></tr>
@ <tr><th align="right" valign="top">Tags:</th>
@ <td valign="top">
@ <input type="text" name="g" size="40" value="%h(zTags)" />
@ </td></tr>
@ <tr><th align="right" valign="top">Markup Style:</th>
@ <td valign="top">
mimetype_option_menu(zMimetype);
@ </td></tr>
@ <tr><th align="right" valign="top">Page Content:</th>
@ <td valign="top">
@ <textarea name="w" class="technoteedit" cols="80"
@ rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
@ </td></tr>
@ <tr><td colspan="2">
@ <input type="submit" name="cancel" value="Cancel" />
@ <input type="submit" name="preview" value="Preview" />
if( P("preview") ){
@ <input type="submit" name="submit" value="Submit" />
}
@ </td></tr></table>
@ </div></form>
style_footer();
}
/*
** Add a new tech note to the repository. The timestamp is
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
1234 1235 1236 1237 1238 1239 1240 |
db_prepare(&q,
"SELECT filename.name, datetime(event.mtime,toLocal()),"
" coalesce(event.ecomment,event.comment),"
" coalesce(event.euser,event.user),"
" b.uuid, mlink.mperm,"
" coalesce((SELECT value FROM tagxref"
| | | 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 |
db_prepare(&q,
"SELECT filename.name, datetime(event.mtime,toLocal()),"
" coalesce(event.ecomment,event.comment),"
" coalesce(event.euser,event.user),"
" b.uuid, mlink.mperm,"
" coalesce((SELECT value FROM tagxref"
" WHERE tagid=%d AND tagtype>0 AND rid=mlink.mid),'trunk'),"
" a.size"
" FROM mlink, filename, event, blob a, blob b"
" WHERE filename.fnid=mlink.fnid"
" AND event.objid=mlink.mid"
" AND a.rid=mlink.fid"
" AND b.rid=mlink.mid"
" AND mlink.fid=%d"
|
| ︙ | ︙ | |||
2175 2176 2177 2178 2179 2180 2181 |
}
}
if( strcmp(zModAction,"approve")==0 ){
moderation_approve(rid);
}
}
zTktTitle = db_table_has_column("repository", "ticket", "title" )
| > | | 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 |
}
}
if( strcmp(zModAction,"approve")==0 ){
moderation_approve(rid);
}
}
zTktTitle = db_table_has_column("repository", "ticket", "title" )
? db_text("(No title)",
"SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
: 0;
style_header("Ticket Change Details");
style_submenu_element("Raw", "%R/artifact/%s", zUuid);
style_submenu_element("History", "%R/tkthistory/%s", zTktName);
style_submenu_element("Page", "%R/tktview/%t", zTktName);
style_submenu_element("Timeline", "%R/tkttimeline/%t", zTktName);
if( P("plaintext") ){
|
| ︙ | ︙ | |||
2318 2319 2320 2321 2322 2323 2324 |
ainfo_page();
}else
{
artifact_page();
}
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 |
ainfo_page();
}else
{
artifact_page();
}
}
/*
** Do a comment comparison.
**
** + Leading and trailing whitespace are ignored.
** + \r\n characters compare equal to \n
**
** Return true if equal and false if not equal.
|
| ︙ | ︙ | |||
2596 2597 2598 2599 2600 2601 2602 |
*/
int is_datetime(const char* zDate){
return db_int(0, "SELECT datetime(%Q) NOT NULL", zDate);
}
/*
** WEBPAGE: ci_edit
| < > > | > > | > > > | | | > > > > > > > > > > > > > | > | | | | | | | | | | < < < > | > > | < > | 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 |
*/
int is_datetime(const char* zDate){
return db_int(0, "SELECT datetime(%Q) NOT NULL", zDate);
}
/*
** WEBPAGE: ci_edit
**
** Edit a check-in. (Check-ins are immutable and do not really change.
** This page really creates supplemental tags that affect the display
** of the check-in.)
**
** Query parmeters:
**
** rid=INTEGER Record ID of the check-in to edit (REQUIRED)
**
** POST parameters after pressing "Perview", "Cancel", or "Apply":
**
** c=TEXT New check-in comment
** u=TEXT New user name
** newclr Apply a background color
** clr=TEXT New background color (only if newclr)
** pclr Propagate new background color (only if newclr)
** dt=TEXT New check-in date/time (ISO8610 format)
** newtag Add a new tag to the check-in
** tagname=TEXT Name of the new tag to be added (only if newtag)
** newbr Put the check-in on a new branch
** brname=TEXT Name of the new branch (only if newbr)
** close Close this check-in
** hide Hide this check-in
** cNNN Cancel tag with tagid=NNN
**
** cancel Cancel the edit. Return to the check-in view
** preview Show a preview of the edited check-in comment
** apply Apply changes
*/
void ci_edit_page(void){
int rid;
const char *zComment; /* Current comment on the check-in */
const char *zNewComment; /* Revised check-in comment */
const char *zUser; /* Current user for the check-in */
const char *zNewUser; /* Revised user */
const char *zDate; /* Current date of the check-in */
const char *zNewDate; /* Revised check-in date */
const char *zNewColorFlag; /* "checked" if "Change color" is checked */
const char *zColor; /* Current background color */
const char *zNewColor; /* Revised background color */
const char *zNewTagFlag; /* "checked" if "Add tag" is checked */
const char *zNewTag; /* Name of the new tag */
const char *zNewBrFlag; /* "checked" if "New branch" is checked */
const char *zNewBranch; /* Name of the new branch */
const char *zCloseFlag; /* "checked" if "Close" is checked */
const char *zHideFlag; /* "checked" if "Hide" is checked */
int fPropagateColor; /* True if color propagates before edit */
int fNewPropagateColor; /* True if color propagates after edit */
int fHasHidden = 0; /* True if hidden tag already set */
int fHasClosed = 0; /* True if closed tag already set */
const char *zChngTime = 0; /* Value of chngtime= query param, if any */
char *zUuid;
Blob comment;
char *zBranchName = 0;
Stmt q;
login_check_credentials();
if( !g.perm.Write ){ login_needed(g.anon.Write); return; }
rid = name_to_typed_rid(P("r"), "ci");
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
zComment = db_text(0, "SELECT coalesce(ecomment,comment)"
" FROM event WHERE objid=%d", rid);
if( zComment==0 ) fossil_redirect_home();
if( P("cancel") ){
cgi_redirectf("%R/ci/%S", zUuid);
}
if( g.perm.Setup ) zChngTime = P("chngtime");
zNewComment = PD("c",zComment);
zUser = db_text(0, "SELECT coalesce(euser,user)"
" FROM event WHERE objid=%d", rid);
if( zUser==0 ) fossil_redirect_home();
zNewUser = PDT("u",zUser);
zDate = db_text(0, "SELECT datetime(mtime)"
" FROM event WHERE objid=%d", rid);
if( zDate==0 ) fossil_redirect_home();
zNewDate = PDT("dt",zDate);
zColor = db_text("", "SELECT bgcolor"
" FROM event WHERE objid=%d", rid);
zNewColor = PDT("clr",zColor);
fPropagateColor = db_int(0, "SELECT tagtype FROM tagxref"
" WHERE rid=%d AND tagid=%d",
rid, TAG_BGCOLOR)==2;
fNewPropagateColor = P("clr")!=0 ? P("pclr")!=0 : fPropagateColor;
zNewColorFlag = P("newclr") ? " checked" : "";
zNewTagFlag = P("newtag") ? " checked" : "";
zNewTag = PDT("tagname","");
zNewBrFlag = P("newbr") ? " checked" : "";
zNewBranch = PDT("brname","");
zCloseFlag = P("close") ? " checked" : "";
zHideFlag = P("hide") ? " checked" : "";
if( P("apply") ){
Blob ctrl;
char *zNow;
login_verify_csrf_secret();
blob_zero(&ctrl);
zNow = date_in_standard_format(zChngTime ? zChngTime : "now");
blob_appendf(&ctrl, "D %s\n", zNow);
init_newtags();
if( zNewColorFlag[0]
&& zNewColor[0]
&& (fPropagateColor!=fNewPropagateColor
|| fossil_strcmp(zColor,zNewColor)!=0)
){
add_color(zNewColor,fNewPropagateColor);
}
if( comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment);
if( fossil_strcmp(zDate,zNewDate)!=0 ) add_date(zNewDate);
if( fossil_strcmp(zUser,zNewUser)!=0 ) add_user(zNewUser);
db_prepare(&q,
"SELECT tag.tagid, tagname FROM tagxref, tag"
" WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid",
rid
|
| ︙ | ︙ | |||
2703 2704 2705 2706 2707 2708 2709 |
}
db_finalize(&q);
if( zHideFlag[0] ) hide_branch();
if( zCloseFlag[0] ) close_leaf(rid);
if( zNewTagFlag[0] && zNewTag[0] ) add_tag(zNewTag);
if( zNewBrFlag[0] && zNewBranch[0] ) change_branch(rid,zNewBranch);
apply_newtags(&ctrl, rid, zUuid);
| | | 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 |
}
db_finalize(&q);
if( zHideFlag[0] ) hide_branch();
if( zCloseFlag[0] ) close_leaf(rid);
if( zNewTagFlag[0] && zNewTag[0] ) add_tag(zNewTag);
if( zNewBrFlag[0] && zNewBranch[0] ) change_branch(rid,zNewBranch);
apply_newtags(&ctrl, rid, zUuid);
cgi_redirectf("%R/ci/%S", zUuid);
}
blob_zero(&comment);
blob_append(&comment, zNewComment, -1);
zUuid[10] = 0;
style_header("Edit Check-in [%s]", zUuid);
/*
** chgcbn/chgbn: Handle change of (checkbox for) branch name in
|
| ︙ | ︙ | |||
2736 2737 2738 2739 2740 2741 2742 |
@ </script>
if( P("preview") ){
Blob suffix;
int nTag = 0;
@ <b>Preview:</b>
@ <blockquote>
@ <table border=0>
| > > | | | 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 |
@ </script>
if( P("preview") ){
Blob suffix;
int nTag = 0;
@ <b>Preview:</b>
@ <blockquote>
@ <table border=0>
if( zNewColorFlag[0] && zNewColor && zNewColor[0] ){
@ <tr><td style="background-color: %h(zNewColor);">
}else if( zColor[0] ){
@ <tr><td style="background-color: %h(zColor);">
}else{
@ <tr><td>
}
@ %!W(blob_str(&comment))
blob_zero(&suffix);
blob_appendf(&suffix, "(user: %h", zNewUser);
db_prepare(&q, "SELECT substr(tagname,5) FROM tagxref, tag"
|
| ︙ | ︙ | |||
2798 2799 2800 2801 2802 2803 2804 |
if( zChngTime ){
@ <tr><th align="right" valign="top">Timestamp of this change:</th>
@ <td valign="top">
@ <input type="text" name="chngtime" size="20" value="%h(zChngTime)" />
@ </td></tr>
}
| | > > > > > | > > > > > | 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 |
if( zChngTime ){
@ <tr><th align="right" valign="top">Timestamp of this change:</th>
@ <td valign="top">
@ <input type="text" name="chngtime" size="20" value="%h(zChngTime)" />
@ </td></tr>
}
@ <tr><th align="right" valign="top">Background Color:</th>
@ <td valign="top">
@ <div><label><input type='checkbox' name='newclr'%s(zNewColorFlag) />
@ Change background color: \
@ <input type='color' name='clr'\
@ value='%s(zNewColor[0]?zNewColor:"#808080")'></label></div>
@ <div><label>
if( fNewPropagateColor ){
@ <input type="checkbox" name="pclr" checked="checked" />
}else{
@ <input type="checkbox" name="pclr" />
}
@ Propagate color to descendants</label></div>
@ </td></tr>
@ <tr><th align="right" valign="top">Tags:</th>
@ <td valign="top">
@ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag) />
@ Add the following new tag name to this check-in:</label>
@ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)"
|
| ︙ | ︙ | |||
2896 2897 2898 2899 2900 2901 2902 |
@ </td></tr>
}
}
if( zBranchName ) fossil_free(zBranchName);
@ <tr><td colspan="2">
| | | > | > | 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 |
@ </td></tr>
}
}
if( zBranchName ) fossil_free(zBranchName);
@ <tr><td colspan="2">
@ <input type="submit" name="cancel" value="Cancel" />
@ <input type="submit" name="preview" value="Preview" />
if( P("preview") ){
@ <input type="submit" name="apply" value="Apply Changes" />
}
@ </td></tr>
@ </table>
@ </div></form>
style_footer();
}
/*
|
| ︙ | ︙ |