Skip to content

Commit

Permalink
♻️ img.srcに必要なメタ情報をフロントエンドで付与するように変更 #22
Browse files Browse the repository at this point in the history
  • Loading branch information
jiro4989 committed Dec 10, 2019
1 parent 5a3b4b1 commit b13d5c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 2 additions & 1 deletion websh_front/src/index.nim
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ proc createDom(): VNode =
h4: text "Images"
for img in outputImages:
tdiv:
img(src = img)
# imgでbase64を表示するときに必要なメタ情報を追加
img(src = "data:image/png;base64," & img)
footer(class = &"page-footer {baseColor}"):
tdiv(class = "footer-copyright"):
tdiv(class = "container"):
Expand Down
5 changes: 1 addition & 4 deletions websh_server/src/websh_server.nim
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ router myrouter:
let (dir, name, ext) = splitFile(path)
if ext.toLowerAscii notin [".png", ".jpg", ".jpeg", ".gif"]:
continue
# JavaScriptのimg.srcにセットする時のプレフィックス
let meta = "data:image/png;base64,"
let data = meta & base64.encode(readFile(path))
images.add(data)
images.add(base64.encode(readFile(path)))

resp %*{"stdout":stdoutStr, "stderr":stderrStr, "images":images}
get "/ping":
Expand Down

0 comments on commit b13d5c7

Please sign in to comment.