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

templates: record detail page #24

Merged
merged 2 commits into from
Mar 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ charset = utf-8
indent_size = 4
# isort plugin configuration
known_first_party = invenio_marc21
known_third_party = dojson,invenio_db,invenio_indexer,invenio_pidstore,invenio_records,invenio_records_rest,invenio_search
known_third_party = dojson,invenio_assets,invenio_db,invenio_indexer,invenio_pidstore,invenio_jsonschemas,invenio_records,invenio_records_rest,invenio_search
multi_line_output = 2
default_section = THIRDPARTY

Expand Down
19 changes: 3 additions & 16 deletions examples/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
$ wget "https://github.com/inveniosoftware/invenio-records/raw/\
master/invenio_records/data/marc21/bibliographic.xml"
$ dojson -i bibliographic.xml -l marcxml do marc21 | \
flask -a app.py records create
$ flask -a app.py fixtures records
flask -a app.py records create --pid-minter recid

4. Download javascript and css libraries:

Expand Down Expand Up @@ -94,6 +93,7 @@
from flask_cli import FlaskCLI
from invenio_assets import InvenioAssets, NpmBundle
from invenio_db import InvenioDB, db
from invenio_pidstore import InvenioPIDStore
from invenio_pidstore.minters import recid_minter
from invenio_pidstore.models import PersistentIdentifier
from invenio_records import InvenioRecords
Expand All @@ -116,6 +116,7 @@
InvenioTheme(app)
assets = InvenioAssets(app)
InvenioRecords(app)
InvenioPIDStore(app)
InvenioSearch(app)
InvenioMARC21(app)

Expand All @@ -138,17 +139,3 @@ def example(index):

return render_template("app/detail.html", record=record.json, pid=pid,
title="Demosite Invenio Org")


@app.cli.group()
def fixtures():
"""Initialize example data."""


@fixtures.command()
def records():
"""Load fixtures."""
with db.session.begin_nested():
for record in RecordMetadata.query.all():
recid_minter(record.id, record.json)
db.session.commit()
3 changes: 2 additions & 1 deletion examples/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
# as an Intergovernmental Organization or submit itself to any jurisdiction.

-e ..[all]
invenio-theme>=1.0.0a9,<1.1
invenio-assets>=1.0.0a4,<1.1
invenio-pidstore>=1.0.0a7,<1.1
invenio-theme>=1.0.0a9,<1.1
82 changes: 82 additions & 0 deletions invenio_marc21/templates/invenio_marc21/detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2016 CERN.
#
# Invenio is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Invenio is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Invenio; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307, USA.
#
# In applying this license, CERN does not
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.
-#}
{%- extends config.MARC21_BASE_TEMPLATE %}

{%- block page_body %}
<div class="container">
<div class="row">
{%- block record_body %}
<div class="body col-sm-12 col-md-9">
{%- block record_title %}
<h4 class="title">{{ record.get('title_statement', {}).get('title', _('No title')) }}</h4>
{%- endblock %}
{%- block record_author %}
{%- if 'main_entry_personal_name' in record %}
<p class="record_authors">
<i>{{ record['main_entry_personal_name']['personal_name'] }}</i>
{%- for author in record.get('added_entry_personal_name', []) %}
, <i>{{ author['personal_name'] }}</i>
{% endfor %}
</p>
{% endif %}
{%- endblock %}
{%- block record_summary %}
{%- for summary in record.get('summary', []) %}
<p class="summary">{{ summary['summary'] }}</p>
{% endfor %}
{%- endblock %}
</div><!-- /.body -->
{%- endblock %}
{%- block record_extra_info %}
<div class="extra-info col-sm-12 col-md-3">
<dl>
{%- if pid %}
{%- block record_control_number %}
<dt>{{ _('Control number') }}</dt>
<dd>{{ record.get('control_number', pid.value) }}</dd>
{%- endblock %}
{% endif %}
{%- if 'publication_distribution_imprint' in record %}
{%- block record_publication_date %}
<dt>{{ _('Publication date') }}</dt>
<dd>{{ record['publication_distribution_imprint'][0]['date_of_publication_distribution'][0] }}</dd>
{%- endblock %}
{% endif %}
{%- if '$schema' in record %}
{%- block record_schema %}
<dt>{{ _('Schema') }}</dt>
<dd>
<a target="_blank" href="{{ record['$schema'] }}">
{{ record['$schema'] }}
</a>
</dd>
{%- endblock %}
{% endif %}
</dl>
</div><!-- /.extra-info -->
{%- endblock %}
</div><!-- /.row -->
</div><!-- /.container -->
{%- endblock %}
3 changes: 3 additions & 0 deletions requirements-devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@
# as an Intergovernmental Organization or submit itself to any jurisdiction.

-e git+git://github.com/inveniosoftware/dojson.git#egg=dojson
-e git+git://github.com/inveniosoftware/invenio-assets.git#egg=invenio-assets
-e git+git://github.com/inveniosoftware/invenio-jsonschemas.git#egg=invenio-jsonschemas
-e git+git://github.com/inveniosoftware/invenio-records-rest.git#egg=invenio-records-rest
-e git+git://github.com/inveniosoftware/invenio-records-ui.git#egg=invenio-records-ui
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
'coverage>=4.0',
'invenio-db>=1.0.0a9',
'invenio-indexer>=1.0.0a1',
'invenio-pidstore>=1.0.0a3',
'invenio-records>=1.0.0a9',
'invenio-pidstore>=1.0.0a7',
'invenio-records>=1.0.0a11',
'invenio-search>=1.0.0a4',
'isort>=4.2.2',
'mock>=1.3.0',
Expand Down Expand Up @@ -68,8 +68,10 @@
install_requires = [
'Flask-BabelEx>=0.9.2',
'dojson>=1.1.0',
'invenio-records-rest>=1.0.0a7.dev20160219',
'invenio-assets>=1.0.0a1',
'invenio-jsonschemas>=1.0.0a2',
'invenio-records-rest>=1.0.0a7.dev20160219',
'invenio-records-ui>=1.0.0a5.dev20150000',
]

packages = find_packages()
Expand Down
7 changes: 4 additions & 3 deletions tests/test_example_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ def test_example_app():

# Testing record creation
cmd = """dojson -i {0} -l marcxml do marc21 | \
flask -a app.py records create""".format(source)
flask -a app.py records create --pid-minter recid""".format(
source
)
exit_status = subprocess.call(cmd, shell=True)
assert exit_status == 0

# Download javascript and css libraries
for cmd in ['flask -a app.py fixtures records',
'flask -a app.py npm',
for cmd in ['flask -a app.py npm',
'cd static && npm install && cd ..',
'npm install -g node-sass clean-css requirejs uglify-js',
'flask -a app.py collect -v',
Expand Down