From 23a0bf3f41e0a76603e1413412019038914cf700 Mon Sep 17 00:00:00 2001 From: Azareal Date: Sun, 24 Mar 2019 17:23:38 +1000 Subject: [PATCH] Try hash based cache busting with stylesheets too. Use a semantic blockquote element instead of span in plugin_bbcode for [quote] You can now use
elements directly in posts. Added styling for quotes to Shadow, Cosora and Nox. Experimenting with the padding on Nox's Control Panel Menu. Tweaked the padding for the User Manager items on Nox. Fixed #back filling up all the space it can on Tempra Simple. Added a bit of padding below the last element before the footer on Tempra Simple. Tempra Simple's misc.js is now loaded asynchronously. Shadow's misc.js is now loaded asynchronously. profile_member.js is now loaded asynchronously. account.js is now loaded asynchronously. --- common/pages.go | 12 ++++++++++-- common/parser.go | 7 +++++-- common/template_init.go | 2 +- plugin_bbcode.go | 6 +++--- plugin_test.go | 8 ++++---- public/account.js | 6 ++++-- public/profile_member.js | 6 ++++-- routes/account.go | 2 +- routes/profile.go | 2 +- templates/header.html | 2 +- themes/cosora/public/main.css | 6 ++++++ themes/nox/public/acc_panel_common.css | 6 ++++-- themes/nox/public/main.css | 14 ++++++++++++++ themes/nox/public/panel.css | 8 ++++++-- themes/shadow/public/main.css | 5 +++++ themes/shadow/public/misc.js | 6 ++++-- themes/shadow/theme.json | 3 ++- themes/tempra_simple/public/account.css | 3 +++ themes/tempra_simple/public/main.css | 16 ++++++++++++++-- themes/tempra_simple/public/media.partial.css | 2 +- themes/tempra_simple/public/misc.js | 6 ++++-- themes/tempra_simple/public/panel.css | 3 +++ themes/tempra_simple/public/profile.css | 3 +++ themes/tempra_simple/theme.json | 3 ++- 24 files changed, 105 insertions(+), 32 deletions(-) diff --git a/common/pages.go b/common/pages.go index fe70a062..097e9a23 100644 --- a/common/pages.go +++ b/common/pages.go @@ -25,7 +25,7 @@ type Header struct { PreScriptsAsync []HResource ScriptsAsync []HResource //Preload []string - Stylesheets []string + Stylesheets []HResource Widgets PageWidgets Site *site Settings SettingMap @@ -92,7 +92,15 @@ func (header *Header) AddScriptAsync(name string) { }*/ func (header *Header) AddSheet(name string) { - header.Stylesheets = append(header.Stylesheets, name) + fname := "/static/" + name + var hash string + if fname[0] == '/' && fname[1] != '/' { + file, ok := StaticFiles.Get(fname) + if ok { + hash = file.Sha256 + } + } + header.Stylesheets = append(header.Stylesheets, HResource{name, hash}) } func (header *Header) AddNotice(name string) { diff --git a/common/parser.go b/common/parser.go index de8e8124..dd7bbf94 100644 --- a/common/parser.go +++ b/common/parser.go @@ -217,7 +217,7 @@ func PreparseMessage(msg string) string { 's': []string{"", "trong", "pan"}, 'd': []string{"el"}, 'u': []string{""}, - 'b': []string{""}, + 'b': []string{"", "lockquote"}, 'i': []string{""}, 'g': []string{""}, // Quick and dirty fix for Grammarly } @@ -261,7 +261,10 @@ func PreparseMessage(msg string) string { }, 'd': []*TagToAction{&TagToAction{"el", buildLitMatch("del"), 0, false}}, 'u': []*TagToAction{&TagToAction{"", buildLitMatch("u"), 0, false}}, - 'b': []*TagToAction{&TagToAction{"", buildLitMatch("strong"), 0, false}}, + 'b': []*TagToAction{ + &TagToAction{"", buildLitMatch("strong"), 0, false}, + &TagToAction{"lockquote", buildLitMatch("blockquote"), 0, false}, + }, 'i': []*TagToAction{&TagToAction{"", buildLitMatch("em"), 0, false}}, 'g': []*TagToAction{ &TagToAction{"", func(act *TagToAction, open bool, i int, runes []rune) (int, string) { diff --git a/common/template_init.go b/common/template_init.go index a99b0a12..a4d56ff6 100644 --- a/common/template_init.go +++ b/common/template_init.go @@ -108,7 +108,7 @@ func tmplInitHeaders(user User, user2 User, user3 User) (*Header, *Header, *Head Theme: Themes[DefaultThemeBox.Load().(string)], CurrentUser: user, NoticeList: []string{"test"}, - Stylesheets: []string{"panel.css"}, + Stylesheets: []HResource{HResource{"panel.css", "d"}}, Scripts: []HResource{HResource{"whatever.js", "d"}}, PreScriptsAsync: []HResource{HResource{"whatever.js", "d"}}, ScriptsAsync: []HResource{HResource{"whatever.js", "d"}}, diff --git a/plugin_bbcode.go b/plugin_bbcode.go index 8d5ca916..acc12638 100644 --- a/plugin_bbcode.go +++ b/plugin_bbcode.go @@ -60,7 +60,7 @@ func bbcodeRegexParse(msg string) string { msg = bbcodeStrikethrough.ReplaceAllString(msg, "$1") msg = bbcodeURL.ReplaceAllString(msg, "$1$2//$3") msg = bbcodeURLLabel.ReplaceAllString(msg, "$4") - msg = bbcodeQuotes.ReplaceAllString(msg, "$1") + msg = bbcodeQuotes.ReplaceAllString(msg, "
$1
") //msg = bbcodeCode.ReplaceAllString(msg,"$1") return msg } @@ -197,7 +197,7 @@ func bbcodeParseWithoutCode(msg string) string { msg = string(msgbytes) msg = bbcodeURL.ReplaceAllString(msg, "
$1$2//$3") msg = bbcodeURLLabel.ReplaceAllString(msg, "$4") - msg = bbcodeQuotes.ReplaceAllString(msg, "$1") + msg = bbcodeQuotes.ReplaceAllString(msg, "
$1
") return bbcodeCode.ReplaceAllString(msg, "$1") } return string(msgbytes) @@ -323,7 +323,7 @@ func bbcodeFullParse(msg string) string { //msg = bbcode_url.ReplaceAllString(msg,"
$1$2//$3") msg = bbcodeURLLabel.ReplaceAllString(msg, "$4") - msg = bbcodeQuotes.ReplaceAllString(msg, "$1") + msg = bbcodeQuotes.ReplaceAllString(msg, "
$1
") msg = bbcodeCode.ReplaceAllString(msg, "$1") } else { msg = string(msgbytes[0 : len(msgbytes)-10]) diff --git a/plugin_test.go b/plugin_test.go index 9b2db4cf..de13d426 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -60,10 +60,10 @@ func TestBBCodeRender(t *testing.T) { msgList.Add("[code]hi[/code]", "hi") msgList.Add("[code][b]hi[/b][/code]", "[b]hi[/b]") msgList.Add("[code][b]hi[/code][/b]", "[b]hi[/b]") - msgList.Add("[quote]hi[/quote]", "hi") - msgList.Add("[quote][b]hi[/b][/quote]", "hi") - msgList.Add("[quote][b]h[/b][/quote]", "h") - msgList.Add("[quote][b][/b][/quote]", "") + msgList.Add("[quote]hi[/quote]", "
hi
") + msgList.Add("[quote][b]hi[/b][/quote]", "
hi
") + msgList.Add("[quote][b]h[/b][/quote]", "
h
") + msgList.Add("[quote][b][/b][/quote]", "
") msgList.Add("[url][/url]", "
") msgList.Add("[url]https://github.com/Azareal/Gosora[/url]", "https://github.com/Azareal/Gosora") msgList.Add("[url]http://github.com/Azareal/Gosora[/url]", "http://github.com/Azareal/Gosora") diff --git a/public/account.js b/public/account.js index 1c4e2bff..ad17da14 100644 --- a/public/account.js +++ b/public/account.js @@ -1,7 +1,9 @@ -"use strict" +"use strict"; -$(document).ready(function(){ +(() => { +addInitHook("end_init", () => { $("#dash_username input").click(function(){ $("#dash_username button").show(); }); }); +})(); \ No newline at end of file diff --git a/public/profile_member.js b/public/profile_member.js index fa940987..a6e03099 100644 --- a/public/profile_member.js +++ b/public/profile_member.js @@ -12,7 +12,9 @@ function handle_profile_hashbit() { $("." + hash_class).show(); } -$(document).ready(() => { +(() => { +addInitHook("end_init", () => { if(window.location.hash) handle_profile_hashbit(); window.addEventListener("hashchange", handle_profile_hashbit, false); -}); \ No newline at end of file +}); +})(); \ No newline at end of file diff --git a/routes/account.go b/routes/account.go index 78d0c392..c491b566 100644 --- a/routes/account.go +++ b/routes/account.go @@ -356,7 +356,7 @@ func accountEditHead(titlePhrase string, w http.ResponseWriter, r *http.Request, header.Title = phrases.GetTitlePhrase(titlePhrase) header.Path = "/user/edit/" header.AddSheet(header.Theme.Name + "/account.css") - header.AddScript("account.js") + header.AddScriptAsync("account.js") } func AccountEdit(w http.ResponseWriter, r *http.Request, user common.User, header *common.Header) common.RouteError { diff --git a/routes/profile.go b/routes/profile.go index 81426580..f360daef 100644 --- a/routes/profile.go +++ b/routes/profile.go @@ -32,7 +32,7 @@ func ViewProfile(w http.ResponseWriter, r *http.Request, user common.User, heade // TODO: Preload this? header.AddSheet(header.Theme.Name + "/profile.css") if user.Loggedin { - header.AddScript("profile_member.js") + header.AddScriptAsync("profile_member.js") } var err error diff --git a/templates/header.html b/templates/header.html index 5d132488..89942567 100644 --- a/templates/header.html +++ b/templates/header.html @@ -4,7 +4,7 @@ {{.Title}} | {{.Header.Site.Name}} {{range .Header.Stylesheets}} - {{end}} + {{end}} {{range .Header.PreScriptsAsync}} {{end}} diff --git a/themes/cosora/public/main.css b/themes/cosora/public/main.css index 8e7cfb1c..cb89e1cf 100644 --- a/themes/cosora/public/main.css +++ b/themes/cosora/public/main.css @@ -997,6 +997,12 @@ textarea { width: 100%; max-width: 240px; } +blockquote { + margin: 0px; + background-color: #EEEEEE; + padding: 12px; + margin-bottom: -3px; +} .post_item { display: flex; margin-bottom: 16px; diff --git a/themes/nox/public/acc_panel_common.css b/themes/nox/public/acc_panel_common.css index 71fdc0ee..b30d4061 100644 --- a/themes/nox/public/acc_panel_common.css +++ b/themes/nox/public/acc_panel_common.css @@ -32,14 +32,16 @@ .rowmenu { margin-left: 18px; - margin-bottom: 2px; + /*margin-bottom: 2px;*/ + margin-bottom: 3px; font-size: 17px; } .rowmenu a { color: rgb(180, 180, 180); } .rowmenu .rowitem { - margin-bottom: 4px; + /*margin-bottom: 4px;*/ + margin-bottom: 6px; } .to_right { diff --git a/themes/nox/public/main.css b/themes/nox/public/main.css index e6dd431b..7826f3f0 100644 --- a/themes/nox/public/main.css +++ b/themes/nox/public/main.css @@ -199,6 +199,7 @@ li a { border-radius: 3px; background-color: #444444; padding: 16px; + /*padding: 18px;*/ } .filter_item { margin-bottom: 5px; @@ -729,6 +730,19 @@ button, .formbutton, .panel_right_button:not(.has_inner_button) { width: 100%; max-width: 320px; } +blockquote { + background-color: #555555; + border-radius: 3px; + padding: 8px; + margin: 0px; + margin-bottom: 8px; +} +blockquote + br { + display: none; +} +blockquote:only-child { + margin-bottom: 0px; +} .post_item { display: flex; margin-bottom: 12px; diff --git a/themes/nox/public/panel.css b/themes/nox/public/panel.css index 08426bdf..0b952302 100644 --- a/themes/nox/public/panel.css +++ b/themes/nox/public/panel.css @@ -18,8 +18,10 @@ {{template "acc_panel_common.css" }} .colstack_left .colstack_head { font-size: 19px; - padding-top: 10px; - padding-bottom: 10px; + /*padding-top: 10px; + padding-bottom: 10px;*/ + padding-top: 12px; + padding-bottom: 12px; } .menu_stats { margin-left: 4px; @@ -120,8 +122,10 @@ } #panel_users .rowitem { + padding-top: 20px; padding-left: 4px; padding-right: 4px; + padding-bottom: 18px; } button, .formbutton, .panel_right_button:not(.has_inner_button), #panel_users .profile_url { background: rgb(100,100,200); diff --git a/themes/shadow/public/main.css b/themes/shadow/public/main.css index 507cecf4..f0bb18c7 100644 --- a/themes/shadow/public/main.css +++ b/themes/shadow/public/main.css @@ -888,6 +888,11 @@ input[type=checkbox]:checked + label.poll_option_label .sel { background-color: rgb(71,71,71); padding: 10px; } +blockquote { + background-color: rgb(71,71,71); + margin: 0px; + padding: 10px; +} /* Profiles */ #profile_left_lane { diff --git a/themes/shadow/public/misc.js b/themes/shadow/public/misc.js index 95358608..9302a94e 100644 --- a/themes/shadow/public/misc.js +++ b/themes/shadow/public/misc.js @@ -1,4 +1,5 @@ -$(document).ready(function(){ +(() => { +addInitHook("end_init", () => { // TODO: Run this when the image is loaded rather than when the document is ready? $(".topic_list img").each(function(){ let aspectRatio = this.naturalHeight / this.naturalWidth; @@ -10,4 +11,5 @@ $(document).ready(function(){ height: aspectRatio * this.width }); }); -}); \ No newline at end of file +}); +})(); \ No newline at end of file diff --git a/themes/shadow/theme.json b/themes/shadow/theme.json index 66dde639..bac0f81b 100644 --- a/themes/shadow/theme.json +++ b/themes/shadow/theme.json @@ -16,7 +16,8 @@ "Resources": [ { "Name":"shadow/misc.js", - "Location":"global" + "Location":"global", + "Async":true } ] } diff --git a/themes/tempra_simple/public/account.css b/themes/tempra_simple/public/account.css index 1ce3e1e3..304aba7b 100644 --- a/themes/tempra_simple/public/account.css +++ b/themes/tempra_simple/public/account.css @@ -1,3 +1,6 @@ +#back { + width: 100%; +} .sidebar { display: none; } diff --git a/themes/tempra_simple/public/main.css b/themes/tempra_simple/public/main.css index 29f39815..c86162d5 100644 --- a/themes/tempra_simple/public/main.css +++ b/themes/tempra_simple/public/main.css @@ -155,6 +155,9 @@ li a { #main { width: 100%; } +main > *:last-child { + margin-bottom: 12px; +} .rowblock { border: 1px solid hsl(0, 0%, 80%); @@ -541,6 +544,14 @@ input, select { background-color: white; padding: 10px; } +/*blockquote { + background-color: #EEEEEE; + padding: 12px; + margin: 0px; +} +.staff_post blockquote { + background-color: rgba(255, 214, 255, 1); +}*/ .little_row_avatar { display: none; @@ -742,7 +753,7 @@ button.username { background-color: rgb(255,245,245); } -.postQuote { +blockquote { border: 1px solid hsl(0, 0%, 80%); background: white; padding: 5px; @@ -967,8 +978,9 @@ input[type=checkbox]:checked + label.poll_option_label .sel { .pageset { display: flex; - margin-bottom: 10px; + /*margin-bottom: 10px;*/ margin-top: 8px; + margin-bottom: 2px; } .pageitem { background-color: white; diff --git a/themes/tempra_simple/public/media.partial.css b/themes/tempra_simple/public/media.partial.css index 40b2195a..9f579c49 100644 --- a/themes/tempra_simple/public/media.partial.css +++ b/themes/tempra_simple/public/media.partial.css @@ -1,7 +1,7 @@ @media(min-width: 881px) { .shrink_main { float: left; - width: calc(75% - 12px); + /*width: calc(75% - 12px);*/ } .sidebar { float: left; diff --git a/themes/tempra_simple/public/misc.js b/themes/tempra_simple/public/misc.js index 95358608..9302a94e 100644 --- a/themes/tempra_simple/public/misc.js +++ b/themes/tempra_simple/public/misc.js @@ -1,4 +1,5 @@ -$(document).ready(function(){ +(() => { +addInitHook("end_init", () => { // TODO: Run this when the image is loaded rather than when the document is ready? $(".topic_list img").each(function(){ let aspectRatio = this.naturalHeight / this.naturalWidth; @@ -10,4 +11,5 @@ $(document).ready(function(){ height: aspectRatio * this.width }); }); -}); \ No newline at end of file +}); +})(); \ No newline at end of file diff --git a/themes/tempra_simple/public/panel.css b/themes/tempra_simple/public/panel.css index 602643e1..d269e958 100644 --- a/themes/tempra_simple/public/panel.css +++ b/themes/tempra_simple/public/panel.css @@ -1,3 +1,6 @@ +#back { + width: 100%; +} .sidebar { display: none; } diff --git a/themes/tempra_simple/public/profile.css b/themes/tempra_simple/public/profile.css index 792c3056..647131d1 100644 --- a/themes/tempra_simple/public/profile.css +++ b/themes/tempra_simple/public/profile.css @@ -1,3 +1,6 @@ +#back { + width: 100%; +} .sidebar { display: none; } diff --git a/themes/tempra_simple/theme.json b/themes/tempra_simple/theme.json index d1b6dba4..c069f96d 100644 --- a/themes/tempra_simple/theme.json +++ b/themes/tempra_simple/theme.json @@ -17,7 +17,8 @@ "Resources": [ { "Name":"tempra_simple/misc.js", - "Location":"global" + "Location":"global", + "Async":true } ] }