mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-02 02:36:24 -07:00
Add non-RPC changes to master
This commit is contained in:
parent
6e40ae8a16
commit
b3a57f50a8
20 changed files with 360 additions and 247 deletions
|
@ -2,57 +2,57 @@
|
|||
- **_GOCHAN_VERSION**
|
||||
- The version string of the running Gochan server
|
||||
|
||||
# Functions
|
||||
- **error_log([error_message string])**
|
||||
- Creates and returns a zerolog [Event](https://pkg.go.dev/github.com/rs/zerolog) object for the error log. If a string is used as the argument, it is used as the error message.
|
||||
|
||||
- **info_log()**
|
||||
- Creates and returns a zerolog [Event](https://pkg.go.dev/github.com/rs/zerolog) object with an info level.
|
||||
|
||||
- **warn_log()**
|
||||
- Creates and returns a zerolog [Event](https://pkg.go.dev/github.com/rs/zerolog) object with a warning level.
|
||||
|
||||
- **register_upload_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](./sample-plugins/pdf_thumbnail.lua) for a usage example.
|
||||
|
||||
- **get_thumbnail_ext(upload_ext string)**
|
||||
- Returns the configured (or built-in) thumbnail file extension to be used for the given upload extension
|
||||
|
||||
- **set_thumbnail_ext(upload_ext string, thumbnail_ext string)**
|
||||
- Sets the thumbnail extension to be used for the given upload extension
|
||||
|
||||
- **system_critical_config()**
|
||||
- Returns the [SystemCriticalConfig](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/config#SystemCriticalConfig)
|
||||
|
||||
- **site_config()**
|
||||
# Modules
|
||||
The following are modules that can be loaded via `require("modulename")`. See [./examples/plugins/](./examples/plugins/) for usage examples
|
||||
## config
|
||||
- **config.system_critical_config()**
|
||||
- Returns the [SystemCriticalConfig](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/config#SystemCriticalConfig)
|
||||
- **config.site_config()**
|
||||
- Returns the [SiteConfig](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/config#SiteConfig)
|
||||
|
||||
- **board_config(board string)**
|
||||
- **config.board_config(board string)**
|
||||
- Returns the [BoardConfig](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/config#BoardConfig) for the given board, or the default BoardConfig if `board` is an empty string
|
||||
|
||||
- **db_query(query string)**
|
||||
- Returns a [Rows](https://pkg.go.dev/database/sql#Rows) object for the given SQL query and an error if any occured, or nil if there were no errors.
|
||||
|
||||
- **db_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.
|
||||
|
||||
- **event_register(events_table, handler_func)**
|
||||
## events
|
||||
- **events.register_event(events_table, handler_func)**
|
||||
- Registers `handler_func` for the events in `events_table`. If any arguments are passed to the event when it is triggered, it will be sent to `handler_func`.
|
||||
|
||||
- **event_trigger(event_name string, data...)**
|
||||
- **events.trigger_event(event_name string, data...)**
|
||||
- Triggers the event registered to `event_name` and passes `data` (if set) to the event handler.
|
||||
|
||||
- **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 by `handler`. See [manage.RegisterManagePage](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/manage#RegisterManagePage) for info on how `handler` should be used, or [registermgmtpage.lua](./sample-plugins/registermgmtpage.lua) for an example
|
||||
## gclog
|
||||
- **gclog.info_log()**
|
||||
- Creates and returns a zerolog [Event](https://pkg.go.dev/github.com/rs/zerolog) object with an info level.
|
||||
- **gclog.warn_log()**
|
||||
- Creates and returns a zerolog [Event](https://pkg.go.dev/github.com/rs/zerolog) object with a warning level.
|
||||
- **gclog.error_log([error_message string])**
|
||||
- Creates and returns a zerolog [Event](https://pkg.go.dev/github.com/rs/zerolog) object for the error log. If a string is used as the argument, it is used as the error message.
|
||||
|
||||
- **load_template(files...)**
|
||||
## gcsql
|
||||
- **gcsql.query_rows(query string, args...)**
|
||||
- Returns a [Rows](https://pkg.go.dev/database/sql#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.
|
||||
- **gcsql.execute_sql(query string, args...)**
|
||||
- Executes the SQL string `query` with the optional `args` as parameters and returns a [Result](https://pkg.go.dev/database/sql#Result) object and an error (or nil if there were no errors)
|
||||
- **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.
|
||||
|
||||
## gctemplates
|
||||
- **gctemplates.load_template(files...)**
|
||||
- Calls [gctemplates.LoadTemplate](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/gctemplates#LoadTemplate) using the given `files` and returns a [Template](https://pkg.go.dev/html/template#Template) and an error object (or nil if there were no errors).
|
||||
|
||||
- **parse_template(template_name string, template_data string)**
|
||||
- **gctemplates.minify_template(template, data_table, writer, media_type)**
|
||||
- Calls [serverutil.MinifyTemplate](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/server/serverutil#MinifyTemplate) with the given `template` object, `data_table` (as variables passed to the template), `writer`, and `media_type`. See [registermgmtpage.lua](./examples/plugins/registermgmtpage.lua) for an example
|
||||
- **gctemplates.parse_template(template_name string, template_data string)**
|
||||
- Calls [gctemplates.ParseTemplate](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/gctemplates#ParseTemplate) with the given template name and Go template data, and returns a [Template](https://pkg.go.dev/html/template#Template) and an error object (or nil if there were no errors).
|
||||
|
||||
- **minify_template(template, data_table, writer, media_type)**
|
||||
- Calls [serverutil.MinifyTemplate](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/server/serverutil#MinifyTemplate) with the given `template` object, `data_table` (as variables passed to the template), `writer`, and `media_type`. See [registermgmtpage.lua](./sample-plugins/registermgmtpage.lua) for an example
|
||||
## 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 by `handler`. See [manage.RegisterManagePage](https://pkg.go.dev/github.com/gochan-org/gochan/pkg/manage#RegisterManagePage) for info on how `handler` should be used, or [registermgmtpage.lua](./examples/plugins/registermgmtpage.lua) for an example
|
||||
|
||||
## 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](./examples//plugins/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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue