@@ -19,6 +19,7 @@ import (
1919)
2020
2121var wikiFrameHandlers = map [string ]func (* wikiRequest ){
22+ // "switch-branch": handleSwitchBranchFrame,
2223 "dashboard" : handleDashboardFrame ,
2324 "pages" : handlePagesFrame ,
2425 "pages/" : handlePagesFrame ,
@@ -31,14 +32,13 @@ var wikiFrameHandlers = map[string]func(*wikiRequest){
3132 "edit-page" : handleEditPageFrame ,
3233 "edit-category" : handleEditCategoryFrame ,
3334 "edit-model" : handleEditModelFrame ,
34- "switch-branch" : handleSwitchBranchFrame ,
3535 "help" : handleWikiHelpFrame ,
3636 "help/" : handleWikiHelpFrame ,
3737}
3838
3939var wikiFuncHandlers = map [string ]func (* wikiRequest ){
40- "switch-branch/" : handleSwitchBranch ,
41- "create-branch" : handleCreateBranch ,
40+ // "switch-branch/": handleSwitchBranch,
41+ // "create-branch": handleCreateBranch,
4242 "write-page" : handleWritePage ,
4343 "write-model" : handleWriteModel ,
4444 "write-config" : handleWriteWikiConfig ,
@@ -146,12 +146,13 @@ func setupWikiHandlers(shortcode string, wi *webserver.WikiInfo) {
146146 }
147147 dot = wr
148148
149- // possibly switch wikis
150- switchUserWiki (wr , wi )
151- if wr .err != nil {
152- // FIXME: don't panic
153- panic (wr .err )
154- }
149+ wr .wi = wi
150+ // DISABLED: possibly switch wikis
151+ // switchUserWiki(wr, wi)
152+ // if wr.err != nil {
153+ // // FIXME: don't panic
154+ // panic(wr.err)
155+ // }
155156
156157 // call handler
157158 handler (wr )
@@ -210,12 +211,13 @@ func setupWikiHandlers(shortcode string, wi *webserver.WikiInfo) {
210211 r : r ,
211212 }
212213
213- // possibly switch wikis
214- switchUserWiki (wr , wi )
215- if wr .err != nil {
216- // FIXME: don't panic
217- panic (wr .err )
218- }
214+ wr .wi = wi
215+ // DISABLED: possibly switch wikis
216+ // switchUserWiki(wr, wi)
217+ // if wr.err != nil {
218+ // // FIXME: don't panic
219+ // panic(wr.err)
220+ // }
219221
220222 // call handler
221223 handler (wr )
@@ -520,76 +522,6 @@ func handleEditor(wr *wikiRequest, path, file, title string, o editorOpts) {
520522 }
521523}
522524
523- func handleSwitchBranchFrame (wr * wikiRequest ) {
524- branches , err := wr .wi .BranchNames ()
525- if err != nil {
526- wr .err = err
527- return
528- }
529- wr .dot = struct {
530- Branches []string
531- wikiTemplate
532- }{
533- Branches : branches ,
534- wikiTemplate : getGenericTemplate (wr ),
535- }
536- }
537-
538- func handleSwitchBranch (wr * wikiRequest ) {
539- branchName := strings .TrimPrefix (wr .r .URL .Path , wr .wikiRoot + "func/switch-branch/" )
540- if branchName == "" {
541- wr .err = errors .New ("no branch selected" )
542- return
543- }
544-
545- // bad branch name
546- if ! wiki .ValidBranchName (branchName ) {
547- wr .err = errors .New ("invalid branch name: " + branchName )
548- return
549- }
550-
551- // fetch the branch
552- _ , wr .err = wr .wi .Branch (branchName )
553- if wr .err != nil {
554- return
555- }
556-
557- // set branch
558- sessMgr .Put (wr .r .Context (), "branch" , branchName )
559-
560- // TODO: when this request is submitted by JS, the UI can just reload
561- // the current frame so the user stays on the same page, just in new branch
562-
563- // redirect back to dashboard
564- http .Redirect (wr .w , wr .r , wr .wikiRoot + "dashboard" , http .StatusTemporaryRedirect )
565- }
566-
567- func handleCreateBranch (wr * wikiRequest ) {
568-
569- // TODO: need a different version of parsePost that returns JSON errors
570- if ! parsePost (wr .w , wr .r , "branch" ) {
571- return
572- }
573-
574- // bad branch name
575- branchName := wr .r .Form .Get ("branch" )
576- if ! wiki .ValidBranchName (branchName ) {
577- wr .err = errors .New ("invalid branch name: " + branchName )
578- return
579- }
580-
581- // create or switch branches
582- _ , err := wr .wi .NewBranch (branchName )
583- if err != nil {
584- wr .err = err
585- return
586- }
587- sessMgr .Put (wr .r .Context (), "branch" , branchName )
588-
589- // redirect back to dashboard
590- http .Redirect (wr .w , wr .r , wr .wikiRoot + "dashboard" , http .StatusTemporaryRedirect )
591- }
592-
593525func handleWritePage (wr * wikiRequest ) {
594526 if ! parsePost (wr .w , wr .r , "name" , "content" ) {
595527 return
@@ -795,21 +727,6 @@ func handleCreate(typ string, wr *wikiRequest, createFunc func(dir, title string
795727 http .Redirect (wr .w , wr .r , wr .wikiRoot + "edit-" + typ + "?page=" + path .Join (dir , filename ), http .StatusTemporaryRedirect )
796728}
797729
798- // possibly switch wiki branches
799- func switchUserWiki (wr * wikiRequest , wi * webserver.WikiInfo ) {
800- userWiki := wi
801- branchName := sessMgr .GetString (wr .r .Context (), "branch" )
802- if branchName != "" {
803- branchWiki , err := wi .Branch (branchName )
804- if err != nil {
805- wr .err = err
806- return
807- }
808- userWiki = wi .Copy (branchWiki )
809- }
810- wr .wi = userWiki
811- }
812-
813730func getGenericTemplate (wr * wikiRequest ) wikiTemplate {
814731
815732 // prepend external root to all wiki roots
0 commit comments