{"id":28746168,"url":"https://github.com/ether/ep_dynamic_default_content","last_synced_at":"2025-06-16T14:30:38.130Z","repository":{"id":37443283,"uuid":"461405059","full_name":"ether/ep_dynamic_default_content","owner":"ether","description":"Etherpad plugin to dynamically generate a pad's initial content.","archived":false,"fork":false,"pushed_at":"2024-03-16T21:39:53.000Z","size":577,"stargazers_count":2,"open_issues_count":10,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-26T01:51:43.867Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ether.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-02-20T06:33:31.000Z","updated_at":"2025-02-12T03:29:11.000Z","dependencies_parsed_at":"2024-03-17T00:46:52.348Z","dependency_job_id":null,"html_url":"https://github.com/ether/ep_dynamic_default_content","commit_stats":{"total_commits":25,"total_committers":3,"mean_commits":8.333333333333334,"dds":0.56,"last_synced_commit":"3f06755360af6175973977626dec1900eb2e7db3"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/ether/ep_dynamic_default_content","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ether%2Fep_dynamic_default_content","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ether%2Fep_dynamic_default_content/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ether%2Fep_dynamic_default_content/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ether%2Fep_dynamic_default_content/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ether","download_url":"https://codeload.github.com/ether/ep_dynamic_default_content/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ether%2Fep_dynamic_default_content/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260175607,"owners_count":22970006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-16T14:30:36.922Z","updated_at":"2025-06-16T14:30:38.017Z","avatar_url":"https://github.com/ether.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Publish Status](https://github.com/ether/ep_dynamic_default_content/workflows/Node.js%20Package/badge.svg) ![Backend Tests Status](https://github.com/ether/ep_dynamic_default_content/workflows/Backend%20tests/badge.svg)\n\n# ep_dynamic_default_content\n\nEtherpad plugin to dynamically generate a pad's initial content.\n\n## Installation\n\nFrom the Etherpad working directory, run:\n\n```shell\nnpm install --no-save --legacy-peer-deps ep_dynamic_default_content\n```\n\nOr, install from Etherpad's `/admin/plugins` page.\n\n## Configuration\n\n### MariaDB\n\nTo obtain the pad's initial content from MariaDB (MySQL), add something like the\nfollowing to your `settings.json`:\n\n```json\n  \"ep_dynamic_default_content\": {\n    \"type\": \"mariadb\",\n    \"mariadb\": {\n      \"config\": \"mariadb://username:password@host/database\",\n      \"sql\": \"SELECT txt FROM config WHERE customer = REGEXP_SUBSTR(:padId, '^[^-]+');\"\n    }\n  },\n```\n\nProperties of the `mariadb` object:\n\n  * `config` (required): Any value accepted by the\n    [`mariadb.createPool()`](https://github.com/mariadb-corporation/mariadb-connector-nodejs/blob/2.5.6/documentation/promise-api.md#createpooloptions--pool)\n    function.\n  * `sql` (required): Query to issue to obtain the pad content. This may use any\n    of the following [named\n    placeholders](https://github.com/mariadb-corporation/mariadb-connector-nodejs/blob/2.5.6/documentation/promise-api.md#namedPlaceholders):\n      * `:authorId` (string): The author ID of the user that is creating the\n        pad.\n      * `:padId` (string): The pad's ID.\n\nThe query should return one row with one column containing the desired text.\n\n### JavaScript\n\nYou can run arbitrary code to generate the default pad content by adding\nsomething like the following to your `settings.json`:\n\n```json\n  \"ep_dynamic_default_content\": {\n    \"type\": \"javascript\",\n    \"javascript\": {\n      \"settings\": {\"place\": \"world\"},\n      \"init\": \"return {place: settings.place.toUpperCase()};\",\n      \"handle\": \"ctx.type = 'text'; ctx.content = `hello ${state.place}!`;\",\n      \"shutdown\": \"doCleanupStuff(state);\"\n    }\n  },\n```\n\nProperties of the `javascript` object:\n\n  * `settings` (optional): Arbitrary value that will be passed to your `init`\n    function (if provided).\n\n  * `init` (optional): Body of an\n    [AsyncFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction)\n    that performs any desired initialization at startup.\n\n    Parameters:\n\n      * `settings`: The value of the\n        `ep_dynamic_default_content.javascript.settings` property in your\n        `settings.json`, or nullish if your `settings.json` does not have such a\n        value.\n\n    Return value: Optional. If your code returns a value, that value\n    will be passed as the `state` parameter to the `handle` and `shutdown`\n    functions.\n\n  * `handle` (required): Body of an\n    [AsyncFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction)\n    that is called to obtain a new pad's initial content.\n\n    Parameters:\n\n      * `state`: The value returned by the `init` function, or nullish if you\n        did not provide an `init` function or the `init` function did not return\n        a value.\n\n      * `ctx`: The context object for the [`padDefaultContent`\n        hook](https://etherpad.org/doc/v1.9.0/#index_padDefaultContext).\n\n    Return value: ignored.\n\n  * `shutdown` (optional): Body of an\n    [AsyncFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction)\n    that is called when Etherpad is shutting down or restarted. Use this to\n    clean up any state (e.g., cancel timers, close connections) created by your\n    `init` or `handle` functions.\n\n    Parameters:\n\n      * `state`: The value returned by the `init` function, or nullish if you\n        did not provide an `init` function or the `init` function did not return\n        a value.\n\n## Copyright and License\n\nCopyright © 2022 Richard Hansen\nand the ep_dynamic_default_content authors and contributors\n\nLicensed under the [Apache License, Version 2.0](LICENSE) (the \"License\"); you\nmay not use this file except in compliance with the License. You may obtain a\ncopy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed\nunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\nCONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fether%2Fep_dynamic_default_content","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fether%2Fep_dynamic_default_content","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fether%2Fep_dynamic_default_content/lists"}