From d43bffdec527e34ba2f901e08d10dc49cfada319 Mon Sep 17 00:00:00 2001 From: Azareal Date: Wed, 11 Mar 2020 13:26:33 +1000 Subject: [PATCH] experiment with ajax load for topic track route perf for BadRoute --- common/template_init.go | 2 + gen_router.go | 2 +- public/global.js | 260 ++++++++++++++----------- public/register.js | 4 +- router_gen/main.go | 4 +- routes/topic.go | 24 ++- templates/forum.html | 7 +- templates/forum_gallery.html | 8 +- templates/topic.html | 112 +---------- templates/topic_alt.html | 123 +----------- templates/topic_alt_inner.html | 120 ++++++++++++ templates/topic_alt_mini.html | 2 + templates/topic_alt_posts.html | 9 +- templates/topic_alt_userinfo.html | 2 +- templates/topic_inner.html | 108 ++++++++++ templates/topic_mini.html | 2 + templates/topics.html | 2 +- templates/topics_topic.html | 4 +- themes/cosora/theme.json | 8 +- themes/nox/overrides/topics_topic.html | 12 +- themes/nox/public/misc.js | 8 +- themes/nox/theme.json | 10 +- themes/shadow/public/misc.js | 8 +- themes/shadow/theme.json | 4 + themes/tempra_simple/public/misc.js | 8 +- themes/tempra_simple/theme.json | 8 +- 26 files changed, 462 insertions(+), 399 deletions(-) create mode 100644 templates/topic_alt_inner.html create mode 100644 templates/topic_alt_mini.html create mode 100644 templates/topic_inner.html create mode 100644 templates/topic_mini.html diff --git a/common/template_init.go b/common/template_init.go index b946a7bd..433961b0 100644 --- a/common/template_init.go +++ b/common/template_init.go @@ -249,7 +249,9 @@ func compileCommons(c *tmpl.CTemplateSet, head, head2 *Header, forumList []Forum tpage := TopicPage{htitle("Topic Name"), replyList, topic, &Forum{ID: 1, Name: "Hahaha"}, poll, Paginator{[]int{1}, 1, 1}} tpage.Forum.Link = BuildForumURL(NameToSlug(tpage.Forum.Name), tpage.Forum.ID) o.Add("topic", "c.TopicPage", tpage) + o.Add("topic_mini", "c.TopicPage", tpage) o.Add("topic_alt", "c.TopicPage", tpage) + o.Add("topic_alt_mini", "c.TopicPage", tpage) return nil } diff --git a/gen_router.go b/gen_router.go index 4c92ab5f..5b6efe37 100644 --- a/gen_router.go +++ b/gen_router.go @@ -2787,7 +2787,7 @@ func (r *GenRouter) routeSwitch(w http.ResponseWriter, req *http.Request, user c } else { r.DumpRequest(req,"Bad Route") } - co.RouteViewCounter.Bump(172) + co.RouteViewCounter.Bump3(172, cn) return c.NotFound(w,req,nil) } return err diff --git a/public/global.js b/public/global.js index 8a0a5ff3..993e33f4 100644 --- a/public/global.js +++ b/public/global.js @@ -28,7 +28,7 @@ function ajaxError(xhr,status,errstr) { console.log("The AJAX request failed"); console.log("xhr", xhr); console.log("status", status); - console.log("errstr", errstr); + console.log("err", errstr); if(status=="parsererror") console.log("The server didn't respond with a valid JSON response"); console.trace(); } @@ -135,8 +135,8 @@ function loadAlerts(menuAlerts, eTc = false) { let tc = ""; if(eTc && lastTc != 0) tc = "&t=" + lastTc + "&c=" + alertCount; $.ajax({ - type: 'get', - dataType: 'json', + type:'get', + dataType:'json', url:'/api/?m=alerts' + tc, success: (data) => { if("errmsg" in data) { @@ -460,9 +460,9 @@ function mainInit(){ if("success" in data && data["success"] == "1") return; // addNotice("Failed to add a like: {err}") //likeCountNode.innerHTML = parseInt(likeCountNode.innerHTML)-1; - console.log("data", data); - console.log("status", status); - console.log("xhr", xhr); + console.log("data",data); + console.log("status",status); + console.log("xhr",xhr); } }); }); @@ -620,110 +620,7 @@ function mainInit(){ }); }); - $(".open_edit").click(ev => { - ev.preventDefault(); - $('.hide_on_edit').addClass("edit_opened"); - $('.show_on_edit').addClass("edit_opened"); - runHook("open_edit"); - }); - - $(".topic_item .submit_edit").click(function(ev){ - ev.preventDefault(); - let topicNameInput = $(".topic_name_input").val(); - $(".topic_name").html(topicNameInput); - $(".topic_name").attr(topicNameInput); - let topicContentInput = $('.topic_content_input').val(); - $(".topic_content").html(quickParse(topicContentInput)); - let topicStatusInput = $('.topic_status_input').val(); - $(".topic_status_e:not(.open_edit)").html(topicStatusInput); - - $('.hide_on_edit').removeClass("edit_opened"); - $('.show_on_edit').removeClass("edit_opened"); - runHook("close_edit"); - - $.ajax({ - url: this.form.getAttribute("action"), - type: "POST", - dataType: "json", - data: { - topic_name: topicNameInput, - topic_status: topicStatusInput, - topic_content: topicContentInput, - js: 1 - }, - error: ajaxError, - success: (data,status,xhr) => { - if("Content" in data) $(".topic_content").html(data["Content"]); - } - }); - }); - - $(".delete_item").click(function(ev) { - postLink(ev); - $(this).closest('.deletable_block').remove(); - }); - - // Miniature implementation of the parser to avoid sending as much data back and forth - function quickParse(m) { - m = m.replace(":)", "😀") - m = m.replace(":(", "😞") - m = m.replace(":D", "😃") - m = m.replace(":P", "😛") - m = m.replace(":O", "😲") - m = m.replace(":p", "😛") - m = m.replace(":o", "😲") - m = m.replace(";)", "😉") - m = m.replace("\n","
") - return m - } - - $(".edit_item").click(function(ev){ - ev.preventDefault(); - - let bp = this.closest('.editable_parent'); - $(bp).find('.hide_on_edit').addClass("edit_opened"); - $(bp).find('.show_on_edit').addClass("edit_opened"); - $(bp).find('.hide_on_block_edit').addClass("edit_opened"); - $(bp).find('.show_on_block_edit').addClass("edit_opened"); - let srcNode = bp.querySelector(".edit_source"); - let block = bp.querySelector('.editable_block'); - block.classList.add("in_edit"); - - let source = ""; - if(srcNode!=null) source = srcNode.innerText; - else source = block.innerHTML; - block.innerHTML = Template_topic_c_edit_post({ - ID: bp.getAttribute("id").slice("post-".length), - Source: source, - Ref: this.closest('a').getAttribute("href") - }) - runHook("edit_item_pre_bind"); - - $(".submit_edit").click(function(ev){ - ev.preventDefault(); - $(bp).find('.hide_on_edit').removeClass("edit_opened"); - $(bp).find('.show_on_edit').removeClass("edit_opened"); - $(bp).find('.hide_on_block_edit').removeClass("edit_opened"); - $(bp).find('.show_on_block_edit').removeClass("edit_opened"); - block.classList.remove("in_edit"); - let content = block.querySelector('textarea').value; - block.innerHTML = quickParse(content); - if(srcNode!=null) srcNode.innerText = content; - - let formAction = this.closest('a').getAttribute("href"); - // TODO: Bounce the parsed post back and set innerHTML to it? - $.ajax({ - url: formAction, - type: "POST", - dataType: "json", - data: { js: 1, edit_item: content }, - error: ajaxError, - success: (data,status,xhr) => { - if("Content" in data) block.innerHTML = data["Content"]; - } - }); - }); - }); + bindTopic(); $(".edit_field").click(function(ev) { ev.preventDefault(); @@ -963,6 +860,149 @@ function mainInit(){ }) }); + $(".rowtopic a, a.rowtopic").click(function(ev) { + let base = this.getAttribute("href"); + let href = base + "?i=1"; + fetch(href, {credentials:"same-origin"}) + .then(resp => { + if(!resp.ok) throw(href+" failed to load"); + return resp.text(); + }).then(data => { + let el = document.createElement("div"); + el.innerHTML = data; + console.log("el",el); + document.querySelector("main").outerHTML = el.children[0].innerHTML; + //$(".sidebar").html(el.children[1]); + document.querySelector(".sidebar").outerHTML = el.children[1].outerHTML; + unbindTopic(); + bindTopic(); + let obj = {Title: document.title, Url: base}; + history.pushState(obj, obj.Title, obj.Url); + }).catch(ex => { + console.log("Unable to get script '"+href+""+"'"); + console.log("ex",ex); + console.trace(); + }); + + ev.stopPropagation(); + ev.preventDefault(); + }) + runInitHook("almost_end_init"); runInitHook("end_init"); +} + +function bindTopic() { + $(".open_edit").click(ev => { + ev.preventDefault(); + $('.hide_on_edit').addClass("edit_opened"); + $('.show_on_edit').addClass("edit_opened"); + runHook("open_edit"); + }); + + $(".topic_item .submit_edit").click(function(ev){ + ev.preventDefault(); + let nameInput = $(".topic_name_input").val(); + $(".topic_name").html(nameInput); + $(".topic_name").attr(nameInput); + let contentInput = $('.topic_content_input').val(); + $(".topic_content").html(quickParse(contentInput)); + let statusInput = $('.topic_status_input').val(); + $(".topic_status_e:not(.open_edit)").html(statusInput); + + $('.hide_on_edit').removeClass("edit_opened"); + $('.show_on_edit').removeClass("edit_opened"); + runHook("close_edit"); + + $.ajax({ + url: this.form.getAttribute("action"), + type: "POST", + dataType: "json", + data: { + name: nameInput, + status: statusInput, + content: contentInput, + js: 1 + }, + error: ajaxError, + success: (data,status,xhr) => { + if("Content" in data) $(".topic_content").html(data["Content"]); + } + }); + }); + + $(".delete_item").click(function(ev) { + postLink(ev); + $(this).closest('.deletable_block').remove(); + }); + + // Miniature implementation of the parser to avoid sending as much data back and forth + function quickParse(m) { + m = m.replace(":)", "😀") + m = m.replace(":(", "😞") + m = m.replace(":D", "😃") + m = m.replace(":P", "😛") + m = m.replace(":O", "😲") + m = m.replace(":p", "😛") + m = m.replace(":o", "😲") + m = m.replace(";)", "😉") + m = m.replace("\n","
") + return m + } + + $(".edit_item").click(function(ev){ + ev.preventDefault(); + + let bp = this.closest('.editable_parent'); + $(bp).find('.hide_on_edit').addClass("edit_opened"); + $(bp).find('.show_on_edit').addClass("edit_opened"); + $(bp).find('.hide_on_block_edit').addClass("edit_opened"); + $(bp).find('.show_on_block_edit').addClass("edit_opened"); + let srcNode = bp.querySelector(".edit_source"); + let block = bp.querySelector('.editable_block'); + block.classList.add("in_edit"); + + let src = ""; + if(srcNode!=null) src = srcNode.innerText; + else src = block.innerHTML; + block.innerHTML = Template_topic_c_edit_post({ + ID: bp.getAttribute("id").slice("post-".length), + Source: src, + Ref: this.closest('a').getAttribute("href") + }) + runHook("edit_item_pre_bind"); + + $(".submit_edit").click(function(ev){ + ev.preventDefault(); + $(bp).find('.hide_on_edit').removeClass("edit_opened"); + $(bp).find('.show_on_edit').removeClass("edit_opened"); + $(bp).find('.hide_on_block_edit').removeClass("edit_opened"); + $(bp).find('.show_on_block_edit').removeClass("edit_opened"); + block.classList.remove("in_edit"); + let content = block.querySelector('textarea').value; + block.innerHTML = quickParse(content); + if(srcNode!=null) srcNode.innerText = content; + + let formAction = this.closest('a').getAttribute("href"); + // TODO: Bounce the parsed post back and set innerHTML to it? + $.ajax({ + url: formAction, + type:"POST", + dataType:"json", + data: { js: 1, edit_item: content }, + error: ajaxError, + success: (data,status,xhr) => { + if("Content" in data) block.innerHTML = data["Content"]; + } + }); + }); + }); +} + +function unbindTopic() { + $(".open_edit").unbind("click"); + $(".topic_item .submit_edit").unbind("click"); + $(".delete_item").unbind("click"); + $(".edit_item").unbind("click"); + $(".submit_edit").unbind("click"); } \ No newline at end of file diff --git a/public/register.js b/public/register.js index c1a96ee3..145c2095 100644 --- a/public/register.js +++ b/public/register.js @@ -3,8 +3,8 @@ fetch("/api/watches/") .then(resp => { if(resp.status!==200) { - console.log("error"); - console.log("resp:", resp); + console.log("err"); + console.log("resp",resp); return; } resp.text().then(data => eval(data)); diff --git a/router_gen/main.go b/router_gen/main.go index 658f9d0e..be026d50 100644 --- a/router_gen/main.go +++ b/router_gen/main.go @@ -348,7 +348,7 @@ func main() { "Googlebot": "googlebot", "yandex": "yandex", // from the URL "DuckDuckBot": "duckduckgo", - "DuckDuckGo":"duckduckgo", + "DuckDuckGo": "duckduckgo", "Baiduspider": "baidu", "Sogou": "sogou", "ToutiaoSpider": "toutiao", @@ -980,7 +980,7 @@ func (r *GenRouter) routeSwitch(w http.ResponseWriter, req *http.Request, user c } else { r.DumpRequest(req,"Bad Route") } - co.RouteViewCounter.Bump({{index .AllRouteMap "routes.BadRoute"}}) + co.RouteViewCounter.Bump3({{index .AllRouteMap "routes.BadRoute"}}, cn) return c.NotFound(w,req,nil) } return err diff --git a/routes/topic.go b/routes/topic.go index cf218e56..df837eb8 100644 --- a/routes/topic.go +++ b/routes/topic.go @@ -165,13 +165,25 @@ func ViewTopic(w http.ResponseWriter, r *http.Request, user c.User, header *c.He var rerr c.RouteError tmpl := forum.Tmpl - if tmpl == "" { - rerr = renderTemplate("topic", w, r, header, tpage) + if r.FormValue("i") == "1" { + if tmpl == "" { + rerr = renderTemplate("topic_mini", w, r, header, tpage) + } else { + tmpl = "topic_mini" + tmpl + err = renderTemplate3(tmpl, tmpl, w, r, header, tpage) + if err != nil { + rerr = renderTemplate("topic_mini", w, r, header, tpage) + } + } } else { - tmpl = "topic_" + tmpl - err = renderTemplate3(tmpl, tmpl, w, r, header, tpage) - if err != nil { + if tmpl == "" { rerr = renderTemplate("topic", w, r, header, tpage) + } else { + tmpl = "topic_" + tmpl + err = renderTemplate3(tmpl, tmpl, w, r, header, tpage) + if err != nil { + rerr = renderTemplate("topic", w, r, header, tpage) + } } } counters.TopicViewCounter.Bump(topic.ID) // TODO: Move this into the router? @@ -576,7 +588,7 @@ func EditTopicSubmit(w http.ResponseWriter, r *http.Request, user c.User, stid s return c.NoPermissionsJSQ(w, r, user, js) } - err = topic.Update(r.PostFormValue("topic_name"), r.PostFormValue("topic_content")) + err = topic.Update(r.PostFormValue("name"), r.PostFormValue("content")) // TODO: Avoid duplicating this across this route and the topic creation route if err != nil { switch err { diff --git a/templates/forum.html b/templates/forum.html index 62fc87fc..ec0f1c7b 100644 --- a/templates/forum.html +++ b/templates/forum.html @@ -1,10 +1,11 @@ {{template "header.html" . }} +
+ {{if gt .Page 1}}{{end}} {{if ne .LastPage .Page}}{{end}} -

{{.Title}}

@@ -59,7 +60,7 @@ {{/** TODO: Phase this out of Cosora and remove it **/}}
- {{.PostCount}}
+ {{.PostCount}}
{{.LikeCount}}
@@ -72,7 +73,7 @@
- + {{.LastUser.Name}}
{{reltime .LastReplyAt}} diff --git a/templates/forum_gallery.html b/templates/forum_gallery.html index 42c07da3..a13d80eb 100644 --- a/templates/forum_gallery.html +++ b/templates/forum_gallery.html @@ -1,8 +1,7 @@ {{template "header.html" . }} - +
-

{{.Title}}

@@ -18,8 +17,7 @@
{{else}}
{{end}} -
-
+
{{end}}
{{if .CurrentUser.Loggedin}} @@ -47,7 +45,7 @@ {{range .ItemList}}
-
{{.Title}} +
{{.Title}}
- Avatar + Avatar
diff --git a/templates/topic_inner.html b/templates/topic_inner.html new file mode 100644 index 00000000..41d03ae3 --- /dev/null +++ b/templates/topic_inner.html @@ -0,0 +1,108 @@ +
+ +{{if gt .Page 1}} +{{end}} + +{{if ne .LastPage .Page}} +{{end}} + + +
+
+

{{.Topic.Title}}

+ {{if .Topic.IsClosed}}🔒︎{{end}} + {{/** TODO: Does this need to be guarded by a permission? It's only visible in edit mode anyway, which can't be triggered, if they don't have the permission **/}} + {{if not .Topic.IsClosed or .CurrentUser.Perms.CloseTopic}} + {{if .CurrentUser.Perms.EditTopic}} +
+ + + {{end}} + {{end}} +
+
+{{if .Poll.ID}}{{template "topic_poll.html" . }}{{end}} + +
+
+
{{.Topic.ContentHTML}}
+ {{if .CurrentUser.Loggedin}}{{end}} + + + +    + + {{if .CurrentUser.Loggedin}} + {{if .CurrentUser.Perms.LikeItem}}{{if ne .CurrentUser.ID .Topic.CreatedBy}} + + {{if .Topic.Liked}} + + {{else}} + + {{end}} + + {{end}}{{end}} + + + + {{if not .Topic.IsClosed or .CurrentUser.Perms.CloseTopic}} + {{if .CurrentUser.Perms.EditTopic}}{{end}} + {{end}} + + {{if .Topic.Deletable}}{{end}} + + {{if .CurrentUser.Perms.CloseTopic}}{{if .Topic.IsClosed}}{{else}}{{end}}{{end}} + + {{if .CurrentUser.Perms.PinTopic}}{{if .Topic.Sticky}}{{else}}{{end}}{{end}} + {{if .CurrentUser.Perms.ViewIPs}}{{end}} + {{end}} + + + + + + {{if .Topic.Tag}}{{.Topic.Tag}}{{else}}{{level .Topic.Level}}{{end}} + + +
+
+ +{{template "topic_posts.html" . }} + +{{if .CurrentUser.Perms.CreateReply}} +{{if not .Topic.IsClosed or .CurrentUser.Perms.CloseTopic}} +
+
+ + +
+
+ +
+
+
+
+
+ + + +
+
+
+
+
+ + + {{if .CurrentUser.Perms.UploadFiles}} + + +
{{end}} +
+
+
+{{end}} +{{end}} + +
\ No newline at end of file diff --git a/templates/topic_mini.html b/templates/topic_mini.html new file mode 100644 index 00000000..04a2bb33 --- /dev/null +++ b/templates/topic_mini.html @@ -0,0 +1,2 @@ +{{template "topic_inner.html" . }} + \ No newline at end of file diff --git a/templates/topics.html b/templates/topics.html index a67f04a0..7430ab11 100644 --- a/templates/topics.html +++ b/templates/topics.html @@ -1,6 +1,6 @@ {{template "header.html" . }} -
+

{{.Title}}

diff --git a/templates/topics_topic.html b/templates/topics_topic.html index 7ee5c624..a614a9d8 100644 --- a/templates/topics_topic.html +++ b/templates/topics_topic.html @@ -6,8 +6,8 @@ {{.Title}} {{if .ForumName}}{{.ForumName}}{{end}}
{{.Creator.Name}} {{/** TODO: Avoid the double '|' when both .IsClosed and .Sticky are set to true. We could probably do this with CSS **/}} - {{if .IsClosed}} | 🔒︎{{end}} - {{if .Sticky}} | 📍︎{{end}} + {{if .IsClosed}} | 🔒︎{{end}} + {{if .Sticky}} | 📍︎{{end}} {{/** TODO: Phase this out of Cosora and remove it **/}}
diff --git a/themes/cosora/theme.json b/themes/cosora/theme.json index adb7af87..59ba1aa9 100644 --- a/themes/cosora/theme.json +++ b/themes/cosora/theme.json @@ -10,6 +10,10 @@ { "Name": "topic", "Source": "topic_alt" + }, + { + "Name": "topic_mini", + "Source": "topic_alt_mini" } ], "Resources": [ @@ -20,7 +24,7 @@ { "Name":"trumbowyg/trumbowyg.min.js", "Location":"global", - "Loggedin": true + "Loggedin":true }, { "Name":"trumbowyg/ui/trumbowyg.custom.css", @@ -33,4 +37,4 @@ "Async":true } ] -} +} \ No newline at end of file diff --git a/themes/nox/overrides/topics_topic.html b/themes/nox/overrides/topics_topic.html index ccd49816..c1c3e185 100644 --- a/themes/nox/overrides/topics_topic.html +++ b/themes/nox/overrides/topics_topic.html @@ -1,8 +1,8 @@ -
+
- + - {{.Title}}{{if .ForumName}}-{{.ForumName}}{{end}} + {{.Title}}{{if .ForumName}}-{{.ForumName}}{{end}}
{{.Creator.Name}}
@@ -15,10 +15,10 @@
diff --git a/themes/nox/public/misc.js b/themes/nox/public/misc.js index f5b8df2d..f33c0236 100644 --- a/themes/nox/public/misc.js +++ b/themes/nox/public/misc.js @@ -45,7 +45,7 @@ function noxMenuBind() { else $('.alert').insertAfter(".rowhead:first"); } - addInitHook("after_update_alert_list", (alertCount) => { + addInitHook("after_update_alert_list", alertCount => { console.log("misc.js"); console.log("alertCount",alertCount); if(alertCount==0) { @@ -57,9 +57,8 @@ function noxMenuBind() { $(".user_box").addClass("has_alerts"); } }); - let tb=$('.topic_block'); - addHook("open_edit", () => tb.addClass("edithead")); - addHook("close_edit", () => tb.removeClass("edithead")); + addHook("open_edit", () => $('.topic_block').addClass("edithead")); + addHook("close_edit", () => $('.topic_block').removeClass("edithead")); addInitHook("end_init", () => { $(".alerts").click(ev => { @@ -77,7 +76,6 @@ function noxMenuBind() { $(".menu_hamburger").click(function() { event.stopPropagation(); - console.log("hi") let mm = document.getElementsByClassName("more_menu")[0]; mm.classList.add("more_menu_selected"); let calc = $(this).offset().left - (mm.offsetWidth / 4); diff --git a/themes/nox/theme.json b/themes/nox/theme.json index fffdfa28..28977598 100644 --- a/themes/nox/theme.json +++ b/themes/nox/theme.json @@ -6,7 +6,7 @@ "URL": "github.com/Azareal/Gosora", "Tag": "WIP", "Docks":["topMenu","rightSidebar","footer"], - "GridLists":true, + "GridLists": true, "MapTmplToDock": { "rightOfNav": { "File": "./templates/userDock.html" @@ -16,13 +16,17 @@ { "Name": "topic", "Source": "topic_alt" + }, + { + "Name": "topic_mini", + "Source": "topic_alt_mini" } ], "Resources": [ { "Name":"trumbowyg/trumbowyg.min.js", "Location":"global", - "Loggedin": true + "Loggedin":true }, { "Name":"trumbowyg/ui/trumbowyg.custom.css", @@ -35,4 +39,4 @@ "Async":true } ] -} +} \ No newline at end of file diff --git a/themes/shadow/public/misc.js b/themes/shadow/public/misc.js index 0a7325f5..0510ae2b 100644 --- a/themes/shadow/public/misc.js +++ b/themes/shadow/public/misc.js @@ -4,12 +4,10 @@ addInitHook("end_init", () => { $(".topic_list img").each(function(){ let aspectRatio = this.naturalHeight / this.naturalWidth; console.log("aspectRatio",aspectRatio); - console.log("this.height",this.naturalHeight); - console.log("this.width",this.naturalWidth); + console.log("height",this.naturalHeight); + console.log("width",this.naturalWidth); - $(this).css({ - height: aspectRatio * this.width - }); + $(this).css({ height: aspectRatio * this.width }); }); }); })() \ No newline at end of file diff --git a/themes/shadow/theme.json b/themes/shadow/theme.json index bac0f81b..f9e5870b 100644 --- a/themes/shadow/theme.json +++ b/themes/shadow/theme.json @@ -11,6 +11,10 @@ { "Name": "topic", "Source": "topic" + }, + { + "Name":"topic_mini", + "Source":"topic_mini" } ], "Resources": [ diff --git a/themes/tempra_simple/public/misc.js b/themes/tempra_simple/public/misc.js index 0a7325f5..0510ae2b 100644 --- a/themes/tempra_simple/public/misc.js +++ b/themes/tempra_simple/public/misc.js @@ -4,12 +4,10 @@ addInitHook("end_init", () => { $(".topic_list img").each(function(){ let aspectRatio = this.naturalHeight / this.naturalWidth; console.log("aspectRatio",aspectRatio); - console.log("this.height",this.naturalHeight); - console.log("this.width",this.naturalWidth); + console.log("height",this.naturalHeight); + console.log("width",this.naturalWidth); - $(this).css({ - height: aspectRatio * this.width - }); + $(this).css({ height: aspectRatio * this.width }); }); }); })() \ No newline at end of file diff --git a/themes/tempra_simple/theme.json b/themes/tempra_simple/theme.json index c069f96d..2cea12b8 100644 --- a/themes/tempra_simple/theme.json +++ b/themes/tempra_simple/theme.json @@ -10,8 +10,12 @@ "Docks":["topMenu","rightSidebar"], "Templates": [ { - "Name": "topic", - "Source": "topic" + "Name":"topic", + "Source":"topic" + }, + { + "Name":"topic_mini", + "Source":"topic_mini" } ], "Resources": [