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

frontend: header size for shared organisation #771

Merged
merged 1 commit into from
Mar 7, 2022
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
6 changes: 4 additions & 2 deletions sonar/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ def init_views(self, app):
"""Initialize the main flask views."""
app.url_map.converters['org_code'] = OrganisationCodeConverter

@app.route('/<org_code:view>')
@app.route('/', defaults={
'view': app.config.get('SONAR_APP_DEFAULT_ORGANISATION')})
@app.route('/<org_code:view>/')
def index(view):
"""Homepage."""
return render_template('sonar/frontpage.html')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to put a default view?

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 view_code == 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', view=view_code) if g.get('organisation', {}).get('isDedicated') and view_code != config.SONAR_APP_DEFAULT_ORGANISATION else url_for('index') %}
<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' }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better with a css class.

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