diff --git a/shroom/rename.go b/shroom/rename.go
index e59bb5a..503f497 100644
--- a/shroom/rename.go
+++ b/shroom/rename.go
@@ -26,6 +26,9 @@ func Rename(oldHypha hyphae.ExistingHypha, newName string, recursive bool, u *us
switch targetHypha := hyphae.ByName(newName); targetHypha.(type) {
case hyphae.ExistingHypha:
+ if targetHypha.CanonicalName() == oldHypha.CanonicalName() {
+ return nil
+ }
rejectRenameLog(oldHypha, u, fmt.Sprintf("name ‘%s’ taken already", newName))
return errors.New("ui.rename_taken_tip") // FIXME: There is a bug related to this.
}
diff --git a/shroom/unattach.go b/shroom/unattach.go
index 14f9af5..ec2ff1c 100644
--- a/shroom/unattach.go
+++ b/shroom/unattach.go
@@ -9,17 +9,11 @@ import (
"github.com/bouncepaw/mycorrhiza/user"
)
-// UnattachHypha unattaches hypha and makes a history record about that.
-func UnattachHypha(u *user.User, h hyphae.Hypha, lc *l18n.Localizer) error {
-
- if err := CanUnattach(u, h, lc); err != nil {
- return err
- }
- H := h.(*hyphae.MediaHypha)
-
+// RemoveMedia unattaches hypha and makes a history record about that.
+func RemoveMedia(u *user.User, h *hyphae.MediaHypha, lc *l18n.Localizer) error {
hop := history.
Operation(history.TypeUnattachHypha).
- WithFilesRemoved(H.MediaFilePath()).
+ WithFilesRemoved(h.MediaFilePath()).
WithMsg(fmt.Sprintf("Unattach ‘%s’", h.CanonicalName())).
WithUser(u).
Apply()
@@ -30,10 +24,10 @@ func UnattachHypha(u *user.User, h hyphae.Hypha, lc *l18n.Localizer) error {
return fmt.Errorf("Could not unattach this hypha due to internal server errors: %v", hop.Errs)
}
- if H.HasTextFile() {
- hyphae.Insert(hyphae.ShrinkMediaToTextual(H))
+ if h.HasTextFile() {
+ hyphae.Insert(hyphae.ShrinkMediaToTextual(h))
} else {
- hyphae.DeleteHypha(H)
+ hyphae.DeleteHypha(h)
}
return nil
}
diff --git a/user/user.go b/user/user.go
index 6020522..886c081 100644
--- a/user/user.go
+++ b/user/user.go
@@ -35,15 +35,9 @@ var minimalRights = map[string]int{
"upload-binary": 1,
"upload-text": 1,
"rename": 2,
- "rename-ask": 2,
- "rename-confirm": 2,
"remove-media": 2,
- "unattach-ask": 2,
- "unattach-confirm": 2,
"update-header-links": 3,
"delete": 3,
- "delete-ask": 3,
- "delete-confirm": 3,
"reindex": 4,
"admin": 4,
"admin/shutdown": 4,
diff --git a/views/modal.qtpl b/views/modal.qtpl
index 8d6adf0..8db2581 100644
--- a/views/modal.qtpl
+++ b/views/modal.qtpl
@@ -7,7 +7,7 @@
lc := l18n.FromRequest(rq)
%}
{%= modalBegin(
- "delete-confirm",
+ "delete",
hyphaName,
"",
fmt.Sprintf(lc.Get("ui.ask_delete"), beautifulLink(hyphaName))) %}
@@ -16,25 +16,27 @@
{%= modalEnd(hyphaName, true, lc) %}
{% endfunc %}
-{% func UnattachAskHTML(rq *http.Request, hyphaName string) %}
+{% func RemoveMediaAskHTML(rq *http.Request, hyphaName string) %}
{% code
lc := l18n.FromRequest(rq)
%}
{%= modalBegin(
- "unattach",
+ "remove-media",
hyphaName,
"",
- fmt.Sprintf(lc.Get("ui.ask_unattach"), beautifulLink(hyphaName))) %}
-{%= modalReallyWant(hyphaName, lc.Get("ui.ask_unattach_verb"), lc) %}
+ fmt.Sprintf(lc.Get("ui.ask_remove_media"), beautifulLink(hyphaName))) %}
+{%= modalReallyWant(hyphaName, lc.Get("ui.ask_remove_media_verb"), lc) %}
{%= modalEnd(hyphaName, true, lc) %}
{% endfunc %}
+bloody hell !!
+
{% func RenameAskHTML(rq *http.Request, hyphaName string) %}
{% code
lc := l18n.FromRequest(rq)
%}
{%= modalBegin(
- "rename-confirm",
+ "rename",
hyphaName,
` method="post" enctype="multipart/form-data"`,
fmt.Sprintf(lc.Get("ui.ask_rename"), beautifulLink(hyphaName))) %}
diff --git a/views/modal.qtpl.go b/views/modal.qtpl.go
index 10bddfe..09b6eb8 100644
--- a/views/modal.qtpl.go
+++ b/views/modal.qtpl.go
@@ -39,7 +39,7 @@ func StreamDeleteAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName
`)
//line views/modal.qtpl:9
streammodalBegin(qw422016,
- "delete-confirm",
+ "delete",
hyphaName,
"",
fmt.Sprintf(lc.Get("ui.ask_delete"), beautifulLink(hyphaName)))
@@ -91,7 +91,7 @@ func DeleteAskHTML(rq *http.Request, hyphaName string) string {
}
//line views/modal.qtpl:19
-func StreamUnattachAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) {
+func StreamRemoveMediaAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:19
qw422016.N().S(`
`)
@@ -103,15 +103,15 @@ func StreamUnattachAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaNam
`)
//line views/modal.qtpl:23
streammodalBegin(qw422016,
- "unattach",
+ "remove-media",
hyphaName,
"",
- fmt.Sprintf(lc.Get("ui.ask_unattach"), beautifulLink(hyphaName)))
+ fmt.Sprintf(lc.Get("ui.ask_remove_media"), beautifulLink(hyphaName)))
//line views/modal.qtpl:27
qw422016.N().S(`
`)
//line views/modal.qtpl:28
- streammodalReallyWant(qw422016, hyphaName, lc.Get("ui.ask_unattach_verb"), lc)
+ streammodalReallyWant(qw422016, hyphaName, lc.Get("ui.ask_remove_media_verb"), lc)
//line views/modal.qtpl:28
qw422016.N().S(`
`)
@@ -124,22 +124,22 @@ func StreamUnattachAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaNam
}
//line views/modal.qtpl:30
-func WriteUnattachAskHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) {
+func WriteRemoveMediaAskHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) {
//line views/modal.qtpl:30
qw422016 := qt422016.AcquireWriter(qq422016)
//line views/modal.qtpl:30
- StreamUnattachAskHTML(qw422016, rq, hyphaName)
+ StreamRemoveMediaAskHTML(qw422016, rq, hyphaName)
//line views/modal.qtpl:30
qt422016.ReleaseWriter(qw422016)
//line views/modal.qtpl:30
}
//line views/modal.qtpl:30
-func UnattachAskHTML(rq *http.Request, hyphaName string) string {
+func RemoveMediaAskHTML(rq *http.Request, hyphaName string) string {
//line views/modal.qtpl:30
qb422016 := qt422016.AcquireByteBuffer()
//line views/modal.qtpl:30
- WriteUnattachAskHTML(qb422016, rq, hyphaName)
+ WriteRemoveMediaAskHTML(qb422016, rq, hyphaName)
//line views/modal.qtpl:30
qs422016 := string(qb422016.B)
//line views/modal.qtpl:30
@@ -149,233 +149,236 @@ func UnattachAskHTML(rq *http.Request, hyphaName string) string {
//line views/modal.qtpl:30
}
-//line views/modal.qtpl:32
-func StreamRenameAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) {
-//line views/modal.qtpl:32
- qw422016.N().S(`
-`)
-//line views/modal.qtpl:34
- lc := l18n.FromRequest(rq)
+// bloody hell !!
+//
-//line views/modal.qtpl:35
+//line views/modal.qtpl:34
+func StreamRenameAskHTML(qw422016 *qt422016.Writer, rq *http.Request, hyphaName string) {
+//line views/modal.qtpl:34
qw422016.N().S(`
`)
//line views/modal.qtpl:36
+ lc := l18n.FromRequest(rq)
+
+//line views/modal.qtpl:37
+ qw422016.N().S(`
+`)
+//line views/modal.qtpl:38
streammodalBegin(qw422016,
- "rename-confirm",
+ "rename",
hyphaName,
` method="post" enctype="multipart/form-data"`,
fmt.Sprintf(lc.Get("ui.ask_rename"), beautifulLink(hyphaName)))
-//line views/modal.qtpl:40
+//line views/modal.qtpl:42
qw422016.N().S(`
`) -//line views/modal.qtpl:47 +//line views/modal.qtpl:49 qw422016.E().S(lc.Get("ui.rename_tip")) -//line views/modal.qtpl:47 +//line views/modal.qtpl:49 qw422016.N().S(`
`) -//line views/modal.qtpl:48 +//line views/modal.qtpl:50 streammodalEnd(qw422016, hyphaName, false, lc) -//line views/modal.qtpl:48 +//line views/modal.qtpl:50 qw422016.N().S(` `) -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 } -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 func WriteRenameAskHTML(qq422016 qtio422016.Writer, rq *http.Request, hyphaName string) { -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 StreamRenameAskHTML(qw422016, rq, hyphaName) -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 qt422016.ReleaseWriter(qw422016) -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 } -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 func RenameAskHTML(rq *http.Request, hyphaName string) string { -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 qb422016 := qt422016.AcquireByteBuffer() -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 WriteRenameAskHTML(qb422016, rq, hyphaName) -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 qs422016 := string(qb422016.B) -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 qt422016.ReleaseByteBuffer(qb422016) -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 return qs422016 -//line views/modal.qtpl:49 +//line views/modal.qtpl:51 } -//line views/modal.qtpl:51 +//line views/modal.qtpl:53 func streammodalReallyWant(qw422016 *qt422016.Writer, hyphaName, verb string, lc *l18n.Localizer) { -//line views/modal.qtpl:51 +//line views/modal.qtpl:53 qw422016.N().S(``) -//line views/modal.qtpl:52 +//line views/modal.qtpl:54 qw422016.N().S(lc.Get("ui.ask_really", &l18n.Replacements{"verb": verb, "name": fmt.Sprintf("%s", hyphaName)})) -//line views/modal.qtpl:52 +//line views/modal.qtpl:54 qw422016.N().S(`
`) -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 } -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 func writemodalReallyWant(qq422016 qtio422016.Writer, hyphaName, verb string, lc *l18n.Localizer) { -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 qw422016 := qt422016.AcquireWriter(qq422016) -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 streammodalReallyWant(qw422016, hyphaName, verb, lc) -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 qt422016.ReleaseWriter(qw422016) -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 } -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 func modalReallyWant(hyphaName, verb string, lc *l18n.Localizer) string { -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 qb422016 := qt422016.AcquireByteBuffer() -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 writemodalReallyWant(qb422016, hyphaName, verb, lc) -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 qs422016 := string(qb422016.B) -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 qt422016.ReleaseByteBuffer(qb422016) -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 return qs422016 -//line views/modal.qtpl:53 +//line views/modal.qtpl:55 } -//line views/modal.qtpl:55 +//line views/modal.qtpl:57 func streammodalBegin(qw422016 *qt422016.Writer, path, hyphaName, formAttrs, legend string) { -//line views/modal.qtpl:55 +//line views/modal.qtpl:57 qw422016.N().S(`