mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-02 02:36:24 -07:00
5.4 KiB
5.4 KiB
Constants
- _GOCHAN_VERSION
- The version string of the running Gochan server
Modules
The following are modules that can be loaded via require("modulename")
. See ./examples/plugins/ for usage examples
config
- config.system_critical_config()
- Returns the SystemCriticalConfig
- config.site_config()
- Returns the SiteConfig
- config.board_config(board string)
- Returns the BoardConfig for the given board, or the default BoardConfig if
board
is an empty string
- Returns the BoardConfig for the given board, or the default BoardConfig if
events
- events.register_event(events_table, handler_func)
- Registers
handler_func
for the events inevents_table
. If any arguments are passed to the event when it is triggered, it will be sent tohandler_func
.
- Registers
- events.trigger_event(event_name string, data...)
- Triggers the event registered to
event_name
and passesdata
(if set) to the event handler.
- Triggers the event registered to
gclog
- gclog.info_log()
- Creates and returns a zerolog Event object with an info level.
- gclog.warn_log()
- Creates and returns a zerolog Event object with a warning level.
- gclog.error_log([error_message string])
- Creates and returns a zerolog Event object for the error log. If a string is used as the argument, it is used as the error message.
gcsql
- gcsql.query_rows(query string, args...)
- Returns a Rows object for the given SQL query and an error if any occured, or nil if there were no errors.
args
if given will be used for a parameterized query.
- Returns a Rows object for the given SQL query and an error if any occured, or nil if there were no errors.
- gcsql.execute_sql(query string, args...)
- Executes the SQL string
query
with the optionalargs
as parameters and returns a Result object and an error (or nil if there were no errors)
- Executes the SQL string
- gcsql.scan_rows(rows, scan_table)
- scans the value of the current row into
scan_table
and returns an error if any occured, or nil if there were no errors.
- scans the value of the current row into
gctemplates
- gctemplates.load_template(files...)
- Calls gctemplates.LoadTemplate using the given
files
and returns a Template and an error object (or nil if there were no errors).
- Calls gctemplates.LoadTemplate using the given
- gctemplates.minify_template(template, data_table, writer, media_type)
- Calls serverutil.MinifyTemplate with the given
template
object,data_table
(as variables passed to the template),writer
, andmedia_type
. See registermgmtpage.lua for an example
- Calls serverutil.MinifyTemplate with the given
- gctemplates.parse_template(template_name string, template_data string)
- Calls gctemplates.ParseTemplate with the given template name and Go template data, and returns a Template and an error object (or nil if there were no errors).
manage
- manage.register_manage_page(action string, title string, perms int, wants_json int, handler func(writer, request, staff, wants_json, info_ev, err_ev))
- Registers the manage page accessible at /manage/
action
to be handled byhandler
. See manage.RegisterManagePage for info on howhandler
should be used, or registermgmtpage.lua for an example
- Registers the manage page accessible at /manage/
uploads
- uploads.register_handler(ext string, function(upload, post, board, filePath, thumbPath, catalogThumbPath, infoEv, accessEv, errEv))
- Registers a function to be called for handling uploaded files with the given extension. See pdf_thumbnail.lua for a usage example.
- uploads.get_thumbnail_ext(upload_ext string)
- Returns the configured (or built-in) thumbnail file extension to be used for the given upload extension
- uploads.set_thumbnail_ext(upload_ext string, thumbnail_ext string)
- Sets the thumbnail extension to be used for the given upload extension
Events
This is a list of events that gochan may trigger at some point and can be used in the plugin system.
-
db-connected
- Triggered after gochan successfully connects to the database but before it is checked and initialized (db version checking, provisisioning, etc)
-
db-initialized
- Triggered after the database is successfully initialized (db version checking, provisioning, etc)
-
incoming-upload
- Triggered by the
gcsql
package when an upload is attached to a post. It is triggered before the upload is entered in the database
- Triggered by the
-
message-pre-format
- Triggered when an incoming post or post edit is about to be formatted
-
shutdown
- Triggered when gochan is about to shut down, in
main()
as a deferred call
- Triggered when gochan is about to shut down, in
-
startup
- Triggered when gochan first starts after its plugin system is initialized. This is (or at least should be) only triggered once.
-
upload-saved
- Triggered by the
posting
package when an upload is saved to the disk but before thumbnails are generated.
- Triggered by the