Fossil

Check-in [57443202]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Better titles for the /wiki page for associated wiki.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | describe-objects-using-wiki
Files: files | file ages | folders
SHA3-256: 57443202ae0ef2353a3682d79c1b4334b206ab302b1cf12c4da02c3d4d12505d
User & Date: drh 2018-12-31 00:00:43
Wiki:describe-objects-using-wiki
Context
2018-12-31
02:13
Change the /info page Overview section to have "Wiki:" links for wiki display, instead of "Edit Wiki:" links. Users who want to edit, can do the additional "Edit" click from the wiki page. Also have /info honor the nowiki query parameter. check-in: f17a5198 user: drh tags: describe-objects-using-wiki
00:00
Better titles for the /wiki page for associated wiki. check-in: 57443202 user: drh tags: describe-objects-using-wiki
2018-12-30
23:27
Improved page titles when editing wiki about branches, checkins, and tags. Honor the wiki-about flag. check-in: 32d9be6d user: drh tags: describe-objects-using-wiki
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/timeline.c.

2270
2271
2272
2273
2274
2275
2276
2277

2278
2279
2280
2281
2282
2283
2284

2285
2286
2287
2288
2289
2290
2291
  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_FULL_TITLE)

  ){
    @ <div class="section">%b(&desc)</div>
  }else
  if( zTagName
   && matchStyle==MS_EXACT
   && !PB("nowiki")
   && wiki_render_associated("tag", zTagName, WIKIASSOC_FULL_TITLE)

  ){
    @ <div class="section">%b(&desc)</div>
  } else{
    @ <h2>%b(&desc)</h2>
  }
  blob_reset(&desc);








|
>






|
>







2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
  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_FULL_TITLE|WIKIASSOC_MENU)
  ){
    @ <div class="section">%b(&desc)</div>
  }else
  if( zTagName
   && matchStyle==MS_EXACT
   && !PB("nowiki")
   && wiki_render_associated("tag", zTagName,
                             WIKIASSOC_FULL_TITLE|WIKIASSOC_MENU)
  ){
    @ <div class="section">%b(&desc)</div>
  } else{
    @ <h2>%b(&desc)</h2>
  }
  blob_reset(&desc);

Changes to src/wiki.c.

341
342
343
344
345
346
347




























348
349
350
351
352
353
354
...
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
...
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606

607
608
609
610
611
612
613
....
1517
1518
1519
1520
1521
1522
1523

1524
1525
1526
1527
1528
1529
1530
....
1535
1536
1537
1538
1539
1540
1541













1542
1543
1544
1545
1546
1547
1548
....
1571
1572
1573
1574
1575
1576
1577

1578
1579
1580
1581
1582
1583

1584
1585
1586
1587
1588
1589
1590

1591
1592
1593
1594
1595
1596
1597
1598



1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
void wiki_srchpage(void){
  login_check_credentials();
  style_header("Wiki Search");
  wiki_standard_submenu(W_HELP|W_LIST|W_SANDBOX);
  search_screen(SRCH_WIKI, 0);
  style_footer();
}





























/*
** WEBPAGE: wiki
** URL: /wiki?name=PAGENAME
*/
void wiki_page(void){
  char *zTag;
................................................................................
    }
    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);
  style_header("%s", 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);
................................................................................
    cgi_redirectf("wiki?name=%T", zPageName);
    return;
  }
  if( zBody==0 ){
    zBody = mprintf("<i>Empty Page</i>");
  }
  style_set_current_page("%T?name=%T", g.zPath, zPageName);

  if( db_get_boolean("wiki-about",1)==0 ){
    style_header("Edit: %s", zPageName);
  }else
  if( sqlite3_strglob("checkin/*", zPageName)==0 
   && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
  ){
    style_header("Notes About Checkin %S", zPageName + 8);
    style_submenu_element("Checkin Timeline","%R/timeline?f=%s",zPageName + 8);
    style_submenu_element("Checkin Info","%R/info/%s",zPageName + 8);
  }else
  if( sqlite3_strglob("branch/*", zPageName)==0 ){
    style_header("Notes About Branch %h", zPageName + 7);
    style_submenu_element("Branch Timeline","%R/timeline?r=%t",zPageName + 7);
  }else
  if( sqlite3_strglob("tag/*", zPageName)==0 ){
    style_header("Notes About Tag %h", zPageName + 4);
    style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName + 4);
  }
  else{
    style_header("Edit: %s", zPageName);
  }


  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",
................................................................................
}

/*
** Allowed flags for wiki_render_associated
*/
#if INTERFACE
#define WIKIASSOC_FULL_TITLE  0x00001   /* Full title */

#endif

/*
** Show the default Section label for an associated wiki page.
*/
static void wiki_section_label(
  const char *zPrefix,   /* "branch", "tag", or "checkin" */
................................................................................
    @ <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>
  }
}














/*
** 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
** return true.
**
** If there is no such wiki page, return false.
................................................................................
    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);
    }

    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);

    @ <pre>
    @ %h(pWiki->zWiki)
    @ </pre>
  }else{
    Blob tail = BLOB_INITIALIZER;
    Blob title = BLOB_INITIALIZER;
    Blob wiki;

    blob_init(&wiki, pWiki->zWiki, -1);
    if( wiki_find_title(&wiki, &title, &tail) ){
      @ <div class="section">%h(blob_str(&title))</div>
      @ <div class="wiki">
      wiki_convert(&tail, 0, WIKI_BUTTONS);
      @ </div>
    }else{
      wiki_section_label(zPrefix, zName, mFlags);



      @ <div class="wiki">
      wiki_convert(&wiki, 0, WIKI_BUTTONS);
      @ </div>
    }
    blob_reset(&tail);
    blob_reset(&title);
    blob_reset(&wiki);
  }
  manifest_destroy(pWiki);
  return 1;
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>







 







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>







 







>






>







>



|
<
<


>
>
>
|
|
|
<







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
...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
...
605
606
607
608
609
610
611























612
613
614
615
616
617
618
619
....
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
....
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
....
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617


1618
1619
1620
1621
1622
1623
1624
1625

1626
1627
1628
1629
1630
1631
1632
void wiki_srchpage(void){
  login_check_credentials();
  style_header("Wiki Search");
  wiki_standard_submenu(W_HELP|W_LIST|W_SANDBOX);
  search_screen(SRCH_WIKI, 0);
  style_footer();
}

/*
** Add an appropriate style_header() for either the /wiki or /wikiedit page
** for zPageName.
*/
static void wiki_page_header(const char *zPageName, const char *zExtra){
  if( db_get_boolean("wiki-about",1)==0 ){
    style_header("%s%s", zExtra, zPageName);
  }else
  if( sqlite3_strglob("checkin/*", zPageName)==0 
   && db_exists("SELECT 1 FROM blob WHERE uuid=%Q",zPageName+8)
  ){
    style_header("Notes About Checkin %S", zPageName + 8);
    style_submenu_element("Checkin Timeline","%R/timeline?f=%s",zPageName + 8);
    style_submenu_element("Checkin Info","%R/info/%s",zPageName + 8);
  }else
  if( sqlite3_strglob("branch/*", zPageName)==0 ){
    style_header("Notes About Branch %h", zPageName + 7);
    style_submenu_element("Branch Timeline","%R/timeline?r=%t",zPageName + 7);
  }else
  if( sqlite3_strglob("tag/*", zPageName)==0 ){
    style_header("Notes About Tag %h", zPageName + 4);
    style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName + 4);
  }
  else{
    style_header("%s%s", zExtra, zPageName);
  }
}

/*
** WEBPAGE: wiki
** URL: /wiki?name=PAGENAME
*/
void wiki_page(void){
  char *zTag;
................................................................................
    }
    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(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);
................................................................................
    cgi_redirectf("wiki?name=%T", zPageName);
    return;
  }
  if( zBody==0 ){
    zBody = mprintf("<i>Empty Page</i>");
  }
  style_set_current_page("%T?name=%T", g.zPath, zPageName);























  wiki_page_header(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",
................................................................................
}

/*
** Allowed flags for wiki_render_associated
*/
#if INTERFACE
#define WIKIASSOC_FULL_TITLE  0x00001   /* Full title */
#define WIKIASSOC_MENU        0x00002   /* Add a submenu to the About section */
#endif

/*
** Show the default Section label for an associated wiki page.
*/
static void wiki_section_label(
  const char *zPrefix,   /* "branch", "tag", or "checkin" */
................................................................................
    @ <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 for a Wiki page.
*/
static void wiki_section_menu(
  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.WrWiki && (mFlags & WIKIASSOC_MENU)!=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
** return true.
**
** If there is no such wiki page, return false.
................................................................................
    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_section_menu(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_section_menu(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_section_menu(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;
}