Jump to content
greghoch

Zotero Support

Recommended Posts

Hi,

 

it would be great if Alfred would work together with Zotero so that Zotero references can be searched from Alfred. How could that be implemented?  The 'search Mail.app' workflow shows the results from a mail search. I am thinking about something similar. What does Alfred need to do that? What scripting would be necessary?

 

Thanks! 

Share this post


Link to post
Share on other sites

I'm not too familiar with Zotero so I could totally off key here but first off we'd have to know where and how Zotero stores its data.

Is it open? Do they have some form of API?

With this info it could be feasible.

Share this post


Link to post
Share on other sites

I'm not too familiar with Zotero so I could totally off key here but first off we'd have to know where and how Zotero stores its data.

Is it open? Do they have some form of API?

With this info it could be feasible.

 

There are basically two ways to access Zotero's data:

 

(A) A server API, which is well documented: http://www.zotero.org/support/dev/server_api/v2/start

Here is also a python library: https://github.com/urschrei/pyzotero

Maybe there are also libraries for other languages

 

(b ) Access the local zotero database (read only). It's a SQLite database. The documentation isn't very good but it's easy to open and take a look at. 

http://www.zotero.org/support/dev/client_coding/direct_sqlite_database_access

Here is a python project that reads the local database: https://github.com/smathot/qnotero

Edited by greghoch

Share this post


Link to post
Share on other sites

There are basically two ways to access Zotero's data:

 

(A) A server API, which is well documented: http://www.zotero.org/support/dev/server_api/v2/start

Here is also a python library: https://github.com/urschrei/pyzotero

Maybe there are also libraries for other languages

 

(b ) Access the local zotero database (read only). It's a SQLite database. The documentation isn't very good but it's easy to open and take a look at. 

http://www.zotero.org/support/dev/client_coding/direct_sqlite_database_access

Here is a python project that reads the local database: https://github.com/smathot/qnotero

It shouldn't be too difficult then to get a functional workflow. I don't have much free time right now but when I do get some, if nobody has tackled this then I'll give it a go.

Share this post


Link to post
Share on other sites

Yeah me too.. I've been longing for that for such a long time...If you can implement that Pedro, that would be amazingly welcome :)

 

I am pretty far with a workflow that allows you to search for items in your zotero database, open attachments and reveal items in zotero standalone. But it's still going to take some time before I can share the version, which requires adding some settings for the location of the zotero database etc. 

Share this post


Link to post
Share on other sites

Hi,

 

is there already progress on a Zotero workflow?

Zotero integration would be greatly appreciated!

 

 

For now, the workflow is running with two operations: a) open attachment file, B) reveal item in Zotero library. 

It is not as fast I would hope though (despite caching) and I still need to implement some settings (mainly directory of zotero library). I will also not really be able to maintain the workflow. So are there people who could help with the last steps and be willing to contribute to maintaining the workflow? I will clean things up and upload it to github over the next days with a beta release.

Share this post


Link to post
Share on other sites

Hi,

 

didn't see the post until today. opening attachments and finding items is great.

Looking forward to installing the workflow.

For maintenance: not sure I can contribute - not a skilled programmer at all.

cheers

Share this post


Link to post
Share on other sites

For now, the workflow is running with two operations: a) open attachment file, B) reveal item in Zotero library. 

It is not as fast I would hope though (despite caching) and I still need to implement some settings (mainly directory of zotero library). I will also not really be able to maintain the workflow. So are there people who could help with the last steps and be willing to contribute to maintaining the workflow? I will clean things up and upload it to github over the next days with a beta release.

I'd love to see a beta of this workflow, and I'd also be willing to work on keeping it running. Is it up on GitHub yet?

Share this post


Link to post
Share on other sites

I have a beta version of a Zotero workflow that I've just gotten off the ground. No actions yet, I've just been fiddling with the script filter. I think I've figured out how to access the local zotero database, regardless of the user (assuming it is consistently located nested within the ~/Library/Application Support/Zotero folder). It is also pretty darn fast. I would love to have a really robust Zotero + Alfred workflow out there, so I'm willing to merge/work together. Hopefully I will get this beta code up on GitHub soon. If you're interested tho, just shoot me a message.

 

stephen

Share this post


Link to post
Share on other sites

The first collection of code is now up on GitHub. The project isn't complete, particularly on the backend. I haven't finished my code for formatting the data once you choose an item. I've spent a vast majority of my time on the true heart of the workflow, which is the script that reads the user's Zotero sqlite database and creates a JSON cache of the citation information. I have also written filters to search that cache generally, title-specific, author-specific, tag-specific, and collection-specific. 

 

This workflow is written in Python using the alp module. 

 

All of the code can be found here: https://github.com/smargh/ZotQuery

 

Feel free to fork anything and help me along.

Share this post


Link to post
Share on other sites

I have put my code on github and invited you as a collaborator. It's private now just because I wanted to get it to you as quickly as possible and still have to check whether there is some private information in there. Afterwards, I will make it public.

 

I haven't looked at the code for a long time so I don't even know whether I included everything. Let me know whether it is working. You have to change the location of the zotero folder in 'cache.py' (mine is not at the default location). It's the zotero_folder variable. I don't think the location is defined anywhere else but maybe I am wrong. 

 

The workflow itself is actually pretty elaborate. You can search zotero items using fuzzy search (‘Ein1931’ would list ’Einstein-1931-Theory’ as one of the top hits), open attachment files or reveal items in the zotero library using cmd as a modifier key. If there are multiple attachments, I am using chaining to open a separate Aldred window that lists the attachments. The Zotero library is cached and updated whenever the zotero file changes. I always had the feeling that the workflow is a little to slow but maybe that is because my library is big and because I want things to be instant. There are two other things missing:
- settings (e.g. to define the location of the zotero library)
- The chaining approach for multiple attachments is way to slow for my taste and there has to be a better approach. My old notes are "filter like the skype workflow" but not sure about that. 

Share this post


Link to post
Share on other sites

Alright. Thanks. I can see the code. Could you also push the actual .workflow file? Its really hard to get a sense of the structure without the big-picture as well. 

 

I already see that we both worked off of libzotero. I ended up highly modifying that stuff (creating my own hybrid versions of sqlite queries) but its at the foundation of my workflow as well. With your auto-cache updating, did you have any problems when Zotero itself was open. I've found that when the app is open, the sqlite database is locked, so I can't read any data. It's primarily for this reason that I made the cache updating manual (so the user can ensure that the app is closed). 

 

Anyway, I'm going to explore some, and I'll get back to you. I'd love to hear your thoughts tho on the functionality you were envisioning. It seems like the goal was to have a simpler search mechanism. So the actions you could take on the item once you chose it was either to open its attachment, or open the Zotero app at that item? I'm interested in formatting the item for inserting in a document, as well as your functions. But like I said, I haven't gotten to that stuff yet. 

Share this post


Link to post
Share on other sites

The workflow file is on github now with '~/Library/Application Support/Zotero' as the location of the Zotero folder. So it might work out of the box but I haven't tested it. 

 

I also modified parts of libzotero but I don't remember how much. My goal was a quick search and lookup function and I never had problems with the caching file zotero is running. Right now, the workflow always caches after a search has ended because it would slow down the search when I do it first. 

Share this post


Link to post
Share on other sites

Well, I've already learned something. Your Gnotero-based script can cache even with Zotero running because the libzotero script creates a clone .sqlite database first, and then reads from that. You can clone a .sqlite database, even if it is locked, while you cannot read/write a locked database. I'm about to update my code accordingly. 

 

Would you be interested in collaborating to create a single workflow? I tried hard to comment out much of my code, to make it fairly explanatory, so that should help somewhat in reaching a modicum of equal knowledge. It will take me a while to digest all of your code (I'm still fairly new to Python, plus, like most decent workflows, there are alot of moving parts and scripts). But I think having one kick-ass workflow for Zotero would be awesome. And I know splitting the coding would save some time (after the initial catch up on each ind. project). It will undoubtedly take time to figure out which parts to merge and how best to merge them, so if that sounds to time-consuming, we can go our separate ways. Tho I would still like to chat. 

 

Let me know what you think,

stephen

Share this post


Link to post
Share on other sites

I really like the idea but my plate is pretty full right now and I wasn't planing to work on my code anytime soon. I am happy to have a conversation though and answer some question if my code is confusing so that you can better use it. How does that sound?

Share this post


Link to post
Share on other sites

Can you confirm that the workflow is working for you, Shawn? The nature of the initial replies is such that only people with problems speak up. It's been working great for me, but I want to ensure that this workflow does indeed function for other people. 

 

I'm also working on a static page on my blog that will have the full README, and along the way I will be posting short blurbs on how I use the workflow in my writing process. 

Share this post


Link to post
Share on other sites

After our debugging marathon, the workflow is great and awesome, and it's definitely good enough I think that a feature request for native Zotero integration with Alfred2 is now moot.

 

Good job, smarg.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...