diff --git a/cli/python/app.py b/cli/app.py
similarity index 100%
rename from cli/python/app.py
rename to cli/app.py
diff --git a/cli/node/app.js b/cli/node/app.js
deleted file mode 100644
index 027ad66..0000000
--- a/cli/node/app.js
+++ /dev/null
@@ -1,217 +0,0 @@
-const axios = require("axios");
-const fs = require("fs");
-const openpgp = require("openpgp");
-var cp = require("child_process");
-
-var settings = JSON.parse(fs.readFileSync("settings.json", { encoding: "utf8", flag: "r" }));
-var pgpkey = fs.readFileSync("key.acs", { encoding: "utf8", flag: "r" });
-var intervalid = null;
-var notes = null;
-var currentnote = null;
-var command = null;
-
-function timestamp()
-{
- var utc = new Date();
- var loc = new Date(utc - utc.getTimezoneOffset() * 60 * 1000);
-
- return loc.toISOString().replace("T", " ").replace(/\..*/, "").replace(/:/g, ".");
-}
-
-function simplifystring(str)
-{
- return str.toLowerCase().normalize('NFD').replace(/\p{Diacritic}/gu, "");
-}
-
-function decrypt(str)
-{
- var keystring = pgpkey.split("-----END PGP PUBLIC KEY BLOCK-----")[1];
- var key = null;
-
- return openpgp.readKey({ armoredKey: keystring })
- .then(privateKey =>
- {
- key = privateKey;
- return openpgp.readMessage({ armoredMessage: str });
- })
- .then(message =>
- {
- return openpgp.decrypt({
- message: message,
- decryptionKeys: key })
- })
- .then(decrypted =>
- {
- var chunks = [];
- for (const chunk of decrypted.data) {
- chunks.push(chunk);
- }
- return chunks.join('');
- });
-}
-
-function encrypt(str)
-{
- var keystring = pgpkey.split("-----BEGIN PGP PRIVATE KEY BLOCK-----")[0];
- var key = null;
- return openpgp.readKey({ armoredKey: keystring })
- .then(publicKey =>
- {
- key = publicKey;
- return openpgp.createMessage({ text: str });
- })
- .then(message =>
- {
- return openpgp.encrypt({
- message: message,
- encryptionKeys: key });
- })
-}
-
-function saveifneeded()
-{
- var newcontent = fs.readFileSync("note.md", { encoding: "utf8", flag: "r" });
- if (currentnote.content != newcontent)
- {
- currentnote.content = newcontent;
-
- notes.splice(notes.indexOf(currentnote), 1);
- notes.unshift(currentnote);
-
- console.log("sending data file to server...");
- encrypt(JSON.stringify(notes))
- .then(encrypted =>
- {
- return axios.post(`${settings.url}/handler.php`,
- {
- action: "push",
- password: settings.password,
- data: encrypted
- },
- {
- headers:
- {
- "Content-type": "application/x-www-form-urlencoded"
- }
- });
- })
- .then(res => {
- console.log("...done.");
- });
- }
- else if (!intervalid)
- {
- console.log("no change.");
- }
-}
-
-function editnote()
-{
- fs.writeFileSync("note.md", currentnote.content);
- cp.exec(`${settings.command} note.md`,
- function (err, stdout, stderr)
- {
- clearInterval(intervalid);
- intervalid = null;
- saveifneeded();
- });
- intervalid = setInterval(saveifneeded, 10000);
-}
-
-// Run part
-if (process.argv.length <= 2)
-{
- command = "list";
-}
-else
-{
- command = process.argv[2];
-}
-
-axios.post(`${settings.url}/handler.php`,
-{
- action: "fetch",
- password: settings.password
-},
-{
- headers:
- {
- "Content-type": "application/x-www-form-urlencoded"
- }
-})
-.then(function(res)
-{
- return decrypt(res.data);
-})
-.then(json =>
-{
- notes = JSON.parse(json);
- switch (command)
- {
- case "help":
- case "-h":
- case "--help":
- var appcmd = "notes";
- console.log(`list notes: ${appcmd} [list]`);
- console.log(`edit a note: ${appcmd} [open|edit]
`);
- console.log(`create a note: ${appcmd} new|create|add []`);
- console.log(`display help: ${appcmd} help|-h|--help`);
- break;
-
- case "new":
- case "create":
- case "add":
- var title = timestamp();
- if (process.argv.length > 3)
- {
- title = process.argv[3];
- }
- if (notes.find(n => n.title == title))
- {
- console.log(`${title}: already exists`);
- }
- else
- {
- currentnote = {
- title: title,
- content: ""
- }
- notes.unshift(currentnote);
- console.log(`Creating new note: ${title}`);
- editnote();
- }
- break;
-
- case "list":
- for (var i = notes.length - 1; i >= 0; i--)
- {
- console.log(`[${i}] ${notes[i].title}`);
- }
- break;
-
- default:
- var arg = command;
- if (arg === "open" || arg === "edit")
- {
- arg = process.argv[3];
- }
- if (isNaN(parseInt(arg)))
- {
- currentnote = notes.find(n => n.title == arg);
- }
- else
- {
- currentnote = notes[parseInt(arg)];
- }
- if (currentnote)
- {
- console.log(`Editing ${currentnote.title}`);
- editnote();
- }
- else
- {
- console.log(`Note ${arg} not found`);
- }
- break;
- }
-});
diff --git a/cli/node/settingssample.json b/cli/node/settingssample.json
deleted file mode 100644
index 081caa8..0000000
--- a/cli/node/settingssample.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "password": "",
- "url": "http://localhost:8000",
- "command": "sublime_text.exe -w"
-}
diff --git a/cli/quick/app.js b/cli/quick/app.js
deleted file mode 100644
index b12d28b..0000000
--- a/cli/quick/app.js
+++ /dev/null
@@ -1,129 +0,0 @@
-function timestamp()
-{
- var utc = new Date();
- var loc = new Date(utc - utc.getTimezoneOffset() * 60 * 1000);
-
- return loc.toISOString().replace("T", " ").replace(/\..*/, "").replace(/:/g, ".");
-}
-
-function editnote()
-{
- var file = std.open("data/note.md", "w");
- file.puts(currentnote.content);
- file.close();
-
- os.exec(["cp", "data/note.md", "data/backup.md"]);
- os.exec(settings.editor.concat("data/note.md"));
-
- var newcontent = std.loadFile("data/note.md");
- if (currentnote.content != newcontent)
- {
- print("diff:");
- os.exec(["diff", "--color", "data/backup.md", "data/note.md"]);
- currentnote.content = newcontent;
-
- notes.splice(notes.indexOf(currentnote), 1);
- notes.unshift(currentnote);
-
- file = std.open("data/data2.json", "w");
- file.puts(JSON.stringify(notes));
- file.close();
-
- os.exec([settings.gpg, "-q", "--encrypt", "--yes", "--trust-model", "always", "--output", "data/data2.acs", "--armor", "-r", settings.gpguser, "data/data2.json"]);
- var newdata = std.loadFile("data/data2.acs");
- console.log("sending data file to server.");
-
- var postdata = "action=push&password=" + settings.password + "&data=" + encodeURIComponent(newdata);
- file = std.open("data/postdata", "w");
- file.puts(postdata);
- file.close();
-
- os.exec(["curl", "-s", "-X", "POST",
- "-d", "@data/postdata",
- settings.url]);
- }
- else
- {
- console.log("no change.");
- }
-}
-
-// Init
-var settings = JSON.parse(std.loadFile("settings.json"));
-var command = scriptArgs.length <= 1 ? "list" : scriptArgs[1];
-var currentnote = null;
-
-// Run part
-if (command == "help" || command == "-h" || command == "--help")
-{
- var appcmd = "./qjs q.js";
- print(`list notes: ${appcmd} [list]`);
- print(`edit a note: ${appcmd} [open|edit] `);
- print(`create a note: ${appcmd} new|create|add []`);
- print(`display help: ${appcmd} help|-h|--help`);
-}
-else
-{
- os.exec(["curl", "-s", "-X", "POST", "-F", "action=fetch", "-F", "password=" + settings.password, "-o", "data/data.acs", settings.url]);
- os.exec([settings.gpg, "-q", "--yes", "--output", "data/data.json", "--decrypt", "data/data.acs"]);
- var notes = JSON.parse(std.loadFile("data/data.json"));
-
- switch (command)
- {
- case "new":
- case "create":
- case "add":
- var title = timestamp();
- if (scriptArgs.length > 2)
- {
- title = scriptArgs[2];
- }
- if (notes.find(n => n.title == title))
- {
- console.log(`${title}: already exists`);
- }
- else
- {
- currentnote = {
- title: title,
- content: ""
- }
- notes.unshift(currentnote);
- console.log(`Creating new note: ${title}`);
- editnote();
- }
- break;
-
- case "list":
- for (var i = notes.length - 1; i >= 0; i--)
- {
- console.log(`[${i}] ${notes[i].title}`);
- }
- break;
-
- default:
- var arg = command;
- if (arg === "open" || arg === "edit")
- {
- arg = scriptArgs[2];
- }
- if (isNaN(parseInt(arg)))
- {
- currentnote = notes.find(n => n.title == arg);
- }
- else
- {
- currentnote = notes[parseInt(arg)];
- }
- if (currentnote)
- {
- console.log(`Editing ${currentnote.title}`);
- editnote();
- }
- else
- {
- console.log(`Note ${arg} not found`);
- }
- break;
- }
-}
diff --git a/cli/quick/settingssample.json b/cli/quick/settingssample.json
deleted file mode 100644
index 7ec5e09..0000000
--- a/cli/quick/settingssample.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "password": "",
- "url": "http://localhost:8000/handler.php",
- "editor": ["vim"],
- "gpg": "gpg",
- "gpguser": ""
-}
diff --git a/cli/python/settingssample.json b/cli/settingssample.json
similarity index 100%
rename from cli/python/settingssample.json
rename to cli/settingssample.json