duangsuse-valid-projects / alldreamwall

一个基于 MDUI & MDUI JQ 的傲梦分享平台客户端
https://popf.rip/all_dream.html
GNU Lesser General Public License v3.0
2 stars 0 forks source link

插件化项目 #3

Open duangsuse opened 6 years ago

duangsuse commented 6 years ago

duangsuse::Echo, [19.07.18 08:54] [In reply to duangsuse::Echo] 马上再往上加功能,这次是支持 URL 参数定位 SID、UID、选择 page 和 rowsize、category 然后支持手动设置 cookie,开启关闭夜间模式 然后支持 基于字段的 JSON prettyprint comment 插件

然后支持插件,允许使用 AllDreamAPI DSL 创建更多功能

plugin foo author buf description 无用的插件 menuitem 你好世界 link 🌐

begin cookie foo as bar ask GET ? ajax get https://foo.com data url param :result param foo as bar success javascript alert(dsl['body']) end end

snackbar :result setlist 你好世界 end

duangsuse::Echo, [19.07.18 08:58] jsoncomment rule for uid do |a| "https://all-dream.com/rest/student/" + a end

for id do |b| //.... 'hello' end end

然后可以在 plugin 里用 using rule 设置当前 JSON pp 插件🌚 反正用户操作不可能是并行的,也不用加锁什么的

duangsuse commented 6 years ago

AllDreamWall DSL 使用空格 ' ' 切分文本来分词, 以 : 开头的字符串指示环境变量,不是所有指令都支持这种表示,环境变量存储在 dsl JavaScript 对象里

所有指令的返回值存储在 result 变量里,一些指令如果没有参数默认使用 result 作为参数 之后支持以下指令:

plugin <name tokens>\n
author <name tokens>\n
descrition <name tokens>\n
menuitem <label tokens> link <link icon tokens>\n

begin <on link clicked code> end
cookie <name> as <value>\n
remove cookie <name>\n
ask <title>\n
confirm <title> do <code> [else code] end
alert <title>\n
snackbar <message>\n
prettyprint <text>\n
setlist <text>\n

ajax <method> ' ' <url> data
// array of
param <name> ' ' <value>\n
url param <name> ' ' <value>\n

// last
success <code>
end

javascript <js code> end

jsoncomment <rule name>\n
// array of
for <field> do |<envar name>|
// JavaScript code that returns a string value
end

// 显示安装提示,安装脚本
setup
duangsuse commented 6 years ago

马上再往上加功能,这次是支持 URL 参数定位 SID、UID、选择 page 和 rowsize、category

然后支持手动设置 cookie,开启关闭夜间模式

做成插件

然后支持 基于字段的 JSON prettyprint comment 插件

然后支持插件,允许使用 AllDreamAPI DSL 创建更多功能

duangsuse commented 6 years ago

为了缩小工程量,先使用 ES 作为插件脚本语言吧

duangsuse commented 6 years ago

duangsuse::Echo, [19.07.18 17:44] [In reply to duangsuse::Echo] 我觉得在开始完成插件系统之前应该先修改一下 DreamScript — DS 必须使用基于缩进的语法,这样才不会出现

begin alert Load end end

解析错误的问题

begin ajax get https://foo.com success javascript mdui.alert("Load finished")

duangsuse::Echo, [19.07.18 17:49] 其实我觉得开始的时候不用专门写 DSL,可以先拿 JavaScript 的 eval() 凑合着用吧

duangsuse::Echo, [19.07.18 17:55] 它要在传入的插件表上定义四个函数: initialize, begin, urlhandle 和 jsoncomment 其中只有 begin 是必须的,因为插件必须有一个打开链接 jsoncomment 用于提供 JSON comment 生成功能,插件可以使用 setCommentEmitter() 来注册全局 JSON Comment 生成器