Merge branch 'feat/clientapp'
This commit is contained in:
commit
3925bc3212
|
@ -0,0 +1,4 @@
|
|||
tools/nodeclient/node_modules/*
|
||||
tools/nodeclient/note.md
|
||||
tools/nodeclient/package-lock.json
|
||||
tools/nodeclient/package.json
|
|
@ -0,0 +1,63 @@
|
|||
const axios = require("axios");
|
||||
const readline = require("readline");
|
||||
const fs = require("fs");
|
||||
var cp = require("child_process");
|
||||
|
||||
var rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
var settings = JSON.parse(fs.readFileSync("settings.json", { encoding: "utf8", flag: "r" }));
|
||||
|
||||
axios.post(`${settings.url}/handler.php`,
|
||||
{
|
||||
action: "fetch",
|
||||
password: settings.password
|
||||
},
|
||||
{
|
||||
headers:
|
||||
{
|
||||
"Content-type": "application/x-www-form-urlencoded"
|
||||
}
|
||||
})
|
||||
.then(res =>
|
||||
{
|
||||
var notes = res.data;
|
||||
notes.every( (note, i) =>
|
||||
{
|
||||
console.log(`[${i}] ${note.title}`)
|
||||
return i < settings.maxcount;
|
||||
});
|
||||
|
||||
rl.prompt();
|
||||
rl.on("line", (line) =>
|
||||
{
|
||||
var note = notes[line]
|
||||
|
||||
fs.writeFileSync("note.md", note.content);
|
||||
|
||||
cp.exec("sublime_text.exe -w note.md", function (err, stdout, stderr)
|
||||
{
|
||||
var newcontent = fs.readFileSync("note.md", { encoding: "utf8", flag: "r" });
|
||||
|
||||
if (note.content != newcontent)
|
||||
{
|
||||
note.content = newcontent;
|
||||
axios.post(`${settings.url}/handler.php`,
|
||||
{
|
||||
action: "push",
|
||||
password: settings.password,
|
||||
data: JSON.stringify(notes)
|
||||
},
|
||||
{
|
||||
headers:
|
||||
{
|
||||
"Content-type": "application/x-www-form-urlencoded"
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
rl.close();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"password": "",
|
||||
"url": "http://localhost:8000",
|
||||
"maxcount": 50
|
||||
}
|
Loading…
Reference in New Issue