from template npm create wiki-plugin@latest FarmManager
This commit is contained in:
commit
be9f5bc20c
10
.editorconfig
Normal file
10
.editorconfig
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
34
.github/workflows/check.yml
vendored
Normal file
34
.github/workflows/check.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
name: Prettier Check
|
||||||
|
|
||||||
|
on: [pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
prettier:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Run Prettier check
|
||||||
|
run: npm run prettier:check
|
||||||
|
|
||||||
|
- name: Annotate Pull Request with Results
|
||||||
|
if: failure()
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
github.rest.issues.createComment({
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
body: '⚠️ Prettier found formatting issues. Please fix them.'
|
||||||
|
})
|
27
.github/workflows/test.yml
vendored
Normal file
27
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
# Releases https://github.com/nodejs/release#release-schedule
|
||||||
|
node-version:
|
||||||
|
- 20.x # Maintenance
|
||||||
|
- 22.x # Active
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
assets
|
||||||
|
client/farmmanager.js
|
||||||
|
client/farmmanager.map
|
||||||
|
commons
|
||||||
|
coverage
|
||||||
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
|
meta-client.json
|
||||||
|
recycle
|
||||||
|
status
|
14
.npmignore
Normal file
14
.npmignore
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
coverage
|
||||||
|
scripts
|
||||||
|
src
|
||||||
|
test
|
||||||
|
meta-client.json
|
||||||
|
eslint.config.js
|
||||||
|
.github
|
||||||
|
.prettier*
|
||||||
|
.vscode
|
||||||
|
.zed
|
||||||
|
assets
|
||||||
|
commons
|
||||||
|
recycle
|
||||||
|
status
|
2
.prettierignore
Normal file
2
.prettierignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
client/*.js
|
||||||
|
coverage
|
8
.prettierrc.json
Normal file
8
.prettierrc.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"bracketSpacing": true,
|
||||||
|
"bracketSameLine": true,
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"printWidth": 120
|
||||||
|
}
|
3
.vscode/extensions.json
vendored
Normal file
3
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
|
||||||
|
}
|
7
.vscode/settings.json
vendored
Normal file
7
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.fixAll.eslint": "explicit"
|
||||||
|
},
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
|
"editor.formatOnSave": true
|
||||||
|
}
|
7
.zed/settings.json
Normal file
7
.zed/settings.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Folder-specific settings
|
||||||
|
//
|
||||||
|
// For a full list of overridable settings, and general information on folder-specific settings,
|
||||||
|
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
|
||||||
|
{
|
||||||
|
"format_on_save": "on"
|
||||||
|
}
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) <YEAR> <COPYRIGHT HOLDER>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Federated Wiki - FarmManager Plugin
|
||||||
|
|
||||||
|
TODO: Add decription about what this plugin does.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
`npm install`
|
||||||
|
`npm run build`
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT
|
23
eslint.config.js
Normal file
23
eslint.config.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import globals from 'globals'
|
||||||
|
import pluginJs from '@eslint/js'
|
||||||
|
|
||||||
|
/** @type {import('eslint').Linter.Config[]} */
|
||||||
|
export default [
|
||||||
|
pluginJs.configs.recommended,
|
||||||
|
{
|
||||||
|
rules: {
|
||||||
|
'no-unused-vars': 'warn',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ ignores: ['client/*'] },
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
wiki: 'readonly',
|
||||||
|
...globals.browser,
|
||||||
|
...globals.jquery,
|
||||||
|
...globals.mocha,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
1589
package-lock.json
generated
Normal file
1589
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
package.json
Normal file
32
package.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "wiki-plugin-farmmanager",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Add description here.",
|
||||||
|
"keywords": [
|
||||||
|
"wiki",
|
||||||
|
"federated wiki",
|
||||||
|
"plugin"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"build": "npm run clean; npm run test; node --no-warnings scripts/build-client.js",
|
||||||
|
"about": "wiki -p 3010 -d . --security_legacy",
|
||||||
|
"clean": "rm client/farmmanager.js client/farmmanager.js.map",
|
||||||
|
"clean-about": "rm -r assets commons recycle status",
|
||||||
|
"prettier:format": "prettier --write './**/*.js'",
|
||||||
|
"prettier:check": "prettier --check ./**/*.js",
|
||||||
|
"test": "node --test"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "MIT",
|
||||||
|
"type": "module",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.x"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^9.28.0",
|
||||||
|
"esbuild": "^0.25.5",
|
||||||
|
"eslint": "^9.28.0",
|
||||||
|
"globals": "^16.2.0",
|
||||||
|
"prettier": "^3.5.3"
|
||||||
|
}
|
||||||
|
}
|
20
pages/about-farmmanager-plugin
Normal file
20
pages/about-farmmanager-plugin
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"title": "About FarmManager Plugin",
|
||||||
|
"story": [
|
||||||
|
{ "type": "paragraph", "id": "9c1d7c35ad98ba82", "text": "Describe the plugin here." },
|
||||||
|
{ "type": "farmmanager", "id": "c5ab6c3b5cadc5f9", "text": "SAMPLE Markup" }
|
||||||
|
],
|
||||||
|
"journal": [
|
||||||
|
{
|
||||||
|
"type": "create",
|
||||||
|
"item": {
|
||||||
|
"title": "About FarmManager Plugin",
|
||||||
|
"story": [
|
||||||
|
{ "type": "paragraph", "id": "9c1d7c35ad98ba82", "text": "Describe the plugin here." },
|
||||||
|
{ "type": "farmmanager", "id": "c5ab6c3b5cadc5f9" , "text":"SAMPLE Markup" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"date": 1749415263346
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
22
scripts/build-client.js
Normal file
22
scripts/build-client.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import * as esbuild from 'esbuild'
|
||||||
|
import fs from 'node:fs/promises'
|
||||||
|
import packJSON from '../package.json' with { type: 'json' }
|
||||||
|
|
||||||
|
const version = packJSON.version
|
||||||
|
const now = new Date()
|
||||||
|
|
||||||
|
let results = await esbuild.build({
|
||||||
|
entryPoints: ['src/client/farmmanager.js'],
|
||||||
|
bundle: true,
|
||||||
|
banner: {
|
||||||
|
js: `/* wiki-plugin-farmmanager - ${version} - ${now.toUTCString()} */`,
|
||||||
|
},
|
||||||
|
minify: true,
|
||||||
|
sourcemap: true,
|
||||||
|
logLevel: 'info',
|
||||||
|
metafile: true,
|
||||||
|
outfile: 'client/farmmanager.js',
|
||||||
|
})
|
||||||
|
|
||||||
|
await fs.writeFile('meta-client.json', JSON.stringify(results.metafile))
|
||||||
|
console.log("\n esbuild metadata written to 'meta-client.json'.")
|
15
scripts/update-authors.cjs
Normal file
15
scripts/update-authors.cjs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
const gitAuthors = require('grunt-git-authors')
|
||||||
|
|
||||||
|
gitAuthors.updatePackageJson({ order: 'date' }, error => {
|
||||||
|
if (error) {
|
||||||
|
console.log('Error: ', error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
gitAuthors.updateAuthors((error, filename) => {
|
||||||
|
if (error) {
|
||||||
|
console.log('Error: ', error)
|
||||||
|
} else {
|
||||||
|
console.log(filename, 'updated')
|
||||||
|
}
|
||||||
|
})
|
26
src/client/farmmanager.js
Normal file
26
src/client/farmmanager.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
const expand = text => {
|
||||||
|
return text
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/\*(.+?)\*/g, '<i>$1</i>')
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = ($item, item) => {
|
||||||
|
return $item.append(`
|
||||||
|
<p style="background-color:#eee;padding:15px;">
|
||||||
|
${expand(item.text)}
|
||||||
|
</p>`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const bind = ($item, item) => {
|
||||||
|
return $item.dblclick(() => {
|
||||||
|
return wiki.textEditor($item, item)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.plugins.farmmanager = { emit, bind }
|
||||||
|
}
|
||||||
|
|
||||||
|
export const farmmanager = typeof window == 'undefined' ? { expand } : undefined
|
12
test/test.js
Normal file
12
test/test.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { farmmanager } from '../src/client/farmmanager.js'
|
||||||
|
import { suite, test } from 'node:test'
|
||||||
|
import assert from 'node:assert'
|
||||||
|
|
||||||
|
suite('farmmanager plugin', () => {
|
||||||
|
suite('expand', () => {
|
||||||
|
test('can escape html markup characters', () => {
|
||||||
|
const result = farmmanager.expand('try < & >')
|
||||||
|
assert.equal(result, 'try < & >')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user