Bear Integration

I’ve been trying to set up a running append note in bear for each day using Drafts the same as the one I have running with Evernote. This was easy with even more because of the way Drafts integrates Evernote. Could we have the same integration for Bear?

Thanks

Ian

Unfortunately I don’t believe that type of interaction is possible as Bear doesn’t have an API that is accessible by third party devs like Evernote does.

But you can create actions with a URL scheme with /add-text Action from Bears URL scheme documentation, which can be found here: http://www.bear-writer.com/faq/X-callback-url%20Scheme%20documentation/

Hi John

Thanks for that. I wasn’t aware it was api based. I have to tried to set it up using the bear url scheme before and technically it is possible but the append using a variable in the title doesn’t seem to work.

Thanks

Ian

I just finished up an posted a Bear integration guide which links to a couple of example actions, including one that demonstrates appending to a monthly journal. Hopefully this is some help.

Josh is right that Bear does not have a web API to integrate with like Evernote, but you can accomplish most of the same things with their URL schemes.

They might have one eventually, they keep saying that they’re working on a web version, maybe they will add an API too?

Thanks Greg. I’ll give it a try.

Ian

Hi Greg

I tried it and it worked as designed and it wouldn’t be hard to change to a day journal but it doesn’t do the bit I’ve struggled with the url scheme which is to time stamp each entry so I end up with one note each day containing time stamped entries.

As shared yours just includes each entry workout ant indication of when each entry was made.

Ian

It can be a little more tricky to configure in a URL because of the encoding requirements, but the same template tags as any template in Drafts are applicable.

In the case of the bear example you mention, you would need to change the text=[[draft]] parameter so it also contains the timestamp…likely something like: text=[[time]]%0A[[draft]]. This would add the time value, and a line feed. The “%0A” is a URL encoded line feed.

You can also make sure a string is URL encoded using {{ }} in a Drafts template.

To tweak that, check on other available tags in the template docs.

You might be interested by the script API I wrote for Bear: Bear script API.

The code to do what I understood you want is pretty simple:

var title = "Journal for " + draft.createdAt.toLocaleDateString();
var text = draft.content + "\n_" + draft.createdAt.toLocaleString() + "_";
Bear.appendTo(title, "section", text);

(you an install it from the action directory)

Thanks Olivier

This gets me much closer than I got using the url scheme. I’ll play a little with it.

One initial problem I’m seeing is is not respecting my timezone which is Pacific.

Thanks

Ian

Weird, it does respect my timezone. Did you note it uses the creation date and not the modification date?

You can simply swap createdAt by modifiedAt if you want the modification date. You can also use Date.now().

The timezone thing may have something to do with my devices as one was set to automatic and one manual although both were set to Vancouver.

Also it adds to notes in trash, but that is only really a problem when testing.

Thanks again.

You’re welcome, I hope you’ll sort out your timezone problem.

I thought “excluding trash” would have been the default behaviour for “add-text”. I updated the BearAPI action to specify it.

Thanks, appreciate it.