Skip to content

Commit

Permalink
collections: introduce collection pages
Browse files Browse the repository at this point in the history
* uses forked ‘pamfilos/invenio-collection’ with model updates

* address cernopendata#1315

Signed-off-by: Pamfilos Fokianos <pamfilosf@gmail.com>
  • Loading branch information
pamfilos committed Sep 5, 2017
1 parent 96a125a commit 7f15e5f
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 26 deletions.
5 changes: 4 additions & 1 deletion cernopendata/modules/fixtures/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def load(collections, parent=None):
"""Create new collection."""
for data in collections or []:
collection = Collection(
name=data['name'], dbquery=data.get('dbquery'),
name=data['name'],
dbquery=data.get('dbquery'),
description=data.get('description', None),
thumb=data.get('thumb', None),
parent=parent
)
db.session.add(collection)
Expand Down
58 changes: 35 additions & 23 deletions cernopendata/modules/fixtures/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,81 +24,93 @@
dbquery=None,
children=[dict(
name='CMS',
dbquery=None,
dbquery='collections.experiment:CMS',
description="Collection for CMS related open data",
thumb="",
children=[dict(
name='CMS-Primary-Datasets',
dbquery='collections.primary:"CMS-Primary-Datasets"',
dbquery='collections.primary:CMS-Primary-Datasets',
), dict(
name='CMS-Derived-Datasets',
dbquery='collections.primary:"CMS-Derived-Datasets"',
dbquery='collections.primary:CMS-Derived-Datasets',
), dict(
name='CMS-Tools',
dbquery='collections.primary:"CMS-Tools"',
dbquery='collections.primary:CMS-Tools',
), dict(
name='CMS-Validated-Runs',
dbquery='collections.primary:"CMS-Validated-Runs"',
dbquery='collections.primary:CMS-Validated-Runs',
), dict(
name='CMS-Learning-Resources',
dbquery='collections.primary:"CMS-Learning-Resources"',
dbquery='collections.primary:CMS-Learning-Resources',
), dict(
name='CMS-Open-Data-Instructions',
dbquery='collections.primary:"CMS-Open-Data-Instructions"',
dbquery='collections.primary:CMS-Open-Data-Instructions',
),
],
), dict(
name='ALICE',
dbquery=None,
dbquery='collections.experiment:ALICE',
description="<h1>Collection for ALICE related open data</h1>",
thumb="",
children=[dict(
name='ALICE-Derived-Datasets',
dbquery='collections.primary:"ALICE-Derived-Datasets"',
dbquery='collections.primary:ALICE-Derived-Datasets',
), dict(
name='ALICE-Tools',
dbquery='collections.primary:"ALICE-Tools"',
dbquery='collections.primary:ALICE-Tools',
), dict(
name='ALICE-Reconstructed-Data',
dbquery='collections.primary:"ALICE-Reconstructed-Data"',
dbquery='collections.primary:ALICE-Reconstructed-Data',
), dict(
name='ALICE-Learning-Resources',
dbquery='collections.primary:"ALICE-Learning-Resources"',
dbquery='collections.primary:ALICE-Learning-Resources',
),
],
), dict(
name='ATLAS',
dbquery=None,
dbquery='collections.experiment:ATLAS',
description="### Collection for ATLAS related open data",
thumb="",
children=[dict(
name='ATLAS-Derived-Datasets',
dbquery='collections.primary:"ATLAS-Derived-Datasets"',
dbquery='collections.primary:ATLAS-Derived-Datasets',
), dict(
name='ATLAS-Learning-Resources',
dbquery='collections.primary:"ATLAS-Learning-Resources"',
dbquery='collections.primary:ATLAS-Learning-Resources',
), dict(
name='ATLAS-Tools',
dbquery='collections.primary:"ATLAS-Tools"',
dbquery='collections.primary:ATLAS-Tools',
), dict(
name='ATLAS-Higgs-Challenge-2014',
dbquery='collections.primary:"ATLAS-Higgs-Challenge-2014"',
dbquery='collections.primary:ATLAS-Higgs-Challenge-2014',
),
],
), dict(
name='LHCb',
dbquery=None,
dbquery='collections.experiment:LHCb',
description="",
thumb="",
children=[dict(
name='LHCb-Derived-Datasets',
dbquery='collections.primary:"LHCb-Derived-Datasets"',
dbquery='collections.primary:LHCb-Derived-Datasets',
), dict(
name='LHCb-Tools',
dbquery='collections.primary:"LHCb-Tools"',
dbquery='collections.primary:LHCb-Tools',
), dict(
name='LHCb-Learning-Resources',
dbquery='collections.primary:"LHCb-Learning-Resources"',
dbquery='collections.primary:LHCb-Learning-Resources',
),
],
), dict(
name='Author-Lists',
dbquery='collections.primary:"Author-Lists"',
dbquery='collections.primary:Author-Lists',
description="",
thumb="",
), dict(
name='Data-Policies',
dbquery='collections.primary:"Data-Policies"',
dbquery='collections.primary:Data-Policies',
description="",
thumb="",
),
],
),
Expand Down
38 changes: 38 additions & 0 deletions cernopendata/templates/invenio_collections/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{%- extends 'cernopendata_theme/page.html' %}

{% from "macros/search_base.html" import search_component %}

{%- block javascript %}
{{ super() }}
{% assets "invenio_search_ui_search_js" %}<script src="{{ ASSET_URL }}"></script>{% endassets %}

