From 48a993d06774e6eb763cd52501da365e3155a04a Mon Sep 17 00:00:00 2001 From: Azareal Date: Mon, 29 Apr 2019 18:17:12 +1000 Subject: [PATCH] The Forum Manager now uses dyntmpl. The User Manager now uses dyntmpl. panel_groups.html now uses dyntmpl. HTMLID is now optional in panel.html Moved the inline JS in panel_forum_edit.html into panel_forum_edit.js Removed the legacy indents from panel_analytics_referrers. --- public/panel_forum_edit.js | 5 ++++ routes/panel/forums.go | 7 +++--- routes/panel/groups.go | 2 +- routes/panel/users.go | 4 ++-- templates/panel.html | 2 +- templates/panel_analytics_referrers.html | 30 ++++++++++++------------ templates/panel_forum_edit.html | 15 +----------- templates/panel_forum_edit_perms.html | 11 +-------- templates/panel_forums.html | 13 +--------- templates/panel_groups.html | 12 +--------- templates/panel_user_edit.html | 12 +--------- templates/panel_users.html | 12 +--------- 12 files changed, 34 insertions(+), 91 deletions(-) create mode 100644 public/panel_forum_edit.js diff --git a/public/panel_forum_edit.js b/public/panel_forum_edit.js new file mode 100644 index 00000000..ffccc207 --- /dev/null +++ b/public/panel_forum_edit.js @@ -0,0 +1,5 @@ +(() => { + addInitHook("end_init", () => { + formVars = {'perm_preset': ['can_moderate','can_post','read_only','no_access','default','custom']}; + }); +})(); \ No newline at end of file diff --git a/routes/panel/forums.go b/routes/panel/forums.go index 357561da..d9658d76 100644 --- a/routes/panel/forums.go +++ b/routes/panel/forums.go @@ -49,7 +49,7 @@ func Forums(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { } pi := c.PanelPage{basePage, forumList, nil} - return renderTemplate("panel_forums", w, r, basePage.Header, &pi) + return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage,"","","panel_forums",&pi}) } func ForumsCreateSubmit(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { @@ -165,6 +165,7 @@ func ForumsEdit(w http.ResponseWriter, r *http.Request, user c.User, sfid string if !user.Perms.ManageForums { return c.NoPermissions(w, r, user) } + basePage.Header.AddScriptAsync("panel_forum_edit.js") fid, err := strconv.Atoi(sfid) if err != nil { @@ -206,7 +207,7 @@ func ForumsEdit(w http.ResponseWriter, r *http.Request, user c.User, sfid string } pi := c.PanelEditForumPage{basePage, forum.ID, forum.Name, forum.Desc, forum.Active, forum.Preset, gplist} - return renderTemplate("panel_forum_edit", w, r, basePage.Header, &pi) + return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage,"","","panel_forum_edit",&pi}) } func ForumsEditSubmit(w http.ResponseWriter, r *http.Request, user c.User, sfid string) c.RouteError { @@ -364,7 +365,7 @@ func ForumsEditPermsAdvance(w http.ResponseWriter, r *http.Request, user c.User, } pi := c.PanelEditForumGroupPage{basePage, forum.ID, gid, forum.Name, forum.Desc, forum.Active, forum.Preset, formattedPermList} - return renderTemplate("panel_forum_edit_perms", w, r, basePage.Header, &pi) + return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage,"","","panel_forum_edit_perms",&pi}) } func ForumsEditPermsAdvanceSubmit(w http.ResponseWriter, r *http.Request, user c.User, paramList string) c.RouteError { diff --git a/routes/panel/groups.go b/routes/panel/groups.go index 000e8afd..d658e591 100644 --- a/routes/panel/groups.go +++ b/routes/panel/groups.go @@ -59,7 +59,7 @@ func Groups(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { pageList := c.Paginate(basePage.Stats.Groups, perPage, 5) pi := c.PanelGroupPage{basePage, groupList, c.Paginator{pageList, page, lastPage}} - return renderTemplate("panel_groups", w, r, basePage.Header, &pi) + return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage,"","","panel_groups",&pi}) } func GroupsEdit(w http.ResponseWriter, r *http.Request, user c.User, sgid string) c.RouteError { diff --git a/routes/panel/users.go b/routes/panel/users.go index 77ac63e5..5be1b27b 100644 --- a/routes/panel/users.go +++ b/routes/panel/users.go @@ -25,7 +25,7 @@ func Users(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { pageList := c.Paginate(basePage.Stats.Users, perPage, 5) pi := c.PanelUserPage{basePage, users, c.Paginator{pageList, page, lastPage}} - return renderTemplate("panel_users", w, r, basePage.Header, &pi) + return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage,"","","panel_users",&pi}) } func UsersEdit(w http.ResponseWriter, r *http.Request, user c.User, suid string) c.RouteError { @@ -75,7 +75,7 @@ func UsersEdit(w http.ResponseWriter, r *http.Request, user c.User, suid string) } pi := c.PanelPage{basePage, groupList, targetUser} - return renderTemplate("panel_user_edit", w, r, basePage.Header, &pi) + return renderTemplate("panel", w, r, basePage.Header, c.Panel{basePage,"","","panel_user_edit",&pi}) } func UsersEditSubmit(w http.ResponseWriter, r *http.Request, user c.User, suid string) c.RouteError { diff --git a/templates/panel.html b/templates/panel.html index 759a8e0b..ce525405 100644 --- a/templates/panel.html +++ b/templates/panel.html @@ -1,7 +1,7 @@ {{template "header.html" . }}
{{template "panel_menu.html" . }} -
+ {{template "panel_before_head.html" . }} {{dyntmpl .TmplName .Inner .Header}}
diff --git a/templates/panel_analytics_referrers.html b/templates/panel_analytics_referrers.html index 3e4c85ad..24cc9381 100644 --- a/templates/panel_analytics_referrers.html +++ b/templates/panel_analytics_referrers.html @@ -1,15 +1,15 @@ -
-
-

{{lang "panel_statistics_referrers_head"}}

- {{template "panel_analytics_time_range.html" . }} -
-
-
-
- {{range .ItemList}} -
- {{.Agent}} - {{.Count}}{{lang "panel_statistics_views_suffix"}} -
- {{else}}
{{lang "panel_statistics_referrers_no_referrers"}}
{{end}} -
\ No newline at end of file +
+
+

{{lang "panel_statistics_referrers_head"}}

+ {{template "panel_analytics_time_range.html" . }} +
+
+
+
+ {{range .ItemList}} +
+ {{.Agent}} + {{.Count}}{{lang "panel_statistics_views_suffix"}} +
+ {{else}}
{{lang "panel_statistics_referrers_no_referrers"}}
{{end}} +
\ No newline at end of file diff --git a/templates/panel_forum_edit.html b/templates/panel_forum_edit.html index b8671c5c..fb8c19c0 100644 --- a/templates/panel_forum_edit.html +++ b/templates/panel_forum_edit.html @@ -1,13 +1,3 @@ -{{template "header.html" . }} - -
-{{template "panel_menu.html" . }} - - -
-{{template "panel_before_head.html" . }}

{{.Name}}{{lang "panel_forum_head_suffix"}}

@@ -65,7 +55,4 @@ var formVars = {'perm_preset': ['can_moderate','can_post','read_only','no_access
{{end}} - - - -{{template "footer.html" . }} + \ No newline at end of file diff --git a/templates/panel_forum_edit_perms.html b/templates/panel_forum_edit_perms.html index f4e479df..da85a8d3 100644 --- a/templates/panel_forum_edit_perms.html +++ b/templates/panel_forum_edit_perms.html @@ -1,9 +1,3 @@ -{{template "header.html" . }} -
-{{template "panel_menu.html" . }} - -
-{{template "panel_before_head.html" . }}

{{.Name}}{{lang "panel_forum_head_suffix"}}

@@ -26,7 +20,4 @@
- - - -{{template "footer.html" . }} + \ No newline at end of file diff --git a/templates/panel_forums.html b/templates/panel_forums.html index 5734f2b3..0157452b 100644 --- a/templates/panel_forums.html +++ b/templates/panel_forums.html @@ -1,10 +1,3 @@ -{{template "header.html" . }} - -
-{{template "panel_menu.html" . }} - -
-{{template "panel_before_head.html" . }}

{{lang "panel.forums_head"}}

@@ -73,8 +66,4 @@
-
-
- -
-{{template "footer.html" . }} + \ No newline at end of file diff --git a/templates/panel_groups.html b/templates/panel_groups.html index 012dd347..31da1b21 100644 --- a/templates/panel_groups.html +++ b/templates/panel_groups.html @@ -1,9 +1,3 @@ -{{template "header.html" . }} -
- -{{template "panel_menu.html" . }} -
-{{template "panel_before_head.html" . }}

{{lang "panel_groups_head"}}

@@ -52,8 +46,4 @@
- {{end}} - - - -{{template "footer.html" . }} + {{end}} \ No newline at end of file diff --git a/templates/panel_user_edit.html b/templates/panel_user_edit.html index 206c6c6d..bc1dcb1a 100644 --- a/templates/panel_user_edit.html +++ b/templates/panel_user_edit.html @@ -1,9 +1,3 @@ -{{template "header.html" . }} -
- -{{template "panel_menu.html" . }} -
-{{template "panel_before_head.html" . }}

{{lang "panel_user_head"}}

@@ -34,8 +28,4 @@
- - - - -{{template "footer.html" . }} + \ No newline at end of file diff --git a/templates/panel_users.html b/templates/panel_users.html index d7529374..1cb7bd8f 100644 --- a/templates/panel_users.html +++ b/templates/panel_users.html @@ -1,9 +1,3 @@ -{{template "header.html" . }} -
- -{{template "panel_menu.html" . }} -
-{{template "panel_before_head.html" . }}

{{lang "panel_users_head"}}

@@ -21,8 +15,4 @@
{{end}} - {{template "paginator.html" . }} - - - -{{template "footer.html" . }} \ No newline at end of file + {{template "paginator.html" . }} \ No newline at end of file