Jump to content

dfay

Member
  • Posts

    1,054
  • Joined

  • Last visited

  • Days Won

    62

Posts posted by dfay

  1. I've run into this issue as well, and don't have a ready solution.  I think any kind of automated sync / merge would probably not be worth the effort to build (for me at least) b/c the # of use cases are so few and the modifications I have made usually only take 5-10 minutes to replicate.  Fortunately most of the workflows I've modified have been fairly stable (or to put it less kindly, abandoned by the authors) so I haven't run into it lately....

     

    One thing which might help would be an option to "Update as Copy" vs. "Update Existing Workflow" i.e. to have the option to create a new instance of the workflow which could then be manually compared to the old modified version.

  2. These were the directions I followed:

     

    https://yourmacguy.wordpress.com/2013/07/17/make-your-own-url-handler/

     

    and here's the script that I used in the handler (complete with all my commented-out testing lines):

     

    on open location theURL
        -- set theURL to "sourceapp://x-callback-url/success?targetId=jsvEPFa6vvq3vDmrAt4KGA&targetURL=ulysses://x-callback-url/open?id%3DjsvEPFa6vvq3vDmrAt4KGA"
        
        --    display dialog theURL
        
        set x to the offset of "ulysses" in theURL
        set y to the offset of "?id%3D" in theURL
        
        --    display dialog y
        
        set theNewSheet to text from x to y of theURL & "id=" & text from (y + 6) to -1 of theURL
        
        --    display dialog theNewSheet
        
        tell application "BibDesk"
            set thePublications to the selection of document 1
            repeat with thePub in thePublications
                add theNewSheet to thePub
            end repeat
        end tell
        
    end open location
     
    and here's the script for the workflow itself:
     
    tell application "BibDesk"
    	activate
    	-- without document, there is no selection, so nothing to do
    	if (count of documents) = 0 then
    		beep
    		display dialog "No documents found." buttons {"•"} default button 1 giving up after 3
    	end if
    	
    	set thePublications to selection of document 1
    	
    	repeat with thePub in thePublications
    		export document 1 using template "exportMarkdown" to clipboard for thePub
    		set Markdown_link to ""
    		set CiteKey to cite key of item 1 of thePub
    		set ItemURL to "x-bdsk://" & CiteKey
    		--			set itemName to title of item i of thePub
    		set theWikiLink to "[" & CiteKey & "]" & "(" & ItemURL & ")"
    		set Markdown_link to (Markdown_link) & theWikiLink
    		set theText to ("# " & (the clipboard) & Markdown_link)
    		
    		set theKeywords to get keywords of thePub as string
    		set theKeywords to my replace_chars(theKeywords, " ", "_")
    		set theHashtagKeywords to "#" & my replace_chars(theKeywords, ",_", " #")
    		
    		set theTemplate to "
    Date: " & my todayISOformat() & "
    Keywords: " & theHashtagKeywords
    		
    		set theCommand to quoted form of ("ulysses://x-callback-url/new-sheet?x-success=ulbd://x-callback-url/success&text=" & theText & theTemplate)
    		do shell script "open " & theCommand
    	end repeat
    end tell
    
    -- -- --  Helpers -- -- --
    
    on todayISOformat()
    	set theDate to current date
    	set y to text -4 thru -1 of ("0000" & (year of theDate))
    	set m to text -2 thru -1 of ("00" & ((month of theDate) as integer))
    	set d to text -2 thru -1 of ("00" & (day of theDate))
    	return y & "-" & m & "-" & d
    end todayISOformat
    
    on replace_chars(this_text, search_string, replacement_string)
    	set AppleScript's text item delimiters to the search_string
    	set the item_list to every text item of this_text
    	set AppleScript's text item delimiters to the replacement_string
    	set this_text to the item_list as string
    	set AppleScript's text item delimiters to ""
    	return this_text
    end replace_chars

    Most of it's getting stuff ready in BibDesk but the line "set theCommand...." is the important one -- it sets the x-success to return a ulbd:// URL which is what the handler is registered for.

     

    It's kind of a kludge since it's really only designed for this one scenario, rather than processing the callback and doing different things with it but it should give the overall idea.

     

  3. Also - writing a callback handler in AppleScript and registering it is pretty easy - I have one that lets me create a new Ulysses sheet then pass the URL back to BibDesk to attach to a publication record , & I'm happy to share it and the links I used to figure it out if you're interested.  I'd expect that Bear's URL scheme will eventually provide callback info & this may yet be an option.

  4. Look at the work Rob Walton (and I, in lesser capacities) have done with the Ulysses workflow : 

    A lot of the challenges are similar - the solution there relies on parsing the library for some parts of the workflow and using the URL scheme for others.

     

    (Incidentally I was in the early Bear betas and ended up moving everything to Ulysses when I ran into the limits of hashtag-based organization--haven't looked back).

  5. see 

     

    There was another discussion recently re Spark in particular.  Readdle hadn't built in any Applescript support, and if they repeat their approach to PDF Expert on the Mac, they won't in the future, unfortunately.

  6. "You could also have this work as you type by making a specific snippet for every possible pair of twin capitals. Doable, but that’s still over one thousand of them."

     

    Easily generated with a couple nested loops.... Now I want to try it just to see if it will break Alfred....

  7. Basically it looks like you're trying to reinvent the wiki, and honestly I think you'd do much better to use an off-the-shelf solution like WIkidot, where all this infrastructure is taken care of for you and you can concentrate on content. Wikidot has a decent API & it would be pretty easy to build a workflow that queries it.  Or you could use mediawiki & adapt the existing Wikipedia workflows.

×
×
  • Create New...