Skip to content

Commit

Permalink
frontend: header size for shared organisation
Browse files Browse the repository at this point in the history
* Closes #641.

Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Mar 1, 2022
1 parent 7db1884 commit 20250c6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion sonar/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ def init_views(self, app):
"""Initialize the main flask views."""
app.url_map.converters['org_code'] = OrganisationCodeConverter

@app.route('/')
@app.route('/<org_code:view>')
def index(view):
"""Homepage."""
return render_template('sonar/frontpage.html')
return render_template('sonar/frontpage.html', view=view)

@app.template_filter()
def nl2br(string):
Expand Down
6 changes: 4 additions & 2 deletions sonar/theme/templates/sonar/frontpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
<http: //www.gnu.org/licenses />.
#}

{% set page = 'home' %}
{% set page = 'organisation' if g.get('organisation') and g.get('organisation')['isShared'] and not g.get('organisation')['isDedicated'] else 'home' %}

{%- extends config.BASE_TEMPLATE %}

{%- set body_css_classes=['homepage'] %}

{% block header %}
{%- if not g.get('organisation') or (g.get('organisation') and g.organisation['isShared'] and g.organisation['isDedicated']) %}
<div class="bg-organisation p-4">
<div class="container">
<div class="row justify-content-center">
<div class="col-8 col-xs-6 col-lg-3 py-3 text-center">
<a
href="{{ url_for('index', view=view_code if g.get('organisation', {}).get('isDedicated') else config.SONAR_APP_DEFAULT_ORGANISATION) }}">
href="{{ url_for('index') if (not view or view == config.SONAR_APP_DEFAULT_ORGANISATION) else url_for('index', view=view_code) }}">
{% if g.get('organisation', {}).get('isDedicated') %}
{% set thumbnail = g.organisation | record_image_url('org') %}
{% if thumbnail %}
Expand Down Expand Up @@ -71,6 +72,7 @@ <h1>{{ g.organisation.name }}</h1>
</div>
</div>
</div>
{%- endif %}
<div class="bg-secondary text-light text-center py-2">
{% if not g.get('organisation', {}).get('isDedicated') and config.ENV != 'production' and current_user_record.is_submitter %}
<h6 class="m-0 mt-1">
Expand Down
10 changes: 5 additions & 5 deletions sonar/theme/templates/sonar/partial/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
<nav class="navbar navbar-expand-lg bg-{{ 'header' if page == 'home' else 'organisation' }}">
<div class="container">
{% if page != 'home' %}
<a class="navbar-brand" href="{{ url_for('index', view=view_code) }}">
{% set url = url_for('index') if (not view or view == config.SONAR_APP_DEFAULT_ORGANISATION) else url_for('index', view=view_code) %}
<a class="navbar-brand" href="{{ url }}">
{% if g.get('organisation', {}).get('isDedicated') %}
{% set thumbnail = g.organisation | record_image_url('org') %}
{% if thumbnail %}
Expand All @@ -29,11 +30,10 @@
{% endif %}
{% else %}
<img src="{{ url_for('static', filename='images/global-logo.svg') }}"
height="{{ '30' if g.get('organisation') else '50' }}"
class="d-inline-block align-top {{ '' if g.get('organisation') else 'my-2' }}" alt="{{ _('SONAR logo') }}">
height="{{ '30' if g.get('organisation') and page == 'home' else '50' }}"
class="d-inline-block align-top {{ '' if g.get('organisation') and page == 'home' else 'my-2' }}" alt="{{ _('SONAR logo') }}">
{% endif %}
</a>

{% endif %}
<button class="ml-auto navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
Expand All @@ -45,7 +45,7 @@
<form
action="{{ url_for('documents.search', view=view_code if g.get('organisation', {}).get('isDedicated') else config.SONAR_APP_DEFAULT_ORGANISATION) }}"
class="form-inline my-2 my-lg-0 ml-lg-3">
<input name="q" class="form-control {{ 'form-control-sm' if g.get('organisation') else '' }} mr-sm-2"
<input name="q" class="form-control {{ 'form-control-sm' if g.get('organisation') and page == 'home' else '' }} mr-sm-2"
type="search" placeholder="{{ _('Search') }}" aria-label="{{ _('Search') }}"
value="{{ request.args.get('q', '') }}">
<button class="btn btn-outline-light {{ 'btn-sm' if g.get('organisation') else '' }} my-2 my-sm-0" type="submit"
Expand Down
4 changes: 2 additions & 2 deletions sonar/theme/templates/sonar/partial/organisation.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h1 class="mb-2">{{ g.organisation.name }}</h1>
<p class="mb-3 text-justify">{{ g.organisation.description | language_value | markdown_filter | safe }}</p>
{% endif %}
<div class="row">
<div class="col-12 col-lg-4">
<div class="col-12 col-lg-6">
<form action="{{ url_for('documents.search', view=view_code) }}" role="search">
<div class="input-group mb-2">
<input type="text" name="q" value="{{ request.args.get('q', '') }}" class="form-control"
Expand All @@ -45,7 +45,7 @@ <h1 class="mb-2">{{ g.organisation.name }}</h1>
</form>
</div>
<div class="col text-right">
<a href="{{ url_for('index', view=config.SONAR_APP_DEFAULT_ORGANISATION) }}"
<a href="{{ url_for('index') }}"
class="btn btn-outline-primary btn-sm">
{{ _('Back to SONAR') }}
</a>
Expand Down

0 comments on commit 20250c6

Please sign in to comment.