Created
December 13, 2021 16:19
-
-
Save PostMonsterG/c3cd6f2c4c5df9ca3bc56c0e21920871 to your computer and use it in GitHub Desktop.
A sample Drumkit script to open the contents of the current outline in iA Writer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<opml version="2.0"> | |
<head> | |
<title>OpenInIAWriterAsNewFile</title> | |
<dateCreated>Mon, 22 Nov 2021 02:05:51 GMT</dateCreated> | |
<flPublic>true</flPublic> | |
<urlPublic>http://drummer.scripting.com/PostMonsterG/OpenInIAWriterAsNewFile.opml</urlPublic> | |
<ownerTwitterScreenName>PostMonsterG</ownerTwitterScreenName> | |
<ownerName>Gary Teter</ownerName> | |
<ownerId>http://twitter.com/PostMonsterG</ownerId> | |
<urlUpdateSocket>ws://drummer.scripting.com:1232/</urlUpdateSocket> | |
<dateModified>Mon, 13 Dec 2021 16:12:35 GMT</dateModified> | |
<expansionState>1,7,14,21,22,24,25,32,33</expansionState> | |
<lastCursor>8</lastCursor> | |
</head> | |
<body> | |
<outline text="<b>Open in iA Writer as New File</b>" created="Sun, 21 Nov 2021 20:08:38 GMT" isComment="false"> | |
<outline text="This Drumkit sends the text from the current outline to iA Writer as a new document." created="Sun, 21 Nov 2021 01:37:48 GMT" isComment="true"/> | |
<outline text="" created="Tue, 23 Nov 2021 20:40:21 GMT" isComment="true"/> | |
<outline text="Created by Gary Teter. " created="Sun, 21 Nov 2021 01:45:54 GMT" isComment="true"/> | |
<outline text="This is the second version, updated with a note, in case anyone opens this file." created="Tue, 23 Nov 2021 20:27:32 GMT" isComment="true"/> | |
<outline text="" created="Thu, 25 Nov 2021 23:52:56 GMT" isComment="true"/> | |
<outline text="// <b>Please note, extremely important</b>" created="Thu, 25 Nov 2021 23:52:59 GMT"> | |
<outline text="I am leaving this file public, with this edit, because it is referenced in some issues on GitHub, and taking it down would be rude." created="Thu, 25 Nov 2021 23:57:10 GMT" isComment="true"/> | |
<outline text="I may update this file as I make new versions of this script, but please do not confuse this with anything resembling any sort of a software release process. You can't tell if I've changed it when you weren't looking. When I update this file with version three, version two will be gone. There will be no history. This is no way to release code, of course. I am just trying to state the obvious, so everybody knows it is obvious. I am pretty sure that particular formulation is from an editorial Ted Nelson wrote back when he was editor of Creative Computing." created="Fri, 26 Nov 2021 00:10:00 GMT" isComment="true"/> | |
<outline text="" created="Fri, 26 Nov 2021 00:01:51 GMT" isComment="true"/> | |
</outline> | |
<outline text="" created="Tue, 23 Nov 2021 20:27:11 GMT" isComment="true"/> | |
<outline text="// <b>To use this</b>" created="Sun, 21 Nov 2021 01:46:44 GMT"> | |
<outline text="Select <b>Open in iA Writer as New File</b> from your scripts menu" created="Sun, 21 Nov 2021 01:46:51 GMT" isComment="true"/> | |
<outline text="The text from the current outline will be sent to iA Writer as a new document." created="Sun, 21 Nov 2021 20:05:11 GMT" isComment="true"/> | |
<outline text="Indentation and node structure is ignored." created="Sun, 21 Nov 2021 20:06:05 GMT" isComment="true"/> | |
<outline text="Each node becomes a new line of text." created="Mon, 22 Nov 2021 00:48:17 GMT" isComment="true"/> | |
<outline text="There is a 4,000-character limit to the amount of text which can be sent this way." created="Mon, 22 Nov 2021 00:25:43 GMT" isComment="true"/> | |
<outline text="" created="Tue, 23 Nov 2021 20:30:04 GMT" isComment="true"/> | |
</outline> | |
<outline text="// <b>To install this</b>" created="Tue, 23 Nov 2021 16:23:24 GMT" isComment="false"> | |
<outline text="Select this entire outline, i.e., the above "<b>Open in iA Writer as New File</b>" node that contains all this" created="Mon, 22 Nov 2021 01:30:51 GMT" isComment="true"/> | |
<outline text="Copy it (cmd-C)" created="Mon, 22 Nov 2021 01:34:09 GMT" isComment="true"/> | |
<outline text="<b>File → Special Files... → Scripts menu... </b>" created="Sun, 21 Nov 2021 01:54:15 GMT" isComment="true"/> | |
<outline text="Paste this outline (cmd-V) " created="Sun, 21 Nov 2021 01:55:14 GMT" isComment="true"/> | |
<outline text="There should be a new entry in your scripts menu named "Open in iA Writer as New File"" created="Mon, 22 Nov 2021 01:33:34 GMT" isComment="true"/> | |
<outline text="" created="Tue, 23 Nov 2021 16:29:35 GMT" isComment="true"/> | |
</outline> | |
<outline text="// <b>Here is the code</b>" created="Tue, 23 Nov 2021 20:33:18 GMT"> | |
<outline text="" created="Tue, 23 Nov 2021 20:33:29 GMT"/> | |
<outline text="EnsureBuffer()" created="Tue, 23 Nov 2021 20:35:47 GMT"/> | |
<outline text="GetOutlineContents()" created="Tue, 23 Nov 2021 20:36:51 GMT"/> | |
<outline text="const url = BuildURL()" created="Tue, 23 Nov 2021 20:37:08 GMT"/> | |
<outline text="webBrowser.openUrl( url )" created="Sun, 21 Nov 2021 23:27:59 GMT"/> | |
<outline text="" created="Tue, 23 Nov 2021 20:34:26 GMT"/> | |
<outline text="// <b>Functions</b>" created="Tue, 23 Nov 2021 20:34:29 GMT"> | |
<outline text="// <b>Ensure buffer</b>" created="Mon, 22 Nov 2021 01:09:26 GMT"> | |
<outline text="function EnsureBuffer() {" created="Tue, 23 Nov 2021 20:35:09 GMT"> | |
<outline text="Probably not the right way to do this, but I ran into scoping issues with op.visitAll" created="Mon, 22 Nov 2021 01:25:30 GMT" isComment="true"/> | |
<outline text="if (root.temp == undefined) { root.temp = new Object() }" created="Sun, 21 Nov 2021 23:12:10 GMT" isComment="false"/> | |
<outline text="root.temp.chunks = """ created="Sun, 21 Nov 2021 23:04:39 GMT"/> | |
<outline text="}" created="Mon, 22 Nov 2021 01:16:51 GMT"/> | |
<outline text="" created="Tue, 23 Nov 2021 20:35:28 GMT"/> | |
</outline> | |
</outline> | |
<outline text="// <b>Get the contents of the outline</b>" created="Mon, 22 Nov 2021 01:09:31 GMT"> | |
<outline text="function GetOutlineContents() {" created="Tue, 23 Nov 2021 20:36:06 GMT"> | |
<outline text="const cursor = op.getCursor()" created="Wed, 07 Apr 2021 16:53:43 GMT"/> | |
<outline text="op.firstSummit()" created="Sun, 21 Nov 2021 22:02:10 GMT"/> | |
<outline text="op.visitAll( " created="Sun, 21 Nov 2021 20:12:27 GMT" isComment="false"> | |
<outline text="function(node, level) {" created="Mon, 22 Nov 2021 01:05:01 GMT"> | |
<outline text="const line = node.getLineText()" created="Sun, 21 Nov 2021 23:53:50 GMT"/> | |
<outline text="root.temp.chunks = root.temp.chunks + line + "\n"" created="Sun, 21 Nov 2021 23:46:13 GMT"/> | |
<outline text="})" created="Sun, 21 Nov 2021 20:14:25 GMT"/> | |
</outline> | |
</outline> | |
<outline text="op.setCursor( cursor )" created="Wed, 07 Apr 2021 16:54:22 GMT"/> | |
<outline text="}" created="Mon, 22 Nov 2021 01:16:55 GMT"/> | |
<outline text="" created="Tue, 23 Nov 2021 20:36:38 GMT"/> | |
</outline> | |
</outline> | |
<outline text="// <b>Construct the URL</b>" created="Mon, 22 Nov 2021 01:11:48 GMT"> | |
<outline text="function BuildURL() {" created="Tue, 23 Nov 2021 20:37:42 GMT"> | |
<outline text="var encoded = encodeURI( root.temp.chunks )" created="Sun, 21 Nov 2021 23:49:22 GMT" isComment="false"/> | |
<outline text="encoded = string.multipleReplaceAll( encoded, {" created="Sun, 21 Nov 2021 23:38:15 GMT" isComment="false"> | |
<outline text=""#" : "%23"" created="Sun, 21 Nov 2021 23:39:58 GMT"/> | |
<outline text="})" created="Sun, 21 Nov 2021 23:38:53 GMT"/> | |
</outline> | |
<outline text="const url = "ia-writer://new?edit=true&text=" + encoded" created="Sun, 21 Nov 2021 23:20:29 GMT"/> | |
<outline text="return url" created="Tue, 23 Nov 2021 20:38:03 GMT"/> | |
<outline text="}" created="Mon, 22 Nov 2021 18:06:36 GMT"/> | |
</outline> | |
</outline> | |
</outline> | |
</outline> | |
</outline> | |
</body> | |
</opml> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment