Fossil SCM
For wiki pages that are associated with a check-in, branch, or tag, redirect to the associated /info or /timeline page unless the "p" query parameter is present.
Commit
093943d744fac4d337336871c53faa4e3faaf3dd877cb2d06e2fc4f1033b5213
Parent
facc16233b95141…
1 file changed
+37
-16
+37
-16
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -394,40 +394,58 @@ | ||
| 394 | 394 | return WIKITYPE_NORMAL; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | /* |
| 398 | 398 | ** Add an appropriate style_header() for either the /wiki or /wikiedit page |
| 399 | -** for zPageName. | |
| 399 | +** for zPageName. zExtra is an empty string for /wiki but has the text | |
| 400 | +** "Edit: " for /wikiedit. | |
| 401 | +** | |
| 402 | +** If the page is /wiki and the page is one of the special times (check-in, | |
| 403 | +** branch, or tag) and the "p" query parameter is omitted, then do a | |
| 404 | +** redirect to the display of the check-in, branch, or tag rather than | |
| 405 | +** continuing to the plain wiki display. | |
| 400 | 406 | */ |
| 401 | 407 | static int wiki_page_header( |
| 402 | - int eType, /* Page type. -1 for unknown */ | |
| 408 | + int eType, /* Page type. Might be WIKITYPE_UNKNOWN */ | |
| 403 | 409 | const char *zPageName, /* Name of the page */ |
| 404 | 410 | const char *zExtra /* Extra prefix text on the page header */ |
| 405 | 411 | ){ |
| 406 | - if( eType<0 ) eType = wiki_page_type(zPageName); | |
| 412 | + if( eType==WIKITYPE_UNKNOWN ) eType = wiki_page_type(zPageName); | |
| 407 | 413 | switch( eType ){ |
| 408 | 414 | case WIKITYPE_NORMAL: { |
| 409 | 415 | style_header("%s%s", zExtra, zPageName); |
| 410 | 416 | break; |
| 411 | 417 | } |
| 412 | 418 | case WIKITYPE_CHECKIN: { |
| 413 | 419 | zPageName += 8; |
| 414 | - style_header("Notes About Checkin %S", zPageName); | |
| 415 | - style_submenu_element("Checkin Timeline","%R/timeline?f=%s", zPageName); | |
| 416 | - style_submenu_element("Checkin Info","%R/info/%s", zPageName); | |
| 420 | + if( zExtra[0]==0 && !P("p") ){ | |
| 421 | + cgi_redirectf("%R/info/%s",zPageName); | |
| 422 | + }else{ | |
| 423 | + style_header("Notes About Checkin %S", zPageName); | |
| 424 | + style_submenu_element("Checkin Timeline","%R/timeline?f=%s", zPageName); | |
| 425 | + style_submenu_element("Checkin Info","%R/info/%s", zPageName); | |
| 426 | + } | |
| 417 | 427 | break; |
| 418 | 428 | } |
| 419 | 429 | case WIKITYPE_BRANCH: { |
| 420 | 430 | zPageName += 7; |
| 421 | - style_header("Notes About Branch %h", zPageName); | |
| 422 | - style_submenu_element("Branch Timeline","%R/timeline?r=%t", zPageName); | |
| 431 | + if( zExtra[0]==0 && !P("p") ){ | |
| 432 | + cgi_redirectf("%R/timeline?r=%t", zPageName); | |
| 433 | + }else{ | |
| 434 | + style_header("Notes About Branch %h", zPageName); | |
| 435 | + style_submenu_element("Branch Timeline","%R/timeline?r=%t", zPageName); | |
| 436 | + } | |
| 423 | 437 | break; |
| 424 | 438 | } |
| 425 | 439 | case WIKITYPE_TAG: { |
| 426 | 440 | zPageName += 4; |
| 427 | - style_header("Notes About Tag %h", zPageName); | |
| 428 | - style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName); | |
| 441 | + if( zExtra[0]==0 && !P("p") ){ | |
| 442 | + cgi_redirectf("%R/timeline?t=%t",zPageName); | |
| 443 | + }else{ | |
| 444 | + style_header("Notes About Tag %h", zPageName); | |
| 445 | + style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName); | |
| 446 | + } | |
| 429 | 447 | break; |
| 430 | 448 | } |
| 431 | 449 | } |
| 432 | 450 | return eType; |
| 433 | 451 | } |
| @@ -459,11 +477,14 @@ | ||
| 459 | 477 | ** |
| 460 | 478 | ** Query parameters: |
| 461 | 479 | ** |
| 462 | 480 | ** name=NAME Name of the wiki page to display. Required. |
| 463 | 481 | ** nsm Omit the submenu if present. (Mnemonic: No SubMenu) |
| 464 | -** | |
| 482 | +** p Always show just the wiki page. For special | |
| 483 | +** pages for check-ins, branches, or tags, there will | |
| 484 | +** be a redirect to the associated /info page unless | |
| 485 | +** this query parameter is present. | |
| 465 | 486 | */ |
| 466 | 487 | void wiki_page(void){ |
| 467 | 488 | char *zTag; |
| 468 | 489 | int rid = 0; |
| 469 | 490 | int isSandbox; |
| @@ -1724,17 +1745,17 @@ | ||
| 1724 | 1745 | } |
| 1725 | 1746 | |
| 1726 | 1747 | /* |
| 1727 | 1748 | ** Add an "Wiki" button in a submenu that links to the read-wiki page. |
| 1728 | 1749 | */ |
| 1729 | -static void wiki_submenu_to_read_wiki( | |
| 1750 | +static void wiki_submenu_to_edit_wiki( | |
| 1730 | 1751 | const char *zPrefix, /* "branch", "tag", or "checkin" */ |
| 1731 | 1752 | const char *zName, /* Name of the object */ |
| 1732 | 1753 | unsigned int mFlags /* Zero or more WIKIASSOC_* flags */ |
| 1733 | 1754 | ){ |
| 1734 | 1755 | if( g.perm.RdWiki && (mFlags & WIKIASSOC_MENU_READ)!=0 ){ |
| 1735 | - style_submenu_element("Wiki", "%R/wiki?name=%s/%t", zPrefix, zName); | |
| 1756 | + style_submenu_element("Wiki", "%R/wikiedit?name=%s/%t", zPrefix, zName); | |
| 1736 | 1757 | } |
| 1737 | 1758 | } |
| 1738 | 1759 | |
| 1739 | 1760 | /* |
| 1740 | 1761 | ** Check to see if there exists a wiki page with a name zPrefix/zName. |
| @@ -1774,20 +1795,20 @@ | ||
| 1774 | 1795 | if( blob_size(&title) ){ |
| 1775 | 1796 | @ <div class="section">%h(blob_str(&title))</div> |
| 1776 | 1797 | }else{ |
| 1777 | 1798 | wiki_section_label(zPrefix, zName, mFlags); |
| 1778 | 1799 | } |
| 1779 | - wiki_submenu_to_read_wiki(zPrefix, zName, mFlags); | |
| 1800 | + wiki_submenu_to_edit_wiki(zPrefix, zName, mFlags); | |
| 1780 | 1801 | @ <div class="accordion_panel"> |
| 1781 | 1802 | convert_href_and_output(&tail); |
| 1782 | 1803 | @ </div> |
| 1783 | 1804 | blob_reset(&tail); |
| 1784 | 1805 | blob_reset(&title); |
| 1785 | 1806 | blob_reset(&markdown); |
| 1786 | 1807 | }else if( fossil_strcmp(pWiki->zMimetype, "text/plain")==0 ){ |
| 1787 | 1808 | wiki_section_label(zPrefix, zName, mFlags); |
| 1788 | - wiki_submenu_to_read_wiki(zPrefix, zName, mFlags); | |
| 1809 | + wiki_submenu_to_edit_wiki(zPrefix, zName, mFlags); | |
| 1789 | 1810 | @ <div class="accordion_panel"><pre> |
| 1790 | 1811 | @ %h(pWiki->zWiki) |
| 1791 | 1812 | @ </pre></div> |
| 1792 | 1813 | }else{ |
| 1793 | 1814 | Blob tail = BLOB_INITIALIZER; |
| @@ -1800,11 +1821,11 @@ | ||
| 1800 | 1821 | pBody = &tail; |
| 1801 | 1822 | }else{ |
| 1802 | 1823 | wiki_section_label(zPrefix, zName, mFlags); |
| 1803 | 1824 | pBody = &wiki; |
| 1804 | 1825 | } |
| 1805 | - wiki_submenu_to_read_wiki(zPrefix, zName, mFlags); | |
| 1826 | + wiki_submenu_to_edit_wiki(zPrefix, zName, mFlags); | |
| 1806 | 1827 | @ <div class="accordion_panel"><div class="wiki"> |
| 1807 | 1828 | wiki_convert(pBody, 0, WIKI_BUTTONS); |
| 1808 | 1829 | @ </div></div> |
| 1809 | 1830 | blob_reset(&tail); |
| 1810 | 1831 | blob_reset(&title); |
| 1811 | 1832 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -394,40 +394,58 @@ | |
| 394 | return WIKITYPE_NORMAL; |
| 395 | } |
| 396 | |
| 397 | /* |
| 398 | ** Add an appropriate style_header() for either the /wiki or /wikiedit page |
| 399 | ** for zPageName. |
| 400 | */ |
| 401 | static int wiki_page_header( |
| 402 | int eType, /* Page type. -1 for unknown */ |
| 403 | const char *zPageName, /* Name of the page */ |
| 404 | const char *zExtra /* Extra prefix text on the page header */ |
| 405 | ){ |
| 406 | if( eType<0 ) eType = wiki_page_type(zPageName); |
| 407 | switch( eType ){ |
| 408 | case WIKITYPE_NORMAL: { |
| 409 | style_header("%s%s", zExtra, zPageName); |
| 410 | break; |
| 411 | } |
| 412 | case WIKITYPE_CHECKIN: { |
| 413 | zPageName += 8; |
| 414 | style_header("Notes About Checkin %S", zPageName); |
| 415 | style_submenu_element("Checkin Timeline","%R/timeline?f=%s", zPageName); |
| 416 | style_submenu_element("Checkin Info","%R/info/%s", zPageName); |
| 417 | break; |
| 418 | } |
| 419 | case WIKITYPE_BRANCH: { |
| 420 | zPageName += 7; |
| 421 | style_header("Notes About Branch %h", zPageName); |
| 422 | style_submenu_element("Branch Timeline","%R/timeline?r=%t", zPageName); |
| 423 | break; |
| 424 | } |
| 425 | case WIKITYPE_TAG: { |
| 426 | zPageName += 4; |
| 427 | style_header("Notes About Tag %h", zPageName); |
| 428 | style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName); |
| 429 | break; |
| 430 | } |
| 431 | } |
| 432 | return eType; |
| 433 | } |
| @@ -459,11 +477,14 @@ | |
| 459 | ** |
| 460 | ** Query parameters: |
| 461 | ** |
| 462 | ** name=NAME Name of the wiki page to display. Required. |
| 463 | ** nsm Omit the submenu if present. (Mnemonic: No SubMenu) |
| 464 | ** |
| 465 | */ |
| 466 | void wiki_page(void){ |
| 467 | char *zTag; |
| 468 | int rid = 0; |
| 469 | int isSandbox; |
| @@ -1724,17 +1745,17 @@ | |
| 1724 | } |
| 1725 | |
| 1726 | /* |
| 1727 | ** Add an "Wiki" button in a submenu that links to the read-wiki page. |
| 1728 | */ |
| 1729 | static void wiki_submenu_to_read_wiki( |
| 1730 | const char *zPrefix, /* "branch", "tag", or "checkin" */ |
| 1731 | const char *zName, /* Name of the object */ |
| 1732 | unsigned int mFlags /* Zero or more WIKIASSOC_* flags */ |
| 1733 | ){ |
| 1734 | if( g.perm.RdWiki && (mFlags & WIKIASSOC_MENU_READ)!=0 ){ |
| 1735 | style_submenu_element("Wiki", "%R/wiki?name=%s/%t", zPrefix, zName); |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | /* |
| 1740 | ** Check to see if there exists a wiki page with a name zPrefix/zName. |
| @@ -1774,20 +1795,20 @@ | |
| 1774 | if( blob_size(&title) ){ |
| 1775 | @ <div class="section">%h(blob_str(&title))</div> |
| 1776 | }else{ |
| 1777 | wiki_section_label(zPrefix, zName, mFlags); |
| 1778 | } |
| 1779 | wiki_submenu_to_read_wiki(zPrefix, zName, mFlags); |
| 1780 | @ <div class="accordion_panel"> |
| 1781 | convert_href_and_output(&tail); |
| 1782 | @ </div> |
| 1783 | blob_reset(&tail); |
| 1784 | blob_reset(&title); |
| 1785 | blob_reset(&markdown); |
| 1786 | }else if( fossil_strcmp(pWiki->zMimetype, "text/plain")==0 ){ |
| 1787 | wiki_section_label(zPrefix, zName, mFlags); |
| 1788 | wiki_submenu_to_read_wiki(zPrefix, zName, mFlags); |
| 1789 | @ <div class="accordion_panel"><pre> |
| 1790 | @ %h(pWiki->zWiki) |
| 1791 | @ </pre></div> |
| 1792 | }else{ |
| 1793 | Blob tail = BLOB_INITIALIZER; |
| @@ -1800,11 +1821,11 @@ | |
| 1800 | pBody = &tail; |
| 1801 | }else{ |
| 1802 | wiki_section_label(zPrefix, zName, mFlags); |
| 1803 | pBody = &wiki; |
| 1804 | } |
| 1805 | wiki_submenu_to_read_wiki(zPrefix, zName, mFlags); |
| 1806 | @ <div class="accordion_panel"><div class="wiki"> |
| 1807 | wiki_convert(pBody, 0, WIKI_BUTTONS); |
| 1808 | @ </div></div> |
| 1809 | blob_reset(&tail); |
| 1810 | blob_reset(&title); |
| 1811 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -394,40 +394,58 @@ | |
| 394 | return WIKITYPE_NORMAL; |
| 395 | } |
| 396 | |
| 397 | /* |
| 398 | ** Add an appropriate style_header() for either the /wiki or /wikiedit page |
| 399 | ** for zPageName. zExtra is an empty string for /wiki but has the text |
| 400 | ** "Edit: " for /wikiedit. |
| 401 | ** |
| 402 | ** If the page is /wiki and the page is one of the special times (check-in, |
| 403 | ** branch, or tag) and the "p" query parameter is omitted, then do a |
| 404 | ** redirect to the display of the check-in, branch, or tag rather than |
| 405 | ** continuing to the plain wiki display. |
| 406 | */ |
| 407 | static int wiki_page_header( |
| 408 | int eType, /* Page type. Might be WIKITYPE_UNKNOWN */ |
| 409 | const char *zPageName, /* Name of the page */ |
| 410 | const char *zExtra /* Extra prefix text on the page header */ |
| 411 | ){ |
| 412 | if( eType==WIKITYPE_UNKNOWN ) eType = wiki_page_type(zPageName); |
| 413 | switch( eType ){ |
| 414 | case WIKITYPE_NORMAL: { |
| 415 | style_header("%s%s", zExtra, zPageName); |
| 416 | break; |
| 417 | } |
| 418 | case WIKITYPE_CHECKIN: { |
| 419 | zPageName += 8; |
| 420 | if( zExtra[0]==0 && !P("p") ){ |
| 421 | cgi_redirectf("%R/info/%s",zPageName); |
| 422 | }else{ |
| 423 | style_header("Notes About Checkin %S", zPageName); |
| 424 | style_submenu_element("Checkin Timeline","%R/timeline?f=%s", zPageName); |
| 425 | style_submenu_element("Checkin Info","%R/info/%s", zPageName); |
| 426 | } |
| 427 | break; |
| 428 | } |
| 429 | case WIKITYPE_BRANCH: { |
| 430 | zPageName += 7; |
| 431 | if( zExtra[0]==0 && !P("p") ){ |
| 432 | cgi_redirectf("%R/timeline?r=%t", zPageName); |
| 433 | }else{ |
| 434 | style_header("Notes About Branch %h", zPageName); |
| 435 | style_submenu_element("Branch Timeline","%R/timeline?r=%t", zPageName); |
| 436 | } |
| 437 | break; |
| 438 | } |
| 439 | case WIKITYPE_TAG: { |
| 440 | zPageName += 4; |
| 441 | if( zExtra[0]==0 && !P("p") ){ |
| 442 | cgi_redirectf("%R/timeline?t=%t",zPageName); |
| 443 | }else{ |
| 444 | style_header("Notes About Tag %h", zPageName); |
| 445 | style_submenu_element("Tag Timeline","%R/timeline?t=%t",zPageName); |
| 446 | } |
| 447 | break; |
| 448 | } |
| 449 | } |
| 450 | return eType; |
| 451 | } |
| @@ -459,11 +477,14 @@ | |
| 477 | ** |
| 478 | ** Query parameters: |
| 479 | ** |
| 480 | ** name=NAME Name of the wiki page to display. Required. |
| 481 | ** nsm Omit the submenu if present. (Mnemonic: No SubMenu) |
| 482 | ** p Always show just the wiki page. For special |
| 483 | ** pages for check-ins, branches, or tags, there will |
| 484 | ** be a redirect to the associated /info page unless |
| 485 | ** this query parameter is present. |
| 486 | */ |
| 487 | void wiki_page(void){ |
| 488 | char *zTag; |
| 489 | int rid = 0; |
| 490 | int isSandbox; |
| @@ -1724,17 +1745,17 @@ | |
| 1745 | } |
| 1746 | |
| 1747 | /* |
| 1748 | ** Add an "Wiki" button in a submenu that links to the read-wiki page. |
| 1749 | */ |
| 1750 | static void wiki_submenu_to_edit_wiki( |
| 1751 | const char *zPrefix, /* "branch", "tag", or "checkin" */ |
| 1752 | const char *zName, /* Name of the object */ |
| 1753 | unsigned int mFlags /* Zero or more WIKIASSOC_* flags */ |
| 1754 | ){ |
| 1755 | if( g.perm.RdWiki && (mFlags & WIKIASSOC_MENU_READ)!=0 ){ |
| 1756 | style_submenu_element("Wiki", "%R/wikiedit?name=%s/%t", zPrefix, zName); |
| 1757 | } |
| 1758 | } |
| 1759 | |
| 1760 | /* |
| 1761 | ** Check to see if there exists a wiki page with a name zPrefix/zName. |
| @@ -1774,20 +1795,20 @@ | |
| 1795 | if( blob_size(&title) ){ |
| 1796 | @ <div class="section">%h(blob_str(&title))</div> |
| 1797 | }else{ |
| 1798 | wiki_section_label(zPrefix, zName, mFlags); |
| 1799 | } |
| 1800 | wiki_submenu_to_edit_wiki(zPrefix, zName, mFlags); |
| 1801 | @ <div class="accordion_panel"> |
| 1802 | convert_href_and_output(&tail); |
| 1803 | @ </div> |
| 1804 | blob_reset(&tail); |
| 1805 | blob_reset(&title); |
| 1806 | blob_reset(&markdown); |
| 1807 | }else if( fossil_strcmp(pWiki->zMimetype, "text/plain")==0 ){ |
| 1808 | wiki_section_label(zPrefix, zName, mFlags); |
| 1809 | wiki_submenu_to_edit_wiki(zPrefix, zName, mFlags); |
| 1810 | @ <div class="accordion_panel"><pre> |
| 1811 | @ %h(pWiki->zWiki) |
| 1812 | @ </pre></div> |
| 1813 | }else{ |
| 1814 | Blob tail = BLOB_INITIALIZER; |
| @@ -1800,11 +1821,11 @@ | |
| 1821 | pBody = &tail; |
| 1822 | }else{ |
| 1823 | wiki_section_label(zPrefix, zName, mFlags); |
| 1824 | pBody = &wiki; |
| 1825 | } |
| 1826 | wiki_submenu_to_edit_wiki(zPrefix, zName, mFlags); |
| 1827 | @ <div class="accordion_panel"><div class="wiki"> |
| 1828 | wiki_convert(pBody, 0, WIKI_BUTTONS); |
| 1829 | @ </div></div> |
| 1830 | blob_reset(&tail); |
| 1831 | blob_reset(&title); |
| 1832 |