2017-09-03 04:50:31 +00:00
/ *
*
* Gosora Phrase System
2019-02-10 05:52:26 +00:00
* Copyright Azareal 2017 - 2020
2017-09-03 04:50:31 +00:00
*
* /
2018-11-01 06:43:56 +00:00
package phrases
2017-03-23 12:13:50 +00:00
2017-09-03 04:50:31 +00:00
import (
2017-09-11 00:56:09 +00:00
"encoding/json"
"errors"
2018-10-02 06:56:24 +00:00
"fmt"
2017-09-11 00:56:09 +00:00
"io/ioutil"
"log"
"os"
"path/filepath"
2018-10-10 07:33:51 +00:00
"strconv"
2018-06-24 13:49:29 +00:00
"strings"
2017-09-03 04:50:31 +00:00
"sync"
"sync/atomic"
)
2017-03-23 12:13:50 +00:00
2017-11-23 05:37:08 +00:00
// TODO: Add a phrase store?
2017-09-10 16:57:22 +00:00
// TODO: Let the admin edit phrases from inside the Control Panel? How should we persist these? Should we create a copy of the langpack or edit the primaries? Use the changeLangpack mutex for this?
// nolint Be quiet megacheck, this *is* used
2017-09-03 04:50:31 +00:00
var currentLangPack atomic . Value
2017-11-11 04:06:16 +00:00
var langPackCount int // TODO: Use atomics for this
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
2017-09-11 10:24:03 +00:00
// TODO: We'll be implementing the level phrases in the software proper very very soon!
2017-09-03 04:50:31 +00:00
type LevelPhrases struct {
Level string
2017-09-11 00:56:09 +00:00
LevelMax string // ? Add a max level setting?
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
2017-09-03 04:50:31 +00:00
// Override the phrase for individual levels, if the phrases exist
Levels [ ] string // index = level
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
2017-09-11 10:24:03 +00:00
// ! For the sake of thread safety, you must never modify a *LanguagePack directly, but to create a copy of it and overwrite the entry in the sync.Map
2017-09-03 04:50:31 +00:00
type LanguagePack struct {
2019-01-21 12:27:59 +00:00
Name string
IsoCode string
2019-04-27 06:32:26 +00:00
//LastUpdated string
2019-01-21 12:27:59 +00:00
2018-07-31 04:02:09 +00:00
// Should we use a sync map or a struct for these? It would be nice, if we could keep all the phrases consistent.
2018-06-24 13:49:29 +00:00
Levels LevelPhrases
2019-10-06 11:32:00 +00:00
Perms map [ string ] string
2018-06-24 13:49:29 +00:00
SettingPhrases map [ string ] string
PermPresets map [ string ] string
Accounts map [ string ] string // TODO: Apply these phrases in the software proper
UserAgents map [ string ] string
OperatingSystems map [ string ] string
HumanLanguages map [ string ] string
2018-11-27 07:40:13 +00:00
Errors map [ string ] string // Temp stand-in
ErrorsBytes map [ string ] [ ] byte
2018-06-24 13:49:29 +00:00
NoticePhrases map [ string ] string
PageTitles map [ string ] string
TmplPhrases map [ string ] string
TmplPhrasesPrefixes map [ string ] map [ string ] string // [prefix][name]phrase
2018-03-08 03:59:47 +00:00
TmplIndicesToPhrases [ ] [ ] [ ] byte // [tmplID][index]phrase
2017-03-23 12:13:50 +00:00
}
2017-09-10 16:57:22 +00:00
// TODO: Add the ability to edit language JSON files from the Control Panel and automatically scan the files for changes
2018-03-08 03:59:47 +00:00
var langPacks sync . Map // nolint it is used
var langTmplIndicesToNames [ ] [ ] string // [tmplID][index]phraseName
2017-09-11 00:56:09 +00:00
2018-11-01 06:43:56 +00:00
func InitPhrases ( lang string ) error {
2017-09-11 00:56:09 +00:00
log . Print ( "Loading the language packs" )
err := filepath . Walk ( "./langs" , func ( path string , f os . FileInfo , err error ) error {
if f . IsDir ( ) {
return nil
}
2019-04-27 06:32:26 +00:00
if err != nil {
return err
}
2017-09-11 00:56:09 +00:00
2020-02-18 23:04:14 +00:00
ext := filepath . Ext ( "/langs/" + path )
2017-09-11 00:56:09 +00:00
if ext != ".json" {
2018-02-19 04:26:01 +00:00
log . Printf ( "Found a '%s' in /langs/" , ext )
2017-09-11 00:56:09 +00:00
return nil
}
2020-02-18 23:04:14 +00:00
data , err := ioutil . ReadFile ( path )
if err != nil {
return err
}
2017-09-11 00:56:09 +00:00
var langPack LanguagePack
err = json . Unmarshal ( data , & langPack )
if err != nil {
return err
}
2018-11-27 07:40:13 +00:00
langPack . ErrorsBytes = make ( map [ string ] [ ] byte )
for name , phrase := range langPack . Errors {
langPack . ErrorsBytes [ name ] = [ ] byte ( phrase )
}
2018-06-24 13:49:29 +00:00
// [prefix][name]phrase
langPack . TmplPhrasesPrefixes = make ( map [ string ] map [ string ] string )
2020-02-18 23:04:14 +00:00
conMap := make ( map [ string ] string ) // Cache phrase strings so we can de-dupe items to reduce memory use. There appear to be some minor improvements with this, although we would need a more thorough check to be sure.
2019-05-13 09:17:44 +00:00
for name , phrase := range langPack . TmplPhrases {
_ , ok := conMap [ phrase ]
if ! ok {
conMap [ phrase ] = phrase
}
cItem := conMap [ phrase ]
prefix := strings . Split ( name , "." ) [ 0 ]
_ , ok = langPack . TmplPhrasesPrefixes [ prefix ]
if ! ok {
langPack . TmplPhrasesPrefixes [ prefix ] = make ( map [ string ] string )
}
langPack . TmplPhrasesPrefixes [ prefix ] [ name ] = cItem
}
// [prefix][name]phrase
/ * langPack . TmplPhrasesPrefixes = make ( map [ string ] map [ string ] string )
2018-06-24 13:49:29 +00:00
for name , phrase := range langPack . TmplPhrases {
prefix := strings . Split ( name , "." ) [ 0 ]
_ , ok := langPack . TmplPhrasesPrefixes [ prefix ]
if ! ok {
langPack . TmplPhrasesPrefixes [ prefix ] = make ( map [ string ] string )
}
langPack . TmplPhrasesPrefixes [ prefix ] [ name ] = phrase
2019-05-13 09:17:44 +00:00
} * /
2018-06-24 13:49:29 +00:00
2018-03-08 03:59:47 +00:00
langPack . TmplIndicesToPhrases = make ( [ ] [ ] [ ] byte , len ( langTmplIndicesToNames ) )
for tmplID , phraseNames := range langTmplIndicesToNames {
2020-01-14 05:07:00 +00:00
phraseSet := make ( [ ] [ ] byte , len ( phraseNames ) )
2018-03-08 03:59:47 +00:00
for index , phraseName := range phraseNames {
2018-03-11 09:33:49 +00:00
phrase , ok := langPack . TmplPhrases [ phraseName ]
if ! ok {
2018-12-14 04:08:53 +00:00
log . Printf ( "langPack.TmplPhrases: %+v\n" , langPack . TmplPhrases )
panic ( "Couldn't find template phrase '" + phraseName + "'" )
2018-03-11 09:33:49 +00:00
}
phraseSet [ index ] = [ ] byte ( phrase )
2018-03-08 03:59:47 +00:00
}
langPack . TmplIndicesToPhrases [ tmplID ] = phraseSet
2020-03-05 04:43:40 +00:00
TmplIndexCallback ( tmplID , phraseSet )
2018-03-08 03:59:47 +00:00
}
2017-09-11 00:56:09 +00:00
log . Print ( "Adding the '" + langPack . Name + "' language pack" )
2017-11-11 04:06:16 +00:00
langPacks . Store ( langPack . Name , & langPack )
langPackCount ++
2017-09-11 00:56:09 +00:00
return nil
} )
if err != nil {
return err
}
2017-11-11 04:06:16 +00:00
if langPackCount == 0 {
2017-09-11 00:56:09 +00:00
return errors . New ( "You don't have any language packs" )
}
2018-11-01 06:43:56 +00:00
langPack , ok := langPacks . Load ( lang )
2017-09-11 00:56:09 +00:00
if ! ok {
2018-11-01 06:43:56 +00:00
return errors . New ( "Couldn't find the " + lang + " language pack" )
2017-09-11 00:56:09 +00:00
}
currentLangPack . Store ( langPack )
return nil
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
2017-09-11 10:24:03 +00:00
// TODO: Implement this
2017-09-11 00:56:09 +00:00
func LoadLangPack ( name string ) error {
_ = name
return nil
2017-03-23 12:13:50 +00:00
}
2017-09-11 10:24:03 +00:00
// TODO: Implement this
func SaveLangPack ( langPack * LanguagePack ) error {
_ = langPack
return nil
}
2019-04-09 07:21:00 +00:00
func GetLangPack ( ) * LanguagePack {
return currentLangPack . Load ( ) . ( * LanguagePack )
}
2018-10-10 07:33:51 +00:00
func GetLevelPhrase ( level int ) string {
levelPhrases := currentLangPack . Load ( ) . ( * LanguagePack ) . Levels
if len ( levelPhrases . Levels ) > 0 && level < len ( levelPhrases . Levels ) {
return strings . Replace ( levelPhrases . Levels [ level ] , "{0}" , strconv . Itoa ( level ) , - 1 )
}
return strings . Replace ( levelPhrases . Level , "{0}" , strconv . Itoa ( level ) , - 1 )
}
2019-10-06 11:32:00 +00:00
func GetPermPhrase ( name string ) string {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . Perms [ name ]
2017-09-03 04:50:31 +00:00
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "perms" , name )
2017-09-03 04:50:31 +00:00
}
return res
}
2018-05-27 09:36:35 +00:00
func GetSettingPhrase ( name string ) string {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . SettingPhrases [ name ]
2017-03-23 12:13:50 +00:00
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "settings" , name )
2017-03-23 12:13:50 +00:00
}
return res
}
2018-05-27 09:36:35 +00:00
func GetAllSettingPhrases ( ) map [ string ] string {
return currentLangPack . Load ( ) . ( * LanguagePack ) . SettingPhrases
2017-09-03 04:50:31 +00:00
}
2017-11-05 01:04:57 +00:00
func GetAllPermPresets ( ) map [ string ] string {
return currentLangPack . Load ( ) . ( * LanguagePack ) . PermPresets
}
2017-09-13 15:09:13 +00:00
func GetAccountPhrase ( name string ) string {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . Accounts [ name ]
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "account" , name )
2017-09-13 15:09:13 +00:00
}
return res
}
2018-02-04 08:15:20 +00:00
func GetUserAgentPhrase ( name string ) ( string , bool ) {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . UserAgents [ name ]
if ! ok {
return "" , false
}
return res , true
}
func GetOSPhrase ( name string ) ( string , bool ) {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . OperatingSystems [ name ]
if ! ok {
return "" , false
}
return res , true
}
2018-03-08 03:59:47 +00:00
func GetHumanLangPhrase ( name string ) ( string , bool ) {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . HumanLanguages [ name ]
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "humanlang" , name ) , false
2018-03-08 03:59:47 +00:00
}
return res , true
}
2017-11-23 05:37:08 +00:00
// TODO: Does comma ok work with multi-dimensional maps?
2018-09-27 10:53:40 +00:00
func GetErrorPhrase ( name string ) string {
2018-09-27 10:29:16 +00:00
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . Errors [ name ]
2017-11-23 05:37:08 +00:00
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "error" , name )
2017-11-23 05:37:08 +00:00
}
2018-09-27 10:53:40 +00:00
return res
2017-11-23 05:37:08 +00:00
}
2018-11-27 07:40:13 +00:00
func GetErrorPhraseBytes ( name string ) [ ] byte {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . ErrorsBytes [ name ]
if ! ok {
return getPlaceholderBytes ( "error" , name )
}
return res
}
2017-11-23 05:37:08 +00:00
2018-03-17 08:16:43 +00:00
func GetNoticePhrase ( name string ) string {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . NoticePhrases [ name ]
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "notices" , name )
2018-03-17 08:16:43 +00:00
}
return res
}
2017-11-23 05:37:08 +00:00
func GetTitlePhrase ( name string ) string {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . PageTitles [ name ]
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "title" , name )
2017-11-23 05:37:08 +00:00
}
return res
}
2018-10-14 05:08:44 +00:00
func GetTitlePhrasef ( name string , params ... interface { } ) string {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . PageTitles [ name ]
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "title" , name )
2018-10-14 05:08:44 +00:00
}
return fmt . Sprintf ( res , params ... )
}
2018-03-08 03:59:47 +00:00
func GetTmplPhrase ( name string ) string {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . TmplPhrases [ name ]
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "tmpl" , name )
2018-03-08 03:59:47 +00:00
}
return res
}
2018-10-02 06:56:24 +00:00
func GetTmplPhrasef ( name string , params ... interface { } ) string {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . TmplPhrases [ name ]
if ! ok {
2018-11-01 06:43:56 +00:00
return getPlaceholder ( "tmpl" , name )
2018-10-02 06:56:24 +00:00
}
return fmt . Sprintf ( res , params ... )
}
2018-05-11 05:41:51 +00:00
func GetTmplPhrases ( ) map [ string ] string {
return currentLangPack . Load ( ) . ( * LanguagePack ) . TmplPhrases
2018-03-11 09:33:49 +00:00
}
2018-06-24 13:49:29 +00:00
func GetTmplPhrasesByPrefix ( prefix string ) ( phrases map [ string ] string , ok bool ) {
res , ok := currentLangPack . Load ( ) . ( * LanguagePack ) . TmplPhrasesPrefixes [ prefix ]
return res , ok
}
2020-02-18 23:04:14 +00:00
func getPlaceholder ( prefix , suffix string ) string {
2018-03-11 09:33:49 +00:00
return "{lang." + prefix + "[" + suffix + "]}"
2017-11-23 05:37:08 +00:00
}
2020-02-18 23:04:14 +00:00
func getPlaceholderBytes ( prefix , suffix string ) [ ] byte {
2018-11-27 07:40:13 +00:00
return [ ] byte ( "{lang." + prefix + "[" + suffix + "]}" )
}
2017-11-23 05:37:08 +00:00
2020-03-05 04:43:40 +00:00
// ! Please don't mutate *LanguagePack
2018-10-27 03:21:02 +00:00
func GetCurrentLangPack ( ) * LanguagePack {
return currentLangPack . Load ( ) . ( * LanguagePack )
}
2017-09-11 10:24:03 +00:00
// ? - Use runtime reflection for updating phrases?
// TODO: Implement these
2017-03-23 12:13:50 +00:00
func AddPhrase ( ) {
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
2017-03-23 12:13:50 +00:00
}
2017-09-03 04:50:31 +00:00
func UpdatePhrase ( ) {
2017-03-23 12:13:50 +00:00
2017-09-03 04:50:31 +00:00
}
2017-03-23 12:13:50 +00:00
func DeletePhrase ( ) {
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
}
2017-09-10 16:57:22 +00:00
// TODO: Use atomics to store the pointer of the current active langpack?
// nolint
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
func ChangeLanguagePack ( name string ) ( exists bool ) {
2017-11-11 04:06:16 +00:00
pack , ok := langPacks . Load ( name )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
if ! ok {
return false
}
2017-09-03 04:50:31 +00:00
currentLangPack . Store ( pack )
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
return true
2017-03-23 12:13:50 +00:00
}
2018-03-08 03:59:47 +00:00
2018-03-11 09:33:49 +00:00
func CurrentLanguagePackName ( ) ( name string ) {
return currentLangPack . Load ( ) . ( * LanguagePack ) . Name
}
func GetLanguagePackByName ( name string ) ( pack * LanguagePack , ok bool ) {
packInt , ok := langPacks . Load ( name )
if ! ok {
return nil , false
}
return packInt . ( * LanguagePack ) , true
}
2018-03-08 03:59:47 +00:00
// Template Transpiler Stuff
func RegisterTmplPhraseNames ( phraseNames [ ] string ) ( tmplID int ) {
langTmplIndicesToNames = append ( langTmplIndicesToNames , phraseNames )
return len ( langTmplIndicesToNames ) - 1
}
func GetTmplPhrasesBytes ( tmplID int ) [ ] [ ] byte {
return currentLangPack . Load ( ) . ( * LanguagePack ) . TmplIndicesToPhrases [ tmplID ]
}
2020-03-05 04:43:40 +00:00
// New
var indexCallbacks [ ] func ( [ ] [ ] byte )
func TmplIndexCallback ( tmplID int , phraseSet [ ] [ ] byte ) {
indexCallbacks [ tmplID ] ( phraseSet )
}
func AddTmplIndexCallback ( h func ( [ ] [ ] byte ) ) {
indexCallbacks = append ( indexCallbacks , h )
}