Skip to content

Commit

Permalink
Merge 25d5e58 into 41f864f
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Nowak committed May 24, 2017
2 parents 41f864f + 25d5e58 commit 8d5bf66
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 26 deletions.
30 changes: 24 additions & 6 deletions INSTALL.rst
Expand Up @@ -15,8 +15,9 @@ For this guide you will need to install
Docker installation is not necessary, although highly recommended.

If you can't use docker you can run Zenodo and all of the required services
directly in your system. Take a look at ``docker-compose.yml`` file to find out
what is required and how the configuration looks like.
directly in your system. Take a look at
`docker-compose.yml <https://github.com/zenodo/zenodo/blob/master/docker-compose.yml/>`_
file to find out what is required and how the configuration looks like.
For development you will need to set-up an configure
four services: PostgreSQL (``db``), Elasticsearch (``es``),
Redis (``cache``) and RabbitMQ (``mq``).
Expand Down Expand Up @@ -189,7 +190,7 @@ As before, there is a script which does that (this time without sudo):
Running services
~~~~~~~~~~~~~~~~

To run Zenodo locally, you will need to have some services runninig on your
To run Zenodo locally, you will need to have some services running on your
machine.
At minimum you must have PostgreSQL, Elasticsearch 2.x, Redis and RabbitMQ.
You can either install all of those from your system package manager and run
Expand All @@ -210,7 +211,7 @@ To run only the essential services using docker, execute the following:
$ cd ~/src/zenodo
$ docker-compose up db es mq cache
This should bring up four docker nodes with PostgreSQL (db) Elasticsearch (es),
This should bring up four docker nodes with PostgreSQL (db), Elasticsearch (es),
RabbitMQ (mq), and Redis (cache). Keep this shell session alive.

Initialization
Expand All @@ -226,6 +227,23 @@ Create the database and Elasticsearch indices in a new shell session:
$ workon zenodo
(zenodo)$ ./scripts/init.sh
.. note::

Here we assume all four services (db, es, mq, cache) are bound to localhost
(see `zenodo/config.py <https://github.com/zenodo/zenodo/blob/master/zenodo/config.py/>`_).
If you fail to connect those services, it is likely
you are running docker through ``docker-machine`` and those services are
bound to other IP addresses. In this case, you can redirect localhost ports
to docker ports as follows.

``ssh -L 6379:localhost:6379 -L 5432:localhost:5432 -L 9200:localhost:9200 -L 5672:localhost:5672 docker@$(docker-machine ip)``

The problem usually occurs among Mac and Windows users. A better solution
is to install the native apps `Docker for Mac <https://docs.docker.com/docker-for-mac/>`_
or `Docker for Windows <https://docs.docker.com/docker-for-windows/>`_
(available since Docker v1.12) if possible,
which binds docker to localhost by default.

Demo records
~~~~~~~~~~~~
Next, load some demo data (licenses, funders, grants, records).
Expand Down Expand Up @@ -264,7 +282,7 @@ Finally, run the Zenodo application:
(zenodo)$ zenodo run
If you go to http://localhost:5000, you should see an instance of Zenodo,
similar to the production instance at https://zenodo.org
similar to the production instance at https://zenodo.org.

.. note::

Expand All @@ -284,5 +302,5 @@ similar to the production instance at https://zenodo.org
Badges
~~~~~~
In order for the DOI badges to work you must have the Cairo SVG library and the
DejaVu Sans font installed on your system . Please see `Invenio-Formatter
DejaVu Sans font installed on your system. Please see `Invenio-Formatter
<http://pythonhosted.org/invenio-formatter/installation.html>`_ for details.
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -37,7 +37,7 @@

.. image:: https://img.shields.io/github/license/zenodo/zenodo.svg
:target: https://github.com/zenodo/zenodo/blob/master/LICENSE

.. image:: https://badges.gitter.im/Join%20Chat.svg
:alt: Join the chat at https://gitter.im/zenodo/zenodo
:target: https://gitter.im/zenodo/zenodo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
Expand Down Expand Up @@ -65,7 +65,7 @@ See https://zenodo.readthedocs.io/

License
=======
Copyright (C) 2009-2016 CERN.
Copyright (C) 2009-2017 CERN.

Zenodo is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
Expand Down
2 changes: 1 addition & 1 deletion docker/es/Dockerfile
@@ -1,3 +1,3 @@
FROM elasticsearch:2.3
RUN plugin install royrusso/elasticsearch-HQ/2.0.3
RUN plugin install royrusso/elasticsearch-HQ/v2.0.3
RUN plugin install mapper-attachments
16 changes: 8 additions & 8 deletions docs/development/guide.rst
Expand Up @@ -43,15 +43,15 @@ Uninstall the installed PyPI version of the module and install the local one:
.. note::

The ``-e`` flag in the ``pip install`` is important for the development.
This way the module will be installed in "editable" mode, meaning that
you will be able edit the code in directly in
``~/src/invenio-communities``, and have the changes be immediately
This way, the module will be installed in the "editable" mode, meaning that
you will be able to edit the code directly in
``~/src/invenio-communities``, and have the changes immediately
available in the installed library inside the virtual environment.

If you now restart the Zenodo application, the relevant ``invenio_communities``
module code should be executed from the locally stored repository in
``~/src/invenio-communities/``.
If you now change the code in ~/src/invenio-communities/ the changes
If you now change the code in ``~/src/invenio-communities/``, the changes
should be propagated to the Zenodo application.

.. note::
Expand All @@ -60,20 +60,20 @@ should be propagated to the Zenodo application.
module, it's usually much newer version than the release (PyPI) version.
This means that if the Zenodo-specified version of the module (see `setup.py <https://github.com/zenodo/zenodo/blob/master/setup.py>`_)
is far behind the master branch, you can expect some incompatibilities
or strange behaviour.
or strange behaviours.

Making a contribution
~~~~~~~~~~~~~~~~~~~~~

If the feature you've implemented involves only the changes in Zenodo
repository, you will only need to create one PR to Zenodo. If the changes
involve also any of the Invenio modules, you will also have to create a PR in
also involve any Invenio modules, you will also have to create a PR in
that corresponding Invenio repository on GitHub.

The recommended way to create a PR is to first fork the repository on GitHub
(both Zenodo and Invenio repositories), push the changes to your fork's
feature branch and create a PR on GitHub against
``[upstream-repository]:[master]`` and ``[your-fork]:[feature-branch]``
feature branch ``[your-fork]:[feature-branch]`` and create a PR on GitHub against
``[upstream-repository]:[master]``.

In the Zenodo PR, please refer to any relevant Invenio PR on which it depends
so the Zenodo reviewers can also review the Invenio PR changes.
2 changes: 1 addition & 1 deletion docs/license.rst
Expand Up @@ -6,7 +6,7 @@ License
does not apply to the name Zenodo (TM) and the Zenodo logo which are trademarked
by CERN. Thus if you instantiate the software you must change the branding to your own.

Copyright (C) 2009-2016 CERN.
Copyright (C) 2009-2017 CERN.

Zenodo is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
Expand Down
5 changes: 3 additions & 2 deletions scripts/index.sh
Expand Up @@ -24,8 +24,9 @@

zenodo index destroy --force --yes-i-know
zenodo index init --force
zenodo migration reindex -t od_lic
zenodo migration reindex -t frdoi
zenodo migration reindex -t grant
zenodo migration reindex -t recid
zenodo migration reindex -t depid
zenodo migration reindex -t od_lic
zenodo migration reindex -t grants
zenodo index run -c 4 -d
24 changes: 24 additions & 0 deletions tests/unit/records/test_bibtex_serializer.py
Expand Up @@ -302,6 +302,8 @@ def test_format_inproceedings(full_record):
""" address = {Staszkowka},\n"""
""" month = feb,\n"""
""" note = {notes},\n"""
""" venue = """
"""{Harvard-Smithsonian Center for Astrophysics},\n"""
""" doi = {10.1234/foo.bar},\n"""
""" url = {https://doi.org/10.1234/foo.bar}\n"""
"""}""")
Expand All @@ -322,13 +324,35 @@ def test_format_inproceedings(full_record):
""" address = {Staszkowka},\n"""
""" month = feb,\n"""
""" note = {notes},\n"""
""" venue = """
"""{Harvard-Smithsonian Center for Astrophysics},\n"""
""" doi = {10.1234/foo.bar},\n"""
""" url = {https://doi.org/10.1234/foo.bar}\n"""
"""}""")
assert bibtex == Bibtex(full_record).format()

