{"id":16817575,"url":"https://github.com/clarkwinkelmann/flarum-ext-scratchpad","last_synced_at":"2025-04-11T02:24:56.280Z","repository":{"id":42922302,"uuid":"245329907","full_name":"clarkwinkelmann/flarum-ext-scratchpad","owner":"clarkwinkelmann","description":"Easily test code on your development forum","archived":false,"fork":false,"pushed_at":"2023-03-04T06:21:15.000Z","size":1415,"stargazers_count":4,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T23:51:25.520Z","etag":null,"topics":["flarum","scratchpad"],"latest_commit_sha":null,"homepage":"https://discuss.flarum.org/d/23016","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clarkwinkelmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"publiccode":null,"codemeta":null}},"created_at":"2020-03-06T04:28:54.000Z","updated_at":"2021-05-28T12:17:13.000Z","dependencies_parsed_at":"2025-02-18T13:45:53.510Z","dependency_job_id":null,"html_url":"https://github.com/clarkwinkelmann/flarum-ext-scratchpad","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarkwinkelmann%2Fflarum-ext-scratchpad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarkwinkelmann%2Fflarum-ext-scratchpad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarkwinkelmann%2Fflarum-ext-scratchpad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clarkwinkelmann%2Fflarum-ext-scratchpad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clarkwinkelmann","download_url":"https://codeload.github.com/clarkwinkelmann/flarum-ext-scratchpad/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085322,"owners_count":21045139,"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":["flarum","scratchpad"],"created_at":"2024-10-13T10:47:38.214Z","updated_at":"2025-04-11T02:24:56.258Z","avatar_url":"https://github.com/clarkwinkelmann.png","language":"PHP","funding_links":["https://www.paypal.me/clarkwinkelmann"],"categories":[],"sub_categories":[],"readme":"# Developer Scratchpad\n\n[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/clarkwinkelmann/flarum-ext-scratchpad/blob/master/LICENSE.md) [![Latest Stable Version](https://img.shields.io/packagist/v/clarkwinkelmann/flarum-ext-scratchpad.svg)](https://packagist.org/packages/clarkwinkelmann/flarum-ext-scratchpad) [![Total Downloads](https://img.shields.io/packagist/dt/clarkwinkelmann/flarum-ext-scratchpad.svg)](https://packagist.org/packages/clarkwinkelmann/flarum-ext-scratchpad) [![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.me/clarkwinkelmann)\n\n\u003e PLEASE DO NOT INSTALL THIS EXTENSION UNLESS YOU KNOW WHAT YOU ARE DOING!\n\u003e\n\u003e Any user with administrative access is able to run any javascript and PHP code on the server and website without any restriction!\n\nThis extension adds a scratchpad feature to the admin panel of Flarum to ease testing and development for developers.\n\nWhile the feature is restricted to admin users, I still recommend installing this on local environments only.\n\nThis is still very experimental. Use at your own risks.\n\nRequirements:\n\n- Debug mode must be turned on\n- `eval()` is used to run PHP code\n- `shell_exec()` is used to run Node\n- The web user must be able to run `npm` and `node` commands\n\nEach scratchpad can contain javascript, Less and PHP code just like any extension.\n\nYou can give names to individual scratchpads and enable/disable them via a checkbox.\n\nThere's a good chance that despite the checks in place you will be able to save invalid code.\nIf that happens, the easier is to go in the database and disable the scratchpad that's responsible.\n\nPHP and Less are validated by doing a \"stateless\" background request to the forum and admin homepage with the new code when saving.\nIf the background request fails, a validation error is shown and the scratchpad is not saved.\nThis background request can be disabled in the extension settings.\n\nJavascript is not validated during save, but if the compilation fails, the compiled code will not be loaded on the forum and you will see a message in the editor.\n\nJavascript compilation is done locally by calling node through PHP.\nA `scratchpad` folder will be created under `storage`.\nThe first time you compile, `npm install` will run.\nSubsequent compilations will re-use the installed dependencies.\n\nIf you end up with an invalid javascript setup, you can delete the `storage/scratchpad` folder and the extension will re-install everything on the next compilation.\n\nThe text editor on the Scratchpad page is [CodeMirror](https://codemirror.net/).\nYou can customize the theme and indentation via the cog icon above the editor.\nFor now the settings are global and apply to all languages.\n\n## Installation\n\nPlease read the disclaimers and requirements above before installing.\n\n    composer require clarkwinkelmann/flarum-ext-scratchpad\n\n## Customizing the NPM and Webpack commands\n\nThe default commands should work fine on most Linux systems, but they are known to fail on some configurations, including (unsurprisingly) Windows.\n\nYou can edit the commands by editing the settings named \"NPM installl command\" and \"Webpack command\" in the modal that can be accessed via the cog icon of the editor.\n\nBelow are the default commands.\n\n`{{path}}` must be kept verbatim and will be replaced with the path to the scratchpad folder, which is the equivalent of the `js` folder of an extension.\n\n`2\u003e\u00261` is necessary at the end to redirect errors to standard output so the compiler can inspect the output and look for error messages.\n\nNPM install:\n\n    cd {{path}} \u0026\u0026 npm install 2\u003e\u00261\n\nWebpack:\n\n    cd {{path}} \u0026\u0026 node_modules/.bin/webpack --mode development --config node_modules/flarum-webpack-config/index.js 2\u003e\u00261\n\n## Links\n\n- [GitHub](https://github.com/clarkwinkelmann/flarum-ext-scratchpad)\n- [Packagist](https://packagist.org/packages/clarkwinkelmann/flarum-ext-scratchpad)\n- [Discuss](https://discuss.flarum.org/d/23016)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarkwinkelmann%2Fflarum-ext-scratchpad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclarkwinkelmann%2Fflarum-ext-scratchpad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclarkwinkelmann%2Fflarum-ext-scratchpad/lists"}