From 974d035ec205451005a72db787e2176637376016 Mon Sep 17 00:00:00 2001 From: ShixiangWang Date: Tue, 25 May 2021 22:37:30 +0800 Subject: [PATCH] Close #7 --- doc.md | 1 + examples/helloworld.R | 1 + hisub.R | 8 +++++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc.md b/doc.md index bf51554..c7938d9 100644 --- a/doc.md +++ b/doc.md @@ -8,6 +8,7 @@ - `@hiplot` - 1 行,后面接 `start` 和 `end` 用来表示插件注释的起始和结束位置。 - `@appname` - 1 行,你的插件名字,显示为 Hiplot 网站 URL 最后一栏名字,例如 `diy-gsea` 对应到 。插件名使用小写字母和数字的组合,如果要组合不同的单词请使用短斜线`-`。 +- `@alias` - 1行,你的插件的别名,显示在插件右侧边栏,**一般**使用首字母大写英文词,词中间使用短杠连接,例如:`Area-Chart`。当没有指定时,默认使用`@appname`指定的名字。 - `@apptitle` - 3 行,你的插件标题,一句话介绍你的插件。 输入 `@apptitle` 后重新起始一行开始输入文字。 - 第 2 行设置英文标题。 - 第 3 行设置中文标题。 diff --git a/examples/helloworld.R b/examples/helloworld.R index db6fb10..ddc4fec 100644 --- a/examples/helloworld.R +++ b/examples/helloworld.R @@ -2,6 +2,7 @@ # # @hiplot start # @appname helloworld +# @alias An-Example # @apptitle # Hiplot Hello World # Hiplot 示例插件 diff --git a/hisub.R b/hisub.R index 8439ac0..6063491 100755 --- a/hisub.R +++ b/hisub.R @@ -10,10 +10,11 @@ # 6. 基于配置和输入文件生成 plot.R # # ./hisub.R examples/helloworld.R test_hello -VERSION <- 0.2 +VERSION <- 0.3 TEMPLATE <- '# @hiplot start # @appname helloworld +# @alias An-Example # @apptitle # Hiplot Hello World # Hiplot 示例插件 @@ -157,6 +158,9 @@ parse_tag_header <- function(x) sub("# *@[^ ]+ +", "", x[1]) parse_tag_appname <- function(x) { list(type = "appname", value = parse_tag_value(x)) } +parse_tag_alias <- function(x) { + list(type = "alias", value = parse_tag_header(x)) +} parse_tag_apptitle <- function(x) { list( type = "apptitle", @@ -331,6 +335,7 @@ parse_tag <- function(x, name) { switch( name, appname = parse_tag_appname(x), + alias = parse_tag_alias(x), apptitle = parse_tag_apptitle(x), target = parse_tag_target(x), tag = parse_tag_tag(x), @@ -527,6 +532,7 @@ a$params <- collect_params(a) # Metadata for the plugin json_meta <- list( name = list(zh_cn = a$apptitle$value$zh, en = a$apptitle$value$en), + alias = if (is.null(a$alias$value)) list(a$appname$value) else list(a$alias$value), intro = list(zh_cn = a$description$value$zh, en = a$description$value$en), src = "", href = paste0("/", a$target$value, "/", a$appname$value),