merge conflicts

This commit is contained in:
quenousimporte 2023-07-13 10:37:00 +02:00
commit 0fc50c22cf
2 changed files with 61 additions and 6 deletions

View File

@ -77,7 +77,7 @@ var themes =
{ {
bgcolor: "white", bgcolor: "white",
fontfamily: "'Inconsolata', 'Consolas', monospace", fontfamily: "'Inconsolata', 'Consolas', monospace",
fontsize: "90%", fontsize: "16px",
fontcolor: "black", fontcolor: "black",
lineheight: "130%", lineheight: "130%",
accentcolor: "#5AA7CE" accentcolor: "#5AA7CE"
@ -1538,6 +1538,7 @@ function md2html(content)
converter.setOption("simpleLineBreaks", true); converter.setOption("simpleLineBreaks", true);
converter.setOption("metadata", true); converter.setOption("metadata", true);
converter.setOption("tasklists", true); converter.setOption("tasklists", true);
converter.setOption("literalMidWordUnderscores", true);
if (settings.linksinnewtab) if (settings.linksinnewtab)
{ {

View File

@ -9,6 +9,15 @@ var rl = readline.createInterface({
}); });
var settings = JSON.parse(fs.readFileSync("settings.json", { encoding: "utf8", flag: "r" })); var settings = JSON.parse(fs.readFileSync("settings.json", { encoding: "utf8", flag: "r" }));
var filter = process.argv.length > 2 ? process.argv[2] : "";
var intervalid = null;
var notes = null;
function filteredlist()
{
return notes
.filter(n => n.title.toLowerCase().includes(filter.toLowerCase()));
}
axios.post(`${settings.url}/handler.php`, axios.post(`${settings.url}/handler.php`,
{ {
@ -23,27 +32,36 @@ axios.post(`${settings.url}/handler.php`,
}) })
.then(res => .then(res =>
{ {
var notes = res.data; notes = res.data;
notes.every( (note, i) =>
filteredlist()
.every( (note, i) =>
{ {
console.log(`[${i}] ${note.title}`) console.log(`[${i}] ${note.title}`)
return i < settings.maxcount; return i < settings.maxcount;
}); });
// todo: open if only one match. quit if no match
rl.prompt(); rl.prompt();
rl.on("line", (line) => rl.on("line", (line) =>
{ {
var note = notes[line] var note = filteredlist()[line];
// todo: use title instead? To put in data folder?
fs.writeFileSync("note.md", note.content); fs.writeFileSync("note.md", note.content);
cp.exec("sublime_text.exe -w note.md", function (err, stdout, stderr) cp.exec(`${settings.command} note.md`, function (err, stdout, stderr)
{ {
clearInterval(intervalid);
var newcontent = fs.readFileSync("note.md", { encoding: "utf8", flag: "r" }); var newcontent = fs.readFileSync("note.md", { encoding: "utf8", flag: "r" });
if (note.content != newcontent) if (note.content != newcontent)
{ {
note.content = newcontent; note.content = newcontent;
notes.splice(notes.indexOf(note), 1);
notes.unshift(note);
console.log("sending data file to server...");
axios.post(`${settings.url}/handler.php`, axios.post(`${settings.url}/handler.php`,
{ {
action: "push", action: "push",
@ -55,9 +73,45 @@ axios.post(`${settings.url}/handler.php`,
{ {
"Content-type": "application/x-www-form-urlencoded" "Content-type": "application/x-www-form-urlencoded"
} }
}).then(res => {
console.log("done.");
}); });
} }
else
{
console.log("no change.");
}
}) })
intervalid = setInterval(function()
{
//todo: refactor "save"
var newcontent = fs.readFileSync("note.md", { encoding: "utf8", flag: "r" });
if (note.content != newcontent)
{
note.content = newcontent;
notes.splice(notes.indexOf(note), 1);
notes.unshift(note);
console.log("sending data file to server...");
axios.post(`${settings.url}/handler.php`,
{
action: "push",
password: settings.password,
data: JSON.stringify(notes)
},
{
headers:
{
"Content-type": "application/x-www-form-urlencoded"
}
}).then(res => {
console.log("done.");
});
}
}, 10000);
rl.close(); rl.close();
}); });
}); });