Commit Graph

70 Commits

Author SHA1 Message Date
a 77d85278a2 adjust path 2022-02-21 03:53:13 +00:00
Azareal e839bc5f2c optimise template gen 2021-05-05 22:30:04 +10:00
Azareal 78fbbcda21 Optimise template generator.
Optimise mysql adapter.
Add TokenScope to mysql adapter.
Add SimpleBulkInsert() to installer.
Optimise panel.Plugins() route.
2021-04-30 08:33:02 +10:00
Azareal a4ba5a2470 Optimise part of fout with string builders in the template generator. 2021-03-29 06:57:49 +10:00
Azareal d47540391a Add Config.LogDir and Config.DisableSuspLog settings.
Reduce default Config.PostIPCutoff from 120 to 90.
Add another startup log call.
2021-03-24 18:08:37 +10:00
Azareal 43d72e6f3b wip allow for more cdns
add res template function
add ExtraCSPOrigins config setting
add StaticResBase config setting
skip flush directives
2020-07-30 18:10:29 +10:00
Azareal b915131ab4 avoid writer indirects in templates 2020-04-30 13:04:52 +10:00
Azareal ab9dc20c3c optimise away the array on single phrase
use sync.Pool to optimise CompressBytesGzip()
2020-04-29 10:26:15 +10:00
Azareal a7773d0ca2 optimise bunit 2020-04-29 09:49:26 +10:00
Azareal 46a87defee optimise topic pages
optimise profiles
simple nil ptr handling in template boolean expressions
2020-04-27 22:41:55 +10:00
Azareal fbc50c9086 eliminate string allocs for HasWidgets
add BuildWidgets3 to avoid string allocs and redundant w.Write calls in templates
2020-04-12 15:37:38 +10:00
Azareal 5fe0c8c95b add BuildWidget2 to avoid allocing as many strings in templates for docks
dynamic load /topics/ page where possible
reduce boilerplate
2020-04-12 15:00:15 +10:00
Azareal 3adee57b37 save allocs in router
better logging for bad char in path
router_pre_route hook now returns properly
2020-03-27 16:05:35 +10:00
Azareal a668cd296b save bytes in the client templates
rename template file and functions to reduce bandwidth usage
replace x-loggedin with theoretically faster x-mem
remove redundant check in ua loop
move extraData initialisation down to where it's needed
2020-03-23 09:14:08 +10:00
Azareal f86346ba22 reduce boilerplate in the client template builder
save a few more bytes in client templates
shave down img tags and global.js mini parse
remove comment in topic alt userinfo
2020-03-22 12:37:32 +10:00
Azareal 75ed0cd5f2 save bytes in client templates 2020-03-22 10:25:10 +10:00
Azareal 133c240350 experiment with range header in StaticFile
optimise StaticFile with StrLength
add things i forgot yesterday
2020-03-07 07:52:58 +10:00
Azareal 8f21d34964 experiment with bce in plist 2020-03-05 14:43:40 +10:00
Azareal 46732286e5 optimise route perf tracking
expand route perf tracking to more routes
2020-02-29 11:10:39 +10:00
Azareal 363826624f Reduce bandwidth usage for client templates.
Add js and ptmpl (stub) template functions.
Simple constant folding for true / false values in templates.
Use empty string instead of 0 for poll vote ips when DisablePollIP is enabled.

Shorten some things.
2020-02-19 09:04:14 +10:00
Azareal 69a2430e5a Add option to delete all of a user's posts.
Add limited dynanicism to langf.
Eliminate a few queries when updating user stats.
Minor clean-up.

Namespace the profile language strings.
2020-01-14 15:07:00 +10:00
Azareal 6e8c241d8b Fix undefined buttons on edit reply.
Move some logic from files.go into templates.go
Shorten some things in templates.go

Fixes #63
2019-11-07 13:53:29 +10:00
Azareal df6e268a06 Speed up template compilation by not building the same parse trees multiple times.
Compile panel_debug.
Add the ability to print int8, int16, int32, uint, uint8, uint16, uint32 and uint64 in compiled templates.
Add the ability to pass string nodes to subtemplates in the template compiler.
Fix bunit in the template compiler.

