Skip to content

Instantly share code, notes, and snippets.

@kevinold
Created September 2, 2021 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinold/587866da4f390abda513253dab035451 to your computer and use it in GitHub Desktop.
Save kevinold/587866da4f390abda513253dab035451 to your computer and use it in GitHub Desktop.
/*
Version: 0.1 (Rough and ready!)
Author: David Sim (nationalinterest on discord)
Date: 22 July 2021
Description: Creates links to
TODO: Validate whether the input information is valid
*/
/* Instructions for setup
0) Install Joschua's Bible Study starter kit (or at least the Bible in Markdown) https://forum.obsidian.md/t/bible-study-in-obsidian-kit-including-the-bible-in-markdown/12503
1) Install the QuickAdd community Plugin
2) Copy this js script to a folder in your vault
4) In QuickAdd go to Manage Macros. Create a new macro called Add_Scripture_Macro.
Configure it like this:
In User Scripts select Scripture_Transclude and click Add
Click the "Capture Button" and an "Untitled Capture Choice" will appear.
Click the settings cog next to it and enter:
Capture to Active File
Capture Format
{{VALUE:content}}
You should have two items in the macro.
5) Back in QuickAdd Settings, enter a name (e.g. Add Scripture) and select Macro from the dropdown. Click Add Choice.
In the settings for the choice, select the Add_Scripture_Macro.
6) In QuickAdd Settings, click the little lightening bolt next to Add Scripture to make this active.
Now, when you go to a file, click CONTROL or COMMAND-P and type Add Scripture and you should be able to select the QuickAdd command
There is no validation yet, so selecting e.g. John 150:39-60 will create links to non existant files.
*/
module.exports = async (params) => {
console.log("Starting...")
console.log(params);
const currentFile = params.app.workspace.getActiveFile();
if (!currentFile) {
new Notice("No active file.");
return;
}
console.log("v1 Found active file: ", currentFile.basename);
const biblebooks = [
'Genesis',
'Exodus',
'Leviticus',
'Numbers',
'Deuteronomy',
'Joshua',
'Judges',
'Ruth',
'1 Samuel',
'2 Samuel',
'1 Kings',
'2 Kings',
'1 Chronicles',
'2 Chronicles',
'Ezra',
'Nehemiah',
'Esther',
'Job',
'Psalm',
'Proverbs',
'Ecclesiastes',
'Song of Solomon',
'Isaiah',
'Jeremiah',
'Lamentations',
'Ezekiel',
'Daniel',
'Hosea',
'Joel',
'Amos',
'Obadiah',
'Jonah',
'Micah',
'Nahum',
'Habakkuk',
'Zephaniah',
'Haggai',
'Zechariah',
'Malachi',
'Matthew',
'Mark',
'Luke',
'John',
'Acts',
'Romans',
'1 Corinthians',
'2 Corinthians',
'Galatians',
'Ephesians',
'Philippians',
'Colossians',
'1 Thessalonians',
'2 Thessalonians',
'1 Timothy',
'2 Timothy',
'Titus',
'Philemon',
'Hebrews',
'James',
'1 Peter',
'2 Peter',
'1 John',
'2 John',
'3 John',
'Jude',
'Revelation'
];
const biblebooksShort = [
'Gene',
'Exod',
'Lev',
'Num',
'Deut',
'Josh',
'Judg',
'Ruth',
'1 Sam',
'2 Sam',
'1 Kings',
'2 Kings',
'1 Chron',
'2 Chron',
'Ezr',
'Neh',
'Esth',
'Job',
'Ps',
'Prov',
'Eccles',
'Song',
'Isa',
'Jere',
'Lam',
'Ezek',
'Dan',
'Hos',
'Joel',
'Am',
'Obad',
'Jonah',
'Micah',
'Nah',
'Haba',
'Zepha',
'Hag',
'Zech',
'Mal',
'Matt',
'Mark',
'Luke',
'John',
'Acts',
'Rom',
'1 Cor',
'2 Cor',
'Gal',
'Ephes',
'Phil',
'Col',
'1 Thess',
'2 Thess',
'1 Tim',
'2 Tim',
'Titus',
'Philem',
'Heb',
'James',
'1 Pet',
'2 Pet',
'1 John',
'2 John',
'3 John',
'Jude',
'Rev'
];
const zeroPad = (num, places) => String(num).padStart(places, '0')
/*
let biblechapters = [];
for (let i = 1; i <= 150; i++) {
biblechapters.push(zeroPad(i),2);
}
*/
const book = await params.quickAddApi.suggester(biblebooks,biblebooksShort);
let chapter = await params.quickAddApi.inputPrompt("Chapter (number only)");
chapter = zeroPad(chapter,2);
const v1 = await params.quickAddApi.inputPrompt("Start Verse (number only)");
const v2 = await params.quickAddApi.inputPrompt("End Verse (number only)");
console.log(chapter);
let content = "";
for (let i = v1; i <= v2; i++) {
content += "![["+book+"-"+chapter+"#v"+i+"]]\n";
}
params.variables["content"] = content;
console.log(params.variables["content"]);
console.log("Finished!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment