Fossil SCM

Better titles for the /wiki page for associated wiki.

drh 2018-12-31 00:00 UTC describe-objects-using-wiki
Commit 57443202ae0ef2353a3682d79c1b4334b206ab302b1cf12c4da02c3d4d12505d
2 files changed +4 -2 +53 -30
+4 -2
--- src/timeline.c
+++ src/timeline.c
@@ -2272,18 +2272,20 @@
22722272
if( fossil_islower(desc.aData[0]) ){
22732273
desc.aData[0] = fossil_toupper(desc.aData[0]);
22742274
}
22752275
if( zBrName
22762276
&& !PB("nowiki")
2277
- && wiki_render_associated("branch", zBrName, WIKIASSOC_FULL_TITLE)
2277
+ && wiki_render_associated("branch", zBrName,
2278
+ WIKIASSOC_FULL_TITLE|WIKIASSOC_MENU)
22782279
){
22792280
@ <div class="section">%b(&desc)</div>
22802281
}else
22812282
if( zTagName
22822283
&& matchStyle==MS_EXACT
22832284
&& !PB("nowiki")
2284
- && wiki_render_associated("tag", zTagName, WIKIASSOC_FULL_TITLE)
2285
+ && wiki_render_associated("tag", zTagName,
2286
+ WIKIASSOC_FULL_TITLE|WIKIASSOC_MENU)
22852287
){
22862288
@ <div class="section">%b(&desc)</div>
22872289
} else{
22882290
@ <h2>%b(&desc)</h2>
22892291
}
22902292
--- src/timeline.c
+++ src/timeline.c
@@ -2272,18 +2272,20 @@
2272 if( fossil_islower(desc.aData[0]) ){
2273 desc.aData[0] = fossil_toupper(desc.aData[0]);
2274 }
2275 if( zBrName
2276 && !PB("nowiki")
2277 && wiki_render_associated("branch", zBrName, WIKIASSOC_FULL_TITLE)
 
2278 ){
2279 @ <div class="section">%b(&desc)</div>
2280 }else
2281 if( zTagName
2282 && matchStyle==MS_EXACT
2283 && !PB("nowiki")
2284 && wiki_render_associated("tag", zTagName, WIKIASSOC_FULL_TITLE)
 
2285 ){
2286 @ <div class="section">%b(&desc)</div>
2287 } else{
2288 @ <h2>%b(&desc)</h2>
2289 }
2290
--- src/timeline.c
+++ src/timeline.c
@@ -2272,18 +2272,20 @@
2272 if( fossil_islower(desc.aData[0]) ){
2273 desc.aData[0] = fossil_toupper(desc.aData[0]);
2274 }
2275 if( zBrName
2276 && !PB("nowiki")
2277 && wiki_render_associated("branch", zBrName,
2278 WIKIASSOC_FULL_TITLE|WIKIASSOC_MENU)
2279 ){
2280 @ <div class="section">%b(&desc)</div>
2281 }else
2282 if( zTagName
2283 && matchStyle==MS_EXACT
2284 && !PB("nowiki")
2285 && wiki_render_associated("tag", zTagName,
2286 WIKIASSOC_FULL_TITLE|WIKIASSOC_MENU)
2287 ){
2288 @ <div class="section">%b(&desc)</div>
2289 } else{
2290 @ <h2>%b(&desc)</h2>
2291 }
2292
+53 -30
--- src/wiki.c
+++ src/wiki.c
@@ -343,10 +343,38 @@
343343
style_header("Wiki Search");
344344
wiki_standard_submenu(W_HELP|W_LIST|W_SANDBOX);
345345
search_screen(SRCH_WIKI, 0);
346346
style_footer();
347347
}
348
+
349
+/*
350
+** Add an appropriate style_header() for either the /wiki or /wikiedit page
351
+** for zPageName.
352
+*/
353
+static void wiki_page_header(const char *zPageName, const char *zExtra){
354
+ if( db_get_boolean("wiki-about",1)==0 ){
355
+ style_header("%s%s", zExtra, zPageName);
356
+ }else
357
+ if( sqlite3_strglob("checkin/*", zPageName)==0
358
+ && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
359
+ ){
360
+ style_header("Notes About Checkin %S", zPageName + 8);
361
+ style_submenu_element("Checkin Timeline","%R/timeline?f=%s",zPageName + 8);
362
+ style_submenu_element("Checkin Info","%R/info/%s",zPageName + 8);
363
+ }else
364
+ if( sqlite3_strglob("branch/*", zPageName)==0 ){
365
+ style_header("Notes About Branch %h", zPageName + 7);
366
+ style_submenu_element("Branch Timeline","%R/timeline?r=%t",zPageName + 7);
367
+ }else
368
+ if( sqlite3_strglob("tag/*", zPageName)==0 ){
369
+ style_header("Notes About Tag %h", zPageName + 4);
370
+ style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName + 4);
371
+ }
372
+ else{
373
+ style_header("%s%s", zExtra, zPageName);
374
+ }
375
+}
348376
349377
/*
350378
** WEBPAGE: wiki
351379
** URL: /wiki?name=PAGENAME
352380
*/
@@ -410,11 +438,11 @@
410438
style_submenu_element("History", "%s/whistory?name=%T",
411439
g.zTop, zPageName);
412440
}
413441
}
414442
style_set_current_page("%T?name=%T", g.zPath, zPageName);
415
- style_header("%s", zPageName);
443
+ wiki_page_header(zPageName, "");
416444
wiki_standard_submenu(submenuFlags);
417445
if( zBody[0]==0 ){
418446
@ <i>This page has been deleted</i>
419447
}else{
420448
blob_init(&wiki, zBody, -1);
@@ -579,33 +607,11 @@
579607
}
580608
if( zBody==0 ){
581609
zBody = mprintf("<i>Empty Page</i>");
582610
}
583611
style_set_current_page("%T?name=%T", g.zPath, zPageName);
584
-
585
- if( db_get_boolean("wiki-about",1)==0 ){
586
- style_header("Edit: %s", zPageName);
587
- }else
588
- if( sqlite3_strglob("checkin/*", zPageName)==0
589
- && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
590
- ){
591
- style_header("Notes About Checkin %S", zPageName + 8);
592
- style_submenu_element("Checkin Timeline","%R/timeline?f=%s",zPageName + 8);
593
- style_submenu_element("Checkin Info","%R/info/%s",zPageName + 8);
594
- }else
595
- if( sqlite3_strglob("branch/*", zPageName)==0 ){
596
- style_header("Notes About Branch %h", zPageName + 7);
597
- style_submenu_element("Branch Timeline","%R/timeline?r=%t",zPageName + 7);
598
- }else
599
- if( sqlite3_strglob("tag/*", zPageName)==0 ){
600
- style_header("Notes About Tag %h", zPageName + 4);
601
- style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName + 4);
602
- }
603
- else{
604
- style_header("Edit: %s", zPageName);
605
- }
606
-
612
+ wiki_page_header(zPageName, "Edit: ");
607613
if( rid && !isSandbox && g.perm.ApndWiki ){
608614
if( g.perm.Attach ){
609615
style_submenu_element("Attach",
610616
"%s/attachadd?page=%T&from=%s/wiki%%3fname=%T",
611617
g.zTop, zPageName, g.zTop, zPageName);
@@ -1519,10 +1525,11 @@
15191525
/*
15201526
** Allowed flags for wiki_render_associated
15211527
*/
15221528
#if INTERFACE
15231529
#define WIKIASSOC_FULL_TITLE 0x00001 /* Full title */
1530
+#define WIKIASSOC_MENU 0x00002 /* Add a submenu to the About section */
15241531
#endif
15251532
15261533
/*
15271534
** Show the default Section label for an associated wiki page.
15281535
*/
@@ -1537,10 +1544,23 @@
15371544
@ <div class="section">About checkin %.20h(zName)</div>
15381545
}else{
15391546
@ <div class="section">About %s(zPrefix) %h(zName)</div>
15401547
}
15411548
}
1549
+
1550
+/*
1551
+** Add an "Wiki" button in a submenu for a Wiki page.
1552
+*/
1553
+static void wiki_section_menu(
1554
+ const char *zPrefix, /* "branch", "tag", or "checkin" */
1555
+ const char *zName, /* Name of the object */
1556
+ unsigned int mFlags /* Zero or more WIKIASSOC_* flags */
1557
+){
1558
+ if( g.perm.WrWiki && (mFlags & WIKIASSOC_MENU)!=0 ){
1559
+ style_submenu_element("Wiki", "%R/wiki?name=%s/%t", zPrefix, zName);
1560
+ }
1561
+}
15421562
15431563
/*
15441564
** Check to see if there exists a wiki page with a name zPrefix/zName.
15451565
** If there is, then render a <div class='section'>..</div> and
15461566
** return true.
@@ -1573,37 +1593,40 @@
15731593
if( blob_size(&title) ){
15741594
@ <div class="section">%h(blob_str(&title))</div>
15751595
}else{
15761596
wiki_section_label(zPrefix, zName, mFlags);
15771597
}
1598
+ wiki_section_menu(zPrefix, zName, mFlags);
15781599
convert_href_and_output(&tail);
15791600
blob_reset(&tail);
15801601
blob_reset(&title);
15811602
blob_reset(&markdown);
15821603
}else if( fossil_strcmp(pWiki->zMimetype, "text/plain")==0 ){
15831604
wiki_section_label(zPrefix, zName, mFlags);
1605
+ wiki_section_menu(zPrefix, zName, mFlags);
15841606
@ <pre>
15851607
@ %h(pWiki->zWiki)
15861608
@ </pre>
15871609
}else{
15881610
Blob tail = BLOB_INITIALIZER;
15891611
Blob title = BLOB_INITIALIZER;
15901612
Blob wiki;
1613
+ Blob *pBody;
15911614
blob_init(&wiki, pWiki->zWiki, -1);
15921615
if( wiki_find_title(&wiki, &title, &tail) ){
15931616
@ <div class="section">%h(blob_str(&title))</div>
1594
- @ <div class="wiki">
1595
- wiki_convert(&tail, 0, WIKI_BUTTONS);
1596
- @ </div>
1617
+ pBody = &tail;
15971618
}else{
15981619
wiki_section_label(zPrefix, zName, mFlags);
1599
- @ <div class="wiki">
1600
- wiki_convert(&wiki, 0, WIKI_BUTTONS);
1601
- @ </div>
1620
+ pBody = &wiki;
16021621
}
1622
+ wiki_section_menu(zPrefix, zName, mFlags);
1623
+ @ <div class="wiki">
1624
+ wiki_convert(pBody, 0, WIKI_BUTTONS);
1625
+ @ </div>
16031626
blob_reset(&tail);
16041627
blob_reset(&title);
16051628
blob_reset(&wiki);
16061629
}
16071630
manifest_destroy(pWiki);
16081631
return 1;
16091632
}
16101633
--- src/wiki.c
+++ src/wiki.c
@@ -343,10 +343,38 @@
343 style_header("Wiki Search");
344 wiki_standard_submenu(W_HELP|W_LIST|W_SANDBOX);
345 search_screen(SRCH_WIKI, 0);
346 style_footer();
347 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
348
349 /*
350 ** WEBPAGE: wiki
351 ** URL: /wiki?name=PAGENAME
352 */
@@ -410,11 +438,11 @@
410 style_submenu_element("History", "%s/whistory?name=%T",
411 g.zTop, zPageName);
412 }
413 }
414 style_set_current_page("%T?name=%T", g.zPath, zPageName);
415 style_header("%s", zPageName);
416 wiki_standard_submenu(submenuFlags);
417 if( zBody[0]==0 ){
418 @ <i>This page has been deleted</i>
419 }else{
420 blob_init(&wiki, zBody, -1);
@@ -579,33 +607,11 @@
579 }
580 if( zBody==0 ){
581 zBody = mprintf("<i>Empty Page</i>");
582 }
583 style_set_current_page("%T?name=%T", g.zPath, zPageName);
584
585 if( db_get_boolean("wiki-about",1)==0 ){
586 style_header("Edit: %s", zPageName);
587 }else
588 if( sqlite3_strglob("checkin/*", zPageName)==0
589 && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
590 ){
591 style_header("Notes About Checkin %S", zPageName + 8);
592 style_submenu_element("Checkin Timeline","%R/timeline?f=%s",zPageName + 8);
593 style_submenu_element("Checkin Info","%R/info/%s",zPageName + 8);
594 }else
595 if( sqlite3_strglob("branch/*", zPageName)==0 ){
596 style_header("Notes About Branch %h", zPageName + 7);
597 style_submenu_element("Branch Timeline","%R/timeline?r=%t",zPageName + 7);
598 }else
599 if( sqlite3_strglob("tag/*", zPageName)==0 ){
600 style_header("Notes About Tag %h", zPageName + 4);
601 style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName + 4);
602 }
603 else{
604 style_header("Edit: %s", zPageName);
605 }
606
607 if( rid && !isSandbox && g.perm.ApndWiki ){
608 if( g.perm.Attach ){
609 style_submenu_element("Attach",
610 "%s/attachadd?page=%T&from=%s/wiki%%3fname=%T",
611 g.zTop, zPageName, g.zTop, zPageName);
@@ -1519,10 +1525,11 @@
1519 /*
1520 ** Allowed flags for wiki_render_associated
1521 */
1522 #if INTERFACE
1523 #define WIKIASSOC_FULL_TITLE 0x00001 /* Full title */
 
1524 #endif
1525
1526 /*
1527 ** Show the default Section label for an associated wiki page.
1528 */
@@ -1537,10 +1544,23 @@
1537 @ <div class="section">About checkin %.20h(zName)</div>
1538 }else{
1539 @ <div class="section">About %s(zPrefix) %h(zName)</div>
1540 }
1541 }
 
 
 
 
 
 
 
 
 
 
 
 
 
