├── media ├── intro-YT-VID.png ├── setup-run-script.png ├── setup-Add-the-template.png ├── setup-credentials-in-script.png ├── setup-napkin-variables-01.png ├── setup-templater-templates.png ├── setup-open-insert-template-modal.png └── setup-api-token-in-napkin-profile.png ├── LICENSE ├── Templater Scripts └── Send selected Obsidian text to Napkin.md └── README.md /media/intro-YT-VID.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TfTHacker/obsidian-to-napkin/HEAD/media/intro-YT-VID.png -------------------------------------------------------------------------------- /media/setup-run-script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TfTHacker/obsidian-to-napkin/HEAD/media/setup-run-script.png -------------------------------------------------------------------------------- /media/setup-Add-the-template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TfTHacker/obsidian-to-napkin/HEAD/media/setup-Add-the-template.png -------------------------------------------------------------------------------- /media/setup-credentials-in-script.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TfTHacker/obsidian-to-napkin/HEAD/media/setup-credentials-in-script.png -------------------------------------------------------------------------------- /media/setup-napkin-variables-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TfTHacker/obsidian-to-napkin/HEAD/media/setup-napkin-variables-01.png -------------------------------------------------------------------------------- /media/setup-templater-templates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TfTHacker/obsidian-to-napkin/HEAD/media/setup-templater-templates.png -------------------------------------------------------------------------------- /media/setup-open-insert-template-modal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TfTHacker/obsidian-to-napkin/HEAD/media/setup-open-insert-template-modal.png -------------------------------------------------------------------------------- /media/setup-api-token-in-napkin-profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TfTHacker/obsidian-to-napkin/HEAD/media/setup-api-token-in-napkin-profile.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 TfTHacker 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Templater Scripts/Send selected Obsidian text to Napkin.md: -------------------------------------------------------------------------------- 1 | <%* 2 | // Updated 2023-05-10 3 | 4 | // Description: Sends selected text in Obsidian to Napkin 5 | 6 | // Prerequisites 7 | // 1. Templater Plugin installed in Obsidian https://obsidian.md/plugins?id=templater-obsidian 8 | // 2. Active Napkin Account. Sign up here: https://www.napkin.one/?via=TfTHacker 9 | 10 | // SETUP 11 | // Add your Napkin Token and email address you registered with Napkin to the following parameters 12 | const NAPKING_INFO = { 13 | token: "", 14 | email: "" 15 | } 16 | 17 | // The following text string will be inserted into Obsidian for ideas sent to Napkin. 18 | // NAPKIN_URL will be replaced with the URL received by Napkin. 19 | // You can replace any text with what you want, just leave NAPKIN_URL 20 | // If you don't want anything to be inserted, just have “” with nothing in the quotes. 21 | const LINK_TO_NAPKIN_IDEA = " [*](NAPKIN_URL) #napkin_idea"; 22 | 23 | async function apiNapkinSendThought(newThought, source) { 24 | try { 25 | return await tp.obsidian.request({ 26 | url: "https://app.napkin.one/api/createThought", 27 | method: "POST", 28 | contentType: "application/json", 29 | body: JSON.stringify({ 30 | token: NAPKING_INFO.token, 31 | email: NAPKING_INFO.email, 32 | thought: newThought, 33 | sourceUrl: source, 34 | }), 35 | throw: true 36 | }) 37 | } catch(e) { 38 | return null; // Likely the token or email in not valid 39 | } 40 | } 41 | 42 | async function createNapkinAPIThoughtFromSelection(){ 43 | const character_limit = 500 // Character limit for the message. 44 | const notice_milliseconds = 5000 // number of milliseconds to show a notice 45 | 46 | if(app.workspace.activeEditor.currentMode.type!="source") { 47 | new Notice(`Napkin: document is not in source mode.`, notice_milliseconds); 48 | return; 49 | } 50 | 51 | let selection = app.workspace.activeEditor.getSelection(); // Get currently selected text in Editor 52 | if(selection.length===0) { 53 | new Notice(`Napkin: no text is selected.`, notice_milliseconds); 54 | return; 55 | } 56 | if(selection.length>NAPKING_INFO.character_limit) { 57 | new Notice(`Napkin: The selection is too long. Please limit the selection to ${NAPKING_INFO.character_limit} characters.`, notice_milliseconds); 58 | return; 59 | } 60 | 61 | const deeplink = "obsidian://open?"+ 62 | "vault=" + encodeURIComponent(app.vault.getName()) + 63 | "&file=" + encodeURIComponent(tp.config.active_file.path); 64 | 65 | console.log("Sending ...") 66 | console.log("Idea:", selection) 67 | console.log("source:", deeplink) 68 | let response = await apiNapkinSendThought(selection, deeplink); 69 | console.log(response); 70 | if(response===null) { 71 | new Notice(`Napkin: The text was not sent to Napkin. Likely the token or email in not valid. Please check these values in the template script.`, notice_milliseconds) 72 | } else { 73 | // Success posting to the Napkin API. Make a note in the document 74 | if(LINK_TO_NAPKIN_IDEA==="") new Notice(`Napkin: The idea was saved to Napkin.`, notice_milliseconds); 75 | selection = selection + LINK_TO_NAPKIN_IDEA.replace("NAPKIN_URL", JSON.parse(response).url); 76 | } 77 | 78 | app.workspace.activeEditor.editor.replaceSelection(selection); 79 | } 80 | 81 | await createNapkinAPIThoughtFromSelection() 82 | 83 | %> -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Obsidian to Napkin Toolbox 2 | This repository contains tools to help send notes (thoughts and ideas) from an [Obsidian](https://obsidian.md) vault to [Napkin](https://www.napkin.one). 3 | 4 | These tools help us to leverage the best of both of these tools. Obsidian is an amazing long-form note-taking tool, while Napkin helps us in a unique visual way to be inspired and more creative by leveraging the ideas we capture in our life. 5 | 6 | ## Watch this tool in action! 7 | Click the image to view it on YouTube: 8 | [![YouTube](/media/intro-YT-VID.png)](https://www.youtube.com/watch?v=-t0dUdfc7PY) 9 | 10 | ## Support my work 11 | If you like my work and would like to help support it, please consider signing up for a Medium membership using my referral link: [https://bit.ly/o42-medium](https://bit.ly/o42-medium) or buy me a coffee at: [https://bit.ly/o42-kofi](https://bit.ly/o42-kofi). 12 | 13 | # Prerequisites 14 | 1. Templater Plugin installed in Obsidian. It is available from this [link](https://obsidian.md/plugins?id=templater-obsidian). 15 | - We assume you have some basic knowledge of using Templater. 16 | 2. An active Napkin account. Sign up for Napkin at this [link](https://www.napkin.one/?via=TfTHacker) if you do not have an account. 17 | 18 | # Installation 19 | **Summary** 20 | This looks harder than it is. Just follow the steps closely and it will be ready to go quickly. 21 | 22 | **Time needed** 23 | 5 to 10 minutes 24 | 25 | **Overview** 26 | The **Templater Scripts** folder of his repository contains example Templater scripts for sending notes from Obsidian to Napkin. These installation instructions will explain the _Send selected Obsidian text to Napkin.md_, however as we add other scripts in the future to this repository, the installation concepts of these instructions will also apply to them as well. 27 | 28 | ## Step 1 - Confirm Templater Plugin Setup 29 | * Confirm that the [Templater Plugin](https://obsidian.md/plugins?id=templater-obsidian) is installed in Obsidian. 30 | * Confirm that a templates folder is defined in the Templater plugin settings, as shown in the following image: 31 | 32 | ![](media/setup-templater-templates.png) 33 | 34 | **Explanation**: 35 | Templater looks for templates in this folder defined in the plugin settings. You can have many templates in this folder. 36 | 37 | # Step 2 - Add the Template 38 | - Copy the file **Send selected Obsidian text to Napkin.md** file from this repository **Templater Scripts** folder to the Templates folder as defined in the previous step. It will look something like this in Obsidian after you complete this step: 39 | ![](media/setup-Add-the-template.png) 40 | 41 | # Step 3 - Napkin User Credentials 42 | - Next, we need to modify the template file that you copied in Step 2 so that it has your Napkin user credentials. Without this information, the script cannot send information to your Napkin database. 43 | - In the script, near the beginning you will see this text: 44 | ![](media/setup-napkin-variables-01.png) 45 | 46 | - We need two pieces of information. Your Napkin token and your Napkin email address. This can be found in your profile in Napkin. The token is under the API section. You need to create a new API token. It will look something like this: 47 | ![](media/setup-api-token-in-napkin-profile.png) 48 | 49 | - Once you get this information from your Napkin profile, in the template file add your Napkin credentials into the script's variables, in between the quotes. 50 | - Don't worry if you are not a programmer, just make sure your information is typed in between the quotes and will look something like this: 51 | ![](media/setup-credentials-in-script.png) 52 | 53 | > NOTE: The token from Napkin gives the script secure access to your notes. You should never share this token with others. 54 | 55 | # Step 4 - Using the Script 56 | Now that Templater and the template script is all set up, you can use the script to send your ideas from Obsidian to Napkin. 57 | 58 | **To do this**: 59 | * First, _select some text in an Obsidian note_. Make sure Obsidian is in edit mode for the note, as this script does not work with documents in Preview mode. 60 | * After selecting the text, pull up the command palette in Obsidian (CTRL/CMD+P) and select "_Templater: Open Insert Template modal_" 61 | ![](media/setup-open-insert-template-modal.png) 62 | * This will then open up a list of templates to run. Select the script we just installed: 63 | ![](media/setup-run-script.png) 64 | 65 | That is it! This will send the selected text to Napkin. 66 | 67 | Just repeat this step each time you want to send a new thought to Napkin. 68 | 69 | This completes the installation of the script. If you run into problems, please start a discussion on this repository and we will help you resolve the problem. 70 | 71 | # Contribute to this Repository 72 | If you develop your own Templater scripts for "Obsidian to Napkin", please consider sharing them with the community in this repository. 73 | --------------------------------------------------------------------------------