2017-09-13 15:09:13 +00:00
/ *
*
* Gosora Forum Store
* Copyright Azareal 2017 - 2018
*
* /
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"
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
2018-10-27 03:21:02 +00:00
"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
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
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
2017-09-28 22:16:34 +00:00
AddTopic ( tid int , uid int , fid int ) error
RemoveTopic ( fid int ) error
UpdateLastTopic ( tid int , uid int , 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)
2017-09-15 22:20:01 +00:00
Create ( forumName string , forumDesc string , active bool , preset string ) ( int , error )
2017-08-15 13:47:56 +00:00
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
GlobalCount ( ) 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 )
CacheSet ( forum * Forum ) error
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
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 ( )
2017-09-29 04:42:35 +00:00
// TODO: Do a proper delete
2017-09-10 16:57:22 +00:00
return & MemoryForumStore {
2017-11-12 03:29:05 +00:00
get : acc . Select ( "forums" ) . Columns ( "name, desc, active, preset, parentID, parentType, topicCount, lastTopicID, lastReplyerID" ) . Where ( "fid = ?" ) . Prepare ( ) ,
getAll : acc . Select ( "forums" ) . Columns ( "fid, name, desc, active, preset, parentID, parentType, topicCount, lastTopicID, lastReplyerID" ) . Orderby ( "fid ASC" ) . Prepare ( ) ,
delete : acc . Update ( "forums" ) . Set ( "name= '', active = 0" ) . Where ( "fid = ?" ) . Prepare ( ) ,
create : acc . Insert ( "forums" ) . Columns ( "name, desc, active, preset" ) . Fields ( "?,?,?,?" ) . Prepare ( ) ,
count : acc . Count ( "forums" ) . Where ( "name != ''" ) . Prepare ( ) ,
updateCache : acc . Update ( "forums" ) . Set ( "lastTopicID = ?, lastReplyerID = ?" ) . Where ( "fid = ?" ) . Prepare ( ) ,
addTopics : acc . Update ( "forums" ) . Set ( "topicCount = topicCount + ?" ) . Where ( "fid = ?" ) . Prepare ( ) ,
removeTopics : acc . Update ( "forums" ) . Set ( "topicCount = topicCount - ?" ) . Where ( "fid = ?" ) . Prepare ( ) ,
2017-11-06 07:23:32 +00:00
} , acc . FirstError ( )
2017-06-15 11:40:35 +00:00
}
2017-09-13 15:09:13 +00:00
// TODO: Add support for subforums
2017-09-10 16:57:22 +00:00
func ( mfs * MemoryForumStore ) LoadForums ( ) error {
var forumView [ ] * Forum
addForum := func ( forum * Forum ) {
mfs . forums . Store ( forum . ID , forum )
2017-09-13 15:09:13 +00:00
if forum . Active && forum . Name != "" && forum . ParentType == "" {
2017-09-10 16:57:22 +00:00
forumView = append ( forumView , forum )
}
2017-06-28 12:05:26 +00:00
}
2017-11-06 04:02:35 +00:00
rows , err := mfs . getAll . Query ( )
2017-06-28 12:05:26 +00:00
if err != nil {
return err
}
defer rows . Close ( )
2017-09-10 16:57:22 +00:00
var i = 0
2017-09-03 04:50:31 +00:00
for ; rows . Next ( ) ; i ++ {
2017-09-28 22:16:34 +00:00
forum := & Forum { ID : 0 , Active : true , Preset : "all" }
err = rows . Scan ( & forum . ID , & forum . Name , & forum . Desc , & forum . Active , & forum . Preset , & forum . ParentID , & forum . ParentType , & forum . TopicCount , & forum . LastTopicID , & forum . LastReplyerID )
2017-06-28 12:05:26 +00:00
if err != nil {
return err
}
if forum . Name == "" {
2018-02-19 04:26:01 +00:00
DebugLog ( "Adding a placeholder forum" )
2017-06-28 12:05:26 +00:00
} else {
2017-11-11 04:06:16 +00:00
log . Printf ( "Adding the '%s' forum" , forum . Name )
2017-06-28 12:05:26 +00:00
}
2017-11-11 04:06:16 +00:00
forum . Link = BuildForumURL ( NameToSlug ( forum . Name ) , forum . ID )
forum . LastTopic = Topics . DirtyGet ( forum . LastTopicID )
forum . LastReplyer = Users . DirtyGet ( forum . LastReplyerID )
2017-09-28 22:16:34 +00:00
addForum ( forum )
2017-06-28 12:05:26 +00:00
}
2017-09-10 16:57:22 +00:00
mfs . 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?
2017-09-10 16:57:22 +00:00
func ( mfs * MemoryForumStore ) rebuildView ( ) {
var forumView [ ] * Forum
mfs . forums . Range ( func ( _ interface { } , value interface { } ) bool {
forum := value . ( * Forum )
2017-09-13 15:09:13 +00:00
// ? - ParentType blank means that it doesn't have a parent
if forum . Active && forum . Name != "" && forum . ParentType == "" {
2017-09-10 16:57:22 +00:00
forumView = append ( forumView , forum )
}
return true
} )
2017-09-23 19:57:13 +00:00
sort . Sort ( SortForum ( forumView ) )
2017-09-10 16:57:22 +00:00
mfs . forumView . Store ( forumView )
2017-06-28 12:05:26 +00:00
}
2017-09-10 16:57:22 +00:00
func ( mfs * MemoryForumStore ) DirtyGet ( id int ) * Forum {
fint , ok := mfs . 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
}
2017-09-15 22:20:01 +00:00
func ( mfs * MemoryForumStore ) CacheGet ( id int ) ( * Forum , error ) {
2017-09-10 16:57:22 +00:00
fint , ok := mfs . 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
}
2017-09-15 22:20:01 +00:00
func ( mfs * MemoryForumStore ) Get ( id int ) ( * Forum , error ) {
2017-09-10 16:57:22 +00:00
fint , ok := mfs . forums . Load ( id )
2017-09-15 22:20:01 +00:00
if ! ok || fint . ( * Forum ) . Name == "" {
var forum = & Forum { ID : id }
2017-09-29 04:42:35 +00:00
err := mfs . get . QueryRow ( id ) . Scan ( & forum . Name , & forum . Desc , & forum . Active , & forum . Preset , & forum . ParentID , & forum . ParentType , & forum . TopicCount , & forum . LastTopicID , & forum . LastReplyerID )
2017-09-28 22:16:34 +00:00
if err != nil {
return forum , err
}
2017-09-10 16:57:22 +00:00
2017-11-11 04:06:16 +00:00
forum . Link = BuildForumURL ( NameToSlug ( forum . Name ) , forum . ID )
forum . LastTopic = Topics . DirtyGet ( forum . LastTopicID )
forum . LastReplyer = Users . DirtyGet ( forum . LastReplyerID )
2017-09-10 16:57:22 +00:00
2017-09-28 22:16:34 +00:00
mfs . CacheSet ( forum )
2017-09-15 22:20:01 +00:00
return forum , err
2017-06-28 12:05:26 +00:00
}
2017-09-28 22:16:34 +00:00
return fint . ( * Forum ) , nil
2017-06-15 11:40:35 +00:00
}
2017-09-10 16:57:22 +00:00
func ( mfs * MemoryForumStore ) BypassGet ( id int ) ( * Forum , error ) {
2017-09-28 22:16:34 +00:00
var forum = & Forum { ID : id }
2017-09-29 04:42:35 +00:00
err := mfs . get . QueryRow ( id ) . Scan ( & forum . Name , & forum . Desc , & forum . Active , & forum . Preset , & forum . ParentID , & forum . ParentType , & forum . TopicCount , & forum . LastTopicID , & forum . LastReplyerID )
2017-09-28 22:16:34 +00:00
if err != nil {
return nil , err
}
2017-09-10 16:57:22 +00:00
2017-11-11 04:06:16 +00:00
forum . Link = BuildForumURL ( NameToSlug ( forum . Name ) , forum . ID )
forum . LastTopic = Topics . DirtyGet ( forum . LastTopicID )
forum . LastReplyer = Users . DirtyGet ( forum . LastReplyerID )
2018-11-19 23:06:15 +00:00
TopicListThaw . Thaw ( )
2017-09-28 22:16:34 +00:00
return forum , err
2017-06-15 11:40:35 +00:00
}
2017-12-26 07:17:26 +00:00
// TODO: Optimise this
func ( mfs * MemoryForumStore ) BulkGetCopy ( ids [ ] int ) ( forums [ ] Forum , err error ) {
forums = make ( [ ] Forum , len ( ids ) )
for i , id := range ids {
forum , err := mfs . Get ( id )
if err != nil {
return nil , err
}
forums [ i ] = forum . Copy ( )
}
return forums , nil
}
2017-09-15 22:20:01 +00:00
func ( mfs * MemoryForumStore ) Reload ( id int ) error {
2017-09-28 22:16:34 +00:00
var forum = & Forum { ID : id }
2017-09-29 04:42:35 +00:00
err := mfs . get . QueryRow ( id ) . Scan ( & forum . Name , & forum . Desc , & forum . Active , & forum . Preset , & forum . ParentID , & forum . ParentType , & forum . TopicCount , & forum . LastTopicID , & forum . LastReplyerID )
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
}
2017-11-11 04:06:16 +00:00
forum . Link = BuildForumURL ( NameToSlug ( forum . Name ) , forum . ID )
forum . LastTopic = Topics . DirtyGet ( forum . LastTopicID )
forum . LastReplyer = Users . DirtyGet ( forum . LastReplyerID )
2017-09-28 22:16:34 +00:00
mfs . CacheSet ( forum )
2018-11-19 23:06:15 +00:00
TopicListThaw . Thaw ( )
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
}
2017-09-15 22:20:01 +00:00
func ( mfs * MemoryForumStore ) CacheSet ( forum * Forum ) error {
2017-09-10 16:57:22 +00:00
mfs . forums . Store ( forum . ID , forum )
mfs . 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
2017-09-10 16:57:22 +00:00
func ( mfs * MemoryForumStore ) GetAll ( ) ( forumView [ ] * Forum , err error ) {
mfs . forums . Range ( func ( _ interface { } , value interface { } ) bool {
forumView = append ( forumView , value . ( * Forum ) )
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?
2017-09-10 16:57:22 +00:00
func ( mfs * MemoryForumStore ) GetAllIDs ( ) ( ids [ ] int , err error ) {
mfs . forums . Range ( func ( _ interface { } , value interface { } ) bool {
ids = append ( ids , value . ( * Forum ) . ID )
return true
} )
2017-09-23 19:57:13 +00:00
sort . Ints ( ids )
2017-09-10 16:57:22 +00:00
return ids , nil
}
2017-09-23 19:57:13 +00:00
func ( mfs * MemoryForumStore ) GetAllVisible ( ) ( forumView [ ] * Forum , err error ) {
forumView = mfs . forumView . Load ( ) . ( [ ] * Forum )
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
}
2017-09-10 16:57:22 +00:00
func ( mfs * MemoryForumStore ) GetAllVisibleIDs ( ) ( [ ] int , error ) {
forumView := mfs . forumView . Load ( ) . ( [ ] * Forum )
var ids = make ( [ ] int , len ( forumView ) )
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.
/ * func ( mfs * MemoryForumStore ) GetChildren ( parentID int , parentType string ) ( [ ] * Forum , error ) {
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-10 16:57:22 +00:00
func ( mfs * MemoryForumStore ) GetFirstChild ( parentID int , parentType string ) ( * Forum , error ) {
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
2017-09-10 16:57:22 +00:00
func ( mfs * MemoryForumStore ) Exists ( id int ) bool {
forum , ok := mfs . forums . Load ( id )
return ok && 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?
2017-09-15 22:20:01 +00:00
func ( mfs * MemoryForumStore ) CacheDelete ( id int ) {
2017-09-10 16:57:22 +00:00
mfs . forums . Delete ( id )
mfs . rebuildView ( )
}
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?
2017-09-15 22:20:01 +00:00
func ( mfs * MemoryForumStore ) Delete ( id int ) error {
2018-06-06 00:21:22 +00:00
if id == ReportForumID {
2017-09-25 00:48:35 +00:00
return errors . New ( "You cannot delete the Reports forum" )
}
2017-09-10 16:57:22 +00:00
_ , err := mfs . delete . Exec ( id )
2017-09-15 22:20:01 +00:00
mfs . CacheDelete ( id )
2018-11-19 23:06:15 +00:00
TopicListThaw . Thaw ( )
2017-11-13 05:22:37 +00:00
return err
2017-06-28 12:05:26 +00:00
}
2017-09-28 22:16:34 +00:00
func ( mfs * MemoryForumStore ) AddTopic ( tid int , uid int , fid int ) error {
2017-11-06 04:02:35 +00:00
_ , err := mfs . updateCache . Exec ( tid , uid , fid )
2017-06-28 12:05:26 +00:00
if err != nil {
return err
}
2017-11-06 07:23:32 +00:00
_ , err = mfs . 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
2017-09-29 04:42:35 +00:00
return mfs . Reload ( fid )
2017-06-28 12:05:26 +00:00
}
2017-09-28 22:16:34 +00:00
// TODO: Update the forum cache with the latest topic
func ( mfs * MemoryForumStore ) RemoveTopic ( fid int ) error {
2017-11-06 07:23:32 +00:00
_ , err := mfs . removeTopics . 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
mfs . Reload ( fid )
2017-06-28 12:05:26 +00:00
return nil
}
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
2017-09-28 22:16:34 +00:00
func ( mfs * MemoryForumStore ) UpdateLastTopic ( tid int , uid int , fid int ) error {
2017-11-06 04:02:35 +00:00
_ , err := mfs . 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
2017-09-29 04:42:35 +00:00
return mfs . Reload ( fid )
2017-06-28 12:05:26 +00:00
}
2017-09-15 22:20:01 +00:00
func ( mfs * MemoryForumStore ) Create ( forumName string , forumDesc string , active bool , preset string ) ( int , error ) {
2017-09-03 04:50:31 +00:00
forumCreateMutex . Lock ( )
2017-11-06 04:02:35 +00:00
res , err := mfs . create . Exec ( forumName , forumDesc , 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
2017-09-28 22:16:34 +00:00
err = mfs . Reload ( fid )
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-03 04:50:31 +00:00
forumCreateMutex . Unlock ( )
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
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
func ( mfs * MemoryForumStore ) Length ( ) ( length int ) {
2017-09-28 22:16:34 +00:00
mfs . forums . Range ( func ( _ interface { } , value interface { } ) bool {
length ++
return true
} )
return length
}
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?
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
// GlobalCount returns the total number of forums
func ( mfs * MemoryForumStore ) GlobalCount ( ) ( fcount int ) {
2017-11-06 04:02:35 +00:00
err := mfs . count . QueryRow ( ) . Scan ( & fcount )
2017-08-15 13:47:56 +00:00
if err != nil {
LogError ( err )
}
return fcount
}
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