Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Installing Zotero Components On a Mac

Hector edited this page Oct 27, 2015 · 18 revisions
  1. 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.

  1. 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
  1. Configure arkivo-sufia
  mkdir config
  vi config/default.json

Paste in default json

 {
    "arkivo": {
      "plugins": [ "arkivo-sufia" ]
    }
 }
  1. 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.
  1. 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

  1. 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.

  1. Create arkivo tokens for the existing users

This step may not be needed if you do not have any existing users locally, but will be needed on production systems.

  rake sufia:user:tokens
  1. Test the zotero Connection

  2. Edit a user profile and you should see "Zotero Profile" as an option

  3. Click on "Link with Zotero"

  4. Authorize with zotero and allow access

  5. You should be redirected to your ScholarSphere profile and see "Successfully connected to Zotero!"

  6. 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

  1. Restart both your rails server and your resque jobs

  2. 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.

    1. Download mypubs from https://zotero-temp.s3.amazonaws.com/mypubs/mypubs-tester-1.0.0.zip

    2. 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
      
    3. configure the testing script

    4. 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"

    5. 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_
     ```
    
    1. install the dependencies
     ```
        npm install
     ```
    
    1. run the test script (you should have arkivo-sufia running from step 5 and ScholarSphere running from step 6)
     ```
        npm start
     ```
    
    1. check your my/files you should see a file appear

    2. To delete the file run the test script

         node --harmony deleteItems.js
      
  3. Trouble Shooting the connection

  4. 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

  5. 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

    1. I do not see my user in the list, the subscription was not made
    2. Check your resque for a failed "ARKIVO_SUBSCRIPTION" job
      1. make sure arkivo-sufia is running
      2. load the user in the rails console and clear the zotero conection for the user
      3. edit to the user's profile and authorize zotero
      4. reload the user in the rails console and validate that it has an arkivo_subscription
  6. 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

  7. 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

    1. load the user in the rails console and compare zotero_userid with mypubs/config/default.json "userID"
  8. Miscellaneous commands needed for testing

  9. 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.
  1. Deleting documents sent by the testing script so you can run it again

      cd mypubs
      node --harmony deleteItems.js
    
  2. listing subscriptions in arkivo-sufia

```
  cd arkivo-sufia
  $(npm bin)/arkivo-subscriptions list
```
  1. 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>
```
Clone this wiki locally