Fossil SCM
Added links to the wiki page's add-attachment and list-attachment pages.
Commit
01ab9241554e0700fff089644b2abf58852c924392c319037417ccb8c2c27004
Parent
63376a80fcdf3d7…
2 files changed
+35
-1
+26
-15
+35
-1
| --- src/fossil.page.wikiedit.js | ||
| +++ src/fossil.page.wikiedit.js | ||
| @@ -423,10 +423,11 @@ | ||
| 423 | 423 | selectFontSizeWrap: E('#select-font-size'), |
| 424 | 424 | // selectDiffWS: E('select[name=diff_ws]'), |
| 425 | 425 | cbAutoPreview: E('#cb-preview-autoupdate > input[type=checkbox]'), |
| 426 | 426 | previewTarget: E('#wikiedit-tab-preview-wrapper'), |
| 427 | 427 | diffTarget: E('#wikiedit-tab-diff-wrapper'), |
| 428 | + attachmentWrapper: E("#wikiedit-attachments"), | |
| 428 | 429 | tabs:{ |
| 429 | 430 | pageList: E('#wikiedit-tab-pages'), |
| 430 | 431 | content: E('#wikiedit-tab-content'), |
| 431 | 432 | preview: E('#wikiedit-tab-preview'), |
| 432 | 433 | diff: E('#wikiedit-tab-diff'), |
| @@ -601,14 +602,15 @@ | ||
| 601 | 602 | P.wikiContent(winfo.content || ''); |
| 602 | 603 | WikiList.e.select.value = winfo.name; |
| 603 | 604 | if(!winfo.version && winfo.type!=='sandbox'){ |
| 604 | 605 | F.error('You are editing a new, unsaved page:',winfo.name); |
| 605 | 606 | } |
| 606 | - P.updatePageTitle(); | |
| 607 | + P.updateAttachmentView().updatePageTitle(); | |
| 607 | 608 | }, |
| 608 | 609 | false |
| 609 | 610 | ); |
| 611 | + P.updateAttachmentView(); | |
| 610 | 612 | }/*F.onPageLoad()*/); |
| 611 | 613 | |
| 612 | 614 | /** |
| 613 | 615 | Returns true if fossil.page.winfo is set, indicating that a page |
| 614 | 616 | has been loaded, else it reports an error and returns false. |
| @@ -641,10 +643,42 @@ | ||
| 641 | 643 | title = title.join(' '); |
| 642 | 644 | f.titleElement.innerText = title; |
| 643 | 645 | f.pageTitleHeader.innerText = title; |
| 644 | 646 | return this; |
| 645 | 647 | }; |
| 648 | + | |
| 649 | + /** Updates attachment-related links and returns this. */ | |
| 650 | + P.updateAttachmentView = function(){ | |
| 651 | + const wrapper = P.e.attachmentWrapper; | |
| 652 | + D.clearElement(wrapper); | |
| 653 | + const ul = D.ul(); | |
| 654 | + D.append(wrapper, ul); | |
| 655 | + if(!P.winfo){ | |
| 656 | + D.append(D.li(ul), "No page loaded."); | |
| 657 | + return this; | |
| 658 | + }else if(!P.winfo.version){ | |
| 659 | + D.append(D.li(ul), "A new/unsaved page cannot have attachments."); | |
| 660 | + return this; | |
| 661 | + } | |
| 662 | + const wi = P.winfo; | |
| 663 | + D.append( | |
| 664 | + D.li(ul), | |
| 665 | + D.a(F.repoUrl('attachadd',{ | |
| 666 | + page:wi.name, | |
| 667 | + from: F.repoUrl('wikiedit',{ | |
| 668 | + name: wi.name | |
| 669 | + }) | |
| 670 | + }), "Add attachments.") | |
| 671 | + ); | |
| 672 | + D.append( | |
| 673 | + D.li(ul), | |
| 674 | + D.a(F.repoUrl('attachlist',{page:wi.name}), | |
| 675 | + "List attachments"), | |
| 676 | + " (if any)." | |
| 677 | + ); | |
| 678 | + return this; | |
| 679 | + }; | |
| 646 | 680 | |
| 647 | 681 | /** |
| 648 | 682 | Getter (if called with no args) or setter (if passed an arg) for |
| 649 | 683 | the current file content. |
| 650 | 684 | |
| 651 | 685 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -423,10 +423,11 @@ | |
| 423 | selectFontSizeWrap: E('#select-font-size'), |
| 424 | // selectDiffWS: E('select[name=diff_ws]'), |
| 425 | cbAutoPreview: E('#cb-preview-autoupdate > input[type=checkbox]'), |
| 426 | previewTarget: E('#wikiedit-tab-preview-wrapper'), |
| 427 | diffTarget: E('#wikiedit-tab-diff-wrapper'), |
| 428 | tabs:{ |
| 429 | pageList: E('#wikiedit-tab-pages'), |
| 430 | content: E('#wikiedit-tab-content'), |
| 431 | preview: E('#wikiedit-tab-preview'), |
| 432 | diff: E('#wikiedit-tab-diff'), |
| @@ -601,14 +602,15 @@ | |
| 601 | P.wikiContent(winfo.content || ''); |
| 602 | WikiList.e.select.value = winfo.name; |
| 603 | if(!winfo.version && winfo.type!=='sandbox'){ |
| 604 | F.error('You are editing a new, unsaved page:',winfo.name); |
| 605 | } |
| 606 | P.updatePageTitle(); |
| 607 | }, |
| 608 | false |
| 609 | ); |
| 610 | }/*F.onPageLoad()*/); |
| 611 | |
| 612 | /** |
| 613 | Returns true if fossil.page.winfo is set, indicating that a page |
| 614 | has been loaded, else it reports an error and returns false. |
| @@ -641,10 +643,42 @@ | |
| 641 | title = title.join(' '); |
| 642 | f.titleElement.innerText = title; |
| 643 | f.pageTitleHeader.innerText = title; |
| 644 | return this; |
| 645 | }; |
| 646 | |
| 647 | /** |
| 648 | Getter (if called with no args) or setter (if passed an arg) for |
| 649 | the current file content. |
| 650 | |
| 651 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -423,10 +423,11 @@ | |
| 423 | selectFontSizeWrap: E('#select-font-size'), |
| 424 | // selectDiffWS: E('select[name=diff_ws]'), |
| 425 | cbAutoPreview: E('#cb-preview-autoupdate > input[type=checkbox]'), |
| 426 | previewTarget: E('#wikiedit-tab-preview-wrapper'), |
| 427 | diffTarget: E('#wikiedit-tab-diff-wrapper'), |
| 428 | attachmentWrapper: E("#wikiedit-attachments"), |
| 429 | tabs:{ |
| 430 | pageList: E('#wikiedit-tab-pages'), |
| 431 | content: E('#wikiedit-tab-content'), |
| 432 | preview: E('#wikiedit-tab-preview'), |
| 433 | diff: E('#wikiedit-tab-diff'), |
| @@ -601,14 +602,15 @@ | |
| 602 | P.wikiContent(winfo.content || ''); |
| 603 | WikiList.e.select.value = winfo.name; |
| 604 | if(!winfo.version && winfo.type!=='sandbox'){ |
| 605 | F.error('You are editing a new, unsaved page:',winfo.name); |
| 606 | } |
| 607 | P.updateAttachmentView().updatePageTitle(); |
| 608 | }, |
| 609 | false |
| 610 | ); |
| 611 | P.updateAttachmentView(); |
| 612 | }/*F.onPageLoad()*/); |
| 613 | |
| 614 | /** |
| 615 | Returns true if fossil.page.winfo is set, indicating that a page |
| 616 | has been loaded, else it reports an error and returns false. |
| @@ -641,10 +643,42 @@ | |
| 643 | title = title.join(' '); |
| 644 | f.titleElement.innerText = title; |
| 645 | f.pageTitleHeader.innerText = title; |
| 646 | return this; |
| 647 | }; |
| 648 | |
| 649 | /** Updates attachment-related links and returns this. */ |
| 650 | P.updateAttachmentView = function(){ |
| 651 | const wrapper = P.e.attachmentWrapper; |
| 652 | D.clearElement(wrapper); |
| 653 | const ul = D.ul(); |
| 654 | D.append(wrapper, ul); |
| 655 | if(!P.winfo){ |
| 656 | D.append(D.li(ul), "No page loaded."); |
| 657 | return this; |
| 658 | }else if(!P.winfo.version){ |
| 659 | D.append(D.li(ul), "A new/unsaved page cannot have attachments."); |
| 660 | return this; |
| 661 | } |
| 662 | const wi = P.winfo; |
| 663 | D.append( |
| 664 | D.li(ul), |
| 665 | D.a(F.repoUrl('attachadd',{ |
| 666 | page:wi.name, |
| 667 | from: F.repoUrl('wikiedit',{ |
| 668 | name: wi.name |
| 669 | }) |
| 670 | }), "Add attachments.") |
| 671 | ); |
| 672 | D.append( |
| 673 | D.li(ul), |
| 674 | D.a(F.repoUrl('attachlist',{page:wi.name}), |
| 675 | "List attachments"), |
| 676 | " (if any)." |
| 677 | ); |
| 678 | return this; |
| 679 | }; |
| 680 | |
| 681 | /** |
| 682 | Getter (if called with no args) or setter (if passed an arg) for |
| 683 | the current file content. |
| 684 | |
| 685 |
+26
-15
| --- src/wiki.c | ||
| +++ src/wiki.c | ||
| @@ -803,10 +803,17 @@ | ||
| 803 | 803 | ** ajax_route_error(). On success, an object in the form documented |
| 804 | 804 | ** for wiki_ajax_emit_page_object(). |
| 805 | 805 | ** |
| 806 | 806 | ** The wikiajax API disallows saving of a sandbox pseudo-page, and |
| 807 | 807 | ** will respond with an error if asked to save one. |
| 808 | +** | |
| 809 | +** Reminder: the original implementation implements sandbox-page | |
| 810 | +** saving using: | |
| 811 | +** | |
| 812 | +** db_set("sandbox",zBody,0); | |
| 813 | +** db_set("sandbox-mimetype",zMimetype,0); | |
| 814 | +** | |
| 808 | 815 | */ |
| 809 | 816 | static void wiki_ajax_route_save(void){ |
| 810 | 817 | const char *zPageName = P("page"); |
| 811 | 818 | const char *zMimetype = P("mimetype"); |
| 812 | 819 | const char *zContent = P("content"); |
| @@ -1025,21 +1032,24 @@ | ||
| 1025 | 1032 | } |
| 1026 | 1033 | pRoute->xCallback(); |
| 1027 | 1034 | } |
| 1028 | 1035 | |
| 1029 | 1036 | /* |
| 1030 | -** Main front-end for the Ajax-based wiki editor app. | |
| 1031 | -** | |
| 1032 | -** Optional URL arguments: | |
| 1033 | -** | |
| 1034 | -** name = wiki page name. Note that Ajax-based "v2" APIs use "page" | |
| 1035 | -** instead because "name" has a special meaning for fossil. | |
| 1036 | -** | |
| 1037 | -** mimetype=fossil-standard mimetype. This is typically only passed in | |
| 1038 | -** via the new-page process. | |
| 1037 | +** WEBPAGE: wikiedit | |
| 1038 | +** URL: /wikedit?name=PAGENAME | |
| 1039 | +** | |
| 1040 | +** The main front-end for the Ajax-based wiki editor app. Passing | |
| 1041 | +** in the name of an unknown page will trigger the creation | |
| 1042 | +** of a new page (which is not actually created in the database | |
| 1043 | +** until the user explicitly saves it). If passed no page name, | |
| 1044 | +** the user may select a page from the list on the first UI tab. | |
| 1045 | +** | |
| 1046 | +** To create a new page, pass both name=PAGENAME and | |
| 1047 | +** mimetype=wiki-mime-type (one of text/x-fossil-wiki, | |
| 1048 | +** text/x-markdown, or text/plain, defauling to the former). | |
| 1039 | 1049 | */ |
| 1040 | -static void wikiedit_page_v2(void){ | |
| 1050 | +void wikiedit_page_v2(void){ | |
| 1041 | 1051 | const char *zPageName; |
| 1042 | 1052 | const char * zMimetype = P("mimetype"); |
| 1043 | 1053 | int isSandbox; |
| 1044 | 1054 | int found = 0; |
| 1045 | 1055 | |
| @@ -1190,10 +1200,13 @@ | ||
| 1190 | 1200 | CX("The wiki formatting rules can be found at:"); |
| 1191 | 1201 | CX("<ul>"); |
| 1192 | 1202 | CX("<li><a href='%R/wiki_rules'>Fossil wiki format</a></li>"); |
| 1193 | 1203 | CX("<li><a href='%R/md_rules'>Markdown format</a></li>"); |
| 1194 | 1204 | CX("</ul>"); |
| 1205 | + CX("<hr>Attachments:"); | |
| 1206 | + CX("<div id='wikiedit-attachments'></div>" | |
| 1207 | + /* Filled out by JS */); | |
| 1195 | 1208 | CX("</div>"); |
| 1196 | 1209 | } |
| 1197 | 1210 | |
| 1198 | 1211 | style_emit_script_fossil_bootstrap(0); |
| 1199 | 1212 | append_diff_javascript(1); |
| @@ -1236,14 +1249,12 @@ | ||
| 1236 | 1249 | style_emit_script_tag(1,0); |
| 1237 | 1250 | style_footer(); |
| 1238 | 1251 | } |
| 1239 | 1252 | |
| 1240 | 1253 | /* |
| 1241 | -** WEBPAGE: wikiedit | |
| 1242 | -** URL: /wikiedit?name=PAGENAME | |
| 1243 | -** | |
| 1244 | -** Edit a wiki page. | |
| 1254 | +** Legacy /wikiedit implementation, kept around solely for comparison | |
| 1255 | +** while implementing v2. | |
| 1245 | 1256 | */ |
| 1246 | 1257 | void wikiedit_page(void){ |
| 1247 | 1258 | char *zTag; |
| 1248 | 1259 | int rid = 0; |
| 1249 | 1260 | int isSandbox; |
| @@ -2060,11 +2071,11 @@ | ||
| 2060 | 2071 | ** -M|--mimetype TEXT-FORMAT The mime type of the update. |
| 2061 | 2072 | ** Defaults to the type used by |
| 2062 | 2073 | ** the previous version of the |
| 2063 | 2074 | ** page, or text/x-fossil-wiki. |
| 2064 | 2075 | ** Valid values are: text/x-fossil-wiki, |
| 2065 | -** text/markdown and text/plain. fossil, | |
| 2076 | +** text/x-markdown and text/plain. fossil, | |
| 2066 | 2077 | ** markdown or plain can be specified as |
| 2067 | 2078 | ** synonyms of these values. |
| 2068 | 2079 | ** -t|--technote DATETIME Specifies the timestamp of |
| 2069 | 2080 | ** the technote to be created or |
| 2070 | 2081 | ** updated. When updating a tech note |
| 2071 | 2082 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -803,10 +803,17 @@ | |
| 803 | ** ajax_route_error(). On success, an object in the form documented |
| 804 | ** for wiki_ajax_emit_page_object(). |
| 805 | ** |
| 806 | ** The wikiajax API disallows saving of a sandbox pseudo-page, and |
| 807 | ** will respond with an error if asked to save one. |
| 808 | */ |
| 809 | static void wiki_ajax_route_save(void){ |
| 810 | const char *zPageName = P("page"); |
| 811 | const char *zMimetype = P("mimetype"); |
| 812 | const char *zContent = P("content"); |
| @@ -1025,21 +1032,24 @@ | |
| 1025 | } |
| 1026 | pRoute->xCallback(); |
| 1027 | } |
| 1028 | |
| 1029 | /* |
| 1030 | ** Main front-end for the Ajax-based wiki editor app. |
| 1031 | ** |
| 1032 | ** Optional URL arguments: |
| 1033 | ** |
| 1034 | ** name = wiki page name. Note that Ajax-based "v2" APIs use "page" |
| 1035 | ** instead because "name" has a special meaning for fossil. |
| 1036 | ** |
| 1037 | ** mimetype=fossil-standard mimetype. This is typically only passed in |
| 1038 | ** via the new-page process. |
| 1039 | */ |
| 1040 | static void wikiedit_page_v2(void){ |
| 1041 | const char *zPageName; |
| 1042 | const char * zMimetype = P("mimetype"); |
| 1043 | int isSandbox; |
| 1044 | int found = 0; |
| 1045 | |
| @@ -1190,10 +1200,13 @@ | |
| 1190 | CX("The wiki formatting rules can be found at:"); |
| 1191 | CX("<ul>"); |
| 1192 | CX("<li><a href='%R/wiki_rules'>Fossil wiki format</a></li>"); |
| 1193 | CX("<li><a href='%R/md_rules'>Markdown format</a></li>"); |
| 1194 | CX("</ul>"); |
| 1195 | CX("</div>"); |
| 1196 | } |
| 1197 | |
| 1198 | style_emit_script_fossil_bootstrap(0); |
| 1199 | append_diff_javascript(1); |
| @@ -1236,14 +1249,12 @@ | |
| 1236 | style_emit_script_tag(1,0); |
| 1237 | style_footer(); |
| 1238 | } |
| 1239 | |
| 1240 | /* |
| 1241 | ** WEBPAGE: wikiedit |
| 1242 | ** URL: /wikiedit?name=PAGENAME |
| 1243 | ** |
| 1244 | ** Edit a wiki page. |
| 1245 | */ |
| 1246 | void wikiedit_page(void){ |
| 1247 | char *zTag; |
| 1248 | int rid = 0; |
| 1249 | int isSandbox; |
| @@ -2060,11 +2071,11 @@ | |
| 2060 | ** -M|--mimetype TEXT-FORMAT The mime type of the update. |
| 2061 | ** Defaults to the type used by |
| 2062 | ** the previous version of the |
| 2063 | ** page, or text/x-fossil-wiki. |
| 2064 | ** Valid values are: text/x-fossil-wiki, |
| 2065 | ** text/markdown and text/plain. fossil, |
| 2066 | ** markdown or plain can be specified as |
| 2067 | ** synonyms of these values. |
| 2068 | ** -t|--technote DATETIME Specifies the timestamp of |
| 2069 | ** the technote to be created or |
| 2070 | ** updated. When updating a tech note |
| 2071 |
| --- src/wiki.c | |
| +++ src/wiki.c | |
| @@ -803,10 +803,17 @@ | |
| 803 | ** ajax_route_error(). On success, an object in the form documented |
| 804 | ** for wiki_ajax_emit_page_object(). |
| 805 | ** |
| 806 | ** The wikiajax API disallows saving of a sandbox pseudo-page, and |
| 807 | ** will respond with an error if asked to save one. |
| 808 | ** |
| 809 | ** Reminder: the original implementation implements sandbox-page |
| 810 | ** saving using: |
| 811 | ** |
| 812 | ** db_set("sandbox",zBody,0); |
| 813 | ** db_set("sandbox-mimetype",zMimetype,0); |
| 814 | ** |
| 815 | */ |
| 816 | static void wiki_ajax_route_save(void){ |
| 817 | const char *zPageName = P("page"); |
| 818 | const char *zMimetype = P("mimetype"); |
| 819 | const char *zContent = P("content"); |
| @@ -1025,21 +1032,24 @@ | |
| 1032 | } |
| 1033 | pRoute->xCallback(); |
| 1034 | } |
| 1035 | |
| 1036 | /* |
| 1037 | ** WEBPAGE: wikiedit |
| 1038 | ** URL: /wikedit?name=PAGENAME |
| 1039 | ** |
| 1040 | ** The main front-end for the Ajax-based wiki editor app. Passing |
| 1041 | ** in the name of an unknown page will trigger the creation |
| 1042 | ** of a new page (which is not actually created in the database |
| 1043 | ** until the user explicitly saves it). If passed no page name, |
| 1044 | ** the user may select a page from the list on the first UI tab. |
| 1045 | ** |
| 1046 | ** To create a new page, pass both name=PAGENAME and |
| 1047 | ** mimetype=wiki-mime-type (one of text/x-fossil-wiki, |
| 1048 | ** text/x-markdown, or text/plain, defauling to the former). |
| 1049 | */ |
| 1050 | void wikiedit_page_v2(void){ |
| 1051 | const char *zPageName; |
| 1052 | const char * zMimetype = P("mimetype"); |
| 1053 | int isSandbox; |
| 1054 | int found = 0; |
| 1055 | |
| @@ -1190,10 +1200,13 @@ | |
| 1200 | CX("The wiki formatting rules can be found at:"); |
| 1201 | CX("<ul>"); |
| 1202 | CX("<li><a href='%R/wiki_rules'>Fossil wiki format</a></li>"); |
| 1203 | CX("<li><a href='%R/md_rules'>Markdown format</a></li>"); |
| 1204 | CX("</ul>"); |
| 1205 | CX("<hr>Attachments:"); |
| 1206 | CX("<div id='wikiedit-attachments'></div>" |
| 1207 | /* Filled out by JS */); |
| 1208 | CX("</div>"); |
| 1209 | } |
| 1210 | |
| 1211 | style_emit_script_fossil_bootstrap(0); |
| 1212 | append_diff_javascript(1); |
| @@ -1236,14 +1249,12 @@ | |
| 1249 | style_emit_script_tag(1,0); |
| 1250 | style_footer(); |
| 1251 | } |
| 1252 | |
| 1253 | /* |
| 1254 | ** Legacy /wikiedit implementation, kept around solely for comparison |
| 1255 | ** while implementing v2. |
| 1256 | */ |
| 1257 | void wikiedit_page(void){ |
| 1258 | char *zTag; |
| 1259 | int rid = 0; |
| 1260 | int isSandbox; |
| @@ -2060,11 +2071,11 @@ | |
| 2071 | ** -M|--mimetype TEXT-FORMAT The mime type of the update. |
| 2072 | ** Defaults to the type used by |
| 2073 | ** the previous version of the |
| 2074 | ** page, or text/x-fossil-wiki. |
| 2075 | ** Valid values are: text/x-fossil-wiki, |
| 2076 | ** text/x-markdown and text/plain. fossil, |
| 2077 | ** markdown or plain can be specified as |
| 2078 | ** synonyms of these values. |
| 2079 | ** -t|--technote DATETIME Specifies the timestamp of |
| 2080 | ** the technote to be created or |
| 2081 | ** updated. When updating a tech note |
| 2082 |