Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

records: integrate public search #122

Merged
merged 1 commit into from
Jan 16, 2020
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
20 changes: 5 additions & 15 deletions sonar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ def _(x):
'content_security_policy': {
'default-src': ["'self'"],
'object-src': ["'none'"],
'script-src': [
"'self'", "'unsafe-inline'", 'https://code.jquery.com',
'https://cdnjs.cloudflare.com',
'https://stackpath.bootstrapcdn.com'
],
'style-src': [
"'self'", "'unsafe-inline'", 'https://cdnjs.cloudflare.com',
'https://fonts.googleapis.com'
Expand Down Expand Up @@ -213,21 +218,6 @@ def _(x):

PIDSTORE_RECID_FIELD = 'pid'

SEARCH_UI_SEARCH_INDEX = 'documents'
SEARCH_UI_SEARCH_API = '/api/documents/'
SEARCH_UI_SEARCH_TEMPLATE = 'sonar/search.html'

SEARCH_UI_JSTEMPLATE_RESULTS = 'templates/documents/search_ui/results.html'
SEARCH_UI_JSTEMPLATE_COUNT = 'templates/documents/search_ui/count.html'
SEARCH_UI_JSTEMPLATE_PAGINATION = 'templates/documents/search_ui/'\
'pagination.html'
SEARCH_UI_JSTEMPLATE_SORT_ORDER = 'templates/documents/search_ui/'\
'sort_order.html'
SEARCH_UI_JSTEMPLATE_SELECT_BOX = 'templates/documents/search_ui/'\
'select_box.html'
SEARCH_UI_JSTEMPLATE_LOADING = 'templates/documents/search_ui/loading.html'
SEARCH_UI_JSTEMPLATE_FACETS = 'templates/documents/search_ui/facets.html'

SECURITY_LOGIN_USER_TEMPLATE = 'sonar/accounts/login.html'
SECURITY_FORGOT_PASSWORD_TEMPLATE = 'sonar/accounts/forgot_password.html'
SECURITY_REGISTER_USER_TEMPLATE = 'sonar/accounts/signup.html'
Expand Down
2 changes: 2 additions & 0 deletions sonar/modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@
SONAR_APP_DISABLE_PERMISSION_CHECKS = False
"""Disable permission checks during API calls. Useful when API is test from
command line or progams like postman."""

SONAR_APP_UI_VERSION = '0.1.4'
10 changes: 3 additions & 7 deletions sonar/modules/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,10 @@ def index():
return render_template('sonar/frontpage.html')


@blueprint.route('/search')
def search():
@blueprint.route('/search/<resource_type>')
def search(resource_type=None):
"""IR search results."""
search_hidden_params = {'institution': g.ir} \
if 'ir' in g and g.ir != 'sonar' else None

return render_template('sonar/search.html',
search_hidden_params=search_hidden_params)
return render_template('sonar/search.html')


def detail(pid, record, template=None, **kwargs):
Expand Down
5 changes: 3 additions & 2 deletions sonar/modules/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@


def utility_processor():
"""Dictionary for checking admin access."""
"""Dictionary for passing data to templates."""
return dict(has_admin_access=has_admin_access,
has_super_admin_access=has_super_admin_access)
has_super_admin_access=has_super_admin_access,
ui_version=config.SONAR_APP_UI_VERSION)


class Sonar(object):
Expand Down
43 changes: 0 additions & 43 deletions sonar/theme/assets/js/config.js

This file was deleted.

29 changes: 0 additions & 29 deletions sonar/theme/assets/js/search_ui.js

This file was deleted.

2 changes: 1 addition & 1 deletion sonar/theme/templates/sonar/frontpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>
<div class="row justify-content-center">
<div class="col-sm-12 col-lg-8 text-right my-4">
<form class="justify-content-end" action="{{ url_for('documents.search', ir=g.ir|default('sonar')) }}" role="search">
<form class="justify-content-end" action="{{ url_for('documents.search', ir=g.ir|default('sonar'), resource_type='documents') }}" role="search">
<div class="row">
<div class="col-12 col-sm-11">
<input class="form-control form-control-lg mr-2" type="search" placeholder="{{_('Search publications, authors, projects, ...')}}" aria-label="Search" name="q">
Expand Down
20 changes: 7 additions & 13 deletions sonar/theme/templates/sonar/manage.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Admin</title>
<title>{{ _("SONAR administration") }}</title>
<base href="/manage" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="/static/favicon.ico" />
{{ webpack["sonar-theme.css"] }}
<link
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css?family=Roboto+Condensed&display=swap"
rel="stylesheet"
/>
{{
webpack["sonar-theme.css"]
}}
</head>

<body>
<sonar-root></sonar-root>
{% assets "sonar_ui_js" %}
<script src="{{ ASSET_URL }}"></script>
{% endassets %}
<script src="/static/sonar-ui/runtime.js?{{ ui_version }}"></script>
<script src="/static/sonar-ui/polyfills.js?{{ ui_version }}"></script>
<script src="/static/sonar-ui/main.js?{{ ui_version }}"></script>
</body>
</html>
26 changes: 13 additions & 13 deletions sonar/theme/templates/sonar/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,35 @@
{%- endfor %}
{%- endif %}
{%- endblock head_meta %}

{%- block head_title %}
{%- set title = title or _(config.THEME_SITENAME) or _('Invenio') %}
<title>{{title}}</title>
{%- endblock head_title %}

{%- block head_links %}
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"/>
{%- if keywords %}
<link rel="canonical" href="{{ canonical_url }}"/>
{% endif %}

{%- block head_links_langs %}
{%- if alternate_urls %}
{%- for alt_ln, alternate_url in alternate_urls.items() %}
<link rel="alternate" hreflang="{{ alt_ln }}" href="{{ alternate_url }}"/>
{%- endfor %}
{%- endif %}
{%- endblock %}

{%- block head_apple_icons %}
{%- for size in [144, 114, 72, 57] %}
{%- set icon_name = 'apple-touch-icon-%d-precomposed.png' | format(size) %}
<link rel="apple-touch-icon-precomposed" sizes="{{ size }}x{{ size }}" href="{{ url_for('static', filename=icon_name) }}"/>
{%- endfor %}
{%- endblock head_apple_icons %}

{%- endblock head_links %}

{%- block css %}
{{ webpack[g.ir|default('sonar') ~ '-theme.css'] }}
{# assets "invenio_theme_css" %}<link href="{{ ASSET_URL }}" rel="stylesheet">{% endassets #}
Expand All @@ -75,7 +75,7 @@
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
{%- endblock css %}

{%- endblock head %}

<base href="/">
Expand All @@ -87,13 +87,13 @@
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
{%- endblock browserupgrade %}

{%- block body_inner %}
<header>
{% include 'sonar/partial/navbar.html' %}
{% include 'sonar/partial/navbar.html' %}
{%- block header %}{%- endblock header %}
</header>

<div class="container my-5">
{%- block breadcrumbs %}
{%- include "sonar/breadcrumbs.html" %}
Expand All @@ -106,14 +106,14 @@

{%- block body %}{%- endblock body %}
</div>

{% include 'sonar/footer.html' %}
{%- endblock body_inner %}

{%- block javascript %}
{% include 'sonar/javascript.html' %}
{%- endblock javascript %}

{%- block trackingcode %}
{% include config.THEME_TRACKINGCODE_TEMPLATE %}
{%- endblock %}
Expand Down
4 changes: 2 additions & 2 deletions sonar/theme/templates/sonar/partial/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<img src="{{ url_for('static', filename='images/' ~ g.ir|default('sonar') ~ '-logo.svg')}}" height="50" class="d-inline-block align-top mr-3 my-4" alt="">
</a>
{% if not admin %}
<form action="{{ url_for('documents.search', ir=g.ir|default('sonar')) }}" class="form-inline my-2 my-lg-0 ml-lg-5">
<form action="{{ url_for('documents.search', ir=g.ir|default('sonar'), resource_type='documents') }}" class="form-inline my-2 my-lg-0 ml-lg-5">
<input name="q" class="form-control mr-sm-2" type="search" placeholder="{{_('Search')}}" aria-label="{{_('Search')}}" value="{{ request.args.get('q', '') }}">
<button class="btn btn-outline-light my-2 my-sm-0" type="submit">
<i class="fa fa-search"></i>
Expand Down Expand Up @@ -97,4 +97,4 @@
</ul>
</div>
</div>
</nav>
</nav>
Loading