Browse Source

Add Plugin ejs

master
186526 1 year ago
parent
commit
c31ae0cbcc
Signed by: 186526 GPG Key ID: C7EB1E6B8CC5E51D
9 changed files with 99 additions and 7 deletions
  1. 5
      src/config/blogging.config.js
  2. 7
      src/core/parse/index.js
  3. 15
      src/plugins/ejs/manifest.json
  4. 20
      src/plugins/ejs/package.json
  5. 20
      src/plugins/ejs/plugin.js
  6. 4
      src/plugins/marked/manifest.json
  7. 4
      src/plugins/marked/package.json
  8. 2
      src/plugins/marked/plugin.js
  9. 29
      yarn.lock

5
src/config/blogging.config.js

@ -1,6 +1,9 @@
const config = {
plugins: {
plugin: [{ manifest: "./blogging_plugins/marked/manifest.json" }],
plugin: [
{ manifest: "./blogging_plugins/marked/manifest.json" },
{ manifest: "./blogging_plugins/ejs/manifest.json" },
],
bundle: { file: "./blogging_plugins/bundle.prod.js" },
},
parser: {

7
src/core/parse/index.js

@ -22,10 +22,15 @@ class parser {
if (x.name === this.default) {
return x;
}
if (x.filetype.includes(filetype)) {
if (x.files_type.includes(filetype)) {
tmp.push(x);
}
}
try {
return tmp[0];
} catch (e) {
new Error(`Can't Find Parser for ${this.type} `);
}
})(handler);
}
handler(text) {

15
src/plugins/ejs/manifest.json

@ -0,0 +1,15 @@
{
"name": "ejs",
"type": "render",
"listen": "render",
"load": {
"js": [
{
"url": "./dist/plugin.prod.js",
"module": true,
"async": false,
"defer": false
}
]
}
}

20
src/plugins/ejs/package.json

@ -0,0 +1,20 @@
{
"name": "@blogging/plugin-render-ejs",
"version": "1.0.0",
"description": "Theme render ejs for Blogging",
"main": "main.js",
"author": "186526 <[email protected]>",
"license": "MIT",
"sourceType": "module",
"dependencies": {
"ejs": "^3.1.5"
},
"devDependencies": {
"browserify": "^17.0.0",
"esmify": "^2.1.1",
"minify": "^6.0.1"
},
"scripts": {
"build": "browserify plugin.js -p esmify -o dist/plugin.js;minify dist/plugin.js>dist/plugin.prod.js"
}
}

20
src/plugins/ejs/plugin.js

@ -0,0 +1,20 @@
import { pluginapi } from "../../core/plugins/plugin-api";
const ejs = require('ejs');
pluginapi.reg({
name: 'ejs',
type: 'render',
filestype: ["ejs"],
handler: (e,t)=>{
if(e==='ejs'){
return ejs.render(t,
{$bl:window.$bl,
$bl_plugins:window.blogging_plugins,
$bl_handler:window.blogging_handler,
$bl_api:pluginapi
});
}
else{
new Error("Plugin EJS only support EJS theme render");
}
},
});

4
src/plugins/marked/manifest.json

@ -1,7 +1,7 @@
{
"name": "marked",
"type": "render",
"listen": "render",
"type": "parser",
"listen": "parser",
"load": {
"js": [
{

4
src/plugins/marked/package.json

@ -1,7 +1,7 @@
{
"name": "@blogging/plugin-render-marked",
"name": "@blogging/plugin-parser-marked",
"version": "1.0.0",
"description": "Markdown render marked for Blogging",
"description": "Markdown parser marked for Blogging",
"main": "main.js",
"author": "186526 <[email protected]>",
"license": "MIT",

2
src/plugins/marked/plugin.js

@ -2,7 +2,7 @@ import { pluginapi } from "../../core/plugins/plugin-api";
const marked = require("marked");
pluginapi.reg({
name: "marked",
type: "render",
type: "parser",
filestype: ["markdown"],
handler: (type, e) => {
if (type === "markdown") {

29
yarn.lock

@ -2322,6 +2322,11 @@ [email protected]^1.0.1:
resolved "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf"
integrity sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==
[email protected]:
version "0.9.2"
resolved "https://registry.npm.taobao.org/async/download/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d"
integrity sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=
[email protected]^2.6.2:
version "2.6.3"
resolved "https://registry.npmjs.org/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
@ -4042,6 +4047,13 @@ [email protected]^3.3.2:
minimist "^1.1.0"
url-join "^2.0.5"
[email protected]^3.1.5:
version "3.1.5"
resolved "https://registry.npm.taobao.org/ejs/download/ejs-3.1.5.tgz?cache=0&sync_timestamp=1598275824341&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fejs%2Fdownload%2Fejs-3.1.5.tgz#aed723844dc20acb4b170cd9ab1017e476a0d93b"
integrity sha1-rtcjhE3CCstLFwzZqxAX5Hag2Ts=
dependencies:
jake "^10.6.1"
[email protected]^1.3.591:
version "1.3.603"
resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.603.tgz#1b71bec27fb940eccd79245f6824c63d5f7e8abf"
@ -4468,6 +4480,13 @@ [email protected]:
resolved "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==
[email protected]^1.0.1:
version "1.0.1"
resolved "https://registry.npm.taobao.org/filelist/download/filelist-1.0.1.tgz?cache=0&sync_timestamp=1597287209500&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffilelist%2Fdownload%2Ffilelist-1.0.1.tgz#f10d1a3ae86c1694808e8f20906f43d4c9132dbb"
integrity sha1-8Q0aOuhsFpSAjo8gkG9D1MkTLbs=
dependencies:
minimatch "^3.0.4"
[email protected]^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7"
@ -5707,6 +5726,16 @@ [email protected]~0.1.2:
resolved "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=
[email protected]^10.6.1:
version "10.8.2"
resolved "https://registry.npm.taobao.org/jake/download/jake-10.8.2.tgz#ebc9de8558160a66d82d0eadc6a2e58fbc500a7b"
integrity sha1-68nehVgWCmbYLQ6txqLlj7xQCns=
dependencies:
async "0.9.x"
chalk "^2.4.2"
filelist "^1.0.1"
minimatch "^3.0.4"
[email protected]^26.5.0:
version "26.6.2"
resolved "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz#7f72cbc4d643c365e27b9fd775f9d0eaa9c7a8ed"
Loading…
Cancel
Save