From e16455ab0691db805430d3166d2225417cd4994c Mon Sep 17 00:00:00 2001 From: hidao80 <8155294+hidao80@users.noreply.github.com> Date: Sun, 29 Apr 2018 14:37:09 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E3=82=BF=E3=82=B0=E4=BB=98=E3=81=8D?= =?UTF-8?q?=E6=8A=95=E7=A8=BF=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/tsumiqiita.css | 11 ++++++++++- src/index.html | 3 ++- src/js/functions.js | 30 ++++++++++++++++++++---------- src/package.json | 4 +++- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/css/tsumiqiita.css b/src/css/tsumiqiita.css index 8b097d7..b092219 100644 --- a/src/css/tsumiqiita.css +++ b/src/css/tsumiqiita.css @@ -13,11 +13,20 @@ html,body { margin: 0; width: calc(100vw - 2px); } +#tags-label { + font-size: 1rem; + width: 3rem; +} +#tags { + border: 1px solid darkgray; + margin: 0; + width: calc(100vw - 22px - 3rem); +} #tsumiqiita-editor { overflow-x: hidden; overflow-y: scroll; border: 1px solid darkgray; - height: calc(50vh - 2px); + height: calc(50vh - 2px - 1.1rem); margin: 0; resize: none; width: calc(100vw - 22px); diff --git a/src/index.html b/src/index.html index c4ad1ee..3925226 100644 --- a/src/index.html +++ b/src/index.html @@ -40,7 +40,7 @@
- + 限定公開に失敗しました…
@@ -52,6 +52,7 @@
+ タグ:
diff --git a/src/js/functions.js b/src/js/functions.js index 180d2a5..4990377 100644 --- a/src/js/functions.js +++ b/src/js/functions.js @@ -141,6 +141,23 @@ function setToken() { config.set("TOKEN", document.querySelector('#input').value); } +function getTags() { + const text = document.querySelector("#tags").value; + let ret = []; + let tags = text.trim().split(" "); + + for(let i = 0; i < tags.length; i++) { + tmp = tags[i].split(":"); + if (tmp.length < 2) { + ret.push({"name":tmp[0]}); + } else { + ret.push({"name":tmp[0], "versions": [tmp[1]]}); + } + } + console.log(JSON.stringify(ret)); + return ret; +} + function post() { const Config = require('electron-config'); const config = new Config(); @@ -159,25 +176,18 @@ function post() { let markdown = fs.readFileSync(p, 'utf-8'); let title = filename.replace(/(\.md)+$/,""); - + var options = { "body": markdown, "private": true, - "tags": [ - { - "name": "TsumiQiita", - "versions": [ - "1.2.0" - ] - } - ], + "tags": getTags(), "title": title }; //execution api Qiita.Resources.Item.create_item(options).then(function(res){ console.log(res); - if (parseInt(res.statusCode, 10) >= 400) { + if (res.message != undefined) { document.querySelector('#ng-dialog').showModal(); } else { document.querySelector('#ok-dialog').showModal(); diff --git a/src/package.json b/src/package.json index 7d8680f..18fdc50 100644 --- a/src/package.json +++ b/src/package.json @@ -8,7 +8,9 @@ }, "scripts": { "build-css": "node-sass scss/default-theme.scss css/style.css", - "build-win": "electron-packager . TsumiQiita --out=../build --pratform=win32 --arch=ia32 --overwrite --asar", + "build-win": "electron-packager . TsumiQiita --out=../build --pratform=win32 --overwrite --asar", + "build-win32": "electron-packager . TsumiQiita --out=../build --pratform=win32 --arch=ia32 --overwrite --asar", + "build-win64": "electron-packager . TsumiQiita --out=../build --pratform=win32 --arch=x64 --overwrite --asar", "build-mac": "electron-packager . TsumiQiita --out=../build --pratform=darwin --arch=x64 --overwrite --asar", "build-linux": "electron-packager . TsumiQiita --out=../build --pratform=linux --arch=ia32 --overwrite --asar", "build": "electron-packager . TsumiQiita --out=../build --overwrite --asar"