2017-09-13 15:09:13 +00:00
/ *
*
* Gosora Forum Store
2019-05-18 10:31:51 +00:00
* Copyright Azareal 2017 - 2020
2017-09-13 15:09:13 +00:00
*
* /
2017-11-10 03:33:11 +00:00
package common
2017-06-15 11:40:35 +00:00
2017-09-10 16:57:22 +00:00
import (
"database/sql"
2017-09-25 00:48:35 +00:00
"errors"
2017-09-10 16:57:22 +00:00
"log"
2019-10-31 08:55:03 +00:00
2019-05-27 09:00:40 +00:00
//"fmt"
2017-09-23 19:57:13 +00:00
"sort"
2017-09-10 16:57:22 +00:00
"sync"
"sync/atomic"
2017-09-03 04:50:31 +00:00
2019-10-31 08:55:03 +00:00
qgen "github.com/Azareal/Gosora/query_gen"
2017-09-10 16:57:22 +00:00
)
2017-06-15 11:40:35 +00:00
2017-09-03 04:50:31 +00:00
var forumCreateMutex sync . Mutex
2017-11-13 05:22:37 +00:00
var forumPerms map [ int ] map [ int ] * ForumPerms // [gid][fid]*ForumPerms // TODO: Add an abstraction around this and make it more thread-safe
2017-11-23 05:37:08 +00:00
var Forums ForumStore
2019-05-18 10:31:51 +00:00
var ErrBlankName = errors . New ( "The name must not be blank" )
2019-05-18 12:17:50 +00:00
var ErrNoDeleteReports = errors . New ( "You cannot delete the Reports forum" )
2017-06-28 12:05:26 +00:00
2017-09-13 15:09:13 +00:00
// ForumStore is an interface for accessing the forums and the metadata stored on them
2017-09-03 04:50:31 +00:00
type ForumStore interface {
2017-06-28 12:05:26 +00:00
LoadForums ( ) error
2020-03-09 03:51:44 +00:00
Each ( h func ( * Forum ) error ) error
2017-06-28 12:05:26 +00:00
DirtyGet ( id int ) * Forum
Get ( id int ) ( * Forum , error )
BypassGet ( id int ) ( * Forum , error )
2017-12-26 07:17:26 +00:00
BulkGetCopy ( ids [ ] int ) ( forums [ ] Forum , err error )
2017-09-25 00:48:35 +00:00
Reload ( id int ) error // ? - Should we move this to ForumCache? It might require us to do some unnecessary casting though
2017-06-15 11:40:35 +00:00
//Update(Forum) error
2017-09-15 22:20:01 +00:00
Delete ( id int ) error
2020-03-09 03:51:44 +00:00
AddTopic ( tid , uid , fid int ) error
2017-09-28 22:16:34 +00:00
RemoveTopic ( fid int ) error
2020-01-14 05:07:00 +00:00
RemoveTopics ( fid , count int ) error
2020-03-09 03:51:44 +00:00
UpdateLastTopic ( tid , uid , fid int ) error
2017-06-28 12:05:26 +00:00
Exists ( id int ) bool
2017-09-03 04:50:31 +00:00
GetAll ( ) ( [ ] * Forum , error )
GetAllIDs ( ) ( [ ] int , error )
2017-09-10 16:57:22 +00:00
GetAllVisible ( ) ( [ ] * Forum , error )
GetAllVisibleIDs ( ) ( [ ] int , error )
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
//GetChildren(parentID int, parentType string) ([]*Forum,error)
//GetFirstChild(parentID int, parentType string) (*Forum,error)
2020-03-09 03:51:44 +00:00
Create ( name , desc string , active bool , preset string ) ( int , error )
2019-04-27 06:32:26 +00:00
UpdateOrder ( updateMap map [ int ] int ) error
2017-08-15 13:47:56 +00:00
2019-06-01 12:31:48 +00:00
Count ( ) int
2017-06-15 11:40:35 +00:00
}
2017-09-15 22:20:01 +00:00
type ForumCache interface {
CacheGet ( id int ) ( * Forum , error )
2020-01-14 05:07:00 +00:00
CacheSet ( f * Forum ) error
2017-09-15 22:20:01 +00:00
CacheDelete ( id int )
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
Length ( ) int
2017-09-15 22:20:01 +00:00
}
2017-09-13 15:09:13 +00:00
// MemoryForumStore is a struct which holds an arbitrary number of forums in memory, usually all of them, although we might introduce functionality to hold a smaller subset in memory for sites with an extremely large number of forums
2017-09-10 16:57:22 +00:00
type MemoryForumStore struct {
2017-09-13 15:09:13 +00:00
forums sync . Map // map[int]*Forum
2017-09-10 16:57:22 +00:00
forumView atomic . Value // []*Forum
2017-06-28 12:05:26 +00:00
2017-11-06 07:23:32 +00:00
get * sql . Stmt
getAll * sql . Stmt
delete * sql . Stmt
create * sql . Stmt
count * sql . Stmt
updateCache * sql . Stmt
addTopics * sql . Stmt
removeTopics * sql . Stmt
2019-10-31 08:55:03 +00:00
lastTopic * sql . Stmt
2019-05-18 10:31:51 +00:00
updateOrder * sql . Stmt
2017-06-15 11:40:35 +00:00
}
2017-09-13 15:09:13 +00:00
// NewMemoryForumStore gives you a new instance of MemoryForumStore
2017-11-02 13:35:19 +00:00
func NewMemoryForumStore ( ) ( * MemoryForumStore , error ) {
2018-08-04 11:46:36 +00:00
acc := qgen . NewAcc ( )
2019-10-28 07:46:14 +00:00
f := "forums"
2021-04-07 14:23:11 +00:00
set := func ( s string ) * sql . Stmt {
return acc . Update ( f ) . Set ( s ) . Where ( "fid=?" ) . Prepare ( )
}
2017-09-29 04:42:35 +00:00
// TODO: Do a proper delete
2017-09-10 16:57:22 +00:00
return & MemoryForumStore {
2020-03-09 03:51:44 +00:00
get : acc . Select ( f ) . Columns ( "name, desc, tmpl, active, order, preset, parentID, parentType, topicCount, lastTopicID, lastReplyerID" ) . Where ( "fid=?" ) . Prepare ( ) ,
2019-10-28 07:46:14 +00:00
getAll : acc . Select ( f ) . Columns ( "fid, name, desc, tmpl, active, order, preset, parentID, parentType, topicCount, lastTopicID, lastReplyerID" ) . Orderby ( "order ASC, fid ASC" ) . Prepare ( ) ,
2021-04-07 14:23:11 +00:00
delete : set ( "name='',active=0" ) ,
create : acc . Insert ( f ) . Columns ( "name,desc,tmpl,active,preset" ) . Fields ( "?,?,'',?,?" ) . Prepare ( ) ,
2019-10-28 07:46:14 +00:00
count : acc . Count ( f ) . Where ( "name != ''" ) . Prepare ( ) ,
2021-04-07 14:23:11 +00:00
updateCache : set ( "lastTopicID=?,lastReplyerID=?" ) ,
addTopics : set ( "topicCount=topicCount+?" ) ,
removeTopics : set ( "topicCount=topicCount-?" ) ,
lastTopic : acc . Select ( "topics" ) . Columns ( "tid" ) . Where ( "parentID=?" ) . Orderby ( "lastReplyAt DESC,createdAt DESC" ) . Limit ( "1" ) . Prepare ( ) ,
updateOrder : set ( "order=?" ) ,
2017-11-06 07:23:32 +00:00
} , acc . FirstError ( )
2017-06-15 11:40:35 +00:00
}
2019-04-27 06:32:26 +00:00
// TODO: Rename to ReloadAll?
2017-09-13 15:09:13 +00:00
// TODO: Add support for subforums
2019-06-18 10:02:45 +00:00
func ( s * MemoryForumStore ) LoadForums ( ) error {
2017-09-10 16:57:22 +00:00
var forumView [ ] * Forum
2020-03-09 03:51:44 +00:00
addForum := func ( f * Forum ) {
s . forums . Store ( f . ID , f )
if f . Active && f . Name != "" && f . ParentType == "" {
forumView = append ( forumView , f )
2017-09-10 16:57:22 +00:00
}
2017-06-28 12:05:26 +00:00
}
2019-06-18 10:02:45 +00:00
rows , err := s . getAll . Query ( )
2017-06-28 12:05:26 +00:00
if err != nil {
return err
}
defer rows . Close ( )
2019-10-28 07:46:14 +00:00
i := 0
2017-09-03 04:50:31 +00:00
for ; rows . Next ( ) ; i ++ {
2019-06-18 10:02:45 +00:00
f := & Forum { ID : 0 , Active : true , Preset : "all" }
err = rows . Scan ( & f . ID , & f . Name , & f . Desc , & f . Tmpl , & f . Active , & f . Order , & f . Preset , & f . ParentID , & f . ParentType , & f . TopicCount , & f . LastTopicID , & f . LastReplyerID )
2017-06-28 12:05:26 +00:00
if err != nil {
return err
}
2019-06-18 10:02:45 +00:00
if f . Name == "" {
2018-02-19 04:26:01 +00:00
DebugLog ( "Adding a placeholder forum" )
2017-06-28 12:05:26 +00:00
} else {
2019-06-18 10:02:45 +00:00
log . Printf ( "Adding the '%s' forum" , f . Name )
2017-06-28 12:05:26 +00:00
}
2019-06-18 10:02:45 +00:00
f . Link = BuildForumURL ( NameToSlug ( f . Name ) , f . ID )
f . LastTopic = Topics . DirtyGet ( f . LastTopicID )
f . LastReplyer = Users . DirtyGet ( f . LastReplyerID )
2020-08-13 03:26:02 +00:00
// TODO: Create a specialised function with a bit less overhead for getting the last page for a post count
_ , _ , lastPage := PageOffset ( f . LastTopic . PostCount , 1 , Config . ItemsPerPage )
f . LastPage = lastPage
2019-06-18 10:02:45 +00:00
addForum ( f )
2017-06-28 12:05:26 +00:00
}
2019-06-18 10:02:45 +00:00
s . forumView . Store ( forumView )
2018-11-19 23:06:15 +00:00
TopicListThaw . Thaw ( )
2017-09-10 16:57:22 +00:00
return rows . Err ( )
}
2017-06-28 12:05:26 +00:00
2017-09-10 16:57:22 +00:00
// TODO: Hide social groups too
2017-11-02 04:12:51 +00:00
// ? - Will this be hit a lot by plugin_guilds?
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) rebuildView ( ) {
2017-09-10 16:57:22 +00:00
var forumView [ ] * Forum
2020-03-09 03:51:44 +00:00
s . forums . Range ( func ( _ , val interface { } ) bool {
f := val . ( * Forum )
2017-09-13 15:09:13 +00:00
// ? - ParentType blank means that it doesn't have a parent
2020-03-09 03:51:44 +00:00
if f . Active && f . Name != "" && f . ParentType == "" {
forumView = append ( forumView , f )
2017-09-10 16:57:22 +00:00
}
return true
} )
2017-09-23 19:57:13 +00:00
sort . Sort ( SortForum ( forumView ) )
2019-05-27 09:00:40 +00:00
s . forumView . Store ( forumView )
2019-04-28 10:08:05 +00:00
TopicListThaw . Thaw ( )
2017-06-28 12:05:26 +00:00
}
2020-03-09 03:51:44 +00:00
func ( s * MemoryForumStore ) Each ( h func ( * Forum ) error ) ( err error ) {
s . forums . Range ( func ( _ , val interface { } ) bool {
err = h ( val . ( * Forum ) )
if err != nil {
return false
}
return true
} )
return err
}
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) DirtyGet ( id int ) * Forum {
fint , ok := s . forums . Load ( id )
2017-09-23 19:57:13 +00:00
if ! ok || fint . ( * Forum ) . Name == "" {
2017-09-03 04:50:31 +00:00
return & Forum { ID : - 1 , Name : "" }
2017-06-28 12:05:26 +00:00
}
2017-09-23 19:57:13 +00:00
return fint . ( * Forum )
2017-06-28 12:05:26 +00:00
}
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) CacheGet ( id int ) ( * Forum , error ) {
fint , ok := s . forums . Load ( id )
2017-09-15 22:20:01 +00:00
if ! ok || fint . ( * Forum ) . Name == "" {
2017-07-12 11:05:18 +00:00
return nil , ErrNoRows
2017-06-15 11:40:35 +00:00
}
2017-09-15 22:20:01 +00:00
return fint . ( * Forum ) , nil
2017-06-15 11:40:35 +00:00
}
2019-05-18 12:17:50 +00:00
func ( s * MemoryForumStore ) Get ( id int ) ( * Forum , error ) {
fint , ok := s . forums . Load ( id )
2019-05-18 10:31:51 +00:00
if ok {
forum := fint . ( * Forum )
if forum . Name == "" {
return nil , ErrNoRows
2017-09-28 22:16:34 +00:00
}
2019-05-18 10:31:51 +00:00
return forum , nil
}
2017-09-10 16:57:22 +00:00
2019-05-18 12:17:50 +00:00
forum , err := s . BypassGet ( id )
2019-05-18 10:31:51 +00:00
if err != nil {
2019-05-18 12:17:50 +00:00
return nil , err
2019-05-18 10:31:51 +00:00
}
2019-05-18 12:17:50 +00:00
s . CacheSet ( forum )
2019-05-18 10:31:51 +00:00
return forum , err
2017-06-15 11:40:35 +00:00
}
2019-05-18 12:17:50 +00:00
func ( s * MemoryForumStore ) BypassGet ( id int ) ( * Forum , error ) {
2019-10-31 08:55:03 +00:00
f := & Forum { ID : id }
err := s . get . QueryRow ( id ) . Scan ( & f . Name , & f . Desc , & f . Tmpl , & f . Active , & f . Order , & f . Preset , & f . ParentID , & f . ParentType , & f . TopicCount , & f . LastTopicID , & f . LastReplyerID )
2017-09-28 22:16:34 +00:00
if err != nil {
return nil , err
}
2019-06-18 10:02:45 +00:00
if f . Name == "" {
2019-05-18 12:17:50 +00:00
return nil , ErrNoRows
}
2019-06-18 10:02:45 +00:00
f . Link = BuildForumURL ( NameToSlug ( f . Name ) , f . ID )
f . LastTopic = Topics . DirtyGet ( f . LastTopicID )
f . LastReplyer = Users . DirtyGet ( f . LastReplyerID )
2020-08-13 03:26:02 +00:00
// TODO: Create a specialised function with a bit less overhead for getting the last page for a post count
_ , _ , lastPage := PageOffset ( f . LastTopic . PostCount , 1 , Config . ItemsPerPage )
f . LastPage = lastPage
2019-04-28 10:08:05 +00:00
//TopicListThaw.Thaw()
2017-09-28 22:16:34 +00:00
2019-06-18 10:02:45 +00:00
return f , err
2017-06-15 11:40:35 +00:00
}
2017-12-26 07:17:26 +00:00
// TODO: Optimise this
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) BulkGetCopy ( ids [ ] int ) ( forums [ ] Forum , err error ) {
2017-12-26 07:17:26 +00:00
forums = make ( [ ] Forum , len ( ids ) )
for i , id := range ids {
2020-03-09 03:51:44 +00:00
f , err := s . Get ( id )
2017-12-26 07:17:26 +00:00
if err != nil {
return nil , err
}
2020-03-09 03:51:44 +00:00
forums [ i ] = f . Copy ( )
2017-12-26 07:17:26 +00:00
}
return forums , nil
}
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) Reload ( id int ) error {
forum , err := s . BypassGet ( id )
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 err != nil {
return err
}
2019-05-27 09:00:40 +00:00
s . CacheSet ( forum )
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 nil
2017-06-28 12:05:26 +00:00
}
2020-03-09 03:51:44 +00:00
func ( s * MemoryForumStore ) CacheSet ( f * Forum ) error {
s . forums . Store ( f . ID , f )
2019-05-27 09:00:40 +00:00
s . rebuildView ( )
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 nil
}
2017-09-23 19:57:13 +00:00
// ! Has a randomised order
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) GetAll ( ) ( forumView [ ] * Forum , err error ) {
2020-03-09 03:51:44 +00:00
s . forums . Range ( func ( _ , val interface { } ) bool {
forumView = append ( forumView , val . ( * Forum ) )
2017-09-10 16:57:22 +00:00
return true
} )
2017-09-23 19:57:13 +00:00
sort . Sort ( SortForum ( forumView ) )
2017-09-10 16:57:22 +00:00
return forumView , nil
2017-06-28 12:05:26 +00:00
}
2017-09-23 19:57:13 +00:00
// ? - Can we optimise the sorting?
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) GetAllIDs ( ) ( ids [ ] int , err error ) {
2020-03-09 03:51:44 +00:00
s . forums . Range ( func ( _ , val interface { } ) bool {
ids = append ( ids , val . ( * Forum ) . ID )
2017-09-10 16:57:22 +00:00
return true
} )
2017-09-23 19:57:13 +00:00
sort . Ints ( ids )
2017-09-10 16:57:22 +00:00
return ids , nil
}
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) GetAllVisible ( ) ( forumView [ ] * Forum , err error ) {
forumView = s . forumView . Load ( ) . ( [ ] * Forum )
2017-09-23 19:57:13 +00:00
return forumView , 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
}
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) GetAllVisibleIDs ( ) ( [ ] int , error ) {
forumView := s . forumView . Load ( ) . ( [ ] * Forum )
2019-10-28 07:46:14 +00:00
ids := make ( [ ] int , len ( forumView ) )
2017-09-10 16:57:22 +00:00
for i := 0 ; i < len ( forumView ) ; i ++ {
ids [ i ] = forumView [ i ] . ID
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 ids , nil
}
2017-09-10 16:57:22 +00:00
// TODO: Implement sub-forums.
2019-06-18 10:02:45 +00:00
/ * func ( s * MemoryForumStore ) GetChildren ( parentID int , parentType string ) ( [ ] * Forum , error ) {
2017-09-10 16:57:22 +00:00
return nil , 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
}
2019-06-18 10:02:45 +00:00
func ( s * MemoryForumStore ) GetFirstChild ( parentID int , parentType string ) ( * Forum , error ) {
2017-09-10 16:57:22 +00:00
return nil , 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-15 22:20:01 +00:00
// TODO: Add a query for this rather than hitting cache
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) Exists ( id int ) bool {
forum , ok := s . forums . Load ( id )
2019-05-18 10:31:51 +00:00
if ! ok {
return false
}
return forum . ( * Forum ) . Name != ""
2017-06-28 12:05:26 +00:00
}
2017-09-10 16:57:22 +00:00
// TODO: Batch deletions with name blanking? Is this necessary?
2019-05-27 09:00:40 +00:00
func ( s * MemoryForumStore ) CacheDelete ( id int ) {
s . forums . Delete ( id )
s . rebuildView ( )
2017-09-10 16:57:22 +00:00
}
2017-06-28 12:05:26 +00:00
2017-11-02 04:12:51 +00:00
// TODO: Add a hook to allow plugin_guilds to detect when one of it's forums has just been deleted?
2019-05-18 10:31:51 +00:00
func ( s * MemoryForumStore ) Delete ( id int ) error {
2018-06-06 00:21:22 +00:00
if id == ReportForumID {
2019-05-18 12:17:50 +00:00
return ErrNoDeleteReports
2017-09-25 00:48:35 +00:00
}
2019-05-18 10:31:51 +00:00
_ , err := s . delete . Exec ( id )
s . CacheDelete ( id )
2017-11-13 05:22:37 +00:00
return err
2017-06-28 12:05:26 +00:00
}
2020-03-09 03:51:44 +00:00
func ( s * MemoryForumStore ) AddTopic ( tid , uid , fid int ) error {
2019-05-27 09:00:40 +00:00
_ , err := s . updateCache . Exec ( tid , uid , fid )
2017-06-28 12:05:26 +00:00
if err != nil {
return err
}
2019-05-27 09:00:40 +00:00
_ , err = s . addTopics . Exec ( 1 , fid )
2017-06-28 12:05:26 +00:00
if err != nil {
return err
}
2017-09-28 22:16:34 +00:00
// TODO: Bypass the database and update this with a lock or an unsafe atomic swap
2019-05-27 09:00:40 +00:00
return s . Reload ( fid )
2017-06-28 12:05:26 +00:00
}
2020-01-14 05:07:00 +00:00
func ( s * MemoryForumStore ) RefreshTopic ( fid int ) ( err error ) {
2019-10-31 08:55:03 +00:00
var tid int
err = s . lastTopic . QueryRow ( fid ) . Scan ( & tid )
if err == sql . ErrNoRows {
2020-01-14 05:07:00 +00:00
f , err := s . CacheGet ( fid )
if err != nil || f . LastTopicID != 0 {
_ , err = s . updateCache . Exec ( 0 , 0 , fid )
if err != nil {
return err
}
s . Reload ( fid )
2019-10-31 08:55:03 +00:00
}
return nil
}
if err != nil {
return err
}
topic , err := Topics . Get ( tid )
if err != nil {
return err
}
_ , err = s . updateCache . Exec ( tid , topic . CreatedBy , fid )
if err != nil {
return err
}
2017-09-28 22:16:34 +00:00
// TODO: Bypass the database and update this with a lock or an unsafe atomic swap
2019-05-27 09:00:40 +00:00
s . Reload ( fid )
2017-06-28 12:05:26 +00:00
return nil
}
2020-01-14 05:07:00 +00:00
// TODO: Make this update more atomic
func ( s * MemoryForumStore ) RemoveTopic ( fid int ) error {
_ , err := s . removeTopics . Exec ( 1 , fid )
if err != nil {
return err
}
return s . RefreshTopic ( fid )
}
2020-03-09 03:51:44 +00:00
func ( s * MemoryForumStore ) RemoveTopics ( fid , count int ) error {
2020-01-14 05:07:00 +00:00
_ , err := s . removeTopics . Exec ( count , fid )
if err != nil {
return err
}
return s . RefreshTopic ( fid )
}
2017-09-28 22:16:34 +00:00
// DEPRECATED. forum.Update() will be the way to do this in the future, once it's completed
2017-09-10 16:57:22 +00:00
// TODO: Have a pointer to the last topic rather than storing it on the forum itself
2020-03-09 03:51:44 +00:00
func ( s * MemoryForumStore ) UpdateLastTopic ( tid , uid , fid int ) error {
2019-05-27 09:00:40 +00:00
_ , err := s . updateCache . Exec ( tid , uid , fid )
2017-06-28 12:05:26 +00:00
if err != nil {
return err
}
2017-09-28 22:16:34 +00:00
// TODO: Bypass the database and update this with a lock or an unsafe atomic swap
2019-05-27 09:00:40 +00:00
return s . Reload ( fid )
2017-06-28 12:05:26 +00:00
}
2020-03-09 03:51:44 +00:00
func ( s * MemoryForumStore ) Create ( name , desc string , active bool , preset string ) ( int , error ) {
2019-09-29 04:56:39 +00:00
if name == "" {
2019-05-18 10:31:51 +00:00
return 0 , ErrBlankName
}
2017-09-03 04:50:31 +00:00
forumCreateMutex . Lock ( )
2019-05-27 09:00:40 +00:00
defer forumCreateMutex . Unlock ( )
2019-09-29 04:56:39 +00:00
res , err := s . create . Exec ( name , desc , active , preset )
2017-06-28 12:05:26 +00:00
if err != nil {
return 0 , err
}
fid64 , err := res . LastInsertId ( )
if err != nil {
return 0 , err
}
2017-09-10 16:57:22 +00:00
fid := int ( fid64 )
2017-06-28 12:05:26 +00:00
2019-05-27 09:00:40 +00:00
err = s . Reload ( fid )
2017-09-28 22:16:34 +00:00
if err != nil {
return 0 , err
}
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-11-11 04:06:16 +00:00
PermmapToQuery ( PresetToPermmap ( preset ) , fid )
2017-09-10 16:57:22 +00:00
return fid , nil
2017-06-15 11:40:35 +00:00
}
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
2019-04-27 06:32:26 +00:00
// TODO: Make this atomic, maybe with a transaction?
func ( s * MemoryForumStore ) UpdateOrder ( updateMap map [ int ] int ) error {
for fid , order := range updateMap {
_ , err := s . updateOrder . Exec ( order , fid )
if err != nil {
return err
}
}
return s . LoadForums ( )
}
2017-09-28 22:16:34 +00:00
// ! Might be slightly inaccurate, if the sync.Map is constantly shifting and churning, but it'll stabilise eventually. Also, slow. Don't use this on every request x.x
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
// Length returns the number of forums in the memory cache
2020-03-09 03:51:44 +00:00
func ( s * MemoryForumStore ) Length ( ) ( len int ) {
s . forums . Range ( func ( _ , _ interface { } ) bool {
len ++
2017-09-28 22:16:34 +00:00
return true
} )
2020-03-09 03:51:44 +00:00
return len
2017-09-28 22:16:34 +00:00
}
2018-08-04 11:46:36 +00:00
// TODO: Get the total count of forums in the forum store rather than doing a heavy query for this?
2019-06-01 12:31:48 +00:00
// Count returns the total number of forums
func ( s * MemoryForumStore ) Count ( ) ( count int ) {
err := s . count . QueryRow ( ) . Scan ( & count )
2017-08-15 13:47:56 +00:00
if err != nil {
LogError ( err )
}
2019-06-01 12:31:48 +00:00
return count
2017-08-15 13:47:56 +00:00
}
2017-09-10 16:57:22 +00:00
// TODO: Work on SqlForumStore
2017-10-21 00:27:47 +00:00
// TODO: Work on the NullForumStore