%s
diff --git a/auth/auth.qtpl b/auth/auth.qtpl index b1f3507..1a27ce7 100644 --- a/auth/auth.qtpl +++ b/auth/auth.qtpl @@ -1,5 +1,5 @@ {% import "net/http" %} -{% import "github.com/bouncepaw/mycorrhiza/cfg" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/cfg" %} {% import "github.com/bouncepaw/mycorrhiza/l18n" %} {% func Register(rq *http.Request) %} diff --git a/auth/auth.qtpl.go b/auth/auth.qtpl.go index f0f8a22..79d7218 100644 --- a/auth/auth.qtpl.go +++ b/auth/auth.qtpl.go @@ -8,7 +8,7 @@ package auth import "net/http" //line auth/auth.qtpl:2 -import "github.com/bouncepaw/mycorrhiza/cfg" +import "github.com/bouncepaw/mycorrhiza/internal/cfg" //line auth/auth.qtpl:3 import "github.com/bouncepaw/mycorrhiza/l18n" diff --git a/categories/files.go b/categories/files.go index 9bac8ac..237a5fd 100644 --- a/categories/files.go +++ b/categories/files.go @@ -2,13 +2,14 @@ package categories import ( "encoding/json" - "github.com/bouncepaw/mycorrhiza/files" - "github.com/bouncepaw/mycorrhiza/util" "golang.org/x/exp/slices" "log" "os" "sort" "sync" + + "github.com/bouncepaw/mycorrhiza/internal/files" + "github.com/bouncepaw/mycorrhiza/util" ) var categoryToHyphae = map[string]*categoryNode{} diff --git a/categories/handlers.go b/categories/handlers.go index db016ce..a6ae643 100644 --- a/categories/handlers.go +++ b/categories/handlers.go @@ -1,9 +1,9 @@ package categories import ( - "github.com/bouncepaw/mycorrhiza/user" + "github.com/bouncepaw/mycorrhiza/internal/user" "github.com/bouncepaw/mycorrhiza/util" - "github.com/bouncepaw/mycorrhiza/viewutil" + "github.com/bouncepaw/mycorrhiza/web/viewutil" "github.com/gorilla/mux" "io" "log" diff --git a/categories/views.go b/categories/views.go index 9292ede..87242a1 100644 --- a/categories/views.go +++ b/categories/views.go @@ -2,7 +2,7 @@ package categories import ( "embed" - "github.com/bouncepaw/mycorrhiza/viewutil" + viewutil2 "github.com/bouncepaw/mycorrhiza/web/viewutil" "log" "sort" "strings" @@ -31,14 +31,14 @@ const ruTranslation = ` var ( //go:embed *.html fs embed.FS - viewListChain, viewPageChain, viewCardChain, viewEditChain viewutil.Chain + viewListChain, viewPageChain, viewCardChain, viewEditChain viewutil2.Chain ) func prepareViews() { - viewCardChain = viewutil.CopyEnRuWith(fs, "view_card.html", ruTranslation) - viewListChain = viewutil.CopyEnRuWith(fs, "view_list.html", ruTranslation) - viewPageChain = viewutil.CopyEnRuWith(fs, "view_page.html", ruTranslation) - viewEditChain = viewutil.CopyEnRuWith(fs, "view_edit.html", ruTranslation) + viewCardChain = viewutil2.CopyEnRuWith(fs, "view_card.html", ruTranslation) + viewListChain = viewutil2.CopyEnRuWith(fs, "view_list.html", ruTranslation) + viewPageChain = viewutil2.CopyEnRuWith(fs, "view_page.html", ruTranslation) + viewEditChain = viewutil2.CopyEnRuWith(fs, "view_edit.html", ruTranslation) } type cardData struct { @@ -48,7 +48,7 @@ type cardData struct { } // CategoryCard is the little sidebar that is shown nearby the hypha view. -func CategoryCard(meta viewutil.Meta, hyphaName string) string { +func CategoryCard(meta viewutil2.Meta, hyphaName string) string { var buf strings.Builder err := viewCardChain.Get(meta).ExecuteTemplate(&buf, "category card", cardData{ HyphaName: hyphaName, @@ -62,15 +62,15 @@ func CategoryCard(meta viewutil.Meta, hyphaName string) string { } type catData struct { - *viewutil.BaseData + *viewutil2.BaseData CatName string Hyphae []string GivenPermissionToModify bool } -func categoryEdit(meta viewutil.Meta, catName string) { - viewutil.ExecutePage(meta, viewEditChain, catData{ - BaseData: &viewutil.BaseData{ +func categoryEdit(meta viewutil2.Meta, catName string) { + viewutil2.ExecutePage(meta, viewEditChain, catData{ + BaseData: &viewutil2.BaseData{ Addr: "/edit-category/" + catName, }, CatName: catName, @@ -79,9 +79,9 @@ func categoryEdit(meta viewutil.Meta, catName string) { }) } -func categoryPage(meta viewutil.Meta, catName string) { - viewutil.ExecutePage(meta, viewPageChain, catData{ - BaseData: &viewutil.BaseData{ +func categoryPage(meta viewutil2.Meta, catName string) { + viewutil2.ExecutePage(meta, viewPageChain, catData{ + BaseData: &viewutil2.BaseData{ Addr: "/category/" + catName, }, CatName: catName, @@ -91,15 +91,15 @@ func categoryPage(meta viewutil.Meta, catName string) { } type listData struct { - *viewutil.BaseData + *viewutil2.BaseData Categories []string } -func categoryList(meta viewutil.Meta) { +func categoryList(meta viewutil2.Meta) { cats := listOfCategories() sort.Strings(cats) - viewutil.ExecutePage(meta, viewListChain, listData{ - BaseData: &viewutil.BaseData{ + viewutil2.ExecutePage(meta, viewListChain, listData{ + BaseData: &viewutil2.BaseData{ Addr: "/category", }, Categories: cats, diff --git a/flag.go b/flag.go index 8253b84..70646bf 100644 --- a/flag.go +++ b/flag.go @@ -12,17 +12,17 @@ import ( "golang.org/x/term" - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/bouncepaw/mycorrhiza/files" - "github.com/bouncepaw/mycorrhiza/user" - "github.com/bouncepaw/mycorrhiza/version" + "github.com/bouncepaw/mycorrhiza/internal/cfg" + "github.com/bouncepaw/mycorrhiza/internal/files" + user2 "github.com/bouncepaw/mycorrhiza/internal/user" + "github.com/bouncepaw/mycorrhiza/internal/version" ) // CLI options are read and parsed here. // printHelp prints the help message. func printHelp() { - fmt.Fprintf( + _, _ = fmt.Fprintf( flag.CommandLine.Output(), "Usage: %s WIKI_PATH\n", os.Args[0], @@ -70,13 +70,13 @@ func createAdminCommand(name string) { } cfg.UseAuth = true cfg.AllowRegistration = true - user.InitUserDatabase() + user2.InitUserDatabase() password, err := askPass("Password") if err != nil { log.Fatal(err) } - if err := user.Register(name, password, "admin", "local", true); err != nil { + if err := user2.Register(name, password, "admin", "local", true); err != nil { log.Fatal(err) } } diff --git a/help/web.go b/help/web.go index c6b3516..f66edda 100644 --- a/help/web.go +++ b/help/web.go @@ -4,7 +4,7 @@ package help import ( "git.sr.ht/~bouncepaw/mycomarkup/v5" "github.com/bouncepaw/mycorrhiza/mycoopts" - "github.com/bouncepaw/mycorrhiza/viewutil" + viewutil2 "github.com/bouncepaw/mycorrhiza/web/viewutil" "github.com/gorilla/mux" "io" "net/http" @@ -14,7 +14,7 @@ import ( ) var ( - chain viewutil.Chain + chain viewutil2.Chain ruTranslation = ` {{define "title"}}Справка{{end}} {{define "entry not found"}}Статья не найдена{{end}} @@ -46,14 +46,14 @@ var ( func InitHandlers(r *mux.Router) { r.PathPrefix("/help").HandlerFunc(handlerHelp) - chain = viewutil.CopyEnRuWith(fs, "view_help.html", ruTranslation) + chain = viewutil2.CopyEnRuWith(fs, "view_help.html", ruTranslation) } // handlerHelp gets the appropriate documentation or tells you where you (personally) have failed. func handlerHelp(w http.ResponseWriter, rq *http.Request) { // See the history of this file to resurrect the old algorithm that supported multiple languages var ( - meta = viewutil.MetaFrom(w, rq) + meta = viewutil2.MetaFrom(w, rq) articlePath = strings.TrimPrefix(strings.TrimPrefix(rq.URL.Path, "/help/"), "/help") lang = "en" ) @@ -88,14 +88,14 @@ func handlerHelp(w http.ResponseWriter, rq *http.Request) { } type helpData struct { - *viewutil.BaseData + *viewutil2.BaseData ContentsHTML string Lang string } -func viewHelp(meta viewutil.Meta, lang, contentsHTML, articlePath string) { - viewutil.ExecutePage(meta, chain, helpData{ - BaseData: &viewutil.BaseData{ +func viewHelp(meta viewutil2.Meta, lang, contentsHTML, articlePath string) { + viewutil2.ExecutePage(meta, chain, helpData{ + BaseData: &viewutil2.BaseData{ Addr: "/help/" + articlePath, }, ContentsHTML: contentsHTML, diff --git a/history/feed.go b/history/feed.go index 65a88e7..4906816 100644 --- a/history/feed.go +++ b/history/feed.go @@ -3,12 +3,11 @@ package history import ( "errors" "fmt" + "github.com/bouncepaw/mycorrhiza/internal/cfg" "net/url" "strings" "time" - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/gorilla/feeds" ) diff --git a/history/history.go b/history/history.go index 571477c..b889e80 100644 --- a/history/history.go +++ b/history/history.go @@ -9,7 +9,7 @@ import ( "path/filepath" "regexp" - "github.com/bouncepaw/mycorrhiza/files" + "github.com/bouncepaw/mycorrhiza/internal/files" "github.com/bouncepaw/mycorrhiza/util" ) diff --git a/history/histweb/histview.go b/history/histweb/histview.go index a761d43..196b998 100644 --- a/history/histweb/histview.go +++ b/history/histweb/histview.go @@ -4,12 +4,12 @@ package histweb import ( "embed" "fmt" - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/bouncepaw/mycorrhiza/files" "github.com/bouncepaw/mycorrhiza/history" - "github.com/bouncepaw/mycorrhiza/hyphae" + "github.com/bouncepaw/mycorrhiza/internal/cfg" + "github.com/bouncepaw/mycorrhiza/internal/files" + hyphae2 "github.com/bouncepaw/mycorrhiza/internal/hyphae" "github.com/bouncepaw/mycorrhiza/util" - "github.com/bouncepaw/mycorrhiza/viewutil" + viewutil2 "github.com/bouncepaw/mycorrhiza/web/viewutil" "github.com/gorilla/mux" "html/template" "log" @@ -30,9 +30,9 @@ func InitHandlers(rtr *mux.Router) { rtr.HandleFunc("/recent-changes-atom", handlerRecentChangesAtom) rtr.HandleFunc("/recent-changes-json", handlerRecentChangesJSON) - chainPrimitiveDiff = viewutil.CopyEnRuWith(fs, "view_primitive_diff.html", ruTranslation) - chainRecentChanges = viewutil.CopyEnRuWith(fs, "view_recent_changes.html", ruTranslation) - chainHistory = viewutil.CopyEnRuWith(fs, "view_history.html", ruTranslation) + chainPrimitiveDiff = viewutil2.CopyEnRuWith(fs, "view_primitive_diff.html", ruTranslation) + chainRecentChanges = viewutil2.CopyEnRuWith(fs, "view_recent_changes.html", ruTranslation) + chainHistory = viewutil2.CopyEnRuWith(fs, "view_history.html", ruTranslation) } func handlerPrimitiveDiff(w http.ResponseWriter, rq *http.Request) { @@ -45,12 +45,12 @@ func handlerPrimitiveDiff(w http.ResponseWriter, rq *http.Request) { } var ( mycoFilePath string - h = hyphae.ByName(util.CanonicalName(slug)) + h = hyphae2.ByName(util.CanonicalName(slug)) ) switch h := h.(type) { - case hyphae.ExistingHypha: + case hyphae2.ExistingHypha: mycoFilePath = h.TextFilePath() - case *hyphae.EmptyHypha: + case *hyphae2.EmptyHypha: mycoFilePath = filepath.Join(files.HyphaeDir(), h.CanonicalName()+".myco") } text, err := history.PrimitiveDiffAtRevision(mycoFilePath, revHash) @@ -58,7 +58,7 @@ func handlerPrimitiveDiff(w http.ResponseWriter, rq *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - primitiveDiff(viewutil.MetaFrom(w, rq), h, revHash, text) + primitiveDiff(viewutil2.MetaFrom(w, rq), h, revHash, text) } // handlerRecentChanges displays the /recent-changes/ page. @@ -68,7 +68,7 @@ func handlerRecentChanges(w http.ResponseWriter, rq *http.Request) { if editCount > 100 { return } - recentChanges(viewutil.MetaFrom(w, rq), editCount, history.RecentChanges(editCount)) + recentChanges(viewutil2.MetaFrom(w, rq), editCount, history.RecentChanges(editCount)) } // handlerHistory lists all revisions of a hypha. @@ -83,7 +83,7 @@ func handlerHistory(w http.ResponseWriter, rq *http.Request) { } log.Println("Found", len(revs), "revisions for", hyphaName) - historyView(viewutil.MetaFrom(w, rq), hyphaName, list) + historyView(viewutil2.MetaFrom(w, rq), hyphaName, list) } // genericHandlerOfFeeds is a helper function for the web feed handlers. @@ -135,20 +135,20 @@ var ( {{define "n recent changes"}}{{.}} свеж{{if eq . 1}}ая правка{{else if le . 4}}их правок{{else}}их правок{{end}}{{end}} {{define "recent empty"}}Правки не найдены.{{end}} ` - chainPrimitiveDiff, chainRecentChanges, chainHistory viewutil.Chain + chainPrimitiveDiff, chainRecentChanges, chainHistory viewutil2.Chain ) type recentChangesData struct { - *viewutil.BaseData + *viewutil2.BaseData EditCount int Changes []history.Revision UserHypha string Stops []int } -func recentChanges(meta viewutil.Meta, editCount int, changes []history.Revision) { - viewutil.ExecutePage(meta, chainRecentChanges, recentChangesData{ - BaseData: &viewutil.BaseData{}, +func recentChanges(meta viewutil2.Meta, editCount int, changes []history.Revision) { + viewutil2.ExecutePage(meta, chainRecentChanges, recentChangesData{ + BaseData: &viewutil2.BaseData{}, EditCount: editCount, Changes: changes, UserHypha: cfg.UserHypha, @@ -157,13 +157,13 @@ func recentChanges(meta viewutil.Meta, editCount int, changes []history.Revision } type primitiveDiffData struct { - *viewutil.BaseData + *viewutil2.BaseData HyphaName string Hash string Text template.HTML } -func primitiveDiff(meta viewutil.Meta, h hyphae.Hypha, hash, text string) { +func primitiveDiff(meta viewutil2.Meta, h hyphae2.Hypha, hash, text string) { hunks := history.SplitPrimitiveDiff(text) if len(hunks) > 0 { var buf strings.Builder @@ -198,8 +198,8 @@ func primitiveDiff(meta viewutil.Meta, h hyphae.Hypha, hash, text string) { text = fmt.Sprintf( `
%s`, text)
}
- viewutil.ExecutePage(meta, chainPrimitiveDiff, primitiveDiffData{
- BaseData: &viewutil.BaseData{},
+ viewutil2.ExecutePage(meta, chainPrimitiveDiff, primitiveDiffData{
+ BaseData: &viewutil2.BaseData{},
HyphaName: h.CanonicalName(),
Hash: hash,
Text: template.HTML(text),
@@ -207,14 +207,14 @@ func primitiveDiff(meta viewutil.Meta, h hyphae.Hypha, hash, text string) {
}
type historyData struct {
- *viewutil.BaseData
+ *viewutil2.BaseData
HyphaName string
Contents string
}
-func historyView(meta viewutil.Meta, hyphaName, contents string) {
- viewutil.ExecutePage(meta, chainHistory, historyData{
- BaseData: &viewutil.BaseData{
+func historyView(meta viewutil2.Meta, hyphaName, contents string) {
+ viewutil2.ExecutePage(meta, chainHistory, historyData{
+ BaseData: &viewutil2.BaseData{
Addr: "/history/" + util.CanonicalName(hyphaName),
},
HyphaName: hyphaName,
diff --git a/history/histweb/view_recent_changes.html b/history/histweb/view_recent_changes.html
index b744f61..b65a262 100644
--- a/history/histweb/view_recent_changes.html
+++ b/history/histweb/view_recent_changes.html
@@ -64,7 +64,7 @@
- + {{block "subscribe via" .}}Subscribe via RSS, Atom or JSON feed.{{end}}
diff --git a/history/operations.go b/history/operations.go index 66aa21f..0f9eb80 100644 --- a/history/operations.go +++ b/history/operations.go @@ -4,11 +4,11 @@ package history // Things related to writing history. import ( "fmt" + "github.com/bouncepaw/mycorrhiza/internal/user" "os" "path/filepath" "sync" - "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" ) diff --git a/history/revision.go b/history/revision.go index e3aa853..7f04309 100644 --- a/history/revision.go +++ b/history/revision.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/bouncepaw/mycorrhiza/files" + "github.com/bouncepaw/mycorrhiza/internal/files" ) // Revision represents a revision, duh. Hash is usually short. Username is extracted from email. diff --git a/history/view.qtpl b/history/view.qtpl index aa7c882..dfba661 100644 --- a/history/view.qtpl +++ b/history/view.qtpl @@ -1,5 +1,5 @@ {% import "fmt" %} -{% import "github.com/bouncepaw/mycorrhiza/cfg" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/cfg" %} HyphaeLinksHTML returns a comma-separated list of hyphae that were affected by this revision as HTML string. {% func (rev Revision) HyphaeLinksHTML() %} diff --git a/history/view.qtpl.go b/history/view.qtpl.go index 9fcaabd..7708c28 100644 --- a/history/view.qtpl.go +++ b/history/view.qtpl.go @@ -8,7 +8,7 @@ package history import "fmt" //line history/view.qtpl:2 -import "github.com/bouncepaw/mycorrhiza/cfg" +import "github.com/bouncepaw/mycorrhiza/internal/cfg" // HyphaeLinksHTML returns a comma-separated list of hyphae that were affected by this revision as HTML string. diff --git a/httpd.go b/httpd.go index 7ee56e7..ee2af1e 100644 --- a/httpd.go +++ b/httpd.go @@ -1,14 +1,13 @@ package main import ( + "github.com/bouncepaw/mycorrhiza/internal/cfg" "log" "net" "net/http" "os" "strings" "time" - - "github.com/bouncepaw/mycorrhiza/cfg" ) func serveHTTP(handler http.Handler) { diff --git a/hypview/hypview.go b/hypview/hypview.go index ea705db..55d5763 100644 --- a/hypview/hypview.go +++ b/hypview/hypview.go @@ -2,13 +2,12 @@ package hypview import ( "embed" - "github.com/bouncepaw/mycorrhiza/backlinks" + "github.com/bouncepaw/mycorrhiza/internal/backlinks" + "github.com/bouncepaw/mycorrhiza/internal/cfg" + viewutil2 "github.com/bouncepaw/mycorrhiza/web/viewutil" "html/template" "log" "strings" - - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/bouncepaw/mycorrhiza/viewutil" ) var ( @@ -77,25 +76,25 @@ var ( {{define "remove media from [[x]]?"}}Убрать медиа у {{beautifulName .MatchedHyphaName}}?{{end}} {{define "remove media for real?"}}Вы точно хотите убрать медиа у гифы «{{beautifulName .MatchedHyphaName}}»?{{end}} ` - chainNaviTitle viewutil.Chain - chainEditHypha viewutil.Chain - chainEmptyHypha viewutil.Chain - chainDeleteHypha viewutil.Chain - chainRenameHypha viewutil.Chain - chainRemoveMedia viewutil.Chain + chainNaviTitle viewutil2.Chain + chainEditHypha viewutil2.Chain + chainEmptyHypha viewutil2.Chain + chainDeleteHypha viewutil2.Chain + chainRenameHypha viewutil2.Chain + chainRemoveMedia viewutil2.Chain ) func Init() { - chainNaviTitle = viewutil.CopyEnRuWith(fs, "view_navititle.html", "") - chainEditHypha = viewutil.CopyEnRuWith(fs, "view_edit.html", ruTranslation) - chainEmptyHypha = viewutil.CopyEnRuWith(fs, "view_empty_hypha.html", ruTranslation) - chainDeleteHypha = viewutil.CopyEnRuWith(fs, "view_delete.html", ruTranslation) - chainRenameHypha = viewutil.CopyEnRuWith(fs, "view_rename.html", ruTranslation) - chainRemoveMedia = viewutil.CopyEnRuWith(fs, "view_remove_media.html", ruTranslation) + chainNaviTitle = viewutil2.CopyEnRuWith(fs, "view_navititle.html", "") + chainEditHypha = viewutil2.CopyEnRuWith(fs, "view_edit.html", ruTranslation) + chainEmptyHypha = viewutil2.CopyEnRuWith(fs, "view_empty_hypha.html", ruTranslation) + chainDeleteHypha = viewutil2.CopyEnRuWith(fs, "view_delete.html", ruTranslation) + chainRenameHypha = viewutil2.CopyEnRuWith(fs, "view_rename.html", ruTranslation) + chainRemoveMedia = viewutil2.CopyEnRuWith(fs, "view_remove_media.html", ruTranslation) } type editData struct { - *viewutil.BaseData + *viewutil2.BaseData HyphaName string IsNew bool Content string @@ -103,9 +102,9 @@ type editData struct { Preview template.HTML } -func EditHypha(meta viewutil.Meta, hyphaName string, isNew bool, content string, message string, preview template.HTML) { - viewutil.ExecutePage(meta, chainEditHypha, editData{ - BaseData: &viewutil.BaseData{ +func EditHypha(meta viewutil2.Meta, hyphaName string, isNew bool, content string, message string, preview template.HTML) { + viewutil2.ExecutePage(meta, chainEditHypha, editData{ + BaseData: &viewutil2.BaseData{ Addr: "/edit/" + hyphaName, EditScripts: cfg.EditScripts, }, @@ -118,14 +117,14 @@ func EditHypha(meta viewutil.Meta, hyphaName string, isNew bool, content string, } type renameData struct { - *viewutil.BaseData + *viewutil2.BaseData HyphaName string LeaveRedirectionDefault bool } -func RenameHypha(meta viewutil.Meta, hyphaName string) { - viewutil.ExecutePage(meta, chainRenameHypha, renameData{ - BaseData: &viewutil.BaseData{ +func RenameHypha(meta viewutil2.Meta, hyphaName string) { + viewutil2.ExecutePage(meta, chainRenameHypha, renameData{ + BaseData: &viewutil2.BaseData{ Addr: "/rename/" + hyphaName, }, HyphaName: hyphaName, @@ -134,22 +133,22 @@ func RenameHypha(meta viewutil.Meta, hyphaName string) { } type deleteRemoveMediaData struct { - *viewutil.BaseData + *viewutil2.BaseData HyphaName string } -func DeleteHypha(meta viewutil.Meta, hyphaName string) { - viewutil.ExecutePage(meta, chainDeleteHypha, deleteRemoveMediaData{ - BaseData: &viewutil.BaseData{ +func DeleteHypha(meta viewutil2.Meta, hyphaName string) { + viewutil2.ExecutePage(meta, chainDeleteHypha, deleteRemoveMediaData{ + BaseData: &viewutil2.BaseData{ Addr: "/delete/" + hyphaName, }, HyphaName: hyphaName, }) } -func RemoveMedia(meta viewutil.Meta, hyphaName string) { - viewutil.ExecutePage(meta, chainRemoveMedia, deleteRemoveMediaData{ - BaseData: &viewutil.BaseData{ +func RemoveMedia(meta viewutil2.Meta, hyphaName string) { + viewutil2.ExecutePage(meta, chainRemoveMedia, deleteRemoveMediaData{ + BaseData: &viewutil2.BaseData{ Addr: "/remove-media/" + hyphaName, }, HyphaName: hyphaName, @@ -157,13 +156,13 @@ func RemoveMedia(meta viewutil.Meta, hyphaName string) { } type emptyHyphaData struct { - Meta viewutil.Meta + Meta viewutil2.Meta HyphaName string AllowRegistration bool UseAuth bool } -func EmptyHypha(meta viewutil.Meta, hyphaName string) string { +func EmptyHypha(meta viewutil2.Meta, hyphaName string) string { var buf strings.Builder if err := chainEmptyHypha.Get(meta).ExecuteTemplate(&buf, "empty hypha card", emptyHyphaData{ Meta: meta, @@ -183,7 +182,7 @@ type naviTitleData struct { HomeHypha string } -func NaviTitle(meta viewutil.Meta, hyphaName string) string { +func NaviTitle(meta viewutil2.Meta, hyphaName string) string { parts, partsWithParents := naviTitleify(hyphaName) var buf strings.Builder err := chainNaviTitle.Get(meta).ExecuteTemplate(&buf, "navititle", naviTitleData{ diff --git a/hypview/nav.qtpl b/hypview/nav.qtpl index 3f6a39d..3768edc 100644 --- a/hypview/nav.qtpl +++ b/hypview/nav.qtpl @@ -1,9 +1,9 @@ -{% import "github.com/bouncepaw/mycorrhiza/backlinks" %} -{% import "github.com/bouncepaw/mycorrhiza/cfg" %} -{% import "github.com/bouncepaw/mycorrhiza/hyphae" %} -{% import "github.com/bouncepaw/mycorrhiza/user" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/backlinks" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/cfg" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/hyphae" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/user" %} {% import "github.com/bouncepaw/mycorrhiza/util" %} -{% import "github.com/bouncepaw/mycorrhiza/viewutil" %} +{% import "github.com/bouncepaw/mycorrhiza/web/viewutil" %} {% func hyphaInfoEntry(h hyphae.Hypha, u *user.User, action string, hasToExist bool, displayText string) %} {% code flag := true %} diff --git a/hypview/nav.qtpl.go b/hypview/nav.qtpl.go index d808df9..965fbe6 100644 --- a/hypview/nav.qtpl.go +++ b/hypview/nav.qtpl.go @@ -5,22 +5,22 @@ package hypview //line hypview/nav.qtpl:1 -import "github.com/bouncepaw/mycorrhiza/backlinks" +import "github.com/bouncepaw/mycorrhiza/internal/backlinks" //line hypview/nav.qtpl:2 -import "github.com/bouncepaw/mycorrhiza/cfg" +import "github.com/bouncepaw/mycorrhiza/internal/cfg" //line hypview/nav.qtpl:3 -import "github.com/bouncepaw/mycorrhiza/hyphae" +import "github.com/bouncepaw/mycorrhiza/internal/hyphae" //line hypview/nav.qtpl:4 -import "github.com/bouncepaw/mycorrhiza/user" +import "github.com/bouncepaw/mycorrhiza/internal/user" //line hypview/nav.qtpl:5 import "github.com/bouncepaw/mycorrhiza/util" //line hypview/nav.qtpl:6 -import "github.com/bouncepaw/mycorrhiza/viewutil" +import "github.com/bouncepaw/mycorrhiza/web/viewutil" //line hypview/nav.qtpl:8 import ( diff --git a/hypview/readers.qtpl b/hypview/readers.qtpl index 7662730..418cbca 100644 --- a/hypview/readers.qtpl +++ b/hypview/readers.qtpl @@ -3,15 +3,15 @@ {% import "path" %} {% import "os" %} -{% import "github.com/bouncepaw/mycorrhiza/cfg" %} -{% import "github.com/bouncepaw/mycorrhiza/hyphae" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/cfg" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/categories" %} {% import "github.com/bouncepaw/mycorrhiza/l18n" %} -{% import "github.com/bouncepaw/mycorrhiza/mimetype" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/mimetype" %} {% import "github.com/bouncepaw/mycorrhiza/tree" %} -{% import "github.com/bouncepaw/mycorrhiza/user" %} +{% import "github.com/bouncepaw/mycorrhiza/internal/user" %} {% import "github.com/bouncepaw/mycorrhiza/util" %} -{% import "github.com/bouncepaw/mycorrhiza/viewutil" %} +{% import "github.com/bouncepaw/mycorrhiza/web/viewutil" %} {% func MediaMenu(rq *http.Request, h hyphae.Hypha, u *user.User) %} {% code diff --git a/hypview/readers.qtpl.go b/hypview/readers.qtpl.go index 5c12150..b55336e 100644 --- a/hypview/readers.qtpl.go +++ b/hypview/readers.qtpl.go @@ -17,10 +17,10 @@ import "path" import "os" //line hypview/readers.qtpl:6 -import "github.com/bouncepaw/mycorrhiza/cfg" +import "github.com/bouncepaw/mycorrhiza/internal/cfg" //line hypview/readers.qtpl:7 -import "github.com/bouncepaw/mycorrhiza/hyphae" +import "github.com/bouncepaw/mycorrhiza/internal/hyphae" //line hypview/readers.qtpl:8 import "github.com/bouncepaw/mycorrhiza/categories" @@ -29,19 +29,19 @@ import "github.com/bouncepaw/mycorrhiza/categories" import "github.com/bouncepaw/mycorrhiza/l18n" //line hypview/readers.qtpl:10 -import "github.com/bouncepaw/mycorrhiza/mimetype" +import "github.com/bouncepaw/mycorrhiza/internal/mimetype" //line hypview/readers.qtpl:11 import "github.com/bouncepaw/mycorrhiza/tree" //line hypview/readers.qtpl:12 -import "github.com/bouncepaw/mycorrhiza/user" +import "github.com/bouncepaw/mycorrhiza/internal/user" //line hypview/readers.qtpl:13 import "github.com/bouncepaw/mycorrhiza/util" //line hypview/readers.qtpl:14 -import "github.com/bouncepaw/mycorrhiza/viewutil" +import "github.com/bouncepaw/mycorrhiza/web/viewutil" //line hypview/readers.qtpl:16 import ( diff --git a/hypview/view_edit.html b/hypview/view_edit.html index 1bec2fe..ae3dc22 100644 --- a/hypview/view_edit.html +++ b/hypview/view_edit.html @@ -39,7 +39,7 @@ {{end}} - + {{end}} {{define "editing hypha"}}Edit {{beautifulName .}}{{end}} @@ -98,7 +98,7 @@ {{end}} {{template "toolbar" .}} - + {{range .EditScripts}} {{end}} diff --git a/backlinks/backlinks.go b/internal/backlinks/backlinks.go similarity index 92% rename from backlinks/backlinks.go rename to internal/backlinks/backlinks.go index c019a45..f2e235a 100644 --- a/backlinks/backlinks.go +++ b/internal/backlinks/backlinks.go @@ -2,11 +2,11 @@ package backlinks import ( + hyphae2 "github.com/bouncepaw/mycorrhiza/internal/hyphae" "log" "os" "sort" - "github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/util" ) @@ -14,7 +14,7 @@ import ( func yieldHyphaBacklinks(hyphaName string) <-chan string { hyphaName = util.CanonicalName(hyphaName) out := make(chan string) - sorted := hyphae.PathographicSort(out) + sorted := hyphae2.PathographicSort(out) go func() { backlinks, exists := backlinkIndex[hyphaName] if exists { @@ -43,7 +43,7 @@ var backlinkIndex = make(map[string]linkSet) // IndexBacklinks traverses all text hyphae, extracts links from them and forms an initial index. Call it when indexing and reindexing hyphae. func IndexBacklinks() { // It is safe to ignore the mutex, because there is only one worker. - for h := range hyphae.FilterHyphaeWithText(hyphae.YieldExistingHyphae()) { + for h := range hyphae2.FilterHyphaeWithText(hyphae2.YieldExistingHyphae()) { foundLinks := extractHyphaLinksFromContent(h.CanonicalName(), fetchText(h)) for _, link := range foundLinks { if _, exists := backlinkIndex[link]; !exists { @@ -72,7 +72,7 @@ func BacklinksFor(hyphaName string) []string { func Orphans() []string { var orphans []string - for h := range hyphae.YieldExistingHyphae() { + for h := range hyphae2.YieldExistingHyphae() { if BacklinksCount(h.CanonicalName()) == 0 { orphans = append(orphans, h.CanonicalName()) } @@ -92,14 +92,14 @@ func toLinkSet(xs []string) linkSet { return result } -func fetchText(h hyphae.Hypha) string { +func fetchText(h hyphae2.Hypha) string { var path string switch h := h.(type) { - case *hyphae.EmptyHypha: + case *hyphae2.EmptyHypha: return "" - case *hyphae.TextualHypha: + case *hyphae2.TextualHypha: path = h.TextFilePath() - case *hyphae.MediaHypha: + case *hyphae2.MediaHypha: if !h.HasTextFile() { return "" } diff --git a/backlinks/hooks.go b/internal/backlinks/hooks.go similarity index 97% rename from backlinks/hooks.go rename to internal/backlinks/hooks.go index 41084f6..ef65952 100644 --- a/backlinks/hooks.go +++ b/internal/backlinks/hooks.go @@ -5,7 +5,7 @@ import ( "git.sr.ht/~bouncepaw/mycomarkup/v5/links" "git.sr.ht/~bouncepaw/mycomarkup/v5/mycocontext" "git.sr.ht/~bouncepaw/mycomarkup/v5/tools" - "github.com/bouncepaw/mycorrhiza/hyphae" + "github.com/bouncepaw/mycorrhiza/internal/hyphae" "github.com/bouncepaw/mycorrhiza/mycoopts" ) diff --git a/cfg/config.go b/internal/cfg/config.go similarity index 100% rename from cfg/config.go rename to internal/cfg/config.go diff --git a/files/files.go b/internal/files/files.go similarity index 97% rename from files/files.go rename to internal/files/files.go index 97cafb4..f3eee48 100644 --- a/files/files.go +++ b/internal/files/files.go @@ -2,12 +2,11 @@ package files import ( + "github.com/bouncepaw/mycorrhiza/internal/cfg" + "github.com/bouncepaw/mycorrhiza/web/static" "io" "os" "path/filepath" - - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/bouncepaw/mycorrhiza/static" ) var paths struct { diff --git a/hyphae/count.go b/internal/hyphae/count.go similarity index 100% rename from hyphae/count.go rename to internal/hyphae/count.go diff --git a/hyphae/deprecated.go b/internal/hyphae/deprecated.go similarity index 100% rename from hyphae/deprecated.go rename to internal/hyphae/deprecated.go diff --git a/hyphae/empty_hypha.go b/internal/hyphae/empty_hypha.go similarity index 100% rename from hyphae/empty_hypha.go rename to internal/hyphae/empty_hypha.go diff --git a/hyphae/existing_hypha.go b/internal/hyphae/existing_hypha.go similarity index 100% rename from hyphae/existing_hypha.go rename to internal/hyphae/existing_hypha.go diff --git a/hyphae/files.go b/internal/hyphae/files.go similarity index 97% rename from hyphae/files.go rename to internal/hyphae/files.go index f1bc400..ba6f762 100644 --- a/hyphae/files.go +++ b/internal/hyphae/files.go @@ -1,11 +1,10 @@ package hyphae import ( + "github.com/bouncepaw/mycorrhiza/internal/mimetype" "log" "os" "path/filepath" - - "github.com/bouncepaw/mycorrhiza/mimetype" ) // Index finds all hypha files in the full `path` and saves them to the hypha storage. diff --git a/hyphae/hypha.go b/internal/hyphae/hypha.go similarity index 100% rename from hyphae/hypha.go rename to internal/hyphae/hypha.go diff --git a/hyphae/iterators.go b/internal/hyphae/iterators.go similarity index 100% rename from hyphae/iterators.go rename to internal/hyphae/iterators.go diff --git a/hyphae/media_hypha.go b/internal/hyphae/media_hypha.go similarity index 93% rename from hyphae/media_hypha.go rename to internal/hyphae/media_hypha.go index 60e3505..581d271 100644 --- a/hyphae/media_hypha.go +++ b/internal/hyphae/media_hypha.go @@ -1,9 +1,10 @@ package hyphae import ( - "github.com/bouncepaw/mycorrhiza/files" "path/filepath" "sync" + + "github.com/bouncepaw/mycorrhiza/internal/files" ) type MediaHypha struct { diff --git a/hyphae/textual_hypha.go b/internal/hyphae/textual_hypha.go similarity index 100% rename from hyphae/textual_hypha.go rename to internal/hyphae/textual_hypha.go diff --git a/migration/headings.go b/internal/migration/headings.go similarity index 95% rename from migration/headings.go rename to internal/migration/headings.go index 14fb2aa..fb8f3cd 100644 --- a/migration/headings.go +++ b/internal/migration/headings.go @@ -2,7 +2,7 @@ package migration import ( "git.sr.ht/~bouncepaw/mycomarkup/v5/tools" - "github.com/bouncepaw/mycorrhiza/files" + "github.com/bouncepaw/mycorrhiza/internal/files" "io/ioutil" "log" "os" diff --git a/migration/migration.go b/internal/migration/migration.go similarity index 95% rename from migration/migration.go rename to internal/migration/migration.go index 00bf1ff..d3f945f 100644 --- a/migration/migration.go +++ b/internal/migration/migration.go @@ -8,13 +8,14 @@ package migration import ( - "github.com/bouncepaw/mycorrhiza/history" - "github.com/bouncepaw/mycorrhiza/hyphae" - "github.com/bouncepaw/mycorrhiza/user" + "github.com/bouncepaw/mycorrhiza/internal/user" "io" "log" "os" "strings" + + "github.com/bouncepaw/mycorrhiza/history" + "github.com/bouncepaw/mycorrhiza/internal/hyphae" ) func genericLineMigrator( diff --git a/migration/rockets.go b/internal/migration/rockets.go similarity index 96% rename from migration/rockets.go rename to internal/migration/rockets.go index 9787eba..5dc050b 100644 --- a/migration/rockets.go +++ b/internal/migration/rockets.go @@ -2,7 +2,7 @@ package migration import ( "git.sr.ht/~bouncepaw/mycomarkup/v5/tools" - "github.com/bouncepaw/mycorrhiza/files" + "github.com/bouncepaw/mycorrhiza/internal/files" "io/ioutil" "log" "os" diff --git a/mimetype/mime.go b/internal/mimetype/mime.go similarity index 100% rename from mimetype/mime.go rename to internal/mimetype/mime.go diff --git a/shroom/can.go b/internal/shroom/can.go similarity index 73% rename from shroom/can.go rename to internal/shroom/can.go index b3885e7..c9d1f3d 100644 --- a/shroom/can.go +++ b/internal/shroom/can.go @@ -2,23 +2,23 @@ package shroom import ( "errors" + hyphae2 "github.com/bouncepaw/mycorrhiza/internal/hyphae" + "github.com/bouncepaw/mycorrhiza/internal/user" - "github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/l18n" - "github.com/bouncepaw/mycorrhiza/user" ) // TODO: get rid of this abomination func canFactory( - rejectLogger func(hyphae.Hypha, *user.User, string), + rejectLogger func(hyphae2.Hypha, *user.User, string), action string, - dispatcher func(hyphae.Hypha, *user.User, *l18n.Localizer) (string, string), + dispatcher func(hyphae2.Hypha, *user.User, *l18n.Localizer) (string, string), noRightsMsg string, notExistsMsg string, mustExist bool, -) func(*user.User, hyphae.Hypha, *l18n.Localizer) error { - return func(u *user.User, h hyphae.Hypha, lc *l18n.Localizer) error { +) func(*user.User, hyphae2.Hypha, *l18n.Localizer) error { + return func(u *user.User, h hyphae2.Hypha, lc *l18n.Localizer) error { if !u.CanProceed(action) { rejectLogger(h, u, "no rights") return errors.New(noRightsMsg) @@ -26,7 +26,7 @@ func canFactory( if mustExist { switch h.(type) { - case *hyphae.EmptyHypha: + case *hyphae2.EmptyHypha: rejectLogger(h, u, "does not exist") return errors.New(notExistsMsg) } diff --git a/shroom/delete.go b/internal/shroom/delete.go similarity index 67% rename from shroom/delete.go rename to internal/shroom/delete.go index d63703f..34ff6cd 100644 --- a/shroom/delete.go +++ b/internal/shroom/delete.go @@ -2,29 +2,29 @@ package shroom import ( "fmt" - "github.com/bouncepaw/mycorrhiza/backlinks" "github.com/bouncepaw/mycorrhiza/categories" "github.com/bouncepaw/mycorrhiza/history" - "github.com/bouncepaw/mycorrhiza/hyphae" - "github.com/bouncepaw/mycorrhiza/user" + "github.com/bouncepaw/mycorrhiza/internal/backlinks" + hyphae2 "github.com/bouncepaw/mycorrhiza/internal/hyphae" + "github.com/bouncepaw/mycorrhiza/internal/user" ) // Delete deletes the hypha and makes a history record about that. -func Delete(u *user.User, h hyphae.ExistingHypha) error { +func Delete(u *user.User, h hyphae2.ExistingHypha) error { hop := history. Operation(history.TypeDeleteHypha). WithMsg(fmt.Sprintf("Delete ‘%s’", h.CanonicalName())). WithUser(u) - originalText, _ := hyphae.FetchMycomarkupFile(h) + originalText, _ := hyphae2.FetchMycomarkupFile(h) switch h := h.(type) { - case *hyphae.MediaHypha: + case *hyphae2.MediaHypha: if h.HasTextFile() { hop.WithFilesRemoved(h.MediaFilePath(), h.TextFilePath()) } else { hop.WithFilesRemoved(h.MediaFilePath()) } - case *hyphae.TextualHypha: + case *hyphae2.TextualHypha: hop.WithFilesRemoved(h.TextFilePath()) } if hop.Apply().HasErrors() { @@ -32,6 +32,6 @@ func Delete(u *user.User, h hyphae.ExistingHypha) error { } backlinks.UpdateBacklinksAfterDelete(h, originalText) categories.RemoveHyphaFromAllCategories(h.CanonicalName()) - hyphae.DeleteHypha(h) + hyphae2.DeleteHypha(h) return nil } diff --git a/shroom/header_links.go b/internal/shroom/header_links.go similarity index 84% rename from shroom/header_links.go rename to internal/shroom/header_links.go index 0d2be2d..dd3ff1b 100644 --- a/shroom/header_links.go +++ b/internal/shroom/header_links.go @@ -4,19 +4,19 @@ import ( "git.sr.ht/~bouncepaw/mycomarkup/v5" "git.sr.ht/~bouncepaw/mycomarkup/v5/blocks" "git.sr.ht/~bouncepaw/mycomarkup/v5/mycocontext" - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/bouncepaw/mycorrhiza/hyphae" + "github.com/bouncepaw/mycorrhiza/internal/cfg" + hyphae2 "github.com/bouncepaw/mycorrhiza/internal/hyphae" "github.com/bouncepaw/mycorrhiza/mycoopts" - "github.com/bouncepaw/mycorrhiza/viewutil" + "github.com/bouncepaw/mycorrhiza/web/viewutil" "os" ) // SetHeaderLinks initializes header links by reading the configured hypha, if there is any, or resorting to default values. func SetHeaderLinks() { - switch userLinksHypha := hyphae.ByName(cfg.HeaderLinksHypha).(type) { - case *hyphae.EmptyHypha: + switch userLinksHypha := hyphae2.ByName(cfg.HeaderLinksHypha).(type) { + case *hyphae2.EmptyHypha: setDefaultHeaderLinks() - case hyphae.ExistingHypha: + case hyphae2.ExistingHypha: contents, err := os.ReadFile(userLinksHypha.TextFilePath()) if err != nil || len(contents) == 0 { setDefaultHeaderLinks() diff --git a/shroom/log.go b/internal/shroom/log.go similarity index 87% rename from shroom/log.go rename to internal/shroom/log.go index 2be9a70..2aef825 100644 --- a/shroom/log.go +++ b/internal/shroom/log.go @@ -1,10 +1,9 @@ package shroom import ( + "github.com/bouncepaw/mycorrhiza/internal/hyphae" + "github.com/bouncepaw/mycorrhiza/internal/user" "log" - - "github.com/bouncepaw/mycorrhiza/hyphae" - "github.com/bouncepaw/mycorrhiza/user" ) func rejectRenameLog(h hyphae.Hypha, u *user.User, errmsg string) { diff --git a/shroom/rename.go b/internal/shroom/rename.go similarity index 74% rename from shroom/rename.go rename to internal/shroom/rename.go index 22bdfb6..dc760e8 100644 --- a/shroom/rename.go +++ b/internal/shroom/rename.go @@ -3,36 +3,36 @@ package shroom import ( "errors" "fmt" - "github.com/bouncepaw/mycorrhiza/backlinks" "github.com/bouncepaw/mycorrhiza/categories" - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/bouncepaw/mycorrhiza/files" + "github.com/bouncepaw/mycorrhiza/internal/backlinks" + "github.com/bouncepaw/mycorrhiza/internal/cfg" + "github.com/bouncepaw/mycorrhiza/internal/files" + hyphae2 "github.com/bouncepaw/mycorrhiza/internal/hyphae" + "github.com/bouncepaw/mycorrhiza/internal/user" "path" "path/filepath" "regexp" "strings" "github.com/bouncepaw/mycorrhiza/history" - "github.com/bouncepaw/mycorrhiza/hyphae" - "github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/util" ) // Rename renames the old hypha to the new name and makes a history record about that. Call if and only if the user has the permission to rename. -func Rename(oldHypha hyphae.ExistingHypha, newName string, recursive bool, leaveRedirections bool, u *user.User) error { +func Rename(oldHypha hyphae2.ExistingHypha, newName string, recursive bool, leaveRedirections bool, u *user.User) error { // * bouncepaw hates this function and related renaming functions if newName == "" { rejectRenameLog(oldHypha, u, "no new name given") return errors.New("ui.rename_noname_tip") } - if !hyphae.IsValidName(newName) { + if !hyphae2.IsValidName(newName) { rejectRenameLog(oldHypha, u, fmt.Sprintf("new name ‘%s’ invalid", newName)) return errors.New("ui.rename_badname_tip") // FIXME: There is a bug related to this. } - switch targetHypha := hyphae.ByName(newName); targetHypha.(type) { - case hyphae.ExistingHypha: + switch targetHypha := hyphae2.ByName(newName); targetHypha.(type) { + case hyphae2.ExistingHypha: if targetHypha.CanonicalName() == oldHypha.CanonicalName() { return nil } @@ -81,7 +81,7 @@ func Rename(oldHypha hyphae.ExistingHypha, newName string, recursive bool, leave oldName = h.CanonicalName() newName = re.ReplaceAllString(oldName, newName) ) - hyphae.RenameHyphaTo(h, newName, replaceName) + hyphae2.RenameHyphaTo(h, newName, replaceName) backlinks.UpdateBacklinksAfterRename(h, oldName) categories.RenameHyphaInAllCategories(oldName, newName) if leaveRedirections { @@ -104,12 +104,12 @@ const redirectionTemplate = `=> %[1]s | 👁️➡️ %[2]s func leaveRedirection(oldName, newName string, hop *history.Op) error { var ( text = fmt.Sprintf(redirectionTemplate, newName, util.BeautifulName(newName)) - emptyHypha = hyphae.ByName(oldName) + emptyHypha = hyphae2.ByName(oldName) ) switch emptyHypha := emptyHypha.(type) { - case *hyphae.EmptyHypha: - h := hyphae.ExtendEmptyToTextual(emptyHypha, filepath.Join(files.HyphaeDir(), oldName+".myco")) - hyphae.Insert(h) + case *hyphae2.EmptyHypha: + h := hyphae2.ExtendEmptyToTextual(emptyHypha, filepath.Join(files.HyphaeDir(), oldName+".myco")) + hyphae2.Insert(h) categories.AddHyphaToCategory(oldName, cfg.RedirectionCategory) defer backlinks.UpdateBacklinksAfterEdit(h, "") return writeTextToDisk(h, []byte(text), hop) @@ -118,15 +118,15 @@ func leaveRedirection(oldName, newName string, hop *history.Op) error { } } -func findHyphaeToRename(superhypha hyphae.ExistingHypha, recursive bool) []hyphae.ExistingHypha { - hyphaList := []hyphae.ExistingHypha{superhypha} +func findHyphaeToRename(superhypha hyphae2.ExistingHypha, recursive bool) []hyphae2.ExistingHypha { + hyphaList := []hyphae2.ExistingHypha{superhypha} if recursive { - hyphaList = append(hyphaList, hyphae.Subhyphae(superhypha)...) + hyphaList = append(hyphaList, hyphae2.Subhyphae(superhypha)...) } return hyphaList } -func renamingPairs(hyphaeToRename []hyphae.ExistingHypha, replaceName func(string) string) (map[string]string, error) { +func renamingPairs(hyphaeToRename []hyphae2.ExistingHypha, replaceName func(string) string) (map[string]string, error) { var ( renameMap = make(map[string]string) newNames = make([]string, len(hyphaeToRename)) @@ -138,12 +138,12 @@ func renamingPairs(hyphaeToRename []hyphae.ExistingHypha, replaceName func(strin renameMap[h.TextFilePath()] = replaceName(h.TextFilePath()) } switch h := h.(type) { - case *hyphae.MediaHypha: + case *hyphae2.MediaHypha: renameMap[h.MediaFilePath()] = replaceName(h.MediaFilePath()) } h.Unlock() } - if firstFailure, ok := hyphae.AreFreeNames(newNames...); !ok { + if firstFailure, ok := hyphae2.AreFreeNames(newNames...); !ok { return nil, errors.New("Hypha " + firstFailure + " already exists") } return renameMap, nil diff --git a/shroom/search.go b/internal/shroom/search.go similarity index 94% rename from shroom/search.go rename to internal/shroom/search.go index 4387abf..57efad0 100644 --- a/shroom/search.go +++ b/internal/shroom/search.go @@ -1,9 +1,9 @@ package shroom import ( + "github.com/bouncepaw/mycorrhiza/internal/hyphae" "strings" - "github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/util" ) diff --git a/shroom/shroom.go b/internal/shroom/shroom.go similarity index 100% rename from shroom/shroom.go rename to internal/shroom/shroom.go diff --git a/shroom/unattach.go b/internal/shroom/unattach.go similarity index 74% rename from shroom/unattach.go rename to internal/shroom/unattach.go index e62ce02..74b76b4 100644 --- a/shroom/unattach.go +++ b/internal/shroom/unattach.go @@ -2,14 +2,14 @@ package shroom import ( "fmt" + hyphae2 "github.com/bouncepaw/mycorrhiza/internal/hyphae" + "github.com/bouncepaw/mycorrhiza/internal/user" "github.com/bouncepaw/mycorrhiza/history" - "github.com/bouncepaw/mycorrhiza/hyphae" - "github.com/bouncepaw/mycorrhiza/user" ) // RemoveMedia removes media from the media hypha and makes a history record about that. If it only had media, the hypha will be deleted. If it also had text, the hypha will become textual. -func RemoveMedia(u *user.User, h *hyphae.MediaHypha) error { +func RemoveMedia(u *user.User, h *hyphae2.MediaHypha) error { hop := history. Operation(history.TypeRemoveMedia). WithFilesRemoved(h.MediaFilePath()). @@ -24,9 +24,9 @@ func RemoveMedia(u *user.User, h *hyphae.MediaHypha) error { } if h.HasTextFile() { - hyphae.Insert(hyphae.ShrinkMediaToTextual(h)) + hyphae2.Insert(hyphae2.ShrinkMediaToTextual(h)) } else { - hyphae.DeleteHypha(h) + hyphae2.DeleteHypha(h) } return nil } diff --git a/shroom/upload.go b/internal/shroom/upload.go similarity index 72% rename from shroom/upload.go rename to internal/shroom/upload.go index 5599b01..1876837 100644 --- a/shroom/upload.go +++ b/internal/shroom/upload.go @@ -4,12 +4,12 @@ import ( "bytes" "errors" "fmt" - "github.com/bouncepaw/mycorrhiza/backlinks" - "github.com/bouncepaw/mycorrhiza/files" "github.com/bouncepaw/mycorrhiza/history" - "github.com/bouncepaw/mycorrhiza/hyphae" - "github.com/bouncepaw/mycorrhiza/mimetype" - "github.com/bouncepaw/mycorrhiza/user" + "github.com/bouncepaw/mycorrhiza/internal/backlinks" + "github.com/bouncepaw/mycorrhiza/internal/files" + hyphae2 "github.com/bouncepaw/mycorrhiza/internal/hyphae" + "github.com/bouncepaw/mycorrhiza/internal/mimetype" + "github.com/bouncepaw/mycorrhiza/internal/user" "io" "log" "mime/multipart" @@ -17,10 +17,10 @@ import ( "path/filepath" ) -func historyMessageForTextUpload(h hyphae.Hypha, userMessage string) string { +func historyMessageForTextUpload(h hyphae2.Hypha, userMessage string) string { var verb string switch h.(type) { - case *hyphae.EmptyHypha: + case *hyphae2.EmptyHypha: verb = "Create" default: verb = "Edit" @@ -32,8 +32,8 @@ func historyMessageForTextUpload(h hyphae.Hypha, userMessage string) string { return fmt.Sprintf("%s ‘%s’: %s", verb, h.CanonicalName(), userMessage) } -func writeTextToDisk(h hyphae.ExistingHypha, data []byte, hop *history.Op) error { - if err := hyphae.WriteToMycoFile(h, data); err != nil { +func writeTextToDisk(h hyphae2.ExistingHypha, data []byte, hop *history.Op) error { + if err := hyphae2.WriteToMycoFile(h, data); err != nil { return err } hop.WithFiles(h.TextFilePath()) @@ -42,7 +42,7 @@ func writeTextToDisk(h hyphae.ExistingHypha, data []byte, hop *history.Op) error } // UploadText edits the hypha's text part and makes a history record about that. -func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) error { +func UploadText(h hyphae2.Hypha, data []byte, userMessage string, u *user.User) error { hop := history. Operation(history.TypeEditText). WithMsg(historyMessageForTextUpload(h, userMessage)). @@ -56,13 +56,13 @@ func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) e } // Hypha name exploit check - if !hyphae.IsValidName(h.CanonicalName()) { + if !hyphae2.IsValidName(h.CanonicalName()) { // We check for the name only. I suppose the filepath would be valid as well. hop.Abort() return errors.New("invalid hypha name") } - oldText, err := hyphae.FetchMycomarkupFile(h) + oldText, err := hyphae2.FetchMycomarkupFile(h) if err != nil { hop.Abort() return err @@ -77,8 +77,8 @@ func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) e // At this point, we have a savable user-generated Mycomarkup document. Gotta save it. switch h := h.(type) { - case *hyphae.EmptyHypha: - H := hyphae.ExtendEmptyToTextual(h, filepath.Join(files.HyphaeDir(), h.CanonicalName()+".myco")) + case *hyphae2.EmptyHypha: + H := hyphae2.ExtendEmptyToTextual(h, filepath.Join(files.HyphaeDir(), h.CanonicalName()+".myco")) err := writeTextToDisk(H, data, hop) if err != nil { @@ -86,9 +86,9 @@ func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) e return err } - hyphae.Insert(H) + hyphae2.Insert(H) backlinks.UpdateBacklinksAfterEdit(H, "") - case *hyphae.MediaHypha: + case *hyphae2.MediaHypha: // TODO: that []byte(...) part should be removed if bytes.Equal(data, []byte(oldText)) { // No changes! Just like cancel button @@ -103,8 +103,8 @@ func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) e } backlinks.UpdateBacklinksAfterEdit(h, oldText) - case *hyphae.TextualHypha: - oldText, err := hyphae.FetchMycomarkupFile(h) + case *hyphae2.TextualHypha: + oldText, err := hyphae2.FetchMycomarkupFile(h) if err != nil { hop.Abort() return err @@ -130,12 +130,12 @@ func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) e return nil } -func historyMessageForMediaUpload(h hyphae.Hypha, mime string) string { +func historyMessageForMediaUpload(h hyphae2.Hypha, mime string) string { return fmt.Sprintf("Upload media for ‘%s’ with type ‘%s’", h.CanonicalName(), mime) } // writeMediaToDisk saves the given data with the given mime type for the given hypha to the disk and returns the path to the saved file and an error, if any. -func writeMediaToDisk(h hyphae.Hypha, mime string, data []byte) (string, error) { +func writeMediaToDisk(h hyphae2.Hypha, mime string, data []byte) (string, error) { var ( ext = mimetype.ToExtension(mime) // That's where the file will go @@ -153,7 +153,7 @@ func writeMediaToDisk(h hyphae.Hypha, mime string, data []byte) (string, error) } // UploadBinary edits the hypha's media part and makes a history record about that. -func UploadBinary(h hyphae.Hypha, mime string, file multipart.File, u *user.User) error { +func UploadBinary(h hyphae2.Hypha, mime string, file multipart.File, u *user.User) error { // Privilege check if !u.CanProceed("upload-binary") { @@ -162,7 +162,7 @@ func UploadBinary(h hyphae.Hypha, mime string, file multipart.File, u *user.User } // Hypha name exploit check - if !hyphae.IsValidName(h.CanonicalName()) { + if !hyphae2.IsValidName(h.CanonicalName()) { // We check for the name only. I suppose the filepath would be valid as well. return errors.New("invalid hypha name") } @@ -185,12 +185,12 @@ func UploadBinary(h hyphae.Hypha, mime string, file multipart.File, u *user.User } switch h := h.(type) { - case *hyphae.EmptyHypha: - H := hyphae.ExtendEmptyToMedia(h, uploadedFilePath) - hyphae.Insert(H) - case *hyphae.TextualHypha: - hyphae.Insert(hyphae.ExtendTextualToMedia(h, uploadedFilePath)) - case *hyphae.MediaHypha: // If this is not the first media the hypha gets + case *hyphae2.EmptyHypha: + H := hyphae2.ExtendEmptyToMedia(h, uploadedFilePath) + hyphae2.Insert(H) + case *hyphae2.TextualHypha: + hyphae2.Insert(hyphae2.ExtendTextualToMedia(h, uploadedFilePath)) + case *hyphae2.MediaHypha: // If this is not the first media the hypha gets prevFilePath := h.MediaFilePath() if prevFilePath != uploadedFilePath { if err := history.Rename(prevFilePath, uploadedFilePath); err != nil { diff --git a/user/files.go b/internal/user/files.go similarity index 96% rename from user/files.go rename to internal/user/files.go index 2139d83..d48d8a9 100644 --- a/user/files.go +++ b/internal/user/files.go @@ -3,11 +3,11 @@ package user import ( "encoding/json" "errors" + "github.com/bouncepaw/mycorrhiza/internal/cfg" "log" "os" - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/bouncepaw/mycorrhiza/files" + "github.com/bouncepaw/mycorrhiza/internal/files" "github.com/bouncepaw/mycorrhiza/util" ) diff --git a/user/net.go b/internal/user/net.go similarity index 99% rename from user/net.go rename to internal/user/net.go index a97503b..03a8b48 100644 --- a/user/net.go +++ b/internal/user/net.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "errors" "fmt" + "github.com/bouncepaw/mycorrhiza/internal/cfg" "log" "net/http" "sort" @@ -14,7 +15,6 @@ import ( "golang.org/x/crypto/bcrypt" - "github.com/bouncepaw/mycorrhiza/cfg" "github.com/bouncepaw/mycorrhiza/util" ) diff --git a/user/user.go b/internal/user/user.go similarity index 98% rename from user/user.go rename to internal/user/user.go index 72a2c25..27f142f 100644 --- a/user/user.go +++ b/internal/user/user.go @@ -2,12 +2,12 @@ package user import ( "fmt" + "github.com/bouncepaw/mycorrhiza/internal/cfg" "net/http" "strings" "sync" "time" - "github.com/bouncepaw/mycorrhiza/cfg" "golang.org/x/crypto/bcrypt" ) diff --git a/user/users.go b/internal/user/users.go similarity index 100% rename from user/users.go rename to internal/user/users.go diff --git a/version/version.go b/internal/version/version.go similarity index 100% rename from version/version.go rename to internal/version/version.go diff --git a/interwiki/interwiki.go b/interwiki/interwiki.go index 5925db3..de4a532 100644 --- a/interwiki/interwiki.go +++ b/interwiki/interwiki.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "git.sr.ht/~bouncepaw/mycomarkup/v5/options" - "github.com/bouncepaw/mycorrhiza/files" + "github.com/bouncepaw/mycorrhiza/internal/files" "github.com/bouncepaw/mycorrhiza/util" "log" "os" diff --git a/interwiki/web.go b/interwiki/web.go index 7e2420c..124859f 100644 --- a/interwiki/web.go +++ b/interwiki/web.go @@ -2,7 +2,7 @@ package interwiki import ( "embed" - "github.com/bouncepaw/mycorrhiza/viewutil" + viewutil2 "github.com/bouncepaw/mycorrhiza/web/viewutil" "github.com/gorilla/mux" "log" "net/http" @@ -29,13 +29,13 @@ var ( {{define "edit separately."}}Изменяйте записи по отдельности.{{end}} {{define "add interwiki entry"}}Добавить запись в интеркарту{{end}} ` - chainInterwiki viewutil.Chain - chainNameTaken viewutil.Chain + chainInterwiki viewutil2.Chain + chainNameTaken viewutil2.Chain ) func InitHandlers(rtr *mux.Router) { - chainInterwiki = viewutil.CopyEnRuWith(fs, "view_interwiki.html", ruTranslation) - chainNameTaken = viewutil.CopyEnRuWith(fs, "view_name_taken.html", ruTranslation) + chainInterwiki = viewutil2.CopyEnRuWith(fs, "view_interwiki.html", ruTranslation) + chainNameTaken = viewutil2.CopyEnRuWith(fs, "view_name_taken.html", ruTranslation) rtr.HandleFunc("/interwiki", handlerInterwiki) rtr.HandleFunc("/interwiki/add-entry", handlerAddEntry).Methods(http.MethodPost) rtr.HandleFunc("/interwiki/modify-entry/{target}", handlerModifyEntry).Methods(http.MethodPost) @@ -64,13 +64,13 @@ func handlerModifyEntry(w http.ResponseWriter, rq *http.Request) { if oldData, ok = entriesByName[name]; !ok { log.Printf("Could not modify interwiki entry ‘%s’ because it does not exist", name) - viewutil.HandlerNotFound(w, rq) + viewutil2.HandlerNotFound(w, rq) return } if err := replaceEntry(oldData, &newData); err != nil { log.Printf("Could not modify interwiki entry ‘%s’ because one of the proposed aliases/name is taken\n", name) - viewNameTaken(viewutil.MetaFrom(w, rq), oldData, err.Error(), "modify-entry/"+name) + viewNameTaken(viewutil2.MetaFrom(w, rq), oldData, err.Error(), "modify-entry/"+name) return } @@ -82,7 +82,7 @@ func handlerModifyEntry(w http.ResponseWriter, rq *http.Request) { func handlerAddEntry(w http.ResponseWriter, rq *http.Request) { wiki := readInterwikiEntryFromRequest(rq) if err := addEntry(&wiki); err != nil { - viewNameTaken(viewutil.MetaFrom(w, rq), &wiki, err.Error(), "add-entry") + viewNameTaken(viewutil2.MetaFrom(w, rq), &wiki, err.Error(), "add-entry") return } saveInterwikiJson() @@ -90,15 +90,15 @@ func handlerAddEntry(w http.ResponseWriter, rq *http.Request) { } type nameTakenData struct { - *viewutil.BaseData + *viewutil2.BaseData *Wiki TakenName string Action string } -func viewNameTaken(meta viewutil.Meta, wiki *Wiki, takenName, action string) { - viewutil.ExecutePage(meta, chainNameTaken, nameTakenData{ - BaseData: &viewutil.BaseData{}, +func viewNameTaken(meta viewutil2.Meta, wiki *Wiki, takenName, action string) { + viewutil2.ExecutePage(meta, chainNameTaken, nameTakenData{ + BaseData: &viewutil2.BaseData{}, Wiki: wiki, TakenName: takenName, Action: action, @@ -106,19 +106,19 @@ func viewNameTaken(meta viewutil.Meta, wiki *Wiki, takenName, action string) { } func handlerInterwiki(w http.ResponseWriter, rq *http.Request) { - viewInterwiki(viewutil.MetaFrom(w, rq)) + viewInterwiki(viewutil2.MetaFrom(w, rq)) } type interwikiData struct { - *viewutil.BaseData + *viewutil2.BaseData Entries []*Wiki CanEdit bool Error string } -func viewInterwiki(meta viewutil.Meta) { - viewutil.ExecutePage(meta, chainInterwiki, interwikiData{ - BaseData: &viewutil.BaseData{}, +func viewInterwiki(meta viewutil2.Meta) { + viewutil2.ExecutePage(meta, chainInterwiki, interwikiData{ + BaseData: &viewutil2.BaseData{}, Entries: listOfEntries, CanEdit: meta.U.Group == "admin", Error: "", diff --git a/main.go b/main.go index 5988df3..734d2c1 100644 --- a/main.go +++ b/main.go @@ -8,23 +8,23 @@ package main import ( - "github.com/bouncepaw/mycorrhiza/backlinks" - "github.com/bouncepaw/mycorrhiza/categories" - "github.com/bouncepaw/mycorrhiza/interwiki" - "github.com/bouncepaw/mycorrhiza/migration" - "github.com/bouncepaw/mycorrhiza/version" - "github.com/bouncepaw/mycorrhiza/viewutil" "log" "os" - "github.com/bouncepaw/mycorrhiza/cfg" - "github.com/bouncepaw/mycorrhiza/files" + "github.com/bouncepaw/mycorrhiza/categories" "github.com/bouncepaw/mycorrhiza/history" - "github.com/bouncepaw/mycorrhiza/hyphae" - "github.com/bouncepaw/mycorrhiza/shroom" - "github.com/bouncepaw/mycorrhiza/static" - "github.com/bouncepaw/mycorrhiza/user" + "github.com/bouncepaw/mycorrhiza/internal/backlinks" + "github.com/bouncepaw/mycorrhiza/internal/cfg" + "github.com/bouncepaw/mycorrhiza/internal/files" + "github.com/bouncepaw/mycorrhiza/internal/hyphae" + migration2 "github.com/bouncepaw/mycorrhiza/internal/migration" + "github.com/bouncepaw/mycorrhiza/internal/shroom" + user2 "github.com/bouncepaw/mycorrhiza/internal/user" + "github.com/bouncepaw/mycorrhiza/internal/version" + "github.com/bouncepaw/mycorrhiza/interwiki" "github.com/bouncepaw/mycorrhiza/web" + "github.com/bouncepaw/mycorrhiza/web/static" + "github.com/bouncepaw/mycorrhiza/web/viewutil" ) func main() { @@ -49,11 +49,11 @@ func main() { hyphae.Index(files.HyphaeDir()) backlinks.IndexBacklinks() go backlinks.RunBacklinksConveyor() - user.InitUserDatabase() + user2.InitUserDatabase() history.Start() history.InitGitRepo() - migration.MigrateRocketsMaybe() - migration.MigrateHeadingsMaybe() + migration2.MigrateRocketsMaybe() + migration2.MigrateHeadingsMaybe() shroom.SetHeaderLinks() categories.Init() interwiki.Init() @@ -61,7 +61,7 @@ func main() { // Static files: static.InitFS(files.StaticFiles()) - if !user.HasAnyAdmins() { + if !user2.HasAnyAdmins() { log.Println("Your wiki has no admin yet. Run Mycorrhiza with -create-admin%s
`, lc.Get("ui.revision_no_text")) textContents string err error mycoFilePath string ) switch h := h.(type) { - case hyphae.ExistingHypha: + case hyphae2.ExistingHypha: mycoFilePath = h.TextFilePath() - case *hyphae.EmptyHypha: + case *hyphae2.EmptyHypha: mycoFilePath = filepath.Join(files.HyphaeDir(), h.CanonicalName()+".myco") } textContents, err = history.FileAtRevision(mycoFilePath, revHash) @@ -152,7 +152,7 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { } page := views2.Revision( - viewutil.MetaFrom(w, rq), + viewutil2.MetaFrom(w, rq), h, contents, revHash, @@ -161,8 +161,8 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { w.WriteHeader(http.StatusOK) _, _ = fmt.Fprint( w, - viewutil.Base( - viewutil.MetaFrom(w, rq), + viewutil2.Base( + viewutil2.MetaFrom(w, rq), lc.Get("ui.revision_title", &l18n.Replacements{"name": util.BeautifulName(hyphaName), "rev": revHash}), page, map[string]string{}, @@ -174,8 +174,8 @@ func handlerRevision(w http.ResponseWriter, rq *http.Request) { func handlerText(w http.ResponseWriter, rq *http.Request) { util.PrepareRq(rq) hyphaName := util.HyphaNameFromRq(rq, "text") - switch h := hyphae.ByName(hyphaName).(type) { - case hyphae.ExistingHypha: + switch h := hyphae2.ByName(hyphaName).(type) { + case hyphae2.ExistingHypha: log.Println("Serving", h.TextFilePath()) w.Header().Set("Content-Type", "text/plain; charset=utf-8") http.ServeFile(w, rq, h.TextFilePath()) @@ -186,12 +186,12 @@ func handlerText(w http.ResponseWriter, rq *http.Request) { func handlerBinary(w http.ResponseWriter, rq *http.Request) { util.PrepareRq(rq) hyphaName := util.HyphaNameFromRq(rq, "binary") - switch h := hyphae.ByName(hyphaName).(type) { - case *hyphae.EmptyHypha: - case *hyphae.TextualHypha: + switch h := hyphae2.ByName(hyphaName).(type) { + case *hyphae2.EmptyHypha: + case *hyphae2.TextualHypha: w.WriteHeader(http.StatusNotFound) log.Printf("Textual hypha ‘%s’ has no media, cannot serve\n", h.CanonicalName()) - case *hyphae.MediaHypha: + case *hyphae2.MediaHypha: log.Println("Serving", h.MediaFilePath()) w.Header().Set("Content-Type", mimetype.FromExtension(filepath.Ext(h.MediaFilePath()))) http.ServeFile(w, rq, h.MediaFilePath()) @@ -203,22 +203,22 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) { util.PrepareRq(rq) var ( hyphaName = util.HyphaNameFromRq(rq, "page", "hypha") - h = hyphae.ByName(hyphaName) + h = hyphae2.ByName(hyphaName) contents string openGraph string lc = l18n.FromRequest(rq) ) switch h := h.(type) { - case *hyphae.EmptyHypha: + case *hyphae2.EmptyHypha: util.HTTP404Page(w, - viewutil.Base( - viewutil.MetaFrom(w, rq), + viewutil2.Base( + viewutil2.MetaFrom(w, rq), util.BeautifulName(hyphaName), - views2.Hypha(viewutil.MetaFrom(w, rq), h, contents), + views2.Hypha(viewutil2.MetaFrom(w, rq), h, contents), map[string]string{}, openGraph)) - case hyphae.ExistingHypha: + case hyphae2.ExistingHypha: fileContentsT, errT := os.ReadFile(h.TextFilePath()) if errT == nil { ctx, _ := mycocontext.ContextFromStringInput(string(fileContentsT), mycoopts.MarkupOptions(hyphaName)) @@ -228,17 +228,17 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) { openGraph = getOpenGraph() } switch h := h.(type) { - case *hyphae.MediaHypha: + case *hyphae2.MediaHypha: contents = mycoopts.Media(h, lc) + contents } category_list := ":" + strings.Join(categories.CategoriesWithHypha(h.CanonicalName()), ":") + ":" util.HTTP200Page(w, - viewutil.Base( - viewutil.MetaFrom(w, rq), + viewutil2.Base( + viewutil2.MetaFrom(w, rq), util.BeautifulName(hyphaName), - views2.Hypha(viewutil.MetaFrom(w, rq), h, contents), + views2.Hypha(viewutil2.MetaFrom(w, rq), h, contents), map[string]string{"cats": category_list}, openGraph)) } @@ -248,7 +248,7 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) { func handlerBacklinks(w http.ResponseWriter, rq *http.Request) { hyphaName := util.HyphaNameFromRq(rq, "backlinks") - _ = pageBacklinks.RenderTo(viewutil.MetaFrom(w, rq), + _ = pageBacklinks.RenderTo(viewutil2.MetaFrom(w, rq), map[string]any{ "Addr": "/backlinks/" + hyphaName, "HyphaName": hyphaName, @@ -257,7 +257,7 @@ func handlerBacklinks(w http.ResponseWriter, rq *http.Request) { } func handlerOrphans(w http.ResponseWriter, rq *http.Request) { - _ = pageOrphans.RenderTo(viewutil.MetaFrom(w, rq), + _ = pageOrphans.RenderTo(viewutil2.MetaFrom(w, rq), map[string]any{ "Addr": "/orphans", "Orphans": backlinks.Orphans(), diff --git a/static/common.js b/web/static/common.js similarity index 100% rename from static/common.js rename to web/static/common.js diff --git a/static/default.css b/web/static/default.css similarity index 98% rename from static/default.css rename to web/static/default.css index d4ce2d9..55731ad 100644 --- a/static/default.css +++ b/web/static/default.css @@ -108,11 +108,11 @@ main h1:not(.navi-title) {font-size:1.7rem;} blockquote { margin: 0; padding-left: .75rem; } .wikilink_external::before { display: inline-block; width: 18px; height: 16px; vertical-align: sub; } /* .wikilink_external { padding-left: 16px; } */ -.wikilink_gopher::before { content: url("/static/icon/gopher-proto.svg"); } -.wikilink_http::before, .wikilink_https::before { content: url("/static/icon/http-proto.svg"); } +.wikilink_gopher::before { content: url("/web/staticatic/icon/gopher-proto.svg"); } +.wikilink_http::before, .wikilink_https::before { content: url("/web/staticatic/icon/http-proto.svg"); } /* .wikilink_https { background: transparent url("/static/icon/http-proto.svg") center left no-repeat; } */ -.wikilink_gemini::before { content: url("/static/icon/gemini-proto.svg"); } -.wikilink_mailto::before { content: url("/static/icon/mailto-proto.svg"); } +.wikilink_gemini::before { content: url("/web/staticatic/icon/gemini-proto.svg"); } +.wikilink_mailto::before { content: url("/web/staticatic/icon/mailto-proto.svg"); } article { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; line-height: 150%; } main h1 { margin: .5rem 0 0 0; } @@ -356,7 +356,7 @@ kbd { margin: 0; padding: 8px; border: none; - background: url(/static/icon/x.svg) no-repeat 8px 8px / 16px 16px; + background: url(/web/static/icon/x.svg) no-repeat 8px 8px / 16px 16px; width: 32px; height: 32px; cursor: pointer; diff --git a/static/editor.js b/web/static/editor.js similarity index 100% rename from static/editor.js rename to web/static/editor.js diff --git a/static/icon/README.md b/web/static/icon/README.md similarity index 100% rename from static/icon/README.md rename to web/static/icon/README.md diff --git a/static/icon/feed.svg b/web/static/icon/feed.svg similarity index 100% rename from static/icon/feed.svg rename to web/static/icon/feed.svg diff --git a/static/icon/gemini-proto.svg b/web/static/icon/gemini-proto.svg similarity index 100% rename from static/icon/gemini-proto.svg rename to web/static/icon/gemini-proto.svg diff --git a/static/icon/gopher-proto.svg b/web/static/icon/gopher-proto.svg similarity index 100% rename from static/icon/gopher-proto.svg rename to web/static/icon/gopher-proto.svg diff --git a/static/icon/http-proto.svg b/web/static/icon/http-proto.svg similarity index 100% rename from static/icon/http-proto.svg rename to web/static/icon/http-proto.svg diff --git a/static/icon/mailto-proto.svg b/web/static/icon/mailto-proto.svg similarity index 100% rename from static/icon/mailto-proto.svg rename to web/static/icon/mailto-proto.svg diff --git a/static/icon/mushroom.png b/web/static/icon/mushroom.png similarity index 100% rename from static/icon/mushroom.png rename to web/static/icon/mushroom.png diff --git a/static/icon/x.svg b/web/static/icon/x.svg similarity index 100% rename from static/icon/x.svg rename to web/static/icon/x.svg diff --git a/static/robots.txt b/web/static/robots.txt similarity index 100% rename from static/robots.txt rename to web/static/robots.txt diff --git a/static/shortcuts.js b/web/static/shortcuts.js similarity index 100% rename from static/shortcuts.js rename to web/static/shortcuts.js diff --git a/static/static.go b/web/static/static.go similarity index 100% rename from static/static.go rename to web/static/static.go diff --git a/static/toolbar.js b/web/static/toolbar.js similarity index 100% rename from static/toolbar.js rename to web/static/toolbar.js diff --git a/static/view.js b/web/static/view.js similarity index 100% rename from static/view.js rename to web/static/view.js diff --git a/viewutil/base.html b/web/viewutil/base.html similarity index 87% rename from viewutil/base.html rename to web/viewutil/base.html index 48ac707..15a90a4 100644 --- a/viewutil/base.html +++ b/web/viewutil/base.html @@ -10,8 +10,8 @@%s
%s
%s
%s
%s