{# assets "cernopendata_theme_js" %}<script src="{{ ASSET_URL }}"></script>{% endassets #}
<script>
angular.module('invenioSearch').filter('unsafe', function($sce) { return $sce.trustAsHtml; });
</script>
{% assets "cernopendata_search_js" %}<script src="{{ ASSET_URL }}"></script>{% endassets %}
{%- endblock javascript %}

{%- block page_body %}
<div class="container">
<h2>{{ collection.name }}</h2>
<hr>
<div class="row">
<div class="col-sm-12">
{% if collection.description %}
<h2>{{ collection.description }}. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laudantium officia praesentium hic, veritatis totam libero alias nostrum provident ex eaque quibusdam, saepe perspiciatis laboriosam nisi, asperiores eius excepturi qui voluptatibus.</h2>
<hr>
{% endif %}
{% for child_col in collection.children %}
<a href="{{ url_for('invenio_collections.collection', name=child_col.name)}}">{{ child_col.name }}</a> {{ "|" if not loop.last }}
{% endfor %}
<hr>

{{
search_component(config.SEARCH_UI_SEARCH_API+"?collections="+collection.name) }}
</div>
</div>
</div>


{%- endblock %}
97 changes: 97 additions & 0 deletions cernopendata/templates/macros/search_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{%- macro search_component(
endpoint=config.SEARCH_UI_SEARCH_API
)
%}


<div id="invenio-search">
<invenio-search
search-endpoint="{{endpoint}}"
search-hidden-params='{% if search_hidden_params %}{{search_hidden_params|tojson}}{% endif %}'
search-headers='{"Accept": "{{ config.SEARCH_UI_SEARCH_MIMETYPE|default('application/json')}}"}'
>
<div class="search-page">
<div class="row">
{%- block search_body %}
<div class="col-xs-12 col-md-9 col-md-push-3">
{%- block search_header %}
<div class="row">
{%- block search_count %}
<div class="col-md-3 col-sm-12">
<invenio-search-count
template="{{ url_for('static', filename=config.SEARCH_UI_JSTEMPLATE_COUNT) }}">
</invenio-search-count>
</div>
{%- endblock search_count %}
{%- block search_pagination_top %}
<div class="col-md-6 col-sm-12 text-center">
<invenio-search-pagination
template="{{ url_for('static', filename=config.SEARCH_UI_JSTEMPLATE_PAGINATION) }}">
</invenio-search-pagination>
</div>
{%- endblock search_pagination_top %}
{%- block search_sort %}
{%- set sort_options = config.get('RECORDS_REST_SORT_OPTIONS', {}).get(config.SEARCH_UI_SEARCH_INDEX) %}
{%- if sort_options %}
<div class="col-md-3 col-sm-12 text-right">
{%- block search_sort_select scoped %}
Sort by:
<invenio-search-select-box
sort-key="sort"
available-options='{{ sort_options|format_sortoptions|safe }}'
template="{{ url_for('static', filename=config.SEARCH_UI_JSTEMPLATE_SELECT_BOX) }}"
>
</invenio-search-select-box>
{%- endblock search_sort_select %}
{%- block search_sort_order scoped %}
<invenio-search-sort-order
sort-key="sort"
template="{{ url_for('static', filename=config.SEARCH_UI_JSTEMPLATE_SORT_ORDER) }}"
>
</invenio-search-sort-order>
{%- endblock search_sort_order %}
</div>
{%- endif %}
{%- endblock search_sort %}
</div>
<hr class="no-margin-top" />
{%- endblock search_header %}
{%- block search_error %}
<invenio-search-error
template="{{ url_for('static', filename=config.SEARCH_UI_JSTEMPLATE_ERROR) }}"
message="{{ _('Search failed.') }}">
</invenio-search-error>
{%- endblock search_error %}
{%- block search_loading %}
<invenio-search-loading
template="{{ url_for('static', filename=config.SEARCH_UI_JSTEMPLATE_LOADING) }}"
message="{{ _('Loading...') }}">
</invenio-search-loading>
{%- endblock search_loading %}
{%- block search_results %}
<invenio-search-results
template="{{ url_for('static', filename='templates/cernopendata_search_ui/results.html') }}">
</invenio-search-results>
{%- endblock search_results %}
{%- block search_pagination_bottom %}
<div align="center">
<invenio-search-pagination
template="{{ url_for('static', filename=config.SEARCH_UI_JSTEMPLATE_PAGINATION) }}">
</invenio-search-pagination>
</div>
{%- endblock search_pagination_bottom %}
</div>
{%- endblock search_body %}
{%- block search_facets %}
<div class="col-md-3 col-md-pull-9 col-xs-12">
<invenio-search-facets
template="{{ url_for('static', filename='templates/cernopendata_search_ui/facets.html') }}">
</invenio-search-facets>
</div>
{%- endblock search_facets %}
</div>
</div>
</invenio-search>
</div>
{%- endmacro %}

3 changes: 3 additions & 0 deletions requirements-devel-cernopendata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
# waive the privileges and immunities granted to it by virtue of its status
# as an Intergovernmental Organization or submit itself to any jurisdiction.


-e git+https://github.com/pamfilos/invenio-collections.git#egg=invenio-collections

-e .[all]
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
'invenio-theme==1.0.0b2',
'invenio-base>=1.0.0a9',
'invenio-celery>=1.0.0b1',
'invenio-collections>=1.0.0a1',
# 'invenio-collections>=1.0.0a1',
'invenio-config>=1.0.0b1',
'invenio-db[versioning,postgresql]>=1.0.0b3',
'invenio-indexer>=1.0.0a1',
Expand Down Expand Up @@ -142,7 +142,7 @@
'cernopendata.modules.theme.views:blueprint',
],
'invenio_config.module': [
'cernopendata = cernopendata.config',
'cernopendata = cernopendata.config',
],
'invenio_pidstore.minters': [
'cernopendata_recid_minter = '
Expand Down

0 comments on commit 7f15e5f

Please sign in to comment.