Shorten some things.
2019-10-13 08:49:08 +10:00
Azareal dcd4d7d7eb The lang template function now accepts dynamic variables. 2019-10-11 10:36:45 +10:00
Azareal 45a3065db1 Use json marshal for the group permissions in querygen.
Add an omitempty json tag to the Perms struct.
Take the opportunity to shorten some things.
2019-10-06 15:32:08 +10:00
Azareal 0e9c459446 Adjust convo permissions.
Speed up convo_view.html
Make ContentLines in ConvoViewRow an int as it should be.
Shorten common. in the generated templates.
Fix the page titles for the convo panes.
Stop non-present users from editing their convo posts but still allow them to delete them, if they somehow have a way to do that.
Reduce the amount of boilerplate in the currently broken guilds plugin.
2019-08-21 08:32:10 +10:00
Azareal 89ca5ee823 langf now works in transpiled templates, albeit a little inefficiently.
Removed the quick_topic.add_poll_option phrase.
Added the quick_topic.add_poll_option_first phrase.
Changed the topic.reply_add_poll_option phrase.
Added the topic.reply_add_poll_option_first phrase.
2019-06-17 09:36:31 +10:00
Azareal 5b5b8339d6 Add instance disk usage to the Control Panel Dashboard.
Split the dashboard grid into two.
Add more analytics tables to the debug page.
Add flushes to the Control Panel Dashboard.
Fix some templates not transpiling properly.
Reduce duplication in the debug route.
Fix the link styling in the Control Panel Dashboard for Tempra Simple.

Transpile the Control Panel Dashboard.

Added the panel_dashboard_disk phrase.
Added the panel_dashboard_disk_desc phrase.
2019-06-03 15:26:27 +10:00
Azareal 9cd3cbadab Expanded upon the control panel debug page and improved the UI a bit.
Trying to de-dupe the phrase strings to avoid allocating as much memory and creating as many pointers.
Shortened topic.status_closed_aria slightly.
Moved some things that should have been in various panel.css' into those panel.css'
Fixed the MemUsed dashboard item on Cosora.

Added the bunit template function.
2019-05-13 19:17:44 +10:00
Azareal efe7a0f3f0 ETags are now set by /api/phrases and Hyperdrive on the topic list for better caching.
Initialised the fields in hyperspace properly.

Eliminate an unnecessary line in client templates.
Cleaned up some thaw code in the forum store.
Fixed a potential premature thaw in Forums.BypassGet
2019-04-28 20:08:05 +10:00
Azareal 27a4a74840 You can now re-order forums by dragging them in the Forum Manager.
Added some visual and textual hints to make it clearer that Menu Items and Forums can be dragged.
Added a hint to flush the page after pushing the <head>
Added the notice client template and pushNotice client function.

Used a pointer instead of a struct for AnalyticsTimeRange in the analytics routes.
Caught a potential missing error check in InitPhrases.
Use struct{} instead of bool in some of the user mapping maps for WebSockets to save space.
Added the buildUserExprs function to eliminate a bit of duplication.
Fixed a typo in ForumsEdit where it referenced a non-existent notice phrase.
Client hooks can now sort of return things.
Panel phrases are now fetched by init.js, but only in the control panel.
Reduced the number of unused phrases loaded in both the front-end and the control panel.

Plugin hyperdrive should handle Gzip better now.

Added the panel.ForumsOrderSubmit route.

Added the panel_hints_reorder phrase.
Moved the panel_forums phrases into the panel. namespace.
Added the panel.forums_order_updated phrase.
Renamed the panel_themes_menus_item_edit_button_aria phrase to panel_themes_menus_items_edit_button_aria
Renamed the panel_themes_menus_item_delete_button_aria phrase to panel_themes_menus_items_delete_button_aria
Added the panel_themes_menus_items_update_button phrase.

