From 24e1c9fccd4639ff8e395bdc07b87a01ba4eff72 Mon Sep 17 00:00:00 2001 From: jiro Date: Thu, 26 Nov 2020 01:32:02 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20code=E3=82=AF=E3=82=A8=E3=83=AA?= =?UTF-8?q?=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC=E3=82=BF=E3=82=92=E3=81=A4?= =?UTF-8?q?=E3=81=91=E3=81=A6=E3=82=A2=E3=82=AF=E3=82=BB=E3=82=B9=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=81=A8=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88=E3=82=92?= =?UTF-8?q?=E5=9F=8B=E3=82=81=E8=BE=BC=E3=82=93=E3=81=A0=E7=8A=B6=E6=85=8B?= =?UTF-8?q?=E3=81=A7=E7=94=BB=E9=9D=A2=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99?= =?UTF-8?q?=E3=82=8B=20#181=20(#192)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 依存ライブラリのバージョンを上げた * code クエリパラメータでシェルを渡せるようにした #181 * ベースURLを定数化、クエリパラメータをつけたリンクを表示するように変更 * デコード処理を修正 --- websh_front/src/index.nim | 24 ++++++++++++++++++++---- websh_front/websh_front.nimble | 4 ++-- websh_server/websh_server.nimble | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/websh_front/src/index.nim b/websh_front/src/index.nim index e08a164..129cecc 100644 --- a/websh_front/src/index.nim +++ b/websh_front/src/index.nim @@ -1,7 +1,7 @@ from strutils import split from strformat import `&` from unicode import isAlpha, toRunes, runeAt, `==`, `$` -from uri import encodeUrl +from uri import encodeUrl, decodeUrl from sequtils import mapIt, toSeq, filterIt, delete import json except `%*` @@ -32,10 +32,12 @@ let when defined local: # ローカル開発用 - const apiUrl = "http://localhost/api/shellgei" + const baseUrl = "http://localhost" + const apiUrl = &"{baseUrl}/api/shellgei" else: # 本番用 - const apiUrl = "https://websh.jiro4989.com/api/shellgei" + const baseUrl = "https://websh.jiro4989.com" + const apiUrl = &"{baseUrl}/api/shellgei" proc newMediaObj(): MediaObj = MediaObj(name: cstring"", data: cstring"") @@ -58,6 +60,16 @@ if localstorage.hasItem("history"): let hist = localstorage.getItem("history").`$`.parseJson.to(seq[string]) shellHistory.add(hist) +proc getCode(q: string): cstring = + let s = q[1..^1] + let kv = s.split("=") + let v = kv[1] + result = decodeUrl(v) + +let query = window.location[].search.`$` +if 1 < query.len: + inputShell.add(query.getCode) + proc respCb(httpStatus: int, response: cstring) = let resp = fromJson[ResponseResult](response) outputStatus = resp.status @@ -181,7 +193,8 @@ proc createDom(): VNode = setFocus = true, onkeydown = inputTextareaOnkeydown, onkeyup = inputTextareaOnkeyup, - ) + ): + text inputShell for ii in 0..= 1.0.2" -requires "karax#c00d7dc34031aa9a74b54a632b21caaec03d3fea" +requires "nim >= 1.4.0" +requires "karax >= 1.1.3" diff --git a/websh_server/websh_server.nimble b/websh_server/websh_server.nimble index 0043e5e..6e97043 100644 --- a/websh_server/websh_server.nimble +++ b/websh_server/websh_server.nimble @@ -11,6 +11,6 @@ binDir = "bin" # Dependencies -requires "nim >= 1.2.0" +requires "nim >= 1.4.0" requires "jester#7e8df6543a57c3ef31d1e5ae33f88a707486ec11" requires "uuids >= 0.1.10"