del full_record['imprint']
full_record['part_of']['publisher'] = "hello"
bibtex = ("""@inproceedings{doe_2014_12345,\n"""
""" author = {Doe, John and\n"""
""" Doe, Jane and\n"""
""" Smith, John and\n"""
""" Nowak, Jack},\n"""
""" title = {Test title},\n"""
""" booktitle = {Bum},\n"""
""" year = 2014,\n"""
""" pages = 30,\n"""
""" publisher = {hello},\n"""
""" month = feb,\n"""
""" note = {notes},\n"""
""" venue = """
"""{Harvard-Smithsonian Center for Astrophysics},\n"""
""" doi = {10.1234/foo.bar},\n"""
""" url = {https://doi.org/10.1234/foo.bar}\n"""
"""}""")
assert bibtex == Bibtex(full_record).format()

del full_record['meeting']
bibtex = ("""@inproceedings{doe_2014_12345,\n"""
""" author = {Doe, John and\n"""
""" Doe, Jane and\n"""
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/records/test_schemas_csl.py
Expand Up @@ -39,7 +39,7 @@ def test_minimal(db, minimal_record, recid_pid):
d = datetime.utcnow().date()
assert obj == {
'id': '123',
'type': 'dataset',
'type': 'article',
'title': 'Test',
'abstract': 'My description',
'author': [
Expand Down
4 changes: 2 additions & 2 deletions zenodo/modules/records/data/objecttypes.json
Expand Up @@ -123,7 +123,7 @@
"datacite": {"general": "Software"},
"eurepo": "info:eu-repo/semantics/other",
"schema.org": "http://schema.org/Code",
"csl": "dataset"
"csl": "article"
},
{
"$schema": "https://zenodo.org/schemas/records/objecttype-v1.0.0.json",
Expand Down Expand Up @@ -250,7 +250,7 @@
"datacite": {"general": "Text", "type": "Report"},
"eurepo": "info:eu-repo/semantics/report",
"parent": {"$ref": "http://zenodo.org/objecttypes/publication"},
"csl": "report"
"csl": "article"
},
{
"$schema": "https://zenodo.org/schemas/records/objecttype-v1.0.0.json",
Expand Down
15 changes: 12 additions & 3 deletions zenodo/modules/records/serializers/bibtex.py
Expand Up @@ -65,14 +65,14 @@ class MissingRequiredFieldError(Exception):
"""Base class for exceptions in this module.
The exception should be raised when the specific,
required filed doesn't exist in the record.
required field doesn't exist in the record.
"""

def _init_(self, field):
self.field = field

def _str_(self):
return "Missing filed: " + self.field
return "Missing field: " + self.field


class Bibtex(object):
Expand Down Expand Up @@ -199,7 +199,7 @@ def _format_inproceedings(self):
"""
name = "inproceedings"
req_fields = ['author', 'title', 'booktitle', 'year']
opt_fields = ['pages', 'publisher', 'address', 'month', 'note']
opt_fields = ['pages', 'publisher', 'address', 'month', 'note', 'venue']
ign_fields = ['doi', 'url']
return self._format_entry(name, req_fields,
opt_fields, ign_fields)
Expand Down Expand Up @@ -269,6 +269,7 @@ def _fetch_fields(self, req_fields, opt_fields=None, ign_fields=None):
'school': self._get_school,
'title': self._get_title,
'url': self._get_url,
'venue': self._get_venue,
'volume': self._get_volume,
'year': self._get_year,
'doi': self._get_doi
Expand Down Expand Up @@ -476,6 +477,14 @@ def _get_url(self):
return "https://doi.org/%s" % self.record['doi'] \
if "doi" in self.record else ""

def _get_venue(self):
"""Return conference's venue."""
if "meeting" in self.record and\
"place" in self.record["meeting"]:
return self.record["meeting"]["place"]
else:
return ""

def _get_volume(self):
"""Return the volume of a journal or multi-volume book."""
return self.record.get("journal", {}).get("volume", "")

0 comments on commit 8d5bf66

Please sign in to comment.