You will need to run the patcher / updater for this commit.
2019-04-27 16:32:26 +10:00
Azareal 660f24acff Experimenting with Nox's Control Panel.
Experimenting with better cache busting for static resources.
HTTPSRedirect requests are now counted in the route analytics.
More scripts are loaded asynchronously now.
Upped the default ReadTimeout to eight seconds.
Reduce the number of unneccesary NewAcc calls.
Added panel_before_head as an injection point for themes.
Themes can now declare scripts to be loaded asynchronously.
Tweaked the WS resumption algorithm to mae the backoffs a little less aggressive.
Fixed an ordering issue in the WS resumption algorithm where backoffs weren't expiring as fast as they should have.
Fixed a bug where template logs weren't being written due to a panic.
You can now use byte slices in more places in the transpiled templates.
Fixed a bug where Cosora's misc.js seemed to be erroring out.
Fixed a bug where YT embeds were getting blocked by the CSP.

Added the panel_back_to_site phrase.
Added the panel_welcome phrase.
2019-03-22 08:59:41 +10:00
Azareal 25846d8942 shrink_main should work again. 2019-02-28 19:31:13 +10:00
Azareal cc1d0f089a Client templates can now be overriden like every other template.
The client templates load earlier now for a smoother user experience.
Added a setting for setting a Google Site Verification meta tag without editing header.html
Added support for favicons. /static/favicon.ico will be mapped to favicon.ico, if it exists.
The parent forum is now visible on the topics list for Nox.

Language headers which contain the wildcard character are no longer considered unknowns.
Meta descriptions and open graph descriptions are no longer emitted for logged in users.
Slimmed down topics_topic slightly for Nox.
Pre-parsed widgets are now minified.
Stale WebSockets connections should be cleaned up far quicker now.
Template generation is now logged separately.
Commented out some obsolete template logic.
Marked a few template generator fields as unexported.

Fixed the styling for the ban page in the profile for Nox.
Fixed the styling for colline for Cosora and Tempra Simple.
Fixed the sidebar overflowing outside of the box on Nox.
Fixed the meta description text overflowing the box in the Setting Manager on Nox.
Fixed excessive padding in the Page Manager.
Fixed a few missing border on the profiles for Tempra Simple.
Fixed the sidebar appearing in places it shouldn't on Tempra Simple.
Fixed the status code emitted by NotFoundJS
Fixed a bug where Gosora kept falling back to interpreted templates.
Fixed a bug where WebSockets connections weren't getting closed properly if the user cache overflowed.
Fixed a bug where WebSocket connections weren't getting initialised for guests.
Fixed a bug where template overrides weren't always getting applied.
Fixed a bug where root template overrides weren't always getting applied.

Added the google_site_verify setting.
Added the google_site_verify phrase.

You will need to run the patcher or updater for this commit.
2019-02-28 17:28:17 +10:00
Azareal d9acf27c5b The Search and Filter Widget is now partly implemented. Just Search to go in the basic implementation.
Added AJAX Pagination for the Topic List and Forum Page.
A new log file pair is now created every-time Gosora starts up.
Added proper per-theme template overrides.

Added EasyJSON to make JSON serialisation faster.
Moved a bit of boilerplate into paginator.html
Improved paginator.html with a richer template with first, last and symbols instead of text.
Phased out direct access to Templates.ExecuteTemplate across the software.
Fixed the Live Topic List so it should work again.
Added MicroAvatar to WsJSONUser for topic list JSON requests.
An instance of the plugin is now passed to plugin handlers rather than having the plugins manipulate the globals directly.
Added the pre_render_panel_forum_edit and pre_render_panel_forum_edit_perms hooks to replace pre_render_panel_edit_forum.
Renamed the pre_render_panel_edit_user hook to pre_render_panel_user_edit
Reduced the amount of noise from fsnotify.
Added RawPrepare() to qgen.Accumulator.
Added a temporary phrase whitelist to the phrase endpoint.
Moved the location of the zone data assignments in the topic list to reduce the chances of security issues in the future.
Changed the signature of routes/panel/renderTemplate() requiring some changes across the panel routes.
Removed bits of boilerplate in some of the panel routes with renderTemplate()
Added a BenchmarkTopicsGuestJSRouteParallelWithRouter benchmark.
Removed a fair bit of boilerplate for each page struct by generating a couple of interface casts for each template file instead.
Added the profile_comments_row_alt template.
Added the topics_quick_topic template to reuse part of the quick topic logic for both the topic list and forum page.
Tweaked the CSS for the Online Users Widget.
Tweaked the CSS for Widgets in every theme with a sidebar.
Refactored the template initialisers to hopefully reduce the amount of boilerplate and make things easier to maintain and follow.
Add genIntTmpl in the template initialiser file to reduce the amount of boilerplate needed for the fallback template bindings.

