diff --git a/history/histweb/histview.go b/history/histweb/histview.go index 1f59d77..4b4bc84 100644 --- a/history/histweb/histview.go +++ b/history/histweb/histview.go @@ -124,8 +124,8 @@ var ( {{define "history of title"}}История «{{.}}»{{end}} {{define "history of heading"}}История {{beautifulName .}}{{end}} -{{define "diff for at title"}}Разница для {{beautifulName .HyphaName}} для {{.Hash}}{{end}} -{{define "diff for at heading"}}Разница для {{beautifulName .HyphaName}} для {{.Hash}}{{end}} +{{define "diff for at title"}}Разница для {{beautifulName .MatchedHyphaName}} для {{.Hash}}{{end}} +{{define "diff for at heading"}}Разница для {{beautifulName .MatchedHyphaName}} для {{.Hash}}{{end}} {{define "no text diff available"}}Нет текстовой разницы.{{end}} {{define "count pre"}}Отобразить{{end}} diff --git a/hypview/hypview.go b/hypview/hypview.go index 753f6d2..ea705db 100644 --- a/hypview/hypview.go +++ b/hypview/hypview.go @@ -74,8 +74,8 @@ var ( {{define "leave redirection"}}Оставить перенаправление{{end}} {{define "remove media from x?"}}Убрать медиа у {{beautifulName .}}?{{end}} -{{define "remove media from [[x]]?"}}Убрать медиа у {{beautifulName .HyphaName}}?{{end}} -{{define "remove media for real?"}}Вы точно хотите убрать медиа у гифы «{{beautifulName .HyphaName}}»?{{end}} +{{define "remove media from [[x]]?"}}Убрать медиа у {{beautifulName .MatchedHyphaName}}?{{end}} +{{define "remove media for real?"}}Вы точно хотите убрать медиа у гифы «{{beautifulName .MatchedHyphaName}}»?{{end}} ` chainNaviTitle viewutil.Chain chainEditHypha viewutil.Chain diff --git a/misc/handlers.go b/misc/handlers.go index d2a41fa..d097763 100644 --- a/misc/handlers.go +++ b/misc/handlers.go @@ -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) } diff --git a/misc/view_title_search.html b/misc/view_title_search.html index d3ef8f3..b8e9c86 100644 --- a/misc/view_title_search.html +++ b/misc/view_title_search.html @@ -3,6 +3,9 @@ {{define "body"}}

{{block "search results for" .Query}}Search results for ‘{{.}}’{{end}}

+ {{if .MatchedHyphaName}} +

{{block "go to hypha" .}}Go to hypha {{beautifulName .MatchedHyphaName}}.{{end}}

+ {{end}} {{if len .Results}}

{{block "search desc" .}}Every hypha name has been compared with the query. Hyphae that have matched the query are listed below.{{end}}

    diff --git a/misc/views.go b/misc/views.go index 9c9f6ac..f19b495 100644 --- a/misc/views.go +++ b/misc/views.go @@ -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"}}Перейти к гифе {{beautifulName .MatchedHyphaName}}.{{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, }) }