From a66a3fa73f10b7b600734ea5b03a44f8aa97bb54 Mon Sep 17 00:00:00 2001 From: David Moss Date: Sat, 29 Mar 2025 14:20:40 +1000 Subject: [PATCH 01/14] Create README.md initial creation of the folder --- packages/logseq-rot13/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/logseq-rot13/README.md diff --git a/packages/logseq-rot13/README.md b/packages/logseq-rot13/README.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/packages/logseq-rot13/README.md @@ -0,0 +1 @@ + From cb17e3b480384782636f6cfffabb5fdee23b4c70 Mon Sep 17 00:00:00 2001 From: David Moss Date: Sat, 29 Mar 2025 14:24:16 +1000 Subject: [PATCH 02/14] Add files via upload Upload files for plugin --- packages/logseq-rot13/index.html | 15 +++ packages/logseq-rot13/index.js | 49 +++++++++ packages/logseq-rot13/logseq_ROT13.md | 148 ++++++++++++++++++++++++++ packages/logseq-rot13/package.json | 14 +++ 4 files changed, 226 insertions(+) create mode 100644 packages/logseq-rot13/index.html create mode 100644 packages/logseq-rot13/index.js create mode 100644 packages/logseq-rot13/logseq_ROT13.md create mode 100644 packages/logseq-rot13/package.json diff --git a/packages/logseq-rot13/index.html b/packages/logseq-rot13/index.html new file mode 100644 index 00000000..786ab446 --- /dev/null +++ b/packages/logseq-rot13/index.html @@ -0,0 +1,15 @@ + + + + + + + Logseq Hello World + + +
+ + + + + diff --git a/packages/logseq-rot13/index.js b/packages/logseq-rot13/index.js new file mode 100644 index 00000000..91fae455 --- /dev/null +++ b/packages/logseq-rot13/index.js @@ -0,0 +1,49 @@ + +/** + * ROT13 + * AUTHOR: David Moss + * DESCRIPTION: performs the classic ROT13 encryption on every block on a page. + * Performing it again reveals the original text + * ROT13 is often used to obfuscate text to avoid shoulder surfing. + */ +function main() { + logseq.Editor.registerSlashCommand('ROT13', async (e) => Rot13()); + +} + +function rotate(thing) { + let code = thing.charCodeAt(0); +//console.log(code + ".." + String.fromCharCode(code)); + if (code > 64 && code < 91) { + // uppercase letter + if (code < 78) { + code = code + 13; + } + else { + code = code - 13; + } + } + + if (code > 96 && code < 123) { + // lowercase letter + if (code < 110) { + code = code + 13; + } + else { + code = code - 13; + } + } + return String.fromCharCode(code); +} + +async function Rot13(e) { + var inblocks = await logseq.Editor.getCurrentPageBlocksTree(); + for (const block of inblocks) { + let output = block.content.split("").map(rotate); + await logseq.Editor.updateBlock(block.uuid, output.join("")); + } +} + + +// bootstrap +logseq.ready(main).catch(console.error); diff --git a/packages/logseq-rot13/logseq_ROT13.md b/packages/logseq-rot13/logseq_ROT13.md new file mode 100644 index 00000000..4b8caaa3 --- /dev/null +++ b/packages/logseq-rot13/logseq_ROT13.md @@ -0,0 +1,148 @@ +- Ebg13 vf na boshfgvpngvba zrgubq gung ebgngrf rnpu punenpgre va n fgevat ol 13 cynprf va gur nycunorg. +- Rot13 is an obfustication method that rotates each character in a string by 13 places in the alphabet. +- Ercrngvat n EBG13 tvirf onpx gur bevtvany grkg. +- Repeating a ROT13 gives back the original text. +- ROT13 is a logseq plugin I wrote to obfuscate a list of passwords I keep in logseq. +- There is an excellent guiide to setting up your development environment for writing logseq plugins at: https://gist.github.com/xyhp915/bb9f67f5b430ac0da2629d586a3e4d69 +- Logseq plugins are written in Javascript. +- They live in their own folder and consist of 3 files: + 1. index.html + 2. index.js + 3. package.json + +- It is best to start with skeletons of these files and fill in your own code where needed. +- index.html is as basic as it gets. Copy and use it as is: +- + ```html + + + + + + + Logseq Hello World + + +
+ + + + + + ``` +- Notice there is a
with an id of app. This is where your plugin displays stuff when needed. Same as in React. +- The first - - - - - ``` -- Notice there is a
with an id of app. This is where your plugin displays stuff when needed. Same as in React. -- The first - - - -