Fossil SCM

Begin adding the ability to use specially-named wiki pages to supplemental information about branches, tags, and/or checkins.

drh 2018-12-30 20:30 UTC trunk
Commit dcf93d034143f49ef848cbae3abb5e2595c761f9f6a648c44df8444c15810835
+1 -1
--- src/doc.c
+++ src/doc.c
@@ -510,11 +510,11 @@
510510
** action="$ROOT/
511511
**
512512
** Convert $ROOT to the root URI of the repository. Allow ' in place of "
513513
** and any case for href or action.
514514
*/
515
-static void convert_href_and_output(Blob *pIn){
515
+void convert_href_and_output(Blob *pIn){
516516
int i, base;
517517
int n = blob_size(pIn);
518518
char *z = blob_buffer(pIn);
519519
for(base=0, i=7; i<n; i++){
520520
if( z[i]=='$'
521521
--- src/doc.c
+++ src/doc.c
@@ -510,11 +510,11 @@
510 ** action="$ROOT/
511 **
512 ** Convert $ROOT to the root URI of the repository. Allow ' in place of "
513 ** and any case for href or action.
514 */
515 static void convert_href_and_output(Blob *pIn){
516 int i, base;
517 int n = blob_size(pIn);
518 char *z = blob_buffer(pIn);
519 for(base=0, i=7; i<n; i++){
520 if( z[i]=='$'
521
--- src/doc.c
+++ src/doc.c
@@ -510,11 +510,11 @@
510 ** action="$ROOT/
511 **
512 ** Convert $ROOT to the root URI of the repository. Allow ' in place of "
513 ** and any case for href or action.
514 */
515 void convert_href_and_output(Blob *pIn){
516 int i, base;
517 int n = blob_size(pIn);
518 char *z = blob_buffer(pIn);
519 for(base=0, i=7; i<n; i++){
520 if( z[i]=='$'
521
+14
--- src/setup.c
+++ src/setup.c
@@ -941,10 +941,24 @@
941941
style_header("Wiki Configuration");
942942
db_begin_transaction();
943943
@ <form action="%s(g.zTop)/setup_config" method="post"><div>
944944
login_insert_csrf_secret();
945945
@ <input type="submit" name="submit" value="Apply Changes" /></p>
946
+ @ <hr />
947
+ onoff_attribute("Associate Wiki Pages With Branches, Tags, or Checkins",
948
+ "wiki-about", "wiki-about", 1, 0);
949
+ @ <p>
950
+ @ Associate wiki pages with branches, tags, or checkins, based on
951
+ @ the wiki page name. Wiki pages that begin with "branch/", "checkin/"
952
+ @ or "tag/" and which continue with the name of an existing branch, checkin
953
+ @ or tag are treated specially when this feature is enabled.
954
+ @ <ul>
955
+ @ <li> <b>branch/</b><i>branch-name</i>
956
+ @ <li> <b>checkin/</b><i>full-checkin-hash</i>
957
+ @ <li> <b>tag/</b><i>tag-name</i>
958
+ @ </ul>
959
+ @ (Property: "wiki-about")</p>
946960
@ <hr />
947961
onoff_attribute("Enable WYSIWYG Wiki Editing",
948962
"wysiwyg-wiki", "wysiwyg-wiki", 0, 0);
949963
@ <p>Enable what-you-see-is-what-you-get (WYSIWYG) editing of wiki pages.
950964
@ The WYSIWYG editor generates HTML instead of markup, which makes
951965
--- src/setup.c
+++ src/setup.c
@@ -941,10 +941,24 @@
941 style_header("Wiki Configuration");
942 db_begin_transaction();
943 @ <form action="%s(g.zTop)/setup_config" method="post"><div>
944 login_insert_csrf_secret();
945 @ <input type="submit" name="submit" value="Apply Changes" /></p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
946 @ <hr />
947 onoff_attribute("Enable WYSIWYG Wiki Editing",
948 "wysiwyg-wiki", "wysiwyg-wiki", 0, 0);
949 @ <p>Enable what-you-see-is-what-you-get (WYSIWYG) editing of wiki pages.
950 @ The WYSIWYG editor generates HTML instead of markup, which makes
951
--- src/setup.c
+++ src/setup.c
@@ -941,10 +941,24 @@
941 style_header("Wiki Configuration");
942 db_begin_transaction();
943 @ <form action="%s(g.zTop)/setup_config" method="post"><div>
944 login_insert_csrf_secret();
945 @ <input type="submit" name="submit" value="Apply Changes" /></p>
946 @ <hr />
947 onoff_attribute("Associate Wiki Pages With Branches, Tags, or Checkins",
948 "wiki-about", "wiki-about", 1, 0);
949 @ <p>
950 @ Associate wiki pages with branches, tags, or checkins, based on
951 @ the wiki page name. Wiki pages that begin with "branch/", "checkin/"
952 @ or "tag/" and which continue with the name of an existing branch, checkin
953 @ or tag are treated specially when this feature is enabled.
954 @ <ul>
955 @ <li> <b>branch/</b><i>branch-name</i>
956 @ <li> <b>checkin/</b><i>full-checkin-hash</i>
957 @ <li> <b>tag/</b><i>tag-name</i>
958 @ </ul>
959 @ (Property: "wiki-about")</p>
960 @ <hr />
961 onoff_attribute("Enable WYSIWYG Wiki Editing",
962 "wysiwyg-wiki", "wysiwyg-wiki", 0, 0);
963 @ <p>Enable what-you-see-is-what-you-get (WYSIWYG) editing of wiki pages.
964 @ The WYSIWYG editor generates HTML instead of markup, which makes
965
+6 -2
--- src/timeline.c
+++ src/timeline.c
@@ -1444,20 +1444,20 @@
14441444
** name matches one of the comma-separate GLOBLIST
14451445
** brbg Background color from branch name
14461446
** ubg Background color from user
14471447
** namechng Show only check-ins that have filename changes
14481448
** forks Show only forks and their children
1449
+** cherrypicks Show all cherrypicks
14491450
** ym=YYYY-MM Show only events for the given year/month
14501451
** yw=YYYY-WW Show only events for the given week of the given year
14511452
** yw=YYYY-MM-DD Show events for the week that includes the given day
14521453
** ymd=YYYY-MM-DD Show only events on the given day
14531454
** days=N Show events over the previous N days
14541455
** datefmt=N Override the date format
14551456
** bisect Show the check-ins that are in the current bisect
14561457
** showid Show RIDs
14571458
** showsql Show the SQL text
1458
-** cherrypicks Show all cherrypicks
14591459
**
14601460
** p= and d= can appear individually or together. If either p= or d=
14611461
** appear, then u=, y=, a=, and b= are ignored.
14621462
**
14631463
** If both a= and b= appear then both upper and lower bounds are honored.
@@ -2269,11 +2269,15 @@
22692269
blob_zero(&sql);
22702270
db_prepare(&q, "SELECT * FROM timeline ORDER BY sortby DESC /*scan*/");
22712271
if( fossil_islower(desc.aData[0]) ){
22722272
desc.aData[0] = fossil_toupper(desc.aData[0]);
22732273
}
2274
- @ <h2>%b(&desc)</h2>
2274
+ if( zBrName && wiki_render_associated("branch", zBrName) ){
2275
+ @ <div class="section">%b(&desc)</div>
2276
+ } else{
2277
+ @ <h2>%b(&desc)</h2>
2278
+ }
22752279
blob_reset(&desc);
22762280
22772281
/* Report any errors. */
22782282
if( zError ){
22792283
@ <p class="generalError">%h(zError)</p>
22802284
--- src/timeline.c
+++ src/timeline.c
@@ -1444,20 +1444,20 @@
1444 ** name matches one of the comma-separate GLOBLIST
1445 ** brbg Background color from branch name
1446 ** ubg Background color from user
1447 ** namechng Show only check-ins that have filename changes
1448 ** forks Show only forks and their children
 
1449 ** ym=YYYY-MM Show only events for the given year/month
1450 ** yw=YYYY-WW Show only events for the given week of the given year
1451 ** yw=YYYY-MM-DD Show events for the week that includes the given day
1452 ** ymd=YYYY-MM-DD Show only events on the given day
1453 ** days=N Show events over the previous N days
1454 ** datefmt=N Override the date format
1455 ** bisect Show the check-ins that are in the current bisect
1456 ** showid Show RIDs
1457 ** showsql Show the SQL text
1458 ** cherrypicks Show all cherrypicks
1459 **
1460 ** p= and d= can appear individually or together. If either p= or d=
1461 ** appear, then u=, y=, a=, and b= are ignored.
1462 **
1463 ** If both a= and b= appear then both upper and lower bounds are honored.
@@ -2269,11 +2269,15 @@
2269 blob_zero(&sql);
2270 db_prepare(&q, "SELECT * FROM timeline ORDER BY sortby DESC /*scan*/");
2271 if( fossil_islower(desc.aData[0]) ){
2272 desc.aData[0] = fossil_toupper(desc.aData[0]);
2273 }
2274 @ <h2>%b(&desc)</h2>
 
 
 
 
2275 blob_reset(&desc);
2276
2277 /* Report any errors. */
2278 if( zError ){
2279 @ <p class="generalError">%h(zError)</p>
2280
--- src/timeline.c
+++ src/timeline.c
@@ -1444,20 +1444,20 @@
1444 ** name matches one of the comma-separate GLOBLIST
1445 ** brbg Background color from branch name
1446 ** ubg Background color from user
1447 ** namechng Show only check-ins that have filename changes
1448 ** forks Show only forks and their children
1449 ** cherrypicks Show all cherrypicks
1450 ** ym=YYYY-MM Show only events for the given year/month
1451 ** yw=YYYY-WW Show only events for the given week of the given year
1452 ** yw=YYYY-MM-DD Show events for the week that includes the given day
1453 ** ymd=YYYY-MM-DD Show only events on the given day
1454 ** days=N Show events over the previous N days
1455 ** datefmt=N Override the date format
1456 ** bisect Show the check-ins that are in the current bisect
1457 ** showid Show RIDs
1458 ** showsql Show the SQL text
 
1459 **
1460 ** p= and d= can appear individually or together. If either p= or d=
1461 ** appear, then u=, y=, a=, and b= are ignored.
1462 **
1463 ** If both a= and b= appear then both upper and lower bounds are honored.
@@ -2269,11 +2269,15 @@
2269 blob_zero(&sql);
2270 db_prepare(&q, "SELECT * FROM timeline ORDER BY sortby DESC /*scan*/");
2271 if( fossil_islower(desc.aData[0]) ){
2272 desc.aData[0] = fossil_toupper(desc.aData[0]);
2273 }
2274 if( zBrName && wiki_render_associated("branch", zBrName) ){
2275 @ <div class="section">%b(&desc)</div>
2276 } else{
2277 @ <h2>%b(&desc)</h2>
2278 }
2279 blob_reset(&desc);
2280
2281 /* Report any errors. */
2282 if( zError ){
2283 @ <p class="generalError">%h(zError)</p>
2284
+68
--- src/wiki.c
+++ src/wiki.c
@@ -1483,5 +1483,73 @@
14831483
blob_zero(&out);
14841484
blob_read_from_file(&in, g.argv[2], ExtFILE);
14851485
markdown_to_html(&in, 0, &out);
14861486
blob_write_to_file(&out, "-");
14871487
}
1488
+
1489
+/*
1490
+** Check to see if there exists a wiki page with a name zPrefix/zName.
1491
+** If there is, then render a <div class='section'>..</div> and
1492
+** return true.
1493
+**
1494
+** If there is no such wiki page, return false.
1495
+*/
1496
+int wiki_render_associated(
1497
+ const char *zPrefix, /* "branch", "tag", or "checkin" */
1498
+ const char *zName /* Name of the object */
1499
+){
1500
+ int rid;
1501
+ Manifest *pWiki;
1502
+ rid = db_int(0,
1503
+ "SELECT rid FROM tagxref"
1504
+ " WHERE tagid=(SELECT tagid FROM tag WHERE tagname='wiki-%q/%q')"
1505
+ " ORDER BY mtime DESC LIMIT 1",
1506
+ zPrefix, zName
1507
+ );
1508
+ if( rid==0 ) return 0;
1509
+ pWiki = manifest_get(rid, CFTYPE_WIKI, 0);
1510
+ if( pWiki==0 ) return 0;
1511
+ if( fossil_strcmp(pWiki->zMimetype, "text/x-markdown")==0 ){
1512
+ Blob tail = BLOB_INITIALIZER;
1513
+ Blob title = BLOB_INITIALIZER;
1514
+ Blob markdown;
1515
+ blob_init(&markdown, pWiki->zWiki, -1);
1516
+ markdown_to_html(&markdown, &title, &tail);
1517
+ if( blob_size(&title) ){
1518
+ @ <div class="section">%h(blob_str(&title))</div>
1519
+ }else{
1520
+ @ <div class="section">About %s(zPrefix) %h(zName)<div>
1521
+ }
1522
+ @ <div class="wiki">
1523
+ convert_href_and_output(&tail);
1524
+ @ </div>
1525
+ blob_reset(&tail);
1526
+ blob_reset(&title);
1527
+ blob_reset(&markdown);
1528
+ }else if( fossil_strcmp(pWiki->zMimetype, "text/plain")==0 ){
1529
+ @ <div class="section">About %s(zPrefix) %h(zName)</div>
1530
+ @ <pre>
1531
+ @ %h(pWiki->zWiki)
1532
+ @ </pre>
1533
+ }else{
1534
+ Blob tail = BLOB_INITIALIZER;
1535
+ Blob title = BLOB_INITIALIZER;
1536
+ Blob wiki;
1537
+ blob_init(&wiki, pWiki->zWiki, -1);
1538
+ if( wiki_find_title(&wiki, &title, &tail) ){
1539
+ @ <div class="section">%h(blob_str(&title))</div>
1540
+ @ <div class="wiki">
1541
+ wiki_convert(&tail, 0, WIKI_BUTTONS);
1542
+ @ </div>
1543
+ }else{
1544
+ @ <div class="section">About %s(zPrefix) %h(zName)</div>
1545
+ @ <div class="wiki">
1546
+ wiki_convert(&wiki, 0, WIKI_BUTTONS);
1547
+ @ </div>
1548
+ }
1549
+ blob_reset(&tail);
1550
+ blob_reset(&title);
1551
+ blob_reset(&wiki);
1552
+ }
1553
+ manifest_destroy(pWiki);
1554
+ return 1;
1555
+}
14881556
--- src/wiki.c
+++ src/wiki.c
@@ -1483,5 +1483,73 @@
1483 blob_zero(&out);
1484 blob_read_from_file(&in, g.argv[2], ExtFILE);
1485 markdown_to_html(&in, 0, &out);
1486 blob_write_to_file(&out, "-");
1487 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1488
--- src/wiki.c
+++ src/wiki.c
@@ -1483,5 +1483,73 @@
1483 blob_zero(&out);
1484 blob_read_from_file(&in, g.argv[2], ExtFILE);
1485 markdown_to_html(&in, 0, &out);
1486 blob_write_to_file(&out, "-");
1487 }
1488
1489 /*
1490 ** Check to see if there exists a wiki page with a name zPrefix/zName.
1491 ** If there is, then render a <div class='section'>..</div> and
1492 ** return true.
1493 **
1494 ** If there is no such wiki page, return false.
1495 */
1496 int wiki_render_associated(
1497 const char *zPrefix, /* "branch", "tag", or "checkin" */
1498 const char *zName /* Name of the object */
1499 ){
1500 int rid;
1501 Manifest *pWiki;
1502 rid = db_int(0,
1503 "SELECT rid FROM tagxref"
1504 " WHERE tagid=(SELECT tagid FROM tag WHERE tagname='wiki-%q/%q')"
1505 " ORDER BY mtime DESC LIMIT 1",
1506 zPrefix, zName
1507 );
1508 if( rid==0 ) return 0;
1509 pWiki = manifest_get(rid, CFTYPE_WIKI, 0);
1510 if( pWiki==0 ) return 0;
1511 if( fossil_strcmp(pWiki->zMimetype, "text/x-markdown")==0 ){
1512 Blob tail = BLOB_INITIALIZER;
1513 Blob title = BLOB_INITIALIZER;
1514 Blob markdown;
1515 blob_init(&markdown, pWiki->zWiki, -1);
1516 markdown_to_html(&markdown, &title, &tail);
1517 if( blob_size(&title) ){
1518 @ <div class="section">%h(blob_str(&title))</div>
1519 }else{
1520 @ <div class="section">About %s(zPrefix) %h(zName)<div>
1521 }
1522 @ <div class="wiki">
1523 convert_href_and_output(&tail);
1524 @ </div>
1525 blob_reset(&tail);
1526 blob_reset(&title);
1527 blob_reset(&markdown);
1528 }else if( fossil_strcmp(pWiki->zMimetype, "text/plain")==0 ){
1529 @ <div class="section">About %s(zPrefix) %h(zName)</div>
1530 @ <pre>
1531 @ %h(pWiki->zWiki)
1532 @ </pre>
1533 }else{
1534 Blob tail = BLOB_INITIALIZER;
1535 Blob title = BLOB_INITIALIZER;
1536 Blob wiki;
1537 blob_init(&wiki, pWiki->zWiki, -1);
1538 if( wiki_find_title(&wiki, &title, &tail) ){
1539 @ <div class="section">%h(blob_str(&title))</div>
1540 @ <div class="wiki">
1541 wiki_convert(&tail, 0, WIKI_BUTTONS);
1542 @ </div>
1543 }else{
1544 @ <div class="section">About %s(zPrefix) %h(zName)</div>
1545 @ <div class="wiki">
1546 wiki_convert(&wiki, 0, WIKI_BUTTONS);
1547 @ </div>
1548 }
1549 blob_reset(&tail);
1550 blob_reset(&title);
1551 blob_reset(&wiki);
1552 }
1553 manifest_destroy(pWiki);
1554 return 1;
1555 }
1556

Keyboard Shortcuts

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