chrisbro Posted June 17, 2017 Posted June 17, 2017 (edited) 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. bst -- Search for a tag (a group of notes) by tag title and open it in Bear. Creating a new note bn I love notes! -- Creates a new note with the title and text "I love notes!" bn I love notes! #love #notes -- Creates a new note with the title and text "I love notes!" and the tags "#love" and "#notes" 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 deanishe for guidance on Alfred workflow creation and capabilities, and for his excellent Python workflow library. dfay for guidance from his experience writing the Ulysses Alfred workflow. Rhyd Lewis for giving me an excellent example to work off of in his Omnifocus Alfred workflow. 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. Edited July 21, 2017 by chrisbro 0.3.1 release richlin71, bivalvegruff, Grug and 1 other 1 3
td. Posted July 20, 2017 Posted July 20, 2017 Hey, nice workflow! Thanks! Unfortunately, it doesn't work anymore since the latest update from Bear (Version 1.2.2) That is the error message:
deanishe Posted July 20, 2017 Posted July 20, 2017 @td. As a rule, pictures aren't much help with trying to diagnose and fix problems. At a minimum, please also include any output in Alfred's debugger.
GuiB Posted July 20, 2017 Posted July 20, 2017 (edited) @td. it seems the path to Bear database has changed (or I don't know, I just tried the workflow now since your post made me think that I could look at a workflow for Bear...). @chrisbro, I made it works by changing the database path in the script "queries.py" at line 11 to 13 From: DB_LOCATION = ( "/Library/Containers/net.shinyfrog.bear/Data/Library/Application Support/" "net.shinyfrog.bear/database.sqlite") To: DB_LOCATION = ( "/Library/Containers/net.shinyfrog.bear/Data/Documents/Application Data/database.sqlite") Also, ( @td., you may need to do that as well) the cached database didn't update so I deleted the "db_path.cpickle" in "~/Library/Application Support/Alfred 3/Workflow Data/com.chrisbro.bear/db_path.cpickle" and after that, now everything seems to be working Here is an updated version while @chrisbro update his version : https://nofile.io/f/wSoOfp0ILrP/Bear.alfredworkflow Edited July 20, 2017 by GuiB
chrisbro Posted July 21, 2017 Author Posted July 21, 2017 @td. @GuiB Thanks for the heads up, y'all! I hadn't updated Bear yet with its recent update so hadn't detected it yet. Sure enough, upgrading in the App Store broke it. Let me hack up a fix real quick and release it.
chrisbro Posted July 21, 2017 Author Posted July 21, 2017 (edited) @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. Edited July 21, 2017 by chrisbro
td. Posted July 21, 2017 Posted July 21, 2017 @chrisbro @GuiB Awesome, it works. Thanks man One more thing: When you type bn title #tag it creates a note with title as h1 and as content. Like this: # title title #tag Shouldn't it be just like this: # title #tag Or is it a known issue or even by design? Thanks
chrisbro Posted July 21, 2017 Author Posted July 21, 2017 @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
td. Posted July 21, 2017 Posted July 21, 2017 Ok, nice Let me chip in some ideas if you like. Note creating (bn) 1. Focus the editor afterward, so you can start typing your note right away 2. Automatically insert two breaks after the tag like in the following image. That's my default layout and I assume the one from the majority? Maybe, I don’t know! 3. Show tag suggestions as soon as you type # like in bs. That would be awesome! Yeah, that’s it for now. Nice that you are so responsive!
chrisbro Posted July 22, 2017 Author Posted July 22, 2017 @td. Thank you for the suggestions! I think they're great ideas that I'd like to implement, so I've created enhancement issues on Github to track them. A couple sound tricky but I do love a good challenge. Feel free to reach out to me if you ever have any other ideas! td. and dunkaroo 2
dunkaroo Posted July 23, 2017 Posted July 23, 2017 (edited) Just wanna say thank you for the wonderful work!! : ) request: multi word search Edited July 23, 2017 by dunkaroo
Jakub Sypiański Posted September 1, 2017 Posted September 1, 2017 (edited) I tried both @chrisbro's and @guib's updates, but I still get this "no such table: ZSFNOTE" error Edited September 1, 2017 by Jakub Sypiański
turanturan Posted September 30, 2017 Posted September 30, 2017 (edited) Thanks for the workflow, this is exactly what I was looking for! Maybe I'm finally ready to transfer my recipe bookmarks from browser to Bear as I'm able to search for them properly. BTW I had the same error than Jakub here before me and I thought the workflow is just broken. Now after few weeks I decided to try again and it works like a charm! What changed in between? I went Pro! Maybe that could affect this workflow? Not sure though, but if that's the problem you might want to add a note about it in Github. Edited September 30, 2017 by turanturan
chrisbro Posted October 20, 2017 Author Posted October 20, 2017 I'm reaching out to the Bear support channel to see what's causing this "no such table" error - it's tough to reproduce even on similar setups, and a reboot fixed it for someone out there experiencing it. If I can figure out what the deal is I'll try to code around it!
LynneS Posted October 31, 2017 Posted October 31, 2017 On 7/21/2017 at 2:04 PM, td. said: Ok, nice Let me chip in some ideas if you like. Note creating (bn) 1. Focus the editor afterward, so you can start typing your note right away 2. Automatically insert two breaks after the tag like in the following image. That's my default layout and I assume the one from the majority? Maybe, I don’t know! 3. Show tag suggestions as soon as you type # like in bs. That would be awesome! Yeah, that’s it for now. Nice that you are so responsive! I second this suggestion. This is exactly the way I do my notes. Great workflow!
alfredclough Posted June 6, 2018 Posted June 6, 2018 I had created a Bear workflow to automate a few things and this workflow adds some really helpful functionality. Thank you
alfredclough Posted June 6, 2018 Posted June 6, 2018 I'm not sure if anyone else has run into this, but it seems like the ability to open a tag in bear does not work if a tag has spaces in it. I'm guessing something's not getting encoded properly somewhere?
alfredclough Posted June 7, 2018 Posted June 7, 2018 I found the bug fix for tags with spaces. In the script that is run by the Bear Search Tag trigger to open Bear, the first line of the script is: orig_query={query} It needs to be changed to enclose {query} in quotes otherwise any tag with spaces in it will fail. Here is what the corrected line should be: orig_query="{query}"
chrisbro Posted June 9, 2018 Author Posted June 9, 2018 Nice find @alfredclough, I'll see if that changes any behavior and tee it up to include.
russcore Posted September 19, 2018 Posted September 19, 2018 Ahoy, looks like Shiny Frog has moved away from sqlite for their backend in the latest release. I've emailed support to confirm and will make a PR on GitHub if there's an easy fix, otherwise if anybody knows more than I do right now that would be great :)
chrisbro Posted September 19, 2018 Author Posted September 19, 2018 @russcore we have a discussion going on a Github issue opened for it here. It looks like the sqlite database location just moved again, so hopefully it's a quick patch.
chrisbro Posted September 19, 2018 Author Posted September 19, 2018 And we're fixed now @russcore ! Download the latest and install from here.
edbro Posted September 20, 2018 Posted September 20, 2018 I'm still getting the same "no such table: ZSFNOTE" using the latest workflow version 0.3.2. I tried uninstalling the previous version and installing the latest but I still get the error.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now