Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Put an "Add Wiki" button in the submenu for /timeline displays of branches and tags. Add the "Add Wiki:" line to the overview section of check-in /info pages. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
867fe0ea9664321a224b7543c555e76f |
| User & Date: | drh 2019-01-02 03:08:13.816 |
Context
|
2019-01-02
| ||
| 03:15 | On the /wikiedit screen, do not show the "Apply" button unless the user has first done a preview. ... (check-in: cfe761679c user: drh tags: trunk) | |
| 03:08 | Put an "Add Wiki" button in the submenu for /timeline displays of branches and tags. Add the "Add Wiki:" line to the overview section of check-in /info pages. ... (check-in: 867fe0ea96 user: drh tags: trunk) | |
|
2019-01-01
| ||
| 19:45 | On the /timeline page with the r= or t= query parameters, change the header to report that it is showing only check-ins, since that is all it will show regardless. ... (check-in: 31edaabf2b user: drh tags: trunk) | |
Changes
Changes to src/info.c.
| ︙ | ︙ | |||
689 690 691 692 693 694 695 |
const char *zUser;
const char *zOrigUser;
const char *zComment;
const char *zDate;
const char *zOrigDate;
const char *zBrName;
int okWiki = 0;
| | > | 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
const char *zUser;
const char *zOrigUser;
const char *zComment;
const char *zDate;
const char *zOrigDate;
const char *zBrName;
int okWiki = 0;
Blob wiki_read_links = BLOB_INITIALIZER;
Blob wiki_add_links = BLOB_INITIALIZER;
style_header("Check-in [%S]", zUuid);
login_anonymous_available();
zEUser = db_text(0,
"SELECT value FROM tagxref"
" WHERE tagid=%d AND rid=%d AND tagtype>0",
TAG_USER, rid);
|
| ︙ | ︙ | |||
759 760 761 762 763 764 765 |
" WHERE rid=%d AND tagtype>0 "
" AND tag.tagid=tagxref.tagid "
" AND +tag.tagname GLOB 'sym-*'", rid);
while( db_step(&q2)==SQLITE_ROW ){
const char *zTagName = db_column_text(&q2, 0);
if( fossil_strcmp(zTagName,zBrName)==0 ){
@ | %z(href("%R/timeline?r=%T&unhide",zTagName))%h(zTagName)</a>
| | | > > > | | > > > | 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 |
" WHERE rid=%d AND tagtype>0 "
" AND tag.tagid=tagxref.tagid "
" AND +tag.tagname GLOB 'sym-*'", rid);
while( db_step(&q2)==SQLITE_ROW ){
const char *zTagName = db_column_text(&q2, 0);
if( fossil_strcmp(zTagName,zBrName)==0 ){
@ | %z(href("%R/timeline?r=%T&unhide",zTagName))%h(zTagName)</a>
if( wiki_tagid2("branch",zTagName)!=0 ){
blob_appendf(&wiki_read_links, " | %z%h</a>",
href("%R/wiki?name=branch/%h",zTagName), zTagName);
}else if( g.perm.Write && g.perm.WrWiki ){
blob_appendf(&wiki_add_links, " | %z%h</a>",
href("%R/wikiedit?name=branch/%h",zTagName), zTagName);
}
}else{
@ | %z(href("%R/timeline?t=%T&unhide",zTagName))%h(zTagName)</a>
if( wiki_tagid2("tag",zTagName)!=0 ){
blob_appendf(&wiki_read_links, " | %z%h</a>",
href("%R/wiki?name=tag/%h",zTagName), zTagName);
}else if( g.perm.Write && g.perm.WrWiki ){
blob_appendf(&wiki_add_links, " | %z%h</a>",
href("%R/wikiedit?name=tag/%h",zTagName), zTagName);
}
}
}
db_finalize(&q2);
@ </td></tr>
@ <tr><th>Files:</th>
|
| ︙ | ︙ | |||
819 820 821 822 823 824 825 |
if( zUser==0 || zUser[0]==0 ) zUser = "unknown";
@ <tr><th>Received From:</th>
@ <td>%h(zUser) @ %h(zIpAddr) on %s(zDate)</td></tr>
}
db_finalize(&q2);
}
| | | < < | > | < > > > > > > > > > > | > > > > > > > > | > > | > | 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 |
if( zUser==0 || zUser[0]==0 ) zUser = "unknown";
@ <tr><th>Received From:</th>
@ <td>%h(zUser) @ %h(zIpAddr) on %s(zDate)</td></tr>
}
db_finalize(&q2);
}
/* Only show links to read wiki pages if the users can read wiki
** and if the wiki pages already exist */
if( g.perm.RdWiki
&& ((okWiki = wiki_tagid2("checkin",zUuid))!=0 ||
blob_size(&wiki_read_links)>0)
&& db_get_boolean("wiki-about",1)
){
const char *zLinks = blob_str(&wiki_read_links);
@ <tr><th>Wiki:</th><td>\
if( okWiki ){
@ %z(href("%R/wiki?name=checkin/%s",zUuid))this checkin</a>\
}else if( zLinks[0] ){
zLinks += 3;
}
@ %s(zLinks)</td></tr>
}
/* Only show links to create new wiki pages if the users can write wiki
** and if the wiki pages do not already exist */
if( g.perm.WrWiki
&& g.perm.RdWiki
&& g.perm.Write
&& (blob_size(&wiki_add_links)>0 || !okWiki)
&& db_get_boolean("wiki-about",1)
){
const char *zLinks = blob_str(&wiki_add_links);
@ <tr><th>Add Wiki:</th><td>\
if( !okWiki ){
@ %z(href("%R/wikiedit?name=checkin/%s",zUuid))this checkin</a>\
}else if( zLinks[0] ){
zLinks += 3;
}
@ %s(zLinks)</td></tr>
}
if( g.perm.Hyperlink ){
@ <tr><th>Other Links:</th>
@ <td>
@ %z(href("%R/artifact/%!S",zUuid))manifest</a>
@ | %z(href("%R/ci_tags/%!S",zUuid))tags</a>
if( g.perm.Admin ){
@ | %z(href("%R/mlink?ci=%!S",zUuid))mlink table</a>
}
if( g.anon.Write ){
@ | %z(href("%R/ci_edit?r=%!S",zUuid))edit</a>
}
@ </td>
@ </tr>
}
@ </table>
blob_reset(&wiki_read_links);
blob_reset(&wiki_add_links);
}else{
style_header("Check-in Information");
login_anonymous_available();
}
db_finalize(&q1);
if( !PB("nowiki") ){
wiki_render_associated("checkin", zUuid, 0);
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
2272 2273 2274 2275 2276 2277 2278 |
blob_zero(&sql);
db_prepare(&q, "SELECT * FROM timeline ORDER BY sortby DESC /*scan*/");
if( fossil_islower(desc.aData[0]) ){
desc.aData[0] = fossil_toupper(desc.aData[0]);
}
if( zBrName
&& !PB("nowiki")
| | < > | < | 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 |
blob_zero(&sql);
db_prepare(&q, "SELECT * FROM timeline ORDER BY sortby DESC /*scan*/");
if( fossil_islower(desc.aData[0]) ){
desc.aData[0] = fossil_toupper(desc.aData[0]);
}
if( zBrName
&& !PB("nowiki")
&& wiki_render_associated("branch", zBrName, WIKIASSOC_ALL)
){
@ <div class="section">%b(&desc)</div>
}else
if( zTagName
&& matchStyle==MS_EXACT
&& zBrName==0
&& !PB("nowiki")
&& wiki_render_associated("tag", zTagName, WIKIASSOC_ALL)
){
@ <div class="section">%b(&desc)</div>
} else{
@ <h2>%b(&desc)</h2>
}
blob_reset(&desc);
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
346 347 348 349 350 351 352 353 |
login_check_credentials();
style_header("Wiki Search");
wiki_standard_submenu(W_HELP|W_LIST|W_SANDBOX);
search_screen(SRCH_WIKI, 0);
style_footer();
}
/*
| > > > > > > > < < > | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | > > | | | | > > | | | > | < < > | 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 |
login_check_credentials();
style_header("Wiki Search");
wiki_standard_submenu(W_HELP|W_LIST|W_SANDBOX);
search_screen(SRCH_WIKI, 0);
style_footer();
}
/* Return values from wiki_page_type() */
#define WIKITYPE_UNKNOWN (-1)
#define WIKITYPE_NORMAL 0
#define WIKITYPE_BRANCH 1
#define WIKITYPE_CHECKIN 2
#define WIKITYPE_TAG 3
/*
** Figure out what type of wiki page we are dealing with.
*/
static int wiki_page_type(const char *zPageName){
if( db_get_boolean("wiki-about",1)==0 ){
return WIKITYPE_NORMAL;
}else
if( sqlite3_strglob("checkin/*", zPageName)==0
&& db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
){
return WIKITYPE_CHECKIN;
}else
if( sqlite3_strglob("branch/*", zPageName)==0 ){
return WIKITYPE_BRANCH;
}else
if( sqlite3_strglob("tag/*", zPageName)==0 ){
return WIKITYPE_TAG;
}
return WIKITYPE_NORMAL;
}
/*
** Add an appropriate style_header() for either the /wiki or /wikiedit page
** for zPageName.
*/
static int wiki_page_header(
int eType, /* Page type. -1 for unknown */
const char *zPageName, /* Name of the page */
const char *zExtra /* Extra prefix text on the page header */
){
if( eType<0 ) eType = wiki_page_type(zPageName);
switch( eType ){
case WIKITYPE_NORMAL: {
style_header("%s%s", zExtra, zPageName);
break;
}
case WIKITYPE_CHECKIN: {
zPageName += 8;
style_header("Notes About Checkin %S", zPageName);
style_submenu_element("Checkin Timeline","%R/timeline?f=%s", zPageName);
style_submenu_element("Checkin Info","%R/info/%s", zPageName);
break;
}
case WIKITYPE_BRANCH: {
zPageName += 7;
style_header("Notes About Branch %h", zPageName);
style_submenu_element("Branch Timeline","%R/timeline?r=%t", zPageName);
break;
}
case WIKITYPE_TAG: {
zPageName += 4;
style_header("Notes About Tag %h", zPageName);
style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName);
break;
}
}
return eType;
}
/*
** Wiki pages with special names "branch/...", "checkin/...", and "tag/..."
** requires perm.Write privilege in addition to perm.WrWiki in order
** to write. This function determines whether the extra perm.Write
** is required and available. Return true if writing to the wiki page
|
| ︙ | ︙ | |||
462 463 464 465 466 467 468 |
}
if( g.perm.Hyperlink ){
style_submenu_element("History", "%s/whistory?name=%T",
g.zTop, zPageName);
}
}
style_set_current_page("%T?name=%T", g.zPath, zPageName);
| | | 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
}
if( g.perm.Hyperlink ){
style_submenu_element("History", "%s/whistory?name=%T",
g.zTop, zPageName);
}
}
style_set_current_page("%T?name=%T", g.zPath, zPageName);
wiki_page_header(WIKITYPE_UNKNOWN, zPageName, "");
wiki_standard_submenu(submenuFlags);
if( zBody[0]==0 ){
@ <i>This page has been deleted</i>
}else{
blob_init(&wiki, zBody, -1);
wiki_render_by_mimetype(&wiki, zMimetype);
blob_reset(&wiki);
|
| ︙ | ︙ | |||
544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
const char *zPageName;
int n;
const char *z;
char *zBody = (char*)P("w");
const char *zMimetype = wiki_filter_mimetypes(P("mimetype"));
int isWysiwyg = P("wysiwyg")!=0;
int goodCaptcha = 1;
if( P("edit-wysiwyg")!=0 ){ isWysiwyg = 1; zBody = 0; }
if( P("edit-markup")!=0 ){ isWysiwyg = 0; zBody = 0; }
if( zBody ){
if( isWysiwyg ){
Blob body;
blob_zero(&body);
| > | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
const char *zPageName;
int n;
const char *z;
char *zBody = (char*)P("w");
const char *zMimetype = wiki_filter_mimetypes(P("mimetype"));
int isWysiwyg = P("wysiwyg")!=0;
int goodCaptcha = 1;
int eType = WIKITYPE_UNKNOWN;
if( P("edit-wysiwyg")!=0 ){ isWysiwyg = 1; zBody = 0; }
if( P("edit-markup")!=0 ){ isWysiwyg = 0; zBody = 0; }
if( zBody ){
if( isWysiwyg ){
Blob body;
blob_zero(&body);
|
| ︙ | ︙ | |||
632 633 634 635 636 637 638 |
cgi_redirectf("wiki?name=%T", zPageName);
}
if( P("cancel")!=0 ){
cgi_redirectf("wiki?name=%T", zPageName);
return;
}
if( zBody==0 ){
| | | | > > > > > > > > > > > > > > > > > > > | | > > | 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 |
cgi_redirectf("wiki?name=%T", zPageName);
}
if( P("cancel")!=0 ){
cgi_redirectf("wiki?name=%T", zPageName);
return;
}
if( zBody==0 ){
zBody = mprintf("");
}
style_set_current_page("%T?name=%T", g.zPath, zPageName);
eType = wiki_page_header(WIKITYPE_UNKNOWN, zPageName, "Edit: ");
if( rid && !isSandbox && g.perm.ApndWiki ){
if( g.perm.Attach ){
style_submenu_element("Attach",
"%s/attachadd?page=%T&from=%s/wiki%%3fname=%T",
g.zTop, zPageName, g.zTop, zPageName);
}
style_submenu_element("Append", "%s/wikiappend?name=%T&mimetype=%s",
g.zTop, zPageName, zMimetype);
}
if( !goodCaptcha ){
@ <p class="generalError">Error: Incorrect security code.</p>
}
blob_zero(&wiki);
blob_append(&wiki, zBody, -1);
if( P("preview")!=0 && zBody[0] ){
@ Preview:<hr />
wiki_render_by_mimetype(&wiki, zMimetype);
@ <hr />
blob_reset(&wiki);
}
for(n=2, z=zBody; z[0]; z++){
if( z[0]=='\n' ) n++;
}
if( n<20 ) n = 20;
if( n>30 ) n = 30;
if( !isWysiwyg ){
/* Traditional markup-only editing */
char *zPlaceholder = 0;
switch( eType ){
case WIKITYPE_NORMAL: {
zPlaceholder = mprintf("Enter text for wiki page %s", zPageName);
break;
}
case WIKITYPE_BRANCH: {
zPlaceholder = mprintf("Enter notes about branch %s", zPageName+7);
break;
}
case WIKITYPE_CHECKIN: {
zPlaceholder = mprintf("Enter notes about check-in %.20s", zPageName+8);
break;
}
case WIKITYPE_TAG: {
zPlaceholder = mprintf("Enter notes about tag %s", zPageName+4);
break;
}
}
form_begin(0, "%R/wikiedit");
@ <div>Markup style:
mimetype_option_menu(zMimetype);
@ <br /><textarea name="w" class="wikiedit" cols="80" \
@ rows="%d(n)" wrap="virtual" placeholder="%h(zPlaceholder)">\
@ %h(zBody)</textarea>
@ <br />
fossil_free(zPlaceholder);
if( db_get_boolean("wysiwyg-wiki", 0) ){
@ <input type="submit" name="edit-wysiwyg" value="Wysiwyg Editor"
@ onclick='return confirm("Switching to WYSIWYG-mode\nwill erase your markup\nedits. Continue?")' />
}
@ <input type="submit" name="preview" value="Preview Your Changes" />
}else{
/* Wysiwyg editing */
|
| ︙ | ︙ | |||
1553 1554 1555 1556 1557 1558 1559 | } /* ** Allowed flags for wiki_render_associated */ #if INTERFACE #define WIKIASSOC_FULL_TITLE 0x00001 /* Full title */ | | > > | | | | 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 |
}
/*
** Allowed flags for wiki_render_associated
*/
#if INTERFACE
#define WIKIASSOC_FULL_TITLE 0x00001 /* Full title */
#define WIKIASSOC_MENU_READ 0x00002 /* Add submenu link to read wiki */
#define WIKIASSOC_MENU_WRITE 0x00004 /* Add submenu link to add wiki */
#define WIKIASSOC_ALL 0x00007 /* All of the above */
#endif
/*
** Show the default Section label for an associated wiki page.
*/
static void wiki_section_label(
const char *zPrefix, /* "branch", "tag", or "checkin" */
const char *zName, /* Name of the object */
unsigned int mFlags /* Zero or more WIKIASSOC_* flags */
){
if( (mFlags & WIKIASSOC_FULL_TITLE)==0 ){
@ <div class="section">About</div>
}else if( zPrefix[0]=='c' ){ /* checkin/... */
@ <div class="section">About checkin %.20h(zName)</div>
}else{
@ <div class="section">About %s(zPrefix) %h(zName)</div>
}
}
/*
** Add an "Wiki" button in a submenu that links to the read-wiki page.
*/
static void wiki_submenu_to_read_wiki(
const char *zPrefix, /* "branch", "tag", or "checkin" */
const char *zName, /* Name of the object */
unsigned int mFlags /* Zero or more WIKIASSOC_* flags */
){
if( g.perm.RdWiki && (mFlags & WIKIASSOC_MENU_READ)!=0 ){
style_submenu_element("Wiki", "%R/wiki?name=%s/%t", zPrefix, zName);
}
}
/*
** Check to see if there exists a wiki page with a name zPrefix/zName.
** If there is, then render a <div class='section'>..</div> and
|
| ︙ | ︙ | |||
1607 1608 1609 1610 1611 1612 1613 |
if( !db_get_boolean("wiki-about",1) ) return 0;
rid = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname='wiki-%q/%q')"
" ORDER BY mtime DESC LIMIT 1",
zPrefix, zName
);
| | > > > > > | | | | 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 |
if( !db_get_boolean("wiki-about",1) ) return 0;
rid = db_int(0,
"SELECT rid FROM tagxref"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname='wiki-%q/%q')"
" ORDER BY mtime DESC LIMIT 1",
zPrefix, zName
);
if( rid==0 ){
if( g.perm.WrWiki && g.perm.Write && (mFlags & WIKIASSOC_MENU_WRITE)!=0 ){
style_submenu_element("Add Wiki", "%R/wikiedit?name=%s/%t",
zPrefix, zName);
}
}
pWiki = manifest_get(rid, CFTYPE_WIKI, 0);
if( pWiki==0 ) return 0;
if( fossil_strcmp(pWiki->zMimetype, "text/x-markdown")==0 ){
Blob tail = BLOB_INITIALIZER;
Blob title = BLOB_INITIALIZER;
Blob markdown;
blob_init(&markdown, pWiki->zWiki, -1);
markdown_to_html(&markdown, &title, &tail);
if( blob_size(&title) ){
@ <div class="section">%h(blob_str(&title))</div>
}else{
wiki_section_label(zPrefix, zName, mFlags);
}
wiki_submenu_to_read_wiki(zPrefix, zName, mFlags);
convert_href_and_output(&tail);
blob_reset(&tail);
blob_reset(&title);
blob_reset(&markdown);
}else if( fossil_strcmp(pWiki->zMimetype, "text/plain")==0 ){
wiki_section_label(zPrefix, zName, mFlags);
wiki_submenu_to_read_wiki(zPrefix, zName, mFlags);
@ <pre>
@ %h(pWiki->zWiki)
@ </pre>
}else{
Blob tail = BLOB_INITIALIZER;
Blob title = BLOB_INITIALIZER;
Blob wiki;
Blob *pBody;
blob_init(&wiki, pWiki->zWiki, -1);
if( wiki_find_title(&wiki, &title, &tail) ){
@ <div class="section">%h(blob_str(&title))</div>
pBody = &tail;
}else{
wiki_section_label(zPrefix, zName, mFlags);
pBody = &wiki;
}
wiki_submenu_to_read_wiki(zPrefix, zName, mFlags);
@ <div class="wiki">
wiki_convert(pBody, 0, WIKI_BUTTONS);
@ </div>
blob_reset(&tail);
blob_reset(&title);
blob_reset(&wiki);
}
manifest_destroy(pWiki);
return 1;
}
|