Jump to content

chrisbro

Member
  • Posts

    17
  • Joined

  • Last visited

Posts posted by chrisbro

  1. @td. I guess I could say it was "by design" but I think that's giving me too much credit. I didn't know which approach I'd like (or users would like) so I had it write the Alfred text entry to both title and text. You're the second or third person to ask me if that's a bug or not, though, so at this point I'm going to remove it for the next version :) 

  2. @td. @GuiB Fixed! Again, thanks so much for bringing it to my attention. I hacked up a cache bust to fix the location it points to - it checks the location key, and if it detects the old version, attempts to find the new version instead. Hopefully this is backwards-compatible for people who haven't upgraded - I'll test it out when I get to work since I haven't upgraded Bear there yet.

  3. Hey everyone! I've created a workflow that allows you to search and create notes for Bear. This is my first workflow, first OSS project, and first foray into Python - let me know what all I messed up :) Available on github and Packal. Many thanks to @deanishe and @dfay for some initial direction.

     

    Install

    To install, download a released alfred-bear workflow and double-click to open in Alfred 3. Easy-peasy.

    Searching and opening results

    bs -- Search for a note by title and open it in Bear.

     

    bs.png

     

     

    bst -- Search for a tag (a group of notes) by tag title and open it in Bear.

    bst.png

    Creating a new note

    bn I love notes! -- Creates a new note with the title and text "I love notes!"

    bn1.png

     

     

    bn I love notes! #love #notes -- Creates a new note with the title and text "I love notes!" and the tags "#love" and "#notes"

    bn2.png

    Known Issues

    • Creating tags only works with single-word tags - multiword tags hopefully to come.

    Todo

    • Append text to existing notes.
    • Figure out multi-word tags.

    Thanks

    Versions

    0.3.1

    • Fixed database location that changed with a Bear update.

    0.3.0

    • Added search results from note text to main search.

    0.2.2

    • Changed search queries to order by last modified date descending, so that more recently modified notes/tags show up at the top.

    0.2.1

    • Added hashtag symbol to "Open Tag" list results to make it a little more obvious that it's a tag and not a note.

    0.2.0

    • Now allows non-ASCII characters.
    • Searching by tag now displays not only tags that match the search query, but notes that match those tags as well.
    • Searching by tag now works with or without the '#' symbol in front of the tag.

     

    0.1.0 

    • Initial public release.
  4. Just now, deanishe said:

    I think you may have misunderstood how x-callback-url works. It isn't HTTP. It is implemented by iOS/macOS, and the system handles the calls.

     

    An app registers a URI scheme, e.g. bear://, and when you call such a URI via macOS, it directs the call to the registered application.

     

    As I understand it, you also do not get a response from the application. What you do instead is pass an x-callback-url for the application to call with the result, i.e. it calls your app back with the result.

     

    As such, you need to create your own app that registers your own URI scheme.

     

    Thanks for the response! I'm definitely misunderstanding, it looks. I was getting thrown off because I can hit that x-callback-url create endpoint in the code snippet in my first post, and it works just fine - it does indeed create a note like I'd expect. I just have no way to get at the callback response from AppleScript. My original assumption is that I was looking for a normal ol' synchronous response, not a callback, because that's what I get for trying to use my brain in the middle of the night when I can't sleep. So this all makes sense now.

     

    @deanishe it looks like I can't call back to Alfred this way, though? I see a little conversation here but can't make out if Alfred has a callback endpoint I can leverage. 

  5. 15 minutes ago, vitor said:

    Especially since x-callback-url is a crappy and hacky solution and it’s insane to do it on macOS. Most apps don’t do it for good reason. For as much as we complain about AppleScript, an AppleScript dictionary is still miles ahead of an x-callback-url in terms of experience.

     

    That's fair. Thank you for your time.

     

    Anyone else have ideas on how to get responses back from arbitrarily-protocoled HTTP requests in a way that Alfred can parse it? Just saw this ("Fetching Data from the Web") and will give that a go next.

  6. Hello! I started to work on creating my own workflow that would allow me to create and search Bear notes. I quickly ran into some problems that I don't think there are reasonable workarounds for, but I wanted to get some opinions first.

     

    My problem is that Bear's extensibility comes via their implementation of the x-callback-url spec. I need to be able to call these URLs from within an Alfred workflow and parse the response. My first approach has been to use AppleScript...this works fine for creating a new note, as I don't need a response. 

    set createUrl to "bear://x-callback-url/create?title=" & my urlencode(sTitle) & "&text=" & my urlencode(sText)
    open location createUrl

    However, I now want to leverage their search endpoint, which requires parsing the response. This doesn't seem doable from within Alfred. The AppleScript open location command does not provide a result - so I can call a URL, but not retrieve anything from it. Therefore, I can't leverage the search endpoint.

     

    I tried getting clever by calling a shell script that then called curl, but curl errors out because it doesn't recognize the "bear://" protocol. I could do "open" from the shell, but that opens the app - not very useful when I just want to grab search results and put them into Alfred.

     

    Any thoughts? Any other clever ways to do this? Given that this x-callback-url spec seems to be gaining traction, it might make a good feature request to add this inter-app messaging natively into Alfred as an action. 

     

    Thanks!

×
×
  • Create New...