mirror of
				https://github.com/osmarks/mycorrhiza.git
				synced 2025-10-30 23:23:04 +00:00 
			
		
		
		
	Isolate hypha renaming view
This commit is contained in:
		| @@ -28,25 +28,42 @@ var ( | ||||
| {{define "delete [[hypha]]?"}}Удалить <a href="/hypha/{{.}}">{{beautifulName .}}</a>?{{end}} | ||||
| {{define "want to delete?"}}Вы действительно хотите удалить эту гифу?{{end}} | ||||
| {{define "delete tip"}}Нельзя отменить удаление гифы, но её история останется доступной.{{end}} | ||||
|  | ||||
| {{define "rename hypha?"}}Переименовать {{beautifulName .}}?{{end}} | ||||
| {{define "rename [[hypha]]?"}}Переименовать <a href="/hypha/{{.}}">{{beautifulName .}}</a>?{{end}} | ||||
| {{define "new name"}}Новое название:{{end}} | ||||
| {{define "rename recursively"}}Также переименовать подгифы{{end}} | ||||
| {{define "rename tip"}}Если вы переименуете эту гифу, сломаются все ссылки, ведущие на неё, а также исходящие относительные ссылки. Также вы потеряете всю текущую историю для нового названия. Переименовывайте аккуратно.{{end}} | ||||
| ` | ||||
| 	chainNaviTitle   viewutil.Chain | ||||
| 	chainEmptyHypha  viewutil.Chain | ||||
| 	chainDeleteHypha viewutil.Chain | ||||
| 	chainRenameHypha viewutil.Chain | ||||
| ) | ||||
|  | ||||
| func Init() { | ||||
| 	chainNaviTitle = viewutil.CopyEnRuWith(fs, "view_navititle.html", "") | ||||
| 	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) | ||||
| } | ||||
|  | ||||
| type deleteData struct { | ||||
| type deleteRenameData struct { | ||||
| 	*viewutil.BaseData | ||||
| 	HyphaName string | ||||
| } | ||||
|  | ||||
| func RenameHypha(meta viewutil.Meta, hyphaName string) { | ||||
| 	viewutil.ExecutePage(meta, chainRenameHypha, deleteRenameData{ | ||||
| 		BaseData: &viewutil.BaseData{ | ||||
| 			Addr: "/rename/" + hyphaName, | ||||
| 		}, | ||||
| 		HyphaName: hyphaName, | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func DeleteHypha(meta viewutil.Meta, hyphaName string) { | ||||
| 	viewutil.ExecutePage(meta, chainDeleteHypha, deleteData{ | ||||
| 	viewutil.ExecutePage(meta, chainDeleteHypha, deleteRenameData{ | ||||
| 		BaseData: &viewutil.BaseData{ | ||||
| 			Addr: "/delete/" + hyphaName, | ||||
| 		}, | ||||
|   | ||||
| @@ -14,7 +14,7 @@ | ||||
| 			<button type="submit" value="Confirm" class="btn" autofocus> | ||||
| 				{{template "confirm"}} | ||||
| 			</button> | ||||
| 			<a href="/hypha/{%s hyphaName %}" class="btn btn_weak"> | ||||
| 			<a href="/hypha/{{.HyphaName}}" class="btn btn_weak"> | ||||
| 				{{template "cancel"}} | ||||
| 			</a> | ||||
| 		</fieldset> | ||||
|   | ||||
							
								
								
									
										26
									
								
								hypview/view_rename.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								hypview/view_rename.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| {{define "rename hypha?"}}Rename {{beautifulName .}}?{{end}} | ||||
| {{define "title"}}{{template "rename hypha?" .HyphaName}}{{end}} | ||||
| {{define "body"}} | ||||
| <main class="main-width"> | ||||
| 	<form class="modal" action="/rename/{{.HyphaName}}" method="post" enctype="multipart/form-data"> | ||||
| 		<fieldset class="modal__fieldset"> | ||||
| 			<legend class="modal__title"> | ||||
| 				{{block "rename [[hypha]]?" .HyphaName}}Rename <a href="/hypha/{{.}}">{{beautifulName .}}</a>?{{end}} | ||||
| 			</legend> | ||||
| 			<label for="new-name">{{block "new name" .}}New name:{{end}}</label> | ||||
| 			<input type="text" value="{{.HyphaName}}" required autofocus id="new-name" name="new-name"/> | ||||
|  | ||||
| 			<input type="checkbox" id="recursive" name="recursive" value="true" checked/> | ||||
| 			<label for="recursive">{{block "rename recursively" .}}Rename subhyphae too{{end}}</label> | ||||
|  | ||||
| 			<p>{{block "rename tip" .}}If you rename this hypha, all incoming links and all relative outcoming links will break. You will also lose all history for the new name. Rename carefully.{{end}}</p> | ||||
| 			<button type="submit" value="Confirm" class="btn"> | ||||
| 				{{template "confirm"}} | ||||
| 			</button> | ||||
| 			<a href="/hypha/{{.HyphaName}}" class="btn btn_weak"> | ||||
| 				{{template "cancel"}} | ||||
| 			</a> | ||||
| 		</fieldset> | ||||
| 	</form> | ||||
| </main> | ||||
| {{end}} | ||||
| @@ -26,30 +26,3 @@ | ||||
| </main> | ||||
| {% endfunc %} | ||||
|  | ||||
| {% func RenameAsk(rq *http.Request, hyphaName string) %} | ||||
| {% code  | ||||
|   lc := l18n.FromRequest(rq) | ||||
| %} | ||||
| <main class="main-width"> | ||||
| 	<form class="modal" action="/rename/{%s hyphaName %}" method="post" enctype="multipart/form-data"> | ||||
| 		<fieldset class="modal__fieldset"> | ||||
| 			<legend class="modal__title"> | ||||
| 				{%s= fmt.Sprintf(lc.Get("ui.ask_rename"), beautifulLink(hyphaName)) %} | ||||
| 			</legend> | ||||
| 			<label for="new-name">{%s lc.Get("ui.rename_to") %}</label> | ||||
| 			<input type="text" value="{%s hyphaName %}" required autofocus id="new-name" name="new-name"/> | ||||
|  | ||||
| 			<input type="checkbox" id="recursive" name="recursive" value="true" checked/> | ||||
| 			<label for="recursive">{%s lc.Get("ui.rename_recurse") %}</label> | ||||
|  | ||||
| 			<p>{%s lc.Get("ui.rename_tip") %}</p> | ||||
| 			<button type="submit" value="Confirm" class="btn"> | ||||
| 				{%s lc.Get("ui.confirm") %} | ||||
| 			</button> | ||||
| 			<a href="/hypha/{%s hyphaName %}" class="btn btn_weak"> | ||||
| 				{%s lc.Get("ui.cancel") %} | ||||
| 			</a> | ||||
| 		</fieldset> | ||||
| 	</form> | ||||
| </main> | ||||
| {% endfunc %} | ||||
|   | ||||
| @@ -107,101 +107,3 @@ func RemoveMediaAsk(rq *http.Request, hyphaName string) string { | ||||
| 	return qs422016 | ||||
| //line views/modal.qtpl:27 | ||||
| } | ||||
|  | ||||
| //line views/modal.qtpl:29 | ||||
| func StreamRenameAsk(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) { | ||||
| //line views/modal.qtpl:29 | ||||
| 	qw422016.N().S(` | ||||
| `) | ||||
| //line views/modal.qtpl:31 | ||||
| 	lc := l18n.FromRequest(rq) | ||||
|  | ||||
| //line views/modal.qtpl:32 | ||||
| 	qw422016.N().S(` | ||||
| <main class="main-width"> | ||||
| 	<form class="modal" action="/rename/`) | ||||
| //line views/modal.qtpl:34 | ||||
| 	qw422016.E().S(hyphaName) | ||||
| //line views/modal.qtpl:34 | ||||
| 	qw422016.N().S(`" method="post" enctype="multipart/form-data"> | ||||
| 		<fieldset class="modal__fieldset"> | ||||
| 			<legend class="modal__title"> | ||||
| 				`) | ||||
| //line views/modal.qtpl:37 | ||||
| 	qw422016.N().S(fmt.Sprintf(lc.Get("ui.ask_rename"), beautifulLink(hyphaName))) | ||||
| //line views/modal.qtpl:37 | ||||
| 	qw422016.N().S(` | ||||
| 			</legend> | ||||
| 			<label for="new-name">`) | ||||
| //line views/modal.qtpl:39 | ||||
| 	qw422016.E().S(lc.Get("ui.rename_to")) | ||||
| //line views/modal.qtpl:39 | ||||
| 	qw422016.N().S(`</label> | ||||
| 			<input type="text" value="`) | ||||
| //line views/modal.qtpl:40 | ||||
| 	qw422016.E().S(hyphaName) | ||||
| //line views/modal.qtpl:40 | ||||
| 	qw422016.N().S(`" required autofocus id="new-name" name="new-name"/> | ||||
|  | ||||
| 			<input type="checkbox" id="recursive" name="recursive" value="true" checked/> | ||||
| 			<label for="recursive">`) | ||||
| //line views/modal.qtpl:43 | ||||
| 	qw422016.E().S(lc.Get("ui.rename_recurse")) | ||||
| //line views/modal.qtpl:43 | ||||
| 	qw422016.N().S(`</label> | ||||
|  | ||||
| 			<p>`) | ||||
| //line views/modal.qtpl:45 | ||||
| 	qw422016.E().S(lc.Get("ui.rename_tip")) | ||||
| //line views/modal.qtpl:45 | ||||
| 	qw422016.N().S(`</p> | ||||
| 			<button type="submit" value="Confirm" class="btn"> | ||||
| 				`) | ||||
| //line views/modal.qtpl:47 | ||||
| 	qw422016.E().S(lc.Get("ui.confirm")) | ||||
| //line views/modal.qtpl:47 | ||||
| 	qw422016.N().S(` | ||||
| 			</button> | ||||
| 			<a href="/hypha/`) | ||||
| //line views/modal.qtpl:49 | ||||
| 	qw422016.E().S(hyphaName) | ||||
| //line views/modal.qtpl:49 | ||||
| 	qw422016.N().S(`" class="btn btn_weak"> | ||||
| 				`) | ||||
| //line views/modal.qtpl:50 | ||||
| 	qw422016.E().S(lc.Get("ui.cancel")) | ||||
| //line views/modal.qtpl:50 | ||||
| 	qw422016.N().S(` | ||||
| 			</a> | ||||
| 		</fieldset> | ||||
| 	</form> | ||||
| </main> | ||||
| `) | ||||
| //line views/modal.qtpl:55 | ||||
| } | ||||
|  | ||||
| //line views/modal.qtpl:55 | ||||
| func WriteRenameAsk(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) { | ||||
| //line views/modal.qtpl:55 | ||||
| 	qw422016 := qt422016.AcquireWriter(qq422016) | ||||
| //line views/modal.qtpl:55 | ||||
| 	StreamRenameAsk(qw422016, rq, hyphaName) | ||||
| //line views/modal.qtpl:55 | ||||
| 	qt422016.ReleaseWriter(qw422016) | ||||
| //line views/modal.qtpl:55 | ||||
| } | ||||
|  | ||||
| //line views/modal.qtpl:55 | ||||
| func RenameAsk(rq *http.Request, hyphaName string) string { | ||||
| //line views/modal.qtpl:55 | ||||
| 	qb422016 := qt422016.AcquireByteBuffer() | ||||
| //line views/modal.qtpl:55 | ||||
| 	WriteRenameAsk(qb422016, rq, hyphaName) | ||||
| //line views/modal.qtpl:55 | ||||
| 	qs422016 := string(qb422016.B) | ||||
| //line views/modal.qtpl:55 | ||||
| 	qt422016.ReleaseByteBuffer(qb422016) | ||||
| //line views/modal.qtpl:55 | ||||
| 	return qs422016 | ||||
| //line views/modal.qtpl:55 | ||||
| } | ||||
|   | ||||
| @@ -130,12 +130,7 @@ func handlerRename(w http.ResponseWriter, rq *http.Request) { | ||||
| 	) | ||||
|  | ||||
| 	if rq.Method == "GET" { | ||||
| 		util.HTTP200Page( | ||||
| 			w, | ||||
| 			views.Base( | ||||
| 				meta, | ||||
| 				fmt.Sprintf(lc.Get("ui.ask_rename"), util.BeautifulName(oldHypha.CanonicalName())), | ||||
| 				views.RenameAsk(rq, oldHypha.CanonicalName()))) | ||||
| 		hypview.RenameHypha(meta, h.CanonicalName()) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Timur Ismagilov
					Timur Ismagilov