1542
1543 /*
1544 ** Check to see if there exists a wiki page with a name zPrefix/zName.
1545 ** If there is, then render a <div class='section'>..</div> and
1546 ** return true.
@@ -1573,37 +1593,40 @@
1573 if( blob_size(&title) ){
1574 @ <div class="section">%h(blob_str(&title))</div>
1575 }else{
1576 wiki_section_label(zPrefix, zName, mFlags);
1577 }
 
1578 convert_href_and_output(&tail);
1579 blob_reset(&tail);
1580 blob_reset(&title);
1581 blob_reset(&markdown);
1582 }else if( fossil_strcmp(pWiki->zMimetype, "text/plain")==0 ){
1583 wiki_section_label(zPrefix, zName, mFlags);
 
1584 @ <pre>
1585 @ %h(pWiki->zWiki)
1586 @ </pre>
1587 }else{
1588 Blob tail = BLOB_INITIALIZER;
1589 Blob title = BLOB_INITIALIZER;
1590 Blob wiki;
 
1591 blob_init(&wiki, pWiki->zWiki, -1);
1592 if( wiki_find_title(&wiki, &title, &tail) ){
1593 @ <div class="section">%h(blob_str(&title))</div>
1594 @ <div class="wiki">
1595 wiki_convert(&tail, 0, WIKI_BUTTONS);
1596 @ </div>
1597 }else{
1598 wiki_section_label(zPrefix, zName, mFlags);
1599 @ <div class="wiki">
1600 wiki_convert(&wiki, 0, WIKI_BUTTONS);
1601 @ </div>
1602 }
 
 
 
 
1603 blob_reset(&tail);
1604 blob_reset(&title);
1605 blob_reset(&wiki);
1606 }
1607 manifest_destroy(pWiki);
1608 return 1;
1609 }
1610
--- src/wiki.c
+++ src/wiki.c
@@ -343,10 +343,38 @@
343 style_header("Wiki Search");
344 wiki_standard_submenu(W_HELP|W_LIST|W_SANDBOX);
345 search_screen(SRCH_WIKI, 0);
346 style_footer();
347 }
348
349 /*
350 ** Add an appropriate style_header() for either the /wiki or /wikiedit page
351 ** for zPageName.
352 */
353 static void wiki_page_header(const char *zPageName, const char *zExtra){
354 if( db_get_boolean("wiki-about",1)==0 ){
355 style_header("%s%s", zExtra, zPageName);
356 }else
357 if( sqlite3_strglob("checkin/*", zPageName)==0
358 && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
359 ){
360 style_header("Notes About Checkin %S", zPageName + 8);
361 style_submenu_element("Checkin Timeline","%R/timeline?f=%s",zPageName + 8);
362 style_submenu_element("Checkin Info","%R/info/%s",zPageName + 8);
363 }else
364 if( sqlite3_strglob("branch/*", zPageName)==0 ){
365 style_header("Notes About Branch %h", zPageName + 7);
366 style_submenu_element("Branch Timeline","%R/timeline?r=%t",zPageName + 7);
367 }else
368 if( sqlite3_strglob("tag/*", zPageName)==0 ){
369 style_header("Notes About Tag %h", zPageName + 4);
370 style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName + 4);
371 }
372 else{
373 style_header("%s%s", zExtra, zPageName);
374 }
375 }
376
377 /*
378 ** WEBPAGE: wiki
379 ** URL: /wiki?name=PAGENAME
380 */
@@ -410,11 +438,11 @@
438 style_submenu_element("History", "%s/whistory?name=%T",
439 g.zTop, zPageName);
440 }
441 }
442 style_set_current_page("%T?name=%T", g.zPath, zPageName);
443 wiki_page_header(zPageName, "");
444 wiki_standard_submenu(submenuFlags);
445 if( zBody[0]==0 ){
446 @ <i>This page has been deleted</i>
447 }else{
448 blob_init(&wiki, zBody, -1);
@@ -579,33 +607,11 @@
607 }
608 if( zBody==0 ){
609 zBody = mprintf("<i>Empty Page</i>");
610 }
611 style_set_current_page("%T?name=%T", g.zPath, zPageName);
612 wiki_page_header(zPageName, "Edit: ");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
613 if( rid && !isSandbox && g.perm.ApndWiki ){
614 if( g.perm.Attach ){
615 style_submenu_element("Attach",
616 "%s/attachadd?page=%T&from=%s/wiki%%3fname=%T",
617 g.zTop, zPageName, g.zTop, zPageName);
@@ -1519,10 +1525,11 @@
1525 /*
1526 ** Allowed flags for wiki_render_associated
1527 */
1528 #if INTERFACE
1529 #define WIKIASSOC_FULL_TITLE 0x00001 /* Full title */
1530 #define WIKIASSOC_MENU 0x00002 /* Add a submenu to the About section */
1531 #endif
1532
1533 /*
1534 ** Show the default Section label for an associated wiki page.
1535 */
@@ -1537,10 +1544,23 @@
1544 @ <div class="section">About checkin %.20h(zName)</div>
1545 }else{
1546 @ <div class="section">About %s(zPrefix) %h(zName)</div>
1547 }
1548 }
1549
1550 /*
1551 ** Add an "Wiki" button in a submenu for a Wiki page.
1552 */
1553 static void wiki_section_menu(
1554 const char *zPrefix, /* "branch", "tag", or "checkin" */
1555 const char *zName, /* Name of the object */
1556 unsigned int mFlags /* Zero or more WIKIASSOC_* flags */
1557 ){
1558 if( g.perm.WrWiki && (mFlags & WIKIASSOC_MENU)!=0 ){
1559 style_submenu_element("Wiki", "%R/wiki?name=%s/%t", zPrefix, zName);
1560 }
1561 }
1562
1563 /*
1564 ** Check to see if there exists a wiki page with a name zPrefix/zName.
1565 ** If there is, then render a <div class='section'>..</div> and
1566 ** return true.
@@ -1573,37 +1593,40 @@
1593 if( blob_size(&title) ){
1594 @ <div class="section">%h(blob_str(&title))</div>
1595 }else{
1596 wiki_section_label(zPrefix, zName, mFlags);
1597 }
1598 wiki_section_menu(zPrefix, zName, mFlags);
1599 convert_href_and_output(&tail);
1600 blob_reset(&tail);
1601 blob_reset(&title);
1602 blob_reset(&markdown);
1603 }else if( fossil_strcmp(pWiki->zMimetype, "text/plain")==0 ){
1604 wiki_section_label(zPrefix, zName, mFlags);
1605 wiki_section_menu(zPrefix, zName, mFlags);
1606 @ <pre>
1607 @ %h(pWiki->zWiki)
1608 @ </pre>
1609 }else{
1610 Blob tail = BLOB_INITIALIZER;
1611 Blob title = BLOB_INITIALIZER;
1612 Blob wiki;
1613 Blob *pBody;
1614 blob_init(&wiki, pWiki->zWiki, -1);
1615 if( wiki_find_title(&wiki, &title, &tail) ){
1616 @ <div class="section">%h(blob_str(&title))</div>
1617 pBody = &tail;
 
 
1618 }else{
1619 wiki_section_label(zPrefix, zName, mFlags);
1620 pBody = &wiki;
 
 
1621 }
1622 wiki_section_menu(zPrefix, zName, mFlags);
1623 @ <div class="wiki">
1624 wiki_convert(pBody, 0, WIKI_BUTTONS);
1625 @ </div>
1626 blob_reset(&tail);
1627 blob_reset(&title);
1628 blob_reset(&wiki);
1629 }
1630 manifest_destroy(pWiki);
1631 return 1;
1632 }
1633

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button