summaryrefslogtreecommitdiff
path: root/src/client/app/common/scripts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-04-30 12:15:41 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-04-30 12:15:41 +0900
commit759719d1249f8f8a5644dff3abf26278c77355c7 (patch)
treef81945f27309846628dd5340f39862fa1d34d3e3 /src/client/app/common/scripts
parent:art: (diff)
downloadsharkey-759719d1249f8f8a5644dff3abf26278c77355c7.tar.gz
sharkey-759719d1249f8f8a5644dff3abf26278c77355c7.tar.bz2
sharkey-759719d1249f8f8a5644dff3abf26278c77355c7.zip
Improve MisskeyPages
Diffstat (limited to 'src/client/app/common/scripts')
-rw-r--r--src/client/app/common/scripts/aiscript.ts4
-rw-r--r--src/client/app/common/scripts/collect-page-vars.ts16
2 files changed, 17 insertions, 3 deletions
diff --git a/src/client/app/common/scripts/aiscript.ts b/src/client/app/common/scripts/aiscript.ts
index 50c73421e1..99caec8c15 100644
--- a/src/client/app/common/scripts/aiscript.ts
+++ b/src/client/app/common/scripts/aiscript.ts
@@ -97,6 +97,7 @@ type PageVar = { name: string; value: any; type: Type; };
const envVarsDef = {
AI: 'string',
+ URL: 'string',
VERSION: 'string',
LOGIN: 'boolean',
NAME: 'string',
@@ -120,7 +121,7 @@ export class AiScript {
public static blockDefs = blockDefs;
public static funcDefs = funcDefs;
private opts: {
- randomSeed?: string; user?: any; visitor?: any;
+ randomSeed?: string; user?: any; visitor?: any; page?: any; url?: string;
};
constructor(variables: Variable[] = [], pageVars: PageVar[] = [], opts: AiScript['opts'] = {}) {
@@ -131,6 +132,7 @@ export class AiScript {
this.envVars = {
AI: 'kawaii',
VERSION: version,
+ URL: opts.page ? `${opts.url}/@${opts.page.user.username}/pages/${opts.page.name}` : '',
LOGIN: opts.visitor != null,
NAME: opts.visitor ? opts.visitor.name : '',
USERNAME: opts.visitor ? opts.visitor.username : '',
diff --git a/src/client/app/common/scripts/collect-page-vars.ts b/src/client/app/common/scripts/collect-page-vars.ts
index 86687e21f4..92727ce6db 100644
--- a/src/client/app/common/scripts/collect-page-vars.ts
+++ b/src/client/app/common/scripts/collect-page-vars.ts
@@ -2,10 +2,22 @@ export function collectPageVars(content) {
const pageVars = [];
const collect = (xs: any[]) => {
for (const x of xs) {
- if (x.type === 'input') {
+ if (x.type === 'textInput') {
pageVars.push({
name: x.name,
- type: x.inputType,
+ type: 'string',
+ value: x.default
+ });
+ } else if (x.type === 'textareaInput') {
+ pageVars.push({
+ name: x.name,
+ type: 'string',
+ value: x.default
+ });
+ } else if (x.type === 'numberInput') {
+ pageVars.push({
+ name: x.name,
+ type: 'number',
value: x.default
});
} else if (x.type === 'switch') {