Removed the topics_head phrase.
Moved the paginator_ phrases into the paginator. namespace and renamed them accordingly.
Added the paginator.first_page phrase.
Added the paginator.first_page_aria phrase.
Added the paginator.last_page phrase.
Added the paginator.last_page_aria phrase.
Added the panel_forum_delete_are_you_sure phrase.

Fixed a data race in LogWarning()
2019-02-10 15:52:26 +10:00
Azareal 8f2f47e8aa Added the In-Progress Widget Manager UI.
Added the IsoCode field to phrase files.
Rewrote a good portion of the widget system logic.
Added some tests for the widget system.
Added the Online Users widget.
Added a few sealed incomplete widgets like the Search & Filter Widget.
Added the AllUsers method to WsHubImpl for Online Users. Please don't abuse it.

Added the optional *DBTableKey field to AddColumn.
Added the panel_analytics_time_range template to reduce the amount of duplication.
Failed registrations now show up in red in the registration logs for Nox.
Failed logins now show up in red in the login logs for Nox.
Added basic h2 CSS to the other themes.
Added .show_on_block_edit and .hide_on_block_edit to the other themes.
Updated contributing.
Updated a bunch of dates to 2019.
Replaced tblKey{} with nil where possible.
Switched out some &s for &amp;s to reduce the number of possible bugs.
Fixed a bug with selector messages where the inspector would get really jittery due to unnecessary DOM updates.
Moved header.Zone and associated fields to the bottom of ViewTopic to reduce the chances of problems arising.
Added the ZoneData field to *Header.
Added IDs to the items in the forum list template.
Split the fetchPhrases function into the initPhrases and fetchPhrases functions in init.js
Added .colstack_sub_head.
Fixed the CSS in the menu list.
Removed an inline style from the simple topic like and unlike buttons.
Removed an inline style from the simple topic IP button.
Simplified the LoginRequired error handler.
Fixed a typo in the comment prior to DatabaseError()
Reduce the number of false leaves for WebSocket page transitions.
Added the error zone.
De-duped the logic in WsHubImpl.getUsers.
Fixed a potential widget security issue.

Added twenty new phrases.
Added the wid column to the widgets table.

You will need to run the patcher / updater for this commit.
2019-01-21 22:27:59 +10:00
Azareal 5db5bc0c7e Reply attachments can be managed too now.
Added eight database indices.
Fixed a bug where the second tick wouldn't fire.
Tweaked the .topic_forum in Nox by a pixel.
Replaced some _installer strings with blank strings for consistency with the builders.
Greatly reduced the number of allocations in the user agent parser.
Added ampersand entities in more attachment URLs to avoid accidental mangling.
.edit_source is now hidden for guests.
Guest noavatars are now pre-calculated to reduce the number of allocations.
Lazily initialised a couple of maps in ViewTopic to reduce the number of unnecessary allocations slightly.

Added the unsafe BytesToString function. Please don't use this, if you don't have to.
Added the AddIndex method to the adapter and associated components.
Added the /reply/attach/add/submit/ route.
Added the /reply/attach/remove/submit/ route.
Added the topic_alt_userinfo template.
Replaced Attachments.MiniTopicGet with MiniGetList.
Added Attachments.BulkMiniGetList.

Added a quick test for ReplyStore.Create.
Added BenchmarkPopulateTopicWithRouter.
Added BenchmarkTopicAdminFullPageRouteParallelWithRouter.
Added BenchmarkTopicGuestFullPageRouteParallelWithRouter.

You will need to run the updater or patcher for this commit.
2018-12-31 19:03:49 +10:00
Azareal a1a90ab9fd The opening posts should be properly rendered after inline edits now.
Switched out the / in the headers for a -
The template generator can now handle FieldNodes passed to templates.

Added the topic_alt_userinfo template.
Added the topic_alt_quick_reply template.
2018-12-28 21:13:06 +10:00
Azareal 3465e4c08f You can now manage the attachments for an opening post by hitting edit.
The update system now uses the database as the source of truth for the last version rather than lastSchema.json
Refactored several structs and bits of code, so we can avoid allocations for contexts where we never use a relative time.
Clicking on the relative times on the topic list and the forum page should now take you to the post on the last page rather than just the last page.
Added the reltime template function.
Fixed some obsolete bits of code.
Fixed some spelling mistakes.
Fixed a bug where MaxBytesReader was capped at the maxFileSize rather than r.ContentLength.
All of the client side templates should work again now.
Shortened some statement names to save some horizontal space.
accUpdateBuilder and SimpleUpdate now use updatePrebuilder behind the scenes to simplify things.
Renamed selectItem to builder in AccSelectBuilder.
Added a Total() method to accCountBuilder to reduce the amount of boilerplate used for row count queries.
The "_builder" strings have been replaced with empty strings to help save memory, to make things slightly faster and to open the door to removing the query name in many contexts down the line.
Added the open_edit and close_edit client hooks.
Removed many query name checks.
Split the attachment logic into separate functions and de-duplicated it between replies and topics.
Improved the UI for editing topics in Nox.
Used type aliases to reduce the amount of boilerplate in tables.go and patches.go
Reduced the amount of boilerplate in the action post logic.
Eliminated a map and a slice in the topic page for users who haven't given any likes. E.g. Guests.
Fixed some long out-dated parts of the update instructions.
Updated the update instructions to remove mention of the obsolete lastSchema.json
Fixed a bug in init.js where /api/me was being loaded for guests.
Added the MiniTopicGet, GlobalCount and CountInTopic methods to AttachmentStore.
Added the MiniAttachment struct.
Split the mod floaters out into their own template to reduce duplication.
Removed a couple of redundant ParseForms.

Added the common.skipUntilIfExistsOrLine function.
Added the NotFoundJS and NotFoundJSQ functions.
Added the lastReplyID and attachCount columns to the topics table.
2018-12-27 15:42:41 +10:00
Azareal 543ad8a018 Added the login log.
Added a better paginator for view topic.
The last post on the topic list and forum pages now link to the last page of a topic for quicker navigation.
The Account Manager now utilises dyntmpl in more areas.
More tooltips.
Tweaked the colour for the validated emails in the Email Manager so it looks nicer on dark themes.
Moved some inline styles from the Email Manager into the stylesheets and removed obsolete ones.
Added the mixed BenchmarkTopicGuestAdminRouteParallelWithRouter benchmark.
The bad route benchmark should no longer abort when erroring, something which doesn't make sense as it's always expected to error.
Reduce a bit more boilerplate with renderTemplate()
Added the *CTemplateSet.addText method and used it to optimise the generated templates a tiny bit more.
The forums route now has guest and member variants generated for it.
Turned the experimental template optimisation back on for more data.

Added the routes.AccountLogins route.

Added the account_logins phrase.
Added the account_menu_logins phrase.
Added the account_logins_head phrase.
Added the account_logins_success phrase.
Added the account_logins_failure phrase.

You need to run the patcher / updater for this commit.
2018-12-17 14:58:55 +10:00
Azareal 72c92672b7 Use unsafe to reduce the number of string to slice copies in templates.
Use sliced arrays to reduce the amount of null padding in template fragments.
Revert a failed optimisation in templates.
Remove a few more redundant branches in variant templates.

Added the unsafe function StringToBytes.
Added BenchmarkTopicGuestRouteParallelWithRouterAlt.
2018-12-15 14:39:50 +10:00
Azareal 6eb69d0c96 Package time isn't needed in these cases. 2018-12-14 14:30:13 +10:00
Azareal bdf7fa40d5 Improved the datetimes on the log pages.
Added an experimental template fragment optimisation.
The template generator can handle time.Time
The forum and profile templates now have guest and member variants generated for them.
Interpreted templates are no longer loaded, if there's a generated version of it.

Added absolute time on hover to the topic, topics, forum, and forums templates.
We now use lang instead of index in the stylesheets for phrases.
Renamed the .trash_label CSS class to .delete_label
Use the new toArr and concat template functions to reduce the amount of boilerplate in the theme stylesheets.
Removed bits of redundant code here and there in the stylesheets.
Added a .CurrentUser.Loggedin to profiles to make them slightly faster.
Shortened some themeStmt names.
Moved GzipResponseWriter, theme.RunTmpl and theme.GetTmpl from theme_list.go to theme.go
The fallback theme now falls back onto the last theme loaded, if the fallback theme doesn't exist.
Added the abstime template function for formatting absolute times a little more nicely.

Began work on the login logs.

Removed the alerts_no_new_alerts phrase.
Renamed the forums_topics_suffix phrase to forums.topics_suffix.
2018-12-14 14:08:53 +10:00
Azareal dc974cf72b Improved mobile usability for Nox in the topic list, profiles, account manager and control panel. More to come.
Fixed a bug in the template generator where fragment indices would sometimes become negative.
Forum pages are now considered to be part of /forums/ instead of /topics/ in the menu tab highlighter.
Fixed a bug in the forum page in Nox where the forum options weren't aligned to the right.
Switched out a couple of {{if ne .CurrentUser.ID 0}}s for {{if .CurrentUser.Loggedin}}s
Moved the filter opt separator into it's own DOM node for easier styling.

Added the quick_topic.create_topic_button_short phrase.
Added the topic_list.moderate_short phrase.
2018-12-08 16:49:14 +10:00
Azareal 99012e8961 Replaced RunThemeTemplate and GetThemeTemplate with methods on *Theme and refactored their implementations to make them more predictable.
Added the Elapsed1 route timer.
2018-12-08 10:45:27 +10:00
Azareal 266f17c23d Revamped the Nox Account Manager and Control Panel Menus.
The topics list template is now generated by loggedin.
Replaced some uses of {{if ne .CurrentUser.ID 0}} with {{if .CurrentUser.Loggedin}}
Fixed a bug in the profiles where the comment creation form was shown to guests.
Added the profile_comments_form_guest phrase.
2018-11-29 07:46:53 +10:00
Azareal 50fef78078 Split the transpiled topic alt route into a guest part and a member part for extra speed.
Fixed a bug in the template fragment coalescer.
Added the loadTemplate function to help reduce the amount of duplicated code in the template generator.
Added a couple of helper methods to CContext to reduce the amount of possibly error prone boilerplate.
2018-11-26 15:08:10 +10:00
Azareal 52c8be4173 Variables which are computed multiple times in templates should only be computed once now.
Enabled the Watchdog Goroutine.
Moved a couple of parser tests into their own file.
Eliminated the hard-coded URLs in TestParser()
Refactored the alert system so that a specific actor is only loaded once rather than once for each alert. This isn't a problem in practice due to the user cache, but it might be on high traffic sites.
Don't run HandleServerSync() on single server setups.
Don't load the user in GetTopicUser(), if the topic creator is the current user.
Fixed a bug in the template generator where endloop nodes were being pushed instead of endif ones.
2018-11-22 17:21:43 +10:00
Azareal 1aac6f1268 Greatly reduced the number of w.Write calls in the generated templates.
The topic list should only be rebuilt for a short window after something related to it changes on single server setups.
Swapped out the RebuildGroupPermissions call in UpdatePerms with a more general and versable Groups.Reload call.
The template generator now use log instead of fmt for writing debug logs.
2018-11-20 09:06:15 +10:00
Azareal f508ef9898 Moved CContext and some related structs into their own file. 2018-11-18 19:28:26 +10:00