Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rfaga/cifonauta
base: 5cc3695770
...
head fork: rfaga/cifonauta
compare: 4b3deb8438
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
55 dummy_settings_local.py
@@ -0,0 +1,55 @@
+# Django settings for weblarvae project.
+
+# Preencha os settings necessários e renomeie para settings_local.py
+
+import os
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+THUMBNAIL_DEBUG = DEBUG
+
+
+ADMINS = (
+ ('Nome', 'Email'),
+)
+
+MANAGERS = ADMINS
+
+# Banco de dados local para desenvolvimento.
+DATABASES = {
+ 'default': {
+ 'NAME': '',
+ 'ENGINE': 'django.db.backends.postgresql_psycopg2',
+ 'USER': '',
+ 'OPTIONS': {
+ 'autocommit': True,
+ }
+ }
+ }
+
+CACHES = {
+ 'default': {
+ 'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
+ 'LOCATION': '',
+ 'TIMEOUT': 3600,
+ 'OPTIONS': {
+ 'MAX_ENTRIES': 100000,
+ }
+ },
+ 'johnny': {
+ 'BACKEND': 'johnny.backends.memcached.MemcachedCache',
+ 'LOCATION': '127.0.0.1:11211',
+ 'JOHNNY_CACHE': False,
+ }
+ }
+
+JOHNNY_MIDDLEWARE_KEY_PREFIX = 'jc_cifo'
+DISABLE_QUERYSET_CACHE = True
+
+CACHE_MIDDLEWARE_ALIAS = 'default'
+CACHE_MIDDLEWARE_SECONDS = 3600
+CACHE_MIDDLEWARE_KEY_PREFIX = 'cifo'
+CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = ''
View
59 dummy_settings_server.py
@@ -0,0 +1,59 @@
+# Django settings for weblarvae project.
+
+# Preencha os settings necessários e renomeie para settings_server.py
+
+import os
+
+DEBUG = False
+TEMPLATE_DEBUG = DEBUG
+THUMBNAIL_DEBUG = DEBUG
+
+
+ADMINS = (
+ ('Nome', 'Email'),
+)
+
+MANAGERS = ADMINS
+
+# Banco de dados local para desenvolvimento.
+DATABASES = {
+ 'default': {
+ 'HOST': '',
+ 'PORT': '',
+ 'NAME': '',
+ 'ENGINE': '',
+ 'USER': '',
+ 'OPTIONS': {
+ 'autocommit': True,
+ }
+ }
+ }
+
+
+CACHES = {
+ 'default': {
+ 'BACKEND': '',
+ 'LOCATION': '',
+ 'TIMEOUT': 3600,
+ 'OPTIONS': {
+ 'MAX_ENTRIES': 1000,
+ }
+ },
+ 'johnny': {
+ 'BACKEND': '',
+ 'LOCATION': '',
+ 'JOHNNY_CACHE': True,
+ }
+ }
+
+JOHNNY_MIDDLEWARE_KEY_PREFIX = 'jc_cifo'
+#DISABLE_QUERYSET_CACHE = True
+
+CACHE_MIDDLEWARE_ALIAS = 'default'
+CACHE_MIDDLEWARE_SECONDS = 3600
+CACHE_MIDDLEWARE_KEY_PREFIX = 'cifo'
+CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
+
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = ''
View
0  external/__init__.py
No changes.
View
13 external/dummy_mendeley.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from mendeley_client import MendeleyClient
+
+# Renomeie o arquivo para mendeley.py após adicionar as chaves abaixo!
+mendeley = MendeleyClient('<consumer_key>', '<secret_key>')
+
+try:
+ mendeley.load_keys()
+except IOError:
+ mendeley.get_required_keys()
+ mendeley.save_keys()
View
603 external/mendeley_client.py
@@ -0,0 +1,603 @@
+"""
+Mendeley Open API Example Client
+
+Copyright (c) 2010, Mendeley Ltd. <copyright@mendeley.com>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+For details of the Mendeley Open API see http://dev.mendeley.com/
+
+Example usage:
+
+>>> from pprint import pprint
+>>> from mendeley_client import MendeleyClient
+>>> mendeley = MendeleyClient('<consumer_key>', '<secret_key>')
+>>> try:
+>>> mendeley.load_keys()
+>>> except IOError:
+>>> mendeley.get_required_keys()
+>>> mendeley.save_keys()
+>>> results = mendeley.search('science')
+>>> pprint(results['documents'][0])
+{u'authors': None,
+ u'doi': None,
+ u'id': u'8c18bd50-6f07-11df-b8f0-001e688e2dcb',
+ u'mendeley_url': u'http://localhost/research//',
+ u'publication_outlet': None,
+ u'title': None,
+ u'year': None}
+>>> documents = mendeley.library()
+>>> pprint(documents)
+{u'current_page': 0,
+ u'document_ids': [u'86175', u'86176', u'86174', u'86177'],
+ u'items_per_page': 20,
+ u'total_pages': 1,
+ u'total_results': 4}
+>>> details = mendeley.document_details(documents['document_ids'][0])
+>>> pprint(details)
+{u'authors': [u'Ben Dowling'],
+ u'discipline': {u'discipline': u'Computer and Information Science',
+ u'subdiscipline': None},
+ u'tags': ['nosql'],
+ u'title': u'NoSQL(EU) Write Up',
+ u'year': 2010}
+"""
+import oauth2 as oauth
+import pickle
+import httplib
+import json
+import urllib
+
+class OAuthClient(object):
+ """General purpose OAuth client"""
+ def __init__(self, consumer_key, consumer_secret, options=None):
+ if options == None: options = {}
+ # Set values based on provided options, or revert to defaults
+ self.host = options.get('host', 'api.mendeley.com')
+ self.port = options.get('port', 80)
+ self.access_token_url = options.get('access_token_url', '/oauth/access_token/')
+ self.request_token_url = options.get('access_token_url', '/oauth/request_token/')
+ self.authorize_url = options.get('access_token_url', '/oauth/authorize/')
+
+ if self.port == 80: self.authority = self.host
+ else: self.authority = "%s:%d" % (self.host, self.port)
+
+ self.consumer = oauth.Consumer(consumer_key, consumer_secret)
+
+ def get(self, path, token=None):
+ url = "http://%s%s" % (self.host, path)
+ request = oauth.Request.from_consumer_and_token(
+ self.consumer,
+ token,
+ http_method='GET',
+ http_url=url,
+ )
+ return self._send_request(request, token)
+
+ def post(self, path, post_params, token=None):
+ url = "http://%s%s" % (self.host, path)
+ request = oauth.Request.from_consumer_and_token(
+ self.consumer,
+ token,
+ http_method='POST',
+ http_url=url,
+ parameters=post_params
+ )
+ return self._send_request(request, token)
+
+ def delete(self, path, token=None):
+ url = "http://%s%s" % (self.host, path)
+ request = oauth.Request.from_consumer_and_token(
+ self.consumer,
+ token,
+ http_method='DELETE',
+ http_url=url,
+ )
+ return self._send_request(request, token)
+
+ def put(self, path, token=None, body=None, body_hash=None, headers=None):
+ url = "http://%s%s" % (self.host, path)
+ request = oauth.Request.from_consumer_and_token(
+ self.consumer,
+ token,
+ http_method='PUT',
+ http_url=url,
+ parameters={'oauth_body_hash': body_hash}
+ )
+ return self._send_request(request, token, body, headers)
+
+ def request_token(self):
+ response = self.get(self.request_token_url).read()
+ token = oauth.Token.from_string(response)
+ return token
+
+ def authorize(self, token, callback_url = "oob"):
+ url = 'http://%s%s' % (self.authority, self.authorize_url)
+ request = oauth.Request.from_token_and_callback(token=token, callback=callback_url, http_url=url)
+ return request.to_url()
+
+ def access_token(self, request_token):
+ response = self.get(self.access_token_url, request_token).read()
+ return oauth.Token.from_string(response)
+
+ def _send_request(self, request, token=None, body=None, extra_headers=None):
+ request.sign_request(oauth.SignatureMethod_HMAC_SHA1(), self.consumer, token)
+ conn = self._get_conn()
+ if request.method == 'POST':
+ conn.request('POST', request.url, body=request.to_postdata(), headers={"Content-type": "application/x-www-form-urlencoded"})
+ elif request.method == 'PUT':
+ final_headers = request.to_header()
+ if extra_headers is not None:
+ final_headers.update(extra_headers)
+ conn.request('PUT', request.url, body, headers=final_headers)
+ elif request.method == 'DELETE':
+ conn.request('DELETE', request.url, headers=request.to_header())
+ else:
+ conn.request('GET', request.url, headers=request.to_header())
+ return conn.getresponse()
+
+ def _get_conn(self):
+ return httplib.HTTPConnection("%s:%d" % (self.host, self.port))
+
+class MendeleyRemoteMethod(object):
+ """Call a Mendeley OpenAPI method and parse and handle the response"""
+ def __init__(self, details, callback):
+ self.details = details # Argument, URL and additional details.
+ self.callback = callback # Callback to actually do the remote call
+
+ def __call__(self, *args, **kwargs):
+ url = self.details['url']
+ # Get the required arguments
+ if self.details.get('required'):
+ required_args = dict(zip(self.details.get('required'), args))
+ if len(required_args) < len(self.details.get('required')):
+ raise ValueError('Missing required args')
+
+ for (key, value) in required_args.items():
+ required_args[key] = urllib.quote_plus(str(value))
+
+ url = url % required_args
+
+ # Optional arguments must be provided as keyword args
+ optional_args = {}
+ for optional in self.details.get('optional', []):
+ if kwargs.has_key(optional):
+ optional_args[optional] = kwargs[optional]
+
+ # Do the callback - will return a HTTPResponse object
+ response = self.callback(url, self.details.get('access_token_required', False), self.details.get('method', 'get'), optional_args)
+ status = response.status
+ body = response.read()
+ content_type = response.getheader("Content-Type")
+ ct = content_type.split("; ")
+ mime = ct[0]
+ attached = None
+ try:
+ content_disposition = response.getheader("Content-Disposition")
+ cd = content_disposition.split("; ")
+ attached = cd[0]
+ filename = cd[1].split("=")
+ filename = filename[1].strip('"')
+ except:
+ pass
+
+ if mime == 'application/json':
+ # HTTP Status 204 means 'No Content' which json.loads cannot deal with
+ if status == 204:
+ data = ''
+ else:
+ data = json.loads(body)
+ return data
+ elif attached == 'attachment':
+ return {'filename': filename, 'data': body}
+ else:
+ return response
+
+class MendeleyClient(object):
+ # API method definitions. Used to create MendeleyRemoteMethod instances
+ methods = {
+ ######## Public Resources ########
+ 'details': {
+ 'required': ['id'],
+ 'optional': ['type'],
+ 'url': '/oapi/documents/details/%(id)s/',
+ },
+ 'categories': {
+ 'url': '/oapi/documents/categories/',
+ },
+ 'subcategories': {
+ 'url': '/oapi/documents/subcategories/%(id)s/',
+ 'required': ['id'],
+ },
+ 'search': {
+ 'url': '/oapi/documents/search/%(query)s/',
+ 'required': ['query'],
+ 'optional': ['page', 'items'],
+ },
+ 'tagged': {
+ 'url': '/oapi/documents/tagged/%(tag)s/',
+ 'required': ['tag'],
+ 'optional': ['cat', 'subcat', 'page', 'items'],
+ },
+ 'related': {
+ 'url': '/oapi/documents/related/%(id)s/',
+ 'required': ['id'],
+ 'optional': ['page', 'items'],
+ },
+ 'authored': {
+ 'url': '/oapi/documents/authored/%(author)s/',
+ 'required': ['author'],
+ 'optional': ['page', 'items'],
+ },
+ 'public_groups': {
+ 'url': '/oapi/documents/groups/',
+ 'optional': ['page', 'items', 'cat']
+ },
+ 'public_group_details': {
+ 'url': '/oapi/documents/groups/%(id)s/',
+ 'required': ['id'],
+ },
+ 'public_group_docs': {
+ 'url': '/oapi/documents/groups/%(id)s/docs/',
+ 'required': ['id'],
+ 'optional': ['details', 'page', 'items'],
+ },
+ 'public_group_people': {
+ 'url': '/oapi/documents/groups/%(id)s/people/',
+ 'required': ['id'],
+ },
+ 'author_stats': {
+ 'url': '/oapi/stats/authors/',
+ 'optional': ['discipline', 'upandcoming'],
+ },
+ 'paper_stats': {
+ 'url': '/oapi/stats/papers/',
+ 'optional': ['discipline', 'upandcoming'],
+ },
+ 'publication_stats': {
+ 'url': '/oapi/stats/publications/',
+ 'optional': ['discipline', 'upandcoming'],
+ },
+ 'tag_stats': {
+ 'url': '/oapi/stats/tags/%(discipline)s/',
+ 'required': ['discipline'],
+ 'optional': ['upandcoming'],
+ },
+ ######## User Specific Resources ########
+ 'library_author_stats': {
+ 'url': '/oapi/library/authors/',
+ 'access_token_required': True,
+ },
+ 'library_tag_stats': {
+ 'url': '/oapi/library/tags/',
+ 'access_token_required': True,
+ },
+ 'library_publication_stats': {
+ 'url': '/oapi/library/publications/',
+ 'access_token_required': True,
+ },
+ 'library': {
+ 'url': '/oapi/library/',
+ 'optional': ['page', 'items'],
+ 'access_token_required': True,
+ },
+ 'create_document': {
+ 'url': '/oapi/library/documents/',
+ # HACK: 'document' is required, but by making it optional here it'll get POSTed
+ # Unfortunately that means it needs to be a named param when calling this method
+ 'optional': ['document'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ 'upload_pdf': {
+ 'url': '/oapi/library/documents/%(id)s/',
+ 'required': ['id'],
+ 'optional': ['data', 'file_name', 'oauth_body_hash', 'sha1_hash'],
+ 'access_token_required': True,
+ 'method': 'put'
+ },
+ 'download_file': {
+ 'url': '/oapi/library/documents/%(id)s/file/%(hash)s/',
+ 'required': ['id', 'hash'],
+ 'access_token_required': True,
+ 'method': 'get'
+ },
+ 'download_file_group': {
+ 'url': '/oapi/library/documents/%(id)s/file/%(hash)s/%(group)s/',
+ 'required': ['id', 'hash', 'group'],
+ 'access_token_required': True,
+ 'method': 'get'
+ },
+ 'document_details': {
+ 'url': '/oapi/library/documents/%(id)s/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ },
+ 'documents_authored': {
+ 'url': '/oapi/library/documents/authored/',
+ 'access_token_required': True,
+ },
+ 'delete_library_document': {
+ 'url': '/oapi/library/documents/%(id)s/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ 'contacts': {
+ 'url': '/oapi/profiles/contacts/',
+ 'access_token_required': True,
+ 'method': 'get',
+ },
+ 'contacts_of_contact': {
+ 'url': '/oapi/profiles/contacts/%(id)s/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ 'method': 'get',
+ },
+ 'add_contact': {
+ 'url': '/oapi/profiles/contacts/%(id)s/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ # Folders methods #
+ 'folders': {
+ 'url': '/oapi/library/folders/',
+ 'access_token_required': True,
+ },
+ 'folder_documents': {
+ 'url': '/oapi/library/folders/%(id)s/',
+ 'required': ['id'],
+ 'optional': ['page', 'items'],
+ 'access_token_required': True,
+ },
+ 'create_folder': {
+ 'url': '/oapi/library/folders/',
+ # HACK: 'collection' is required, but by making it optional here it'll get POSTed
+ # Unfortunately that means it needs to be a named param when calling this method
+ 'optional': ['folder'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ 'delete_folder': {
+ 'url': '/oapi/library/folders/%(id)s/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ 'add_document_to_folder': {
+ 'url': '/oapi/library/folders/%(folder_id)s/%(document_id)s/',
+ 'required': ['folder_id', 'document_id'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ 'delete_document_from_folder': {
+ 'url': '/oapi/library/folders/%(folder_id)s/%(document_id)s/',
+ 'required': ['folder_id', 'document_id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ # Groups methods #
+ 'groups': {
+ 'url': '/oapi/library/groups/',
+ 'access_token_required': True,
+ },
+ 'group_documents': {
+ 'url': '/oapi/library/groups/%(id)s/',
+ 'required': ['id'],
+ 'optional': ['page', 'items'],
+ 'access_token_required': True,
+ },
+ 'group_doc_details': {
+ 'url': '/oapi/library/groups/%(group_id)s/%(doc_id)s/',
+ 'required': ['group_id', 'doc_id'],
+ 'access_token_required': True,
+ },
+ 'group_people': {
+ 'url': '/oapi/library/groups/%(id)s/people/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ },
+ 'create_group': {
+ 'url': '/oapi/library/groups/',
+ 'optional': ['group'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ 'delete_group': {
+ 'url': '/oapi/library/groups/%(id)s/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ 'leave_group': {
+ 'url': '/oapi/library/groups/%(id)s/leave/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ 'unfollow_group': {
+ 'url': '/oapi/library/groups/%(id)s/unfollow/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ 'delete_group_document': {
+ 'url': '/oapi/library/groups/%(group_id)s/%(document_id)s/',
+ 'required': ['group_id', 'document_id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ # Group Folders methods #
+ 'group_folders': {
+ 'url': '/oapi/library/groups/%(group_id)s/folders/',
+ 'required': ['group_id'],
+ 'access_token_required': True,
+ },
+ 'group_folder_documents': {
+ 'url': '/oapi/library/groups/%(group_id)s/folders/%(id)s/',
+ 'required': ['group_id', 'id'],
+ 'optional': ['page', 'items'],
+ 'access_token_required': True,
+ },
+ 'create_group_folder': {
+ 'url': '/oapi/library/groups/%(group_id)s/folders/',
+ 'required': ['group_id'],
+ # HACK: 'collection' is required, but by making it optional here it'll get POSTed
+ # Unfortunately that means it needs to be a named param when calling this method
+ 'optional': ['folder'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ 'delete_group_folder': {
+ 'url': '/oapi/library/groups/%(group_id)s/folders/%(id)s/',
+ 'required': ['group_id', 'id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ 'add_document_to_group_folder': {
+ 'url': '/oapi/library/groups/%(group_id)s/folders/%(folder_id)s/%(document_id)s/',
+ 'required': ['group_id', 'folder_id', 'document_id'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ 'delete_document_from_group_folder': {
+ 'url': '/oapi/library/groups/%(group_id)s/folders/%(folder_id)s/%(document_id)s/',
+ 'required': ['group_id', 'folder_id', 'document_id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ ######## DEPRECATED METHODS ########
+ # Deprecated
+ 'collections': {
+ 'url': '/oapi/library/collections/',
+ 'access_token_required': True,
+ },
+ # Deprecated
+ 'sharedcollections': {
+ 'url': '/oapi/library/sharedcollections/',
+ 'access_token_required': True,
+ },
+ # Deprecated
+ 'collection_documents': {
+ 'url': '/oapi/library/collections/%(id)s/',
+ 'required': ['id'],
+ 'optional': ['page', 'items'],
+ 'access_token_required': True,
+ },
+ # Deprecated
+ 'sharedcollection_documents': {
+ 'url': '/oapi/library/sharedcollections/%(id)s/',
+ 'required': ['id'],
+ 'optional': ['page', 'items'],
+ 'access_token_required': True,
+ },
+ # Deprecated
+ 'sharedcollection_members': {
+ 'url': '/oapi/library/sharedcollections/%(id)s/members/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ },
+ # Deprecated
+ 'delete_collection': {
+ 'url': '/oapi/library/collections/%(id)s/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ # Deprecated
+ 'delete_sharedcollection': {
+ 'url': '/oapi/library/sharedcollections/%(id)s/',
+ 'required': ['id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ # Deprecated
+ 'create_collection': {
+ 'url': '/oapi/library/collections/',
+ # HACK: 'collection' is required, but by making it optional here it'll get POSTed
+ # Unfortunately that means it needs to be a named param when calling this method
+ 'optional': ['collection'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ # Deprecated
+ 'create_sharedcollection': {
+ 'url': '/oapi/library/sharedcollections/',
+ 'optional': ['sharedcollection'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ # Deprecated
+ 'add_document_to_collection': {
+ 'url': '/oapi/library/collections/add/%(collection_id)s/%(document_id)s/',
+ 'required': ['collection_id', 'document_id'],
+ 'access_token_required': True,
+ 'method': 'post',
+ },
+ # Deprecated
+ 'remove_document_from_collection': {
+ 'url': '/oapi/library/collections/%(collection_id)s/%(document_id)s/',
+ 'required': ['collection_id', 'document_id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ },
+ # Deprecated
+ 'delete_sharedcollection_document': {
+ 'url': '/oapi/library/sharedcollections/%(collection_id)s/%(document_id)s/',
+ 'required': ['collection_id', 'document_id'],
+ 'access_token_required': True,
+ 'method': 'delete',
+ }
+ }
+
+ def __init__(self, consumer_key, consumer_secret, options=None):
+ self.mendeley = OAuthClient(consumer_key, consumer_secret, options)
+ # Create methods for all of the API calls
+ for method, details in self.methods.items():
+ setattr(self, method, MendeleyRemoteMethod(details, self.api_request))
+
+ def api_request(self, url, access_token_required=False, method='get', params=None):
+ if params == None: params = {}
+ if access_token_required: access_token = self.access_token
+ else: access_token = None
+
+ if method == 'get':
+ if len(params) > 0:
+ url += "?%s" % urllib.urlencode(params)
+ response = self.mendeley.get(url, access_token)
+ elif method == 'delete':
+ response = self.mendeley.delete(url, access_token)
+ elif method == 'put':
+ headers = {'Content-disposition': 'attachment; filename="%s"' % params.get('file_name')}
+ response = self.mendeley.put(url, access_token, params.get('data'), params.get('oauth_body_hash'), headers)
+ else:
+ response = self.mendeley.post(url, params, access_token)
+ return response
+
+ def get_required_keys(self):
+ self.request_token = self.mendeley.request_token()
+ auth_url = self.mendeley.authorize(self.request_token)
+ print 'Go to the following url to auth the token:\n%s' % (auth_url,)
+ verifier = raw_input('Enter verification code: ')
+ self.request_token.set_verifier(verifier)
+ self.access_token = self.mendeley.access_token(self.request_token)
+
+ def load_keys(self):
+ data = pickle.load(open('mendeley_api_keys.pkl', 'r'))
+ self.request_token = data['request_token']
+ self.access_token = data['access_token']
+
+ def save_keys(self):
+ data = {'request_token': self.request_token, 'access_token': self.access_token}
+ pickle.dump(data, open('mendeley_api_keys.pkl', 'w'))
View
10 meta/locale/en/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-11-29 00:53+0100\n"
+"POT-Creation-Date: 2011-11-29 01:30+0100\n"
"PO-Revision-Date: 2011-11-04 12:41\n"
"Last-Translator: <organelas@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -42,15 +42,15 @@ msgstr "biology"
msgid "Centro de Biologia Marinha da Universidade de São Paulo"
msgstr "Marine Biology Center of University of São Paulo"
-#: feeds.py:25 templates/base.html:49 templates/main_page.html:47
+#: feeds.py:25 templates/base.html:50 templates/main_page.html:47
msgid "Cifonauta: últimas fotos e vídeos"
msgstr "Cifonauta: latest photos and videos"
-#: feeds.py:27 templates/base.html:50
+#: feeds.py:27 templates/base.html:51
msgid "Cifonauta: últimas fotos"
msgstr "Cifonauta: latest photos"
-#: feeds.py:29 templates/base.html:51
+#: feeds.py:29 templates/base.html:52
msgid "Cifonauta: últimos vídeos"
msgstr "Cifonauta: latest videos"
@@ -924,7 +924,7 @@ msgstr "authors, biodiversity, marine biology"
msgid "Autores incluídos no banco de imagens Cifonauta."
msgstr "Authors included in the Cifonauta image database."
-#: templates/authors_page.html:12 templates/base.html:16
+#: templates/authors_page.html:12 templates/base.html:17
#: templates/buscar.html:14 templates/embed.html:7 templates/main_page.html:10
#: templates/main_page.html.py:15 templates/media_page.html:16
#: templates/meta_page.html:17 templates/organizacao.html:15
View
185 meta/static/js/plugins.js
@@ -3935,5 +3935,188 @@ if (window.jQuery) {
window.VideoJS = window._V_ = VideoJS;
// End self-executing function
-})(window);
+})(window);var Dajaxice = {
+
+ meta: {
+
+
+ update_counter: function(callback_function, argv, custom_settings){
+ Dajaxice.call('meta.update_counter', callback_function, argv, custom_settings);
+ }
+
+
+
+ }
+ ,
+
+ get_cookie: function(name)
+ {
+ var cookieValue = null;
+ if (document.cookie && document.cookie != '') {
+ var cookies = document.cookie.split(';');
+ for (var i = 0; i < cookies.length; i++) {
+ var cookie = cookies[i].toString().replace(/^\s+/, "").replace(/\s+$/, "");
+ // Does this cookie string begin with the name we want?
+ if (cookie.substring(0, name.length + 1) == (name + '=')) {
+ cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
+ break;
+ }
+ }
+ }
+ return cookieValue;
+ },
+
+ call: function(dajaxice_function, dajaxice_callback, argv, custom_settings)
+ {
+ var send_data = [];
+ var is_callback_a_function = (typeof(dajaxice_callback) == 'function');
+
+ if(!is_callback_a_function){
+ alert("dajaxice_callback should be a function since dajaxice 0.2")
+ }
+
+ if(custom_settings == undefined){
+ custom_settings = {};
+ }
+
+ var error_callback = this.get_setting('default_exception_callback');
+ if('error_callback' in custom_settings && typeof(custom_settings['error_callback']) == 'function'){
+ error_callback = custom_settings['error_callback'];
+ }
+
+ send_data.push('argv='+encodeURIComponent(JSON.stringify(argv)));
+ send_data = send_data.join('&');
+ var oXMLHttpRequest = new XMLHttpRequest;
+ oXMLHttpRequest.open('POST', '/dajaxice/'+dajaxice_function+'/');
+ oXMLHttpRequest.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ oXMLHttpRequest.setRequestHeader("X-CSRFToken",Dajaxice.get_cookie('csrftoken'));
+ oXMLHttpRequest.onreadystatechange = function() {
+ if (this.readyState == XMLHttpRequest.DONE) {
+ if(this.responseText == Dajaxice.EXCEPTION || !(this.status in Dajaxice.valid_http_responses())){
+ error_callback();
+ }
+ else{
+ var response;
+ try {
+ response = JSON.parse(this.responseText);
+ }
+ catch (exception) {
+ response = this.responseText;
+ }
+ dajaxice_callback(response);
+ }
+ }
+ }
+ oXMLHttpRequest.send(send_data);
+ },
+
+ setup: function(settings)
+ {
+ this.settings = settings;
+ },
+
+ get_setting: function(key){
+ if(this.settings == undefined || this.settings[key] == undefined){
+ return this.default_settings[key];
+ }
+ return this.settings[key];
+ },
+
+ default_exception_callback: function(data){
+ alert('Something goes wrong');
+ },
+
+ valid_http_responses: function(){
+ return {200: null, 301: null, 302: null, 304: null}
+ }
+};
+
+Dajaxice.EXCEPTION = 'DAJAXICE_EXCEPTION';
+Dajaxice.default_settings = {'default_exception_callback': Dajaxice.default_exception_callback}
+
+window['Dajaxice'] = Dajaxice;
+
+
+
+(function(){function b(){this._object=i?new i:new window.ActiveXObject("Microsoft.XMLHTTP");this._listeners=[]}function k(a){b.onreadystatechange&&b.onreadystatechange.apply(a);a.dispatchEvent({type:"readystatechange",bubbles:false,cancelable:false,timeStamp:new Date+0})}function p(a){var c=a.responseXML,d=a.responseText;if(h&&d&&c&&!c.documentElement&&a.getResponseHeader("Content-Type").match(/[^\/]+\/[^\+]+\+xml/)){c=new window.ActiveXObject("Microsoft.XMLDOM");c.async=false;c.validateOnParse=false;
+c.loadXML(d)}if(c)if(h&&c.parseError!=0||!c.documentElement||c.documentElement&&c.documentElement.tagName=="parsererror")return null;return c}function o(a){try{a.responseText=a._object.responseText}catch(c){}try{a.responseXML=p(a._object)}catch(d){}try{a.status=a._object.status}catch(g){}try{a.statusText=a._object.statusText}catch(e){}}function l(a){a._object.onreadystatechange=new window.Function}var i=window.XMLHttpRequest,j=!!window.controllers,h=window.document.all&&!window.opera;if(j&&i.wrapped)b.wrapped=
+i.wrapped;b.UNSENT=0;b.OPENED=1;b.HEADERS_RECEIVED=2;b.LOADING=3;b.DONE=4;b.prototype.readyState=b.UNSENT;b.prototype.responseText="";b.prototype.responseXML=null;b.prototype.status=0;b.prototype.statusText="";b.prototype.onreadystatechange=null;b.onreadystatechange=null;b.onopen=null;b.onsend=null;b.onabort=null;b.prototype.open=function(a,c,d,g,e){delete this._headers;if(arguments.length<3)d=true;this._async=d;var f=this,m=this.readyState,n;if(h&&d){n=function(){if(m!=b.DONE){l(f);f.abort()}};window.attachEvent("onunload",
+n)}b.onopen&&b.onopen.apply(this,arguments);if(arguments.length>4)this._object.open(a,c,d,g,e);else arguments.length>3?this._object.open(a,c,d,g):this._object.open(a,c,d);if(!j&&!h){this.readyState=b.OPENED;k(this)}this._object.onreadystatechange=function(){if(!(j&&!d)){f.readyState=f._object.readyState;o(f);if(f._aborted)f.readyState=b.UNSENT;else{if(f.readyState==b.DONE){l(f);h&&d&&window.detachEvent("onunload",n)}m!=f.readyState&&k(f);m=f.readyState}}}};b.prototype.send=function(a){b.onsend&&b.onsend.apply(this,
+arguments);if(a&&a.nodeType){a=window.XMLSerializer?(new window.XMLSerializer).serializeToString(a):a.xml;this._headers["Content-Type"]||this._object.setRequestHeader("Content-Type","application/xml")}this._object.send(a);if(j&&!this._async){this.readyState=b.OPENED;for(o(this);this.readyState<b.DONE;){this.readyState++;k(this);if(this._aborted)return}}};b.prototype.abort=function(){b.onabort&&b.onabort.apply(this,arguments);if(this.readyState>b.UNSENT)this._aborted=true;this._object.abort();l(this)};
+b.prototype.getAllResponseHeaders=function(){return this._object.getAllResponseHeaders()};b.prototype.getResponseHeader=function(a){return this._object.getResponseHeader(a)};b.prototype.setRequestHeader=function(a,c){if(!this._headers)this._headers={};this._headers[a]=c;return this._object.setRequestHeader(a,c)};b.prototype.addEventListener=function(a,c,d){for(var g=0,e;e=this._listeners[g];g++)if(e[0]==a&&e[1]==c&&e[2]==d)return;this._listeners.push([a,c,d])};b.prototype.removeEventListener=function(a,
+c,d){for(var g=0,e;e=this._listeners[g];g++)if(e[0]==a&&e[1]==c&&e[2]==d)break;e&&this._listeners.splice(g,1)};b.prototype.dispatchEvent=function(a){a={type:a.type,target:this,currentTarget:this,eventPhase:2,bubbles:a.bubbles,cancelable:a.cancelable,timeStamp:a.timeStamp,stopPropagation:function(){},preventDefault:function(){},initEvent:function(){}};if(a.type=="readystatechange"&&this.onreadystatechange)(this.onreadystatechange.handleEvent||this.onreadystatechange).apply(this,[a]);for(var c=0,d;d=
+this._listeners[c];c++)if(d[0]==a.type&&!d[2])(d[1].handleEvent||d[1]).apply(this,[a])};b.prototype.toString=function(){return"[object XMLHttpRequest]"};b.toString=function(){return"[XMLHttpRequest]"};if(!window.Function.prototype.apply)window.Function.prototype.apply=function(a,c){c||(c=[]);a.__func=this;a.__func(c[0],c[1],c[2],c[3],c[4]);delete a.__func};window.XMLHttpRequest=b})();
+
+
+
+
+if(!this.JSON)this.JSON={};
+(function(){function k(a){return a<10?"0"+a:a}function n(a){o.lastIndex=0;return o.test(a)?'"'+a.replace(o,function(c){var d=q[c];return typeof d==="string"?d:"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function l(a,c){var d,f,i=g,e,b=c[a];if(b&&typeof b==="object"&&typeof b.toJSON==="function")b=b.toJSON(a);if(typeof j==="function")b=j.call(c,a,b);switch(typeof b){case "string":return n(b);case "number":return isFinite(b)?String(b):"null";case "boolean":case "null":return String(b);case "object":if(!b)return"null";
+g+=m;e=[];if(Object.prototype.toString.apply(b)==="[object Array]"){f=b.length;for(a=0;a<f;a+=1)e[a]=l(a,b)||"null";c=e.length===0?"[]":g?"[\n"+g+e.join(",\n"+g)+"\n"+i+"]":"["+e.join(",")+"]";g=i;return c}if(j&&typeof j==="object"){f=j.length;for(a=0;a<f;a+=1){d=j[a];if(typeof d==="string")if(c=l(d,b))e.push(n(d)+(g?": ":":")+c)}}else for(d in b)if(Object.hasOwnProperty.call(b,d))if(c=l(d,b))e.push(n(d)+(g?": ":":")+c);c=e.length===0?"{}":g?"{\n"+g+e.join(",\n"+g)+"\n"+i+"}":"{"+e.join(",")+"}";
+g=i;return c}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+k(this.getUTCMonth()+1)+"-"+k(this.getUTCDate())+"T"+k(this.getUTCHours())+":"+k(this.getUTCMinutes())+":"+k(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var p=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,g,m,q={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},j;if(typeof JSON.stringify!=="function")JSON.stringify=function(a,c,d){var f;m=g="";if(typeof d==="number")for(f=0;f<d;f+=1)m+=" ";else if(typeof d==="string")m=d;if((j=c)&&typeof c!=="function"&&(typeof c!=="object"||typeof c.length!=="number"))throw new Error("JSON.stringify");return l("",
+{"":a})};if(typeof JSON.parse!=="function")JSON.parse=function(a,c){function d(f,i){var e,b,h=f[i];if(h&&typeof h==="object")for(e in h)if(Object.hasOwnProperty.call(h,e)){b=d(h,e);if(b!==undefined)h[e]=b;else delete h[e]}return c.call(f,i,h)}p.lastIndex=0;if(p.test(a))a=a.replace(p,function(f){return"\\u"+("0000"+f.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
+"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){a=eval("("+a+")");return typeof c==="function"?d({"":a},""):a}throw new SyntaxError("JSON.parse");}})();
+
+
+/* Copyright (c) 2009-2010, Benito Jorge Bastida :: For further information check COPYING */
+var Dajax = {
+ process: function(data)
+ {
+ $.each(data, function(i,elem){
+ switch(elem.cmd)
+ {
+ case 'alert':
+ alert(elem.val)
+ break;
+
+ case 'data':
+ eval( elem.fun+"(elem.val);" );
+ break;
+ case 'as':
+ jQuery.each($(elem.id),function(){ this[elem.prop] = elem.val; });
+ break;
+
+ case 'addcc':
+ jQuery.each(elem.val,function(){
+ $(elem.id).addClass(String(this));
+ });
+ break;
+
+ case 'remcc':
+ jQuery.each(elem.val,function(){
+ $(elem.id).removeClass(String(this));
+ });
+ break;
+
+ case 'ap':
+ jQuery.each($(elem.id),function(){ this[elem.prop] += elem.val; });
+ break;
+
+ case 'pp':
+ jQuery.each($(elem.id),function(){ this[elem.prop] = elem.val + this[elem.prop]; });
+ break;
+
+ case 'clr':
+ jQuery.each($(elem.id),function(){ this[elem.prop] = ""; });
+ break;
+
+ case 'red':
+ window.setTimeout('window.location="'+elem.url+'";',elem.delay);
+ break;
+
+ case 'js':
+ eval(elem.val);
+ break;
+
+ case 'rm':
+ $(elem.id).remove();
+ break;
+
+ default:
+ break;
+ }
+ });
+ }
+};

No commit comments for this range

Something went wrong with that request. Please try again.