Fossil SCM
Added -html|-h flag to [/help?cmd=wiki|the wiki command], as discussed in [https://fossil-scm.org/forum/forumpost/7377c83dca|forumpost/7377c83dca], and cleaned up the command's help text and argument validation.
Commit
b23eb8331488435e423eefae2aee76071b3f1aed64ca4f16a43d1b8a0ea580c4
Parent
890614f13711f96…
1 file changed
+52
-17
+52
-17
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -1224,11 +1224,11 @@ | ||
| 1224 | 1224 | if( wrid==0 ){ |
| 1225 | 1225 | if( !showAll ) continue; |
| 1226 | 1226 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 1227 | 1227 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| 1228 | 1228 | }else{ |
| 1229 | - @ <tr><td data=sortkey='%h(zSort)">\ | |
| 1229 | + @ <tr><td data=sortkey="%h(zSort)">\ | |
| 1230 | 1230 | @ %z(href("%R/wiki?name=%T",zWName))%h(zWDisplayName)</a></td> |
| 1231 | 1231 | } |
| 1232 | 1232 | zAge = human_readable_age(rNow - rWmtime); |
| 1233 | 1233 | @ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td> |
| 1234 | 1234 | fossil_free(zAge); |
| @@ -1364,19 +1364,25 @@ | ||
| 1364 | 1364 | ** |
| 1365 | 1365 | ** Usage: %fossil wiki (export|create|commit|list) WikiName |
| 1366 | 1366 | ** |
| 1367 | 1367 | ** Run various subcommands to work with wiki entries or tech notes. |
| 1368 | 1368 | ** |
| 1369 | -** %fossil wiki export PAGENAME ?FILE? | |
| 1370 | -** %fossil wiki export ?FILE? -t|--technote DATETIME|TECHNOTE-ID | |
| 1369 | +** %fossil wiki export ?OPTIONS? ?PAGENAME? ?FILE? | |
| 1370 | +** %fossil wiki export ?OPTIONS? -t|--technote DATETIME|TECHNOTE-ID ?FILE? | |
| 1371 | 1371 | ** |
| 1372 | 1372 | ** Sends the latest version of either a wiki page or of a tech note |
| 1373 | 1373 | ** to the given file or standard output. |
| 1374 | -** If PAGENAME is provided, the wiki page will be output. For | |
| 1375 | -** a tech note either DATETIME or TECHNOTE-ID must be specified. If | |
| 1376 | -** DATETIME is used, the most recently modified tech note with that | |
| 1377 | -** DATETIME will be sent. | |
| 1374 | +** | |
| 1375 | +** Options: | |
| 1376 | +** If PAGENAME is provided, the named wiki page will be output. | |
| 1377 | +** --technote|-t DATETIME|TECHNOTE-ID | |
| 1378 | +** Specifies that a technote, rather than a wiki page, | |
| 1379 | +** will be exported. If DATETIME is used, the most | |
| 1380 | +** recently modified tech note with that DATETIME will | |
| 1381 | +** output. | |
| 1382 | +** -h|--html The body (only) is rendered in HTML form, without | |
| 1383 | +** any page header/foot or HTML/BODY tag wrappers. | |
| 1378 | 1384 | ** |
| 1379 | 1385 | ** %fossil wiki (create|commit) PAGENAME ?FILE? ?OPTIONS? |
| 1380 | 1386 | ** |
| 1381 | 1387 | ** Create a new or commit changes to an existing wiki page or |
| 1382 | 1388 | ** technote from FILE or from standard input. PAGENAME is the |
| @@ -1444,17 +1450,20 @@ | ||
| 1444 | 1450 | const char *zFile; /* Name of the output file (0=stdout) */ |
| 1445 | 1451 | const char *zETime; /* The name of the technote to export */ |
| 1446 | 1452 | int rid; /* Artifact ID of the wiki page */ |
| 1447 | 1453 | int i; /* Loop counter */ |
| 1448 | 1454 | char *zBody = 0; /* Wiki page content */ |
| 1449 | - Blob body; /* Wiki page content */ | |
| 1455 | + Blob body = empty_blob; /* Wiki page content */ | |
| 1450 | 1456 | Manifest *pWiki = 0; /* Parsed wiki page content */ |
| 1457 | + int fHtml = 0; /* Export in HTML form */ | |
| 1451 | 1458 | |
| 1459 | + fHtml = find_option("html","h",0)!=0; | |
| 1452 | 1460 | zETime = find_option("technote","t",1); |
| 1461 | + verify_all_options(); | |
| 1453 | 1462 | if( !zETime ){ |
| 1454 | 1463 | if( (g.argc!=4) && (g.argc!=5) ){ |
| 1455 | - usage("export PAGENAME ?FILE?"); | |
| 1464 | + usage("export ?-html? PAGENAME ?FILE?"); | |
| 1456 | 1465 | } |
| 1457 | 1466 | zPageName = g.argv[3]; |
| 1458 | 1467 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| 1459 | 1468 | " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" |
| 1460 | 1469 | " ORDER BY x.mtime DESC LIMIT 1", |
| @@ -1467,11 +1476,12 @@ | ||
| 1467 | 1476 | fossil_fatal("wiki page [%s] not found",zPageName); |
| 1468 | 1477 | } |
| 1469 | 1478 | zFile = (g.argc==4) ? "-" : g.argv[4]; |
| 1470 | 1479 | }else{ |
| 1471 | 1480 | if( (g.argc!=3) && (g.argc!=4) ){ |
| 1472 | - usage("export ?FILE? --technote DATETIME|TECHNOTE-ID"); | |
| 1481 | + usage("export ?-html? ?FILE? --technote " | |
| 1482 | + "DATETIME|TECHNOTE-ID"); | |
| 1473 | 1483 | } |
| 1474 | 1484 | rid = wiki_technote_to_rid(zETime); |
| 1475 | 1485 | if ( rid==-1 ){ |
| 1476 | 1486 | fossil_fatal("ambiguous tech note id: %s", zETime); |
| 1477 | 1487 | } |
| @@ -1484,11 +1494,36 @@ | ||
| 1484 | 1494 | zFile = (g.argc==3) ? "-" : g.argv[3]; |
| 1485 | 1495 | } |
| 1486 | 1496 | for(i=strlen(zBody); i>0 && fossil_isspace(zBody[i-1]); i--){} |
| 1487 | 1497 | zBody[i] = 0; |
| 1488 | 1498 | blob_init(&body, zBody, -1); |
| 1489 | - blob_append(&body, "\n", 1); | |
| 1499 | + if(fHtml==0){ | |
| 1500 | + blob_append(&body, "\n", 1); | |
| 1501 | + }else{ | |
| 1502 | + Blob html = empty_blob; /* HTML-ized content */ | |
| 1503 | + const char * zMimetype = wiki_filter_mimetypes(pWiki->zMimetype); | |
| 1504 | + if( fossil_strcmp(zMimetype, "text/x-fossil-wiki")==0 ){ | |
| 1505 | + wiki_convert(&body,&html,0); | |
| 1506 | + }else if( fossil_strcmp(zMimetype, "text/x-markdown")==0 ){ | |
| 1507 | + markdown_to_html(&body,0,&html) | |
| 1508 | + /* TODO: add -HTML|-H flag to work like -html|-h but also | |
| 1509 | + ** add <html><body> tag wrappers around the output. The | |
| 1510 | + ** hurdle here is that the markdown converter resets its | |
| 1511 | + ** input blob before appending the output, which is | |
| 1512 | + ** different from wiki_convert() and htmlize_to_blob(), and | |
| 1513 | + ** precludes us simply appending the opening <html><body> | |
| 1514 | + ** part to the body | |
| 1515 | + */; | |
| 1516 | + }else if( fossil_strcmp(zMimetype, "text/plain")==0 ){ | |
| 1517 | + htmlize_to_blob(&html,zBody,i); | |
| 1518 | + }else{ | |
| 1519 | + fossil_fatal("Unsupported MIME type '%s' for wiki page '%s'.", | |
| 1520 | + zMimetype, pWiki->zWikiTitle ); | |
| 1521 | + } | |
| 1522 | + blob_reset(&body); | |
| 1523 | + body = html /* transfer memory */; | |
| 1524 | + } | |
| 1490 | 1525 | blob_write_to_file(&body, zFile); |
| 1491 | 1526 | blob_reset(&body); |
| 1492 | 1527 | manifest_destroy(pWiki); |
| 1493 | 1528 | return; |
| 1494 | 1529 | }else if( strncmp(g.argv[2],"commit",n)==0 |
| @@ -1500,10 +1535,11 @@ | ||
| 1500 | 1535 | const int isCreate = 'r'==g.argv[2][1] /* else "commit" */; |
| 1501 | 1536 | const char *zMimeType = find_option("mimetype", "M", 1); |
| 1502 | 1537 | const char *zETime = find_option("technote", "t", 1); |
| 1503 | 1538 | const char *zTags = find_option("technote-tags", NULL, 1); |
| 1504 | 1539 | const char *zClr = find_option("technote-bgcolor", NULL, 1); |
| 1540 | + verify_all_options(); | |
| 1505 | 1541 | if( g.argc!=4 && g.argc!=5 ){ |
| 1506 | 1542 | usage("commit|create PAGENAME ?FILE? [--mimetype TEXT-FORMAT]" |
| 1507 | 1543 | " [--technote DATETIME] [--technote-tags TAGS]" |
| 1508 | 1544 | " [--technote-bgcolor COLOR]"); |
| 1509 | 1545 | } |
| @@ -1577,36 +1613,35 @@ | ||
| 1577 | 1613 | } |
| 1578 | 1614 | } |
| 1579 | 1615 | manifest_destroy(pWiki); |
| 1580 | 1616 | blob_reset(&content); |
| 1581 | 1617 | }else if( strncmp(g.argv[2],"delete",n)==0 ){ |
| 1582 | - if( g.argc!=5 ){ | |
| 1618 | + if( g.argc!=4 ){ | |
| 1583 | 1619 | usage("delete PAGENAME"); |
| 1584 | 1620 | } |
| 1585 | 1621 | fossil_fatal("delete not yet implemented."); |
| 1586 | 1622 | }else if(( strncmp(g.argv[2],"list",n)==0 ) |
| 1587 | 1623 | || ( strncmp(g.argv[2],"ls",n)==0 )){ |
| 1588 | 1624 | Stmt q; |
| 1589 | - int showIds = 0; | |
| 1590 | - | |
| 1591 | - if ( !find_option("technote","t",0) ){ | |
| 1625 | + const int fTechnote = find_option("technote","t",0)!=0; | |
| 1626 | + const int showIds = find_option("show-technote-ids","s",0)!=0; | |
| 1627 | + verify_all_options(); | |
| 1628 | + if (fTechnote==0){ | |
| 1592 | 1629 | db_prepare(&q, |
| 1593 | 1630 | "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'" |
| 1594 | 1631 | " ORDER BY lower(tagname) /*sort*/" |
| 1595 | 1632 | ); |
| 1596 | 1633 | }else{ |
| 1597 | - showIds = find_option("show-technote-ids","s",0)!=0; | |
| 1598 | 1634 | db_prepare(&q, |
| 1599 | 1635 | "SELECT datetime(e.mtime), substr(t.tagname,7)" |
| 1600 | 1636 | " FROM event e, tag t" |
| 1601 | 1637 | " WHERE e.type='e'" |
| 1602 | 1638 | " AND e.tagid IS NOT NULL" |
| 1603 | 1639 | " AND t.tagid=e.tagid" |
| 1604 | 1640 | " ORDER BY e.mtime DESC /*sort*/" |
| 1605 | 1641 | ); |
| 1606 | 1642 | } |
| 1607 | - | |
| 1608 | 1643 | while( db_step(&q)==SQLITE_ROW ){ |
| 1609 | 1644 | const char *zName = db_column_text(&q, 0); |
| 1610 | 1645 | if( showIds ){ |
| 1611 | 1646 | const char *zUuid = db_column_text(&q, 1); |
| 1612 | 1647 | fossil_print("%s ",zUuid); |
| 1613 | 1648 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1224,11 +1224,11 @@ | |
| 1224 | if( wrid==0 ){ |
| 1225 | if( !showAll ) continue; |
| 1226 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 1227 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| 1228 | }else{ |
| 1229 | @ <tr><td data=sortkey='%h(zSort)">\ |
| 1230 | @ %z(href("%R/wiki?name=%T",zWName))%h(zWDisplayName)</a></td> |
| 1231 | } |
| 1232 | zAge = human_readable_age(rNow - rWmtime); |
| 1233 | @ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td> |
| 1234 | fossil_free(zAge); |
| @@ -1364,19 +1364,25 @@ | |
| 1364 | ** |
| 1365 | ** Usage: %fossil wiki (export|create|commit|list) WikiName |
| 1366 | ** |
| 1367 | ** Run various subcommands to work with wiki entries or tech notes. |
| 1368 | ** |
| 1369 | ** %fossil wiki export PAGENAME ?FILE? |
| 1370 | ** %fossil wiki export ?FILE? -t|--technote DATETIME|TECHNOTE-ID |
| 1371 | ** |
| 1372 | ** Sends the latest version of either a wiki page or of a tech note |
| 1373 | ** to the given file or standard output. |
| 1374 | ** If PAGENAME is provided, the wiki page will be output. For |
| 1375 | ** a tech note either DATETIME or TECHNOTE-ID must be specified. If |
| 1376 | ** DATETIME is used, the most recently modified tech note with that |
| 1377 | ** DATETIME will be sent. |
| 1378 | ** |
| 1379 | ** %fossil wiki (create|commit) PAGENAME ?FILE? ?OPTIONS? |
| 1380 | ** |
| 1381 | ** Create a new or commit changes to an existing wiki page or |
| 1382 | ** technote from FILE or from standard input. PAGENAME is the |
| @@ -1444,17 +1450,20 @@ | |
| 1444 | const char *zFile; /* Name of the output file (0=stdout) */ |
| 1445 | const char *zETime; /* The name of the technote to export */ |
| 1446 | int rid; /* Artifact ID of the wiki page */ |
| 1447 | int i; /* Loop counter */ |
| 1448 | char *zBody = 0; /* Wiki page content */ |
| 1449 | Blob body; /* Wiki page content */ |
| 1450 | Manifest *pWiki = 0; /* Parsed wiki page content */ |
| 1451 | |
| 1452 | zETime = find_option("technote","t",1); |
| 1453 | if( !zETime ){ |
| 1454 | if( (g.argc!=4) && (g.argc!=5) ){ |
| 1455 | usage("export PAGENAME ?FILE?"); |
| 1456 | } |
| 1457 | zPageName = g.argv[3]; |
| 1458 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| 1459 | " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" |
| 1460 | " ORDER BY x.mtime DESC LIMIT 1", |
| @@ -1467,11 +1476,12 @@ | |
| 1467 | fossil_fatal("wiki page [%s] not found",zPageName); |
| 1468 | } |
| 1469 | zFile = (g.argc==4) ? "-" : g.argv[4]; |
| 1470 | }else{ |
| 1471 | if( (g.argc!=3) && (g.argc!=4) ){ |
| 1472 | usage("export ?FILE? --technote DATETIME|TECHNOTE-ID"); |
| 1473 | } |
| 1474 | rid = wiki_technote_to_rid(zETime); |
| 1475 | if ( rid==-1 ){ |
| 1476 | fossil_fatal("ambiguous tech note id: %s", zETime); |
| 1477 | } |
| @@ -1484,11 +1494,36 @@ | |
| 1484 | zFile = (g.argc==3) ? "-" : g.argv[3]; |
| 1485 | } |
| 1486 | for(i=strlen(zBody); i>0 && fossil_isspace(zBody[i-1]); i--){} |
| 1487 | zBody[i] = 0; |
| 1488 | blob_init(&body, zBody, -1); |
| 1489 | blob_append(&body, "\n", 1); |
| 1490 | blob_write_to_file(&body, zFile); |
| 1491 | blob_reset(&body); |
| 1492 | manifest_destroy(pWiki); |
| 1493 | return; |
| 1494 | }else if( strncmp(g.argv[2],"commit",n)==0 |
| @@ -1500,10 +1535,11 @@ | |
| 1500 | const int isCreate = 'r'==g.argv[2][1] /* else "commit" */; |
| 1501 | const char *zMimeType = find_option("mimetype", "M", 1); |
| 1502 | const char *zETime = find_option("technote", "t", 1); |
| 1503 | const char *zTags = find_option("technote-tags", NULL, 1); |
| 1504 | const char *zClr = find_option("technote-bgcolor", NULL, 1); |
| 1505 | if( g.argc!=4 && g.argc!=5 ){ |
| 1506 | usage("commit|create PAGENAME ?FILE? [--mimetype TEXT-FORMAT]" |
| 1507 | " [--technote DATETIME] [--technote-tags TAGS]" |
| 1508 | " [--technote-bgcolor COLOR]"); |
| 1509 | } |
| @@ -1577,36 +1613,35 @@ | |
| 1577 | } |
| 1578 | } |
| 1579 | manifest_destroy(pWiki); |
| 1580 | blob_reset(&content); |
| 1581 | }else if( strncmp(g.argv[2],"delete",n)==0 ){ |
| 1582 | if( g.argc!=5 ){ |
| 1583 | usage("delete PAGENAME"); |
| 1584 | } |
| 1585 | fossil_fatal("delete not yet implemented."); |
| 1586 | }else if(( strncmp(g.argv[2],"list",n)==0 ) |
| 1587 | || ( strncmp(g.argv[2],"ls",n)==0 )){ |
| 1588 | Stmt q; |
| 1589 | int showIds = 0; |
| 1590 | |
| 1591 | if ( !find_option("technote","t",0) ){ |
| 1592 | db_prepare(&q, |
| 1593 | "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'" |
| 1594 | " ORDER BY lower(tagname) /*sort*/" |
| 1595 | ); |
| 1596 | }else{ |
| 1597 | showIds = find_option("show-technote-ids","s",0)!=0; |
| 1598 | db_prepare(&q, |
| 1599 | "SELECT datetime(e.mtime), substr(t.tagname,7)" |
| 1600 | " FROM event e, tag t" |
| 1601 | " WHERE e.type='e'" |
| 1602 | " AND e.tagid IS NOT NULL" |
| 1603 | " AND t.tagid=e.tagid" |
| 1604 | " ORDER BY e.mtime DESC /*sort*/" |
| 1605 | ); |
| 1606 | } |
| 1607 | |
| 1608 | while( db_step(&q)==SQLITE_ROW ){ |
| 1609 | const char *zName = db_column_text(&q, 0); |
| 1610 | if( showIds ){ |
| 1611 | const char *zUuid = db_column_text(&q, 1); |
| 1612 | fossil_print("%s ",zUuid); |
| 1613 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -1224,11 +1224,11 @@ | |
| 1224 | if( wrid==0 ){ |
| 1225 | if( !showAll ) continue; |
| 1226 | @ <tr><td data-sortkey="%h(zSort)">\ |
| 1227 | @ %z(href("%R/whistory?name=%T",zWName))<s>%h(zWDisplayName)</s></a></td> |
| 1228 | }else{ |
| 1229 | @ <tr><td data=sortkey="%h(zSort)">\ |
| 1230 | @ %z(href("%R/wiki?name=%T",zWName))%h(zWDisplayName)</a></td> |
| 1231 | } |
| 1232 | zAge = human_readable_age(rNow - rWmtime); |
| 1233 | @ <td data-sortkey="%016llx(iMtime)">%s(zAge)</td> |
| 1234 | fossil_free(zAge); |
| @@ -1364,19 +1364,25 @@ | |
| 1364 | ** |
| 1365 | ** Usage: %fossil wiki (export|create|commit|list) WikiName |
| 1366 | ** |
| 1367 | ** Run various subcommands to work with wiki entries or tech notes. |
| 1368 | ** |
| 1369 | ** %fossil wiki export ?OPTIONS? ?PAGENAME? ?FILE? |
| 1370 | ** %fossil wiki export ?OPTIONS? -t|--technote DATETIME|TECHNOTE-ID ?FILE? |
| 1371 | ** |
| 1372 | ** Sends the latest version of either a wiki page or of a tech note |
| 1373 | ** to the given file or standard output. |
| 1374 | ** |
| 1375 | ** Options: |
| 1376 | ** If PAGENAME is provided, the named wiki page will be output. |
| 1377 | ** --technote|-t DATETIME|TECHNOTE-ID |
| 1378 | ** Specifies that a technote, rather than a wiki page, |
| 1379 | ** will be exported. If DATETIME is used, the most |
| 1380 | ** recently modified tech note with that DATETIME will |
| 1381 | ** output. |
| 1382 | ** -h|--html The body (only) is rendered in HTML form, without |
| 1383 | ** any page header/foot or HTML/BODY tag wrappers. |
| 1384 | ** |
| 1385 | ** %fossil wiki (create|commit) PAGENAME ?FILE? ?OPTIONS? |
| 1386 | ** |
| 1387 | ** Create a new or commit changes to an existing wiki page or |
| 1388 | ** technote from FILE or from standard input. PAGENAME is the |
| @@ -1444,17 +1450,20 @@ | |
| 1450 | const char *zFile; /* Name of the output file (0=stdout) */ |
| 1451 | const char *zETime; /* The name of the technote to export */ |
| 1452 | int rid; /* Artifact ID of the wiki page */ |
| 1453 | int i; /* Loop counter */ |
| 1454 | char *zBody = 0; /* Wiki page content */ |
| 1455 | Blob body = empty_blob; /* Wiki page content */ |
| 1456 | Manifest *pWiki = 0; /* Parsed wiki page content */ |
| 1457 | int fHtml = 0; /* Export in HTML form */ |
| 1458 | |
| 1459 | fHtml = find_option("html","h",0)!=0; |
| 1460 | zETime = find_option("technote","t",1); |
| 1461 | verify_all_options(); |
| 1462 | if( !zETime ){ |
| 1463 | if( (g.argc!=4) && (g.argc!=5) ){ |
| 1464 | usage("export ?-html? PAGENAME ?FILE?"); |
| 1465 | } |
| 1466 | zPageName = g.argv[3]; |
| 1467 | rid = db_int(0, "SELECT x.rid FROM tag t, tagxref x" |
| 1468 | " WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'" |
| 1469 | " ORDER BY x.mtime DESC LIMIT 1", |
| @@ -1467,11 +1476,12 @@ | |
| 1476 | fossil_fatal("wiki page [%s] not found",zPageName); |
| 1477 | } |
| 1478 | zFile = (g.argc==4) ? "-" : g.argv[4]; |
| 1479 | }else{ |
| 1480 | if( (g.argc!=3) && (g.argc!=4) ){ |
| 1481 | usage("export ?-html? ?FILE? --technote " |
| 1482 | "DATETIME|TECHNOTE-ID"); |
| 1483 | } |
| 1484 | rid = wiki_technote_to_rid(zETime); |
| 1485 | if ( rid==-1 ){ |
| 1486 | fossil_fatal("ambiguous tech note id: %s", zETime); |
| 1487 | } |
| @@ -1484,11 +1494,36 @@ | |
| 1494 | zFile = (g.argc==3) ? "-" : g.argv[3]; |
| 1495 | } |
| 1496 | for(i=strlen(zBody); i>0 && fossil_isspace(zBody[i-1]); i--){} |
| 1497 | zBody[i] = 0; |
| 1498 | blob_init(&body, zBody, -1); |
| 1499 | if(fHtml==0){ |
| 1500 | blob_append(&body, "\n", 1); |
| 1501 | }else{ |
| 1502 | Blob html = empty_blob; /* HTML-ized content */ |
| 1503 | const char * zMimetype = wiki_filter_mimetypes(pWiki->zMimetype); |
| 1504 | if( fossil_strcmp(zMimetype, "text/x-fossil-wiki")==0 ){ |
| 1505 | wiki_convert(&body,&html,0); |
| 1506 | }else if( fossil_strcmp(zMimetype, "text/x-markdown")==0 ){ |
| 1507 | markdown_to_html(&body,0,&html) |
| 1508 | /* TODO: add -HTML|-H flag to work like -html|-h but also |
| 1509 | ** add <html><body> tag wrappers around the output. The |
| 1510 | ** hurdle here is that the markdown converter resets its |
| 1511 | ** input blob before appending the output, which is |
| 1512 | ** different from wiki_convert() and htmlize_to_blob(), and |
| 1513 | ** precludes us simply appending the opening <html><body> |
| 1514 | ** part to the body |
| 1515 | */; |
| 1516 | }else if( fossil_strcmp(zMimetype, "text/plain")==0 ){ |
| 1517 | htmlize_to_blob(&html,zBody,i); |
| 1518 | }else{ |
| 1519 | fossil_fatal("Unsupported MIME type '%s' for wiki page '%s'.", |
| 1520 | zMimetype, pWiki->zWikiTitle ); |
| 1521 | } |
| 1522 | blob_reset(&body); |
| 1523 | body = html /* transfer memory */; |
| 1524 | } |
| 1525 | blob_write_to_file(&body, zFile); |
| 1526 | blob_reset(&body); |
| 1527 | manifest_destroy(pWiki); |
| 1528 | return; |
| 1529 | }else if( strncmp(g.argv[2],"commit",n)==0 |
| @@ -1500,10 +1535,11 @@ | |
| 1535 | const int isCreate = 'r'==g.argv[2][1] /* else "commit" */; |
| 1536 | const char *zMimeType = find_option("mimetype", "M", 1); |
| 1537 | const char *zETime = find_option("technote", "t", 1); |
| 1538 | const char *zTags = find_option("technote-tags", NULL, 1); |
| 1539 | const char *zClr = find_option("technote-bgcolor", NULL, 1); |
| 1540 | verify_all_options(); |
| 1541 | if( g.argc!=4 && g.argc!=5 ){ |
| 1542 | usage("commit|create PAGENAME ?FILE? [--mimetype TEXT-FORMAT]" |
| 1543 | " [--technote DATETIME] [--technote-tags TAGS]" |
| 1544 | " [--technote-bgcolor COLOR]"); |
| 1545 | } |
| @@ -1577,36 +1613,35 @@ | |
| 1613 | } |
| 1614 | } |
| 1615 | manifest_destroy(pWiki); |
| 1616 | blob_reset(&content); |
| 1617 | }else if( strncmp(g.argv[2],"delete",n)==0 ){ |
| 1618 | if( g.argc!=4 ){ |
| 1619 | usage("delete PAGENAME"); |
| 1620 | } |
| 1621 | fossil_fatal("delete not yet implemented."); |
| 1622 | }else if(( strncmp(g.argv[2],"list",n)==0 ) |
| 1623 | || ( strncmp(g.argv[2],"ls",n)==0 )){ |
| 1624 | Stmt q; |
| 1625 | const int fTechnote = find_option("technote","t",0)!=0; |
| 1626 | const int showIds = find_option("show-technote-ids","s",0)!=0; |
| 1627 | verify_all_options(); |
| 1628 | if (fTechnote==0){ |
| 1629 | db_prepare(&q, |
| 1630 | "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'" |
| 1631 | " ORDER BY lower(tagname) /*sort*/" |
| 1632 | ); |
| 1633 | }else{ |
| 1634 | db_prepare(&q, |
| 1635 | "SELECT datetime(e.mtime), substr(t.tagname,7)" |
| 1636 | " FROM event e, tag t" |
| 1637 | " WHERE e.type='e'" |
| 1638 | " AND e.tagid IS NOT NULL" |
| 1639 | " AND t.tagid=e.tagid" |
| 1640 | " ORDER BY e.mtime DESC /*sort*/" |
| 1641 | ); |
| 1642 | } |
| 1643 | while( db_step(&q)==SQLITE_ROW ){ |
| 1644 | const char *zName = db_column_text(&q, 0); |
| 1645 | if( showIds ){ |
| 1646 | const char *zUuid = db_column_text(&q, 1); |
| 1647 | fossil_print("%s ",zUuid); |
| 1648 |