2016-12-13 02:14:14 +00:00
|
|
|
package main
|
2017-05-29 14:52:37 +00:00
|
|
|
|
|
|
|
//import "fmt"
|
2016-12-13 02:14:14 +00:00
|
|
|
import "regexp"
|
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
|
|
|
import "strings"
|
2017-05-29 14:52:37 +00:00
|
|
|
|
|
|
|
var markdown_max_depth int = 25 // How deep the parser will go when parsing Markdown strings
|
|
|
|
var markdown_unclosed_element []byte
|
|
|
|
|
2017-06-05 11:57:27 +00:00
|
|
|
var markdown_bold_tag_open, markdown_bold_tag_close []byte
|
|
|
|
var markdown_italic_tag_open, markdown_italic_tag_close []byte
|
|
|
|
var markdown_underline_tag_open, markdown_underline_tag_close []byte
|
|
|
|
var markdown_strike_tag_open, markdown_strike_tag_close []byte
|
2016-12-13 02:14:14 +00:00
|
|
|
|
2017-01-05 14:41:14 +00:00
|
|
|
var markdown_bold_italic *regexp.Regexp
|
|
|
|
var markdown_bold *regexp.Regexp
|
|
|
|
var markdown_italic *regexp.Regexp
|
2017-05-29 14:52:37 +00:00
|
|
|
var markdown_strike *regexp.Regexp
|
|
|
|
var markdown_underline *regexp.Regexp
|
2016-12-13 02:14:14 +00:00
|
|
|
|
|
|
|
func init() {
|
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
|
|
|
plugins["markdown"] = NewPlugin("markdown","Markdown","Azareal","http://github.com/Azareal","","","",init_markdown,nil,deactivate_markdown,nil,nil)
|
2016-12-13 02:14:14 +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
|
|
|
func init_markdown() error {
|
2017-05-29 14:52:37 +00:00
|
|
|
//plugins["markdown"].AddHook("parse_assign", markdown_regex_parse)
|
2017-01-05 14:41:14 +00:00
|
|
|
plugins["markdown"].AddHook("parse_assign", markdown_parse)
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
markdown_unclosed_element = []byte("<span style='color: red;'>[Unclosed Element]</span>")
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
markdown_bold_tag_open = []byte("<b>")
|
|
|
|
markdown_bold_tag_close = []byte("</b>")
|
|
|
|
markdown_italic_tag_open = []byte("<i>")
|
|
|
|
markdown_italic_tag_close = []byte("</i>")
|
|
|
|
markdown_underline_tag_open = []byte("<u>")
|
|
|
|
markdown_underline_tag_close = []byte("</u>")
|
|
|
|
markdown_strike_tag_open = []byte("<s>")
|
|
|
|
markdown_strike_tag_close = []byte("</s>")
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-01-05 14:41:14 +00:00
|
|
|
markdown_bold_italic = regexp.MustCompile(`\*\*\*(.*)\*\*\*`)
|
|
|
|
markdown_bold = regexp.MustCompile(`\*\*(.*)\*\*`)
|
|
|
|
markdown_italic = regexp.MustCompile(`\*(.*)\*`)
|
2017-05-29 14:52:37 +00:00
|
|
|
//markdown_strike = regexp.MustCompile(`\~\~(.*)\~\~`)
|
|
|
|
markdown_strike = regexp.MustCompile(`\~(.*)\~`)
|
|
|
|
//markdown_underline = regexp.MustCompile(`\_\_(.*)\_\_`)
|
|
|
|
markdown_underline = regexp.MustCompile(`\_(.*)\_`)
|
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
|
2016-12-13 02:14:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func deactivate_markdown() {
|
2017-05-29 14:52:37 +00:00
|
|
|
//plugins["markdown"].RemoveHook("parse_assign", markdown_regex_parse)
|
2017-01-05 14:41:14 +00:00
|
|
|
plugins["markdown"].RemoveHook("parse_assign", markdown_parse)
|
2016-12-13 02:14:14 +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
|
|
|
func markdown_regex_parse(msg string) string {
|
2017-01-05 14:41:14 +00:00
|
|
|
msg = markdown_bold_italic.ReplaceAllString(msg,"<i><b>$1</b></i>")
|
|
|
|
msg = markdown_bold.ReplaceAllString(msg,"<b>$1</b>")
|
|
|
|
msg = markdown_italic.ReplaceAllString(msg,"<i>$1</i>")
|
2017-05-29 14:52:37 +00:00
|
|
|
msg = markdown_strike.ReplaceAllString(msg,"<s>$1</s>")
|
|
|
|
msg = markdown_underline.ReplaceAllString(msg,"<u>$1</u>")
|
2016-12-13 02:14:14 +00:00
|
|
|
return msg
|
2017-05-29 14:52:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// An adapter for the parser, so that the parser can call itself recursively.
|
|
|
|
// This is less for the simple Markdown elements like bold and italics and more for the really complicated ones I plan on adding at some point.
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
func markdown_parse(msg string) string {
|
|
|
|
return strings.TrimSpace(_markdown_parse(msg + " ",0))
|
2017-05-29 14:52:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Under Construction!
|
|
|
|
func _markdown_parse(msg string, n int) string {
|
|
|
|
if n > markdown_max_depth {
|
|
|
|
return "<span style='color: red;'>[Markdown Error: Overflowed the max depth of 20]</span>"
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
var outbytes []byte
|
|
|
|
var lastElement int
|
|
|
|
//fmt.Println("enter message loop")
|
|
|
|
//fmt.Printf("Message: %v\n",strings.Replace(msg,"\r","\\r",-1))
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
for index := 0; index < len(msg); index++ {
|
|
|
|
/*//fmt.Println("--OUTER MARKDOWN LOOP START--")
|
|
|
|
//fmt.Println("index",index)
|
|
|
|
//fmt.Println("msg[index]",msg[index])
|
|
|
|
//fmt.Println("string(msg[index])",string(msg[index]))
|
|
|
|
//fmt.Println("--OUTER MARKDOWN LOOP END--")
|
|
|
|
//fmt.Println(" ")*/
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
switch(msg[index]) {
|
|
|
|
case '_':
|
|
|
|
var startIndex int = index
|
|
|
|
if (index + 1) >= len(msg) {
|
|
|
|
break
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
index++
|
|
|
|
index = markdown_skip_until_char(msg, index, '_')
|
|
|
|
if (index - (startIndex + 1)) < 2 || index >= len(msg) {
|
|
|
|
break
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
sIndex := startIndex + 1
|
|
|
|
lIndex := index
|
|
|
|
index++
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
|
|
|
outbytes = append(outbytes, markdown_underline_tag_open...)
|
|
|
|
outbytes = append(outbytes, msg[sIndex:lIndex]...)
|
|
|
|
outbytes = append(outbytes, markdown_underline_tag_close...)
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
lastElement = index
|
|
|
|
index--
|
|
|
|
case '~':
|
|
|
|
var startIndex int = index
|
|
|
|
if (index + 1) >= len(msg) {
|
|
|
|
break
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
index++
|
|
|
|
index = markdown_skip_until_char(msg, index, '~')
|
|
|
|
if (index - (startIndex + 1)) < 2 || index >= len(msg) {
|
|
|
|
break
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
sIndex := startIndex + 1
|
|
|
|
lIndex := index
|
|
|
|
index++
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
|
|
|
outbytes = append(outbytes, markdown_strike_tag_open...)
|
|
|
|
outbytes = append(outbytes, msg[sIndex:lIndex]...)
|
|
|
|
outbytes = append(outbytes, markdown_strike_tag_close...)
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
lastElement = index
|
|
|
|
index--
|
|
|
|
case '*':
|
|
|
|
//fmt.Println("------")
|
|
|
|
//fmt.Println("[]byte(msg):",[]byte(msg))
|
|
|
|
//fmt.Println("len(msg)",len(msg))
|
|
|
|
//fmt.Println("start index",index)
|
|
|
|
//fmt.Println("start msg[index]",msg[index])
|
|
|
|
//fmt.Println("start string(msg[index])",string(msg[index]))
|
|
|
|
//fmt.Println("start []byte(msg[:index])",[]byte(msg[:index]))
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
var startIndex int = index
|
|
|
|
var italic bool = true
|
|
|
|
var bold bool
|
|
|
|
if (index + 2) < len(msg) {
|
|
|
|
//fmt.Println("start index + 1",index + 1)
|
|
|
|
//fmt.Println("start msg[index]",msg[index + 1])
|
|
|
|
//fmt.Println("start string(msg[index])",string(msg[index + 1]))
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
if msg[index + 1] == '*' {
|
|
|
|
//fmt.Println("two asterisks")
|
|
|
|
bold = true
|
|
|
|
index++
|
|
|
|
if msg[index + 1] != '*' {
|
|
|
|
italic = false
|
|
|
|
} else {
|
|
|
|
//fmt.Println("three asterisks")
|
|
|
|
index++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
//fmt.Println("lastElement",lastElement)
|
|
|
|
//fmt.Println("startIndex:",startIndex)
|
|
|
|
//fmt.Println("msg[startIndex]",msg[startIndex])
|
|
|
|
//fmt.Println("string(msg[startIndex])",string(msg[startIndex]))
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
//fmt.Println("preabrupt index",index)
|
|
|
|
//fmt.Println("preabrupt msg[index]",msg[index])
|
|
|
|
//fmt.Println("preabrupt string(msg[index])",string(msg[index]))
|
|
|
|
//fmt.Println("preabrupt []byte(msg[:index])",[]byte(msg[:index]))
|
|
|
|
//fmt.Println("preabrupt msg[:index]",msg[:index])
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
// Does the string terminate abruptly?
|
|
|
|
if (index + 1) >= len(msg) {
|
|
|
|
break
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
index++
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
//fmt.Println("preskip index",index)
|
|
|
|
//fmt.Println("preskip msg[index]",msg[index])
|
|
|
|
//fmt.Println("preskip string(msg[index])",string(msg[index]))
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
index = markdown_skip_until_asterisk(msg,index)
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
if index >= len(msg) {
|
|
|
|
break
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
//fmt.Println("index",index)
|
|
|
|
//fmt.Println("[]byte(msg[:index])",[]byte(msg[:index]))
|
|
|
|
//fmt.Println("msg[index]",msg[index])
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
sIndex := startIndex
|
|
|
|
lIndex := index
|
|
|
|
if bold && italic {
|
|
|
|
//fmt.Println("bold & italic final code")
|
|
|
|
if (index + 3) >= len(msg) {
|
|
|
|
//fmt.Println("unclosed markdown element @ exit element")
|
|
|
|
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
|
|
|
outbytes = append(outbytes, markdown_unclosed_element...)
|
|
|
|
lastElement = startIndex
|
|
|
|
break
|
|
|
|
}
|
|
|
|
index += 3
|
|
|
|
sIndex += 3
|
|
|
|
} else if bold {
|
|
|
|
//fmt.Println("bold final code")
|
|
|
|
if (index + 2) >= len(msg) {
|
|
|
|
//fmt.Println("true unclosed markdown element @ exit element")
|
|
|
|
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
|
|
|
outbytes = append(outbytes, markdown_unclosed_element...)
|
|
|
|
lastElement = startIndex
|
|
|
|
break
|
|
|
|
}
|
|
|
|
index += 2
|
|
|
|
sIndex += 2
|
|
|
|
} else {
|
|
|
|
//fmt.Println("italic final code")
|
|
|
|
if (index + 1) >= len(msg) {
|
|
|
|
//fmt.Println("true unclosed markdown element @ exit element")
|
|
|
|
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
|
|
|
outbytes = append(outbytes, markdown_unclosed_element...)
|
|
|
|
lastElement = startIndex
|
|
|
|
break
|
|
|
|
}
|
|
|
|
index++
|
|
|
|
sIndex++
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
//fmt.Println("sIndex",sIndex)
|
|
|
|
//fmt.Println("lIndex",lIndex)
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
if lIndex <= sIndex {
|
|
|
|
//fmt.Println("unclosed markdown element @ lIndex <= sIndex")
|
|
|
|
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
|
|
|
outbytes = append(outbytes, markdown_unclosed_element...)
|
|
|
|
lastElement = startIndex
|
|
|
|
break
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
if sIndex < 0 || lIndex < 0 {
|
|
|
|
//fmt.Println("unclosed markdown element @ sIndex < 0 || lIndex < 0")
|
|
|
|
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
|
|
|
outbytes = append(outbytes, markdown_unclosed_element...)
|
|
|
|
lastElement = startIndex
|
|
|
|
break
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
//fmt.Println("final sIndex",sIndex)
|
|
|
|
//fmt.Println("final lIndex",lIndex)
|
|
|
|
//fmt.Println("final index",index)
|
|
|
|
//fmt.Println("final msg[index]",msg[index])
|
|
|
|
//fmt.Println("final string(msg[index])",string(msg[index]))
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
//fmt.Println("final msg[sIndex]",msg[sIndex])
|
|
|
|
//fmt.Println("final string(msg[sIndex])",string(msg[sIndex]))
|
|
|
|
//fmt.Println("final msg[lIndex]",msg[lIndex])
|
|
|
|
//fmt.Println("final string(msg[lIndex])",string(msg[lIndex]))
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
//fmt.Println("[]byte(msg[:sIndex])",[]byte(msg[:sIndex]))
|
|
|
|
//fmt.Println("[]byte(msg[:lIndex])",[]byte(msg[:lIndex]))
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
outbytes = append(outbytes, msg[lastElement:startIndex]...)
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
if bold {
|
|
|
|
outbytes = append(outbytes, markdown_bold_tag_open...)
|
|
|
|
}
|
|
|
|
if italic {
|
|
|
|
outbytes = append(outbytes, markdown_italic_tag_open...)
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
outbytes = append(outbytes, msg[sIndex:lIndex]...)
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
if italic {
|
|
|
|
outbytes = append(outbytes, markdown_italic_tag_close...)
|
|
|
|
}
|
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 bold {
|
|
|
|
outbytes = append(outbytes, markdown_bold_tag_close...)
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
lastElement = index
|
|
|
|
index--
|
|
|
|
//case '`':
|
|
|
|
//case '_':
|
|
|
|
//case '~':
|
|
|
|
//case 10: // newline
|
|
|
|
}
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
//fmt.Println("exit message loop")
|
|
|
|
//fmt.Println(" ")
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
if len(outbytes) == 0 {
|
|
|
|
return msg
|
|
|
|
} else if lastElement < (len(msg) - 1) {
|
|
|
|
return string(outbytes) + msg[lastElement:]
|
|
|
|
}
|
|
|
|
return string(outbytes)
|
|
|
|
}
|
|
|
|
|
|
|
|
func markdown_find_char(data string ,index int ,char byte) bool {
|
|
|
|
for ; index < len(data); index++ {
|
|
|
|
item := data[index]
|
|
|
|
if item > 32 {
|
|
|
|
return (item == char)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func markdown_skip_until_char(data string, index int, char byte) int {
|
|
|
|
for ; index < len(data); index++ {
|
|
|
|
if data[index] == char {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return index
|
|
|
|
}
|
|
|
|
|
|
|
|
func markdown_skip_until_asterisk(data string, index int) int {
|
|
|
|
SwitchLoop:
|
|
|
|
for ; index < len(data); index++ {
|
|
|
|
switch(data[index]) {
|
|
|
|
case 10:
|
|
|
|
if ((index+1) < len(data)) && markdown_find_char(data,index,'*') {
|
|
|
|
index = markdown_skip_list(data,index)
|
|
|
|
}
|
|
|
|
case '*': break SwitchLoop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return index
|
|
|
|
}
|
|
|
|
|
|
|
|
// plugin_markdown doesn't support lists yet, but I want it to be easy to have nested lists when we do have them
|
|
|
|
func markdown_skip_list(data string, index int) int {
|
|
|
|
var lastNewline int
|
|
|
|
var datalen int = len(data)
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
for ; index < datalen; index++ {
|
|
|
|
SkipListInnerLoop:
|
|
|
|
if data[index] == 10 {
|
|
|
|
lastNewline = index
|
|
|
|
for ; index < datalen; index++ {
|
|
|
|
if data[index] > 32 {
|
|
|
|
break
|
|
|
|
} else if data[index] == 10 {
|
|
|
|
goto SkipListInnerLoop
|
|
|
|
}
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
if index >= datalen {
|
|
|
|
if data[index] != '*' && data[index] != '-' {
|
|
|
|
if (lastNewline + 1) < datalen {
|
|
|
|
return lastNewline + 1
|
|
|
|
}
|
|
|
|
return lastNewline
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-06-05 11:57:27 +00:00
|
|
|
|
2017-05-29 14:52:37 +00:00
|
|
|
return index
|
|
|
|
}
|