-
Notifications
You must be signed in to change notification settings - Fork 24
Installing Zotero Components On a Mac
- Install Node
brew install node
Alternatively, if a specific version of Node is required, you may want to install Node via nvm (similar to rvm, but for Node) https://github.com/creationix/nvm
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
Then install node via nvm
nvm install 0.12
nvm use 0.12
Homebrew currently installs Node.js version 0.12.7 which is the minimal required by the Arkivo code. You shouldn't need to use nvm. Run node --version
to see what version is on your system.
- Install arkivo-sufia
I am using my_apps to represent the directory above where you have scholarsphere currently installed
cd my_apps
mkdir arkivo-sufia
cd arkivo-sufia
npm install arkivo-sufia hiredis arkivo
- Configure arkivo-sufia
mkdir config
vi config/default.json
Paste in default json
{
"arkivo": {
"plugins": [ "arkivo-sufia" ]
}
}
- Check to make sure the sufia plugin is installed
$(npm bin)/arkivo-plugins list
You should see the following output
1 plugin(s) available.
sufia: Synchronizes data to a Sufia host.
- Run arkivo-sufia
The following command will run arkivo in the current context and output debug information about what is happening as arkivo runs. Omit the DEBUG= if you do not wish to see the debug
DEBUG=arkivo:*,zotero* $(npm bin)/arkivo up
The rest of the directions assume you leave this running
- Configuring ScholarSphere for zotero
You will need an account on Zotero (see sites for the PSU account) and then go to zotero oauth to generate or retrieve a key.
Once you have the Client Secret and Client Key edit scholarsphere/config/zotero.yml to include them and restart your rails server
You will need to leave ScholarSphere running. Make sure you run ScholarSphere with rails s -b 127.0.0.1
because that's how Arkivo will attempt to communicate with it.
- Create arkivo tokens for the existing users
rake sufia:user:tokens
-
Test the zotero Connection
-
Edit a user profile and you should see "Zotero Profile" as an option
-
Click on "Link with Zotero"
-
Authorize with zotero and allow access
-
You should be redirected to your ScholarSphere profile and see "Successfully connected to Zotero!"
-
Configure ScholarSphere for arkivo-sufia
cd scholarsphere
cp config/arkivo.yml.sample config/arkivo.yml
Note: In development this is likely enough since the arkivo-sufia server is running on the same machine as scholarsphere. In production you will need to edit the file to point to the running version of arkivo-sufia
-
Restart both your rails server and your resque jobs
-
Testing arkivo-sufia connection
In the future zotero will have a way to publish items from the zotero screens. Once published those items should automatically show up in /dashboard/files for a user that has connected with zotero. Currently we can test the connection using a testing script called mypubs.
-
Download mypubs from https://zotero-temp.s3.amazonaws.com/mypubs/mypubs-tester-1.0.0.zip
-
unzip into a directory at the same level as arkivo-sufia
cd my_apps unzip mypubs-tester-1.0.0.zip ls my_apps my_apps/scholarsphere my_apps/arkivo-sufia my_apps/mypubs
-
configure the testing script
-
create an api key (different from OAuth Client Key, and Client Secret) by https://www.zotero.org/settings/keys Make sure to check the boxes for "Allow write access"
-
update the testing script with the api key, and userID from Zotero (which will likely be a 6 digit number) found on https://www.zotero.org/settings/keys
``` cd mypubs vi config/default.json _replace the bogus userid and apikey with the one you created in the step above_ ```
- install the dependencies
``` npm install ```
- run the test script (you should have arkivo-sufia running from step 5 and ScholarSphere running from step 6)
``` npm start ```
-
In ScholarSphere, check your my/files you should see a file appear
-
To delete the file run the test script
node --harmony deleteItems.js
-
-
Trouble Shooting the connection
-
I see "Unhandled rejection Error: Forbidden" from the testing script 1. you need to edit the user key on zotero and check
Allow write access
-
I run the test script and nothing happens on the arkivo-sufia window Check the subscriptions for arkivo-sufia
$(npm bin)/arkivo-subscriptions list
you should see the userID you configure in mypubs/config/default.json- I do not see my user in the list, the subscription was not made
- Check your resque for a failed "ARKIVO_SUBSCRIPTION" job
- make sure arkivo-sufia is running
- load the user in the rails console and clear the zotero conection for the user
- edit to the user's profile and authorize zotero
- reload the user in the rails console and validate that it has an arkivo_subscription
-
I see "plugin sufia failed: connect ECONNREFUSED" in the arkivo-sufia window 1. you may need to set the url correctly (scholarsphere/config/initializers/arkivo_constraint.rb is where this access is set to allow IP addresses access) look above the error for the url being used 1. you may need to run your server with an IPV 4 ip
rails s -b 127.0.0.1
-
I run the script and I see action in the archivo-sufia window with no errors, but files do not show up 1. check to make sure the user configured in mypubs is the user you are looking at in scholarsphere
- load the user in the rails console and compare zotero_userid with mypubs/config/default.json "userID"
-
Miscellaneous commands needed for testing
-
Clearing the zotero connection for a user in the rails console
cd scholarsphere rails c > u = User.find_by(login:"cam156") > u.arkivo_subscription = nil; > u.zotero_token = nil; > u.zotero_userid = nil; > u.save
Re-run `rake sufia:user:tokens` to initialize the users and then re-connect the user profile to Zotero.
-
Deleting documents sent by the testing script so you can run it again
cd mypubs node --harmony deleteItems.js
-
listing subscriptions in arkivo-sufia
```
cd arkivo-sufia
$(npm bin)/arkivo-subscriptions list
```
- Deleting a subscription in arkivo-sufia
```
cd arkivo-sufia
$(npm bin)/arkivo-subscriptions list #see the subcription hash for the user you wish to delete
$(npm bin)/arkivo-subscriptions rm <hash found in list>
```