~bouncepaw/mycorrhiza

b29042a52c0388254dec5765e1d57402103822a0 — Timur Ismagilov 1 year, 10 months ago 2dab26d
Search: Add go to hypha section
M history/histweb/histview.go => history/histweb/histview.go +2 -2
@@ 124,8 124,8 @@ var (
{{define "history of title"}}История «{{.}}»{{end}}
{{define "history of heading"}}История <a href="/hypha/{{.}}">{{beautifulName .}}</a>{{end}}

{{define "diff for at title"}}Разница для {{beautifulName .HyphaName}} для {{.Hash}}{{end}}
{{define "diff for at heading"}}Разница для <a href="/hypha/{{.HyphaName}}">{{beautifulName .HyphaName}}</a> для {{.Hash}}{{end}}
{{define "diff for at title"}}Разница для {{beautifulName .MatchedHyphaName}} для {{.Hash}}{{end}}
{{define "diff for at heading"}}Разница для <a href="/hypha/{{.MatchedHyphaName}}">{{beautifulName .MatchedHyphaName}}</a> для {{.Hash}}{{end}}
{{define "no text diff available"}}Нет текстовой разницы.{{end}}

{{define "count pre"}}Отобразить{{end}}

M hypview/hypview.go => hypview/hypview.go +2 -2
@@ 74,8 74,8 @@ var (
{{define "leave redirection"}}Оставить перенаправление{{end}}

{{define "remove media from x?"}}Убрать медиа у {{beautifulName .}}?{{end}}
{{define "remove media from [[x]]?"}}Убрать медиа у <a href="/hypha/{{.HyphaName}}">{{beautifulName .HyphaName}}</a>?{{end}}
{{define "remove media for real?"}}Вы точно хотите убрать медиа у гифы «{{beautifulName .HyphaName}}»?{{end}}
{{define "remove media from [[x]]?"}}Убрать медиа у <a href="/hypha/{{.MatchedHyphaName}}">{{beautifulName .MatchedHyphaName}}</a>?{{end}}
{{define "remove media for real?"}}Вы точно хотите убрать медиа у гифы «{{beautifulName .MatchedHyphaName}}»?{{end}}
`
	chainNaviTitle   viewutil.Chain
	chainEditHypha   viewutil.Chain

M misc/handlers.go => misc/handlers.go +5 -3
@@ 172,12 172,14 @@ func handlerTitleSearch(w http.ResponseWriter, rq *http.Request) {
	util.PrepareRq(rq)
	_ = rq.ParseForm()
	var (
		query   = rq.FormValue("q")
		results []string
		query       = rq.FormValue("q")
		hyphaName   = util.CanonicalName(query)
		_, nameFree = hyphae.AreFreeNames(hyphaName)
		results     []string
	)
	for hyphaName := range shroom.YieldHyphaNamesContainingString(query) {
		results = append(results, hyphaName)
	}
	w.WriteHeader(http.StatusOK)
	viewTitleSearch(viewutil.MetaFrom(w, rq), query, results)
	viewTitleSearch(viewutil.MetaFrom(w, rq), query, hyphaName, !nameFree, results)
}

M misc/view_title_search.html => misc/view_title_search.html +3 -0
@@ 3,6 3,9 @@
{{define "body"}}
<main class="main-width">
	<h1>{{block "search results for" .Query}}Search results for ‘{{.}}’{{end}}</h1>
	{{if .MatchedHyphaName}}
		<p>{{block "go to hypha" .}}Go to hypha <a class="wikilink{{if .HasExactMatch | not}} wikilink_new{{end}}" href="/hypha/{{.MatchedHyphaName}}">{{beautifulName .MatchedHyphaName}}</a>.{{end}}</p>
	{{end}}
	{{if len .Results}}
		<p>{{block "search desc" .}}Every hypha name has been compared with the query. Hyphae that have matched the query are listed below.{{end}}</p>
		<ol>

M misc/views.go => misc/views.go +12 -7
@@ 15,8 15,9 @@ var (
{{define "search:"}}Поиск:{{end}}
{{define "search results for"}}Результаты поиска для «{{.}}»{{end}}
{{define "search desc"}}Название каждой из существующих гиф сопоставлено с запросом. Подходящие гифы приведены ниже.{{end}}
{{define "search no results"}}Ничего не найдено{{end}}
{{define "search no results"}}Ничего не найдено.{{end}}
{{define "x total"}}{{.}} всего.{{end}}
{{define "go to hypha"}}Перейти к гифе <a class="wikilink{{if .HasExactMatch | not}} wikilink_new{{end}}" href="/hypha/{{.MatchedHyphaName}}">{{beautifulName .MatchedHyphaName}}</a>.{{end}}
`
)



@@ 46,14 47,18 @@ func viewList(meta viewutil.Meta, entries []listDatum) {

type titleSearchData struct {
	*viewutil.BaseData
	Query   string
	Results []string
	Query            string
	Results          []string
	MatchedHyphaName string
	HasExactMatch    bool
}

func viewTitleSearch(meta viewutil.Meta, query string, results []string) {
func viewTitleSearch(meta viewutil.Meta, query string, hyphaName string, hasExactMatch bool, results []string) {
	viewutil.ExecutePage(meta, chainTitleSearch, titleSearchData{
		BaseData: &viewutil.BaseData{},
		Query:    query,
		Results:  results,
		BaseData:         &viewutil.BaseData{},
		Query:            query,
		Results:          results,
		MatchedHyphaName: hyphaName,
		HasExactMatch:    hasExactMatch,
	})
}