From 24c9471c59d1b3bea222ea0180cf58a2aff78fce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-S=C3=A9bastien=20Caux?= <git@jscaux.org>
Date: Sun, 31 Oct 2021 08:37:56 +0100
Subject: [PATCH] Rework navbar for new home and portal

---
 .../scipost/templates/scipost/bare_base.html  |   4 +-
 .../scipost/templates/scipost/index2.html     |   3 +
 .../scipost/templates/scipost/navbar2.html    | 153 ++++++++++++++++++
 .../templates/scipost/portal/portal.html      |   3 +
 .../templates/bi/person-workspace.html        |   4 +
 .../templates/bi/question-square-fill.html    |   3 +
 6 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 scipost_django/scipost/templates/scipost/navbar2.html
 create mode 100644 scipost_django/templates/bi/person-workspace.html
 create mode 100644 scipost_django/templates/bi/question-square-fill.html

diff --git a/scipost_django/scipost/templates/scipost/bare_base.html b/scipost_django/scipost/templates/scipost/bare_base.html
index 940472be8..6654ab36f 100644
--- a/scipost_django/scipost/templates/scipost/bare_base.html
+++ b/scipost_django/scipost/templates/scipost/bare_base.html
@@ -30,7 +30,9 @@
     {% block header %}
       {% include 'scipost/header.html' %}
     {% endblock header %}
-    {% include 'scipost/navbar.html' %}
+    {% block navbar %}
+      {% include 'scipost/navbar.html' %}
+    {% endblock navbar %}
     {% block breadcrumb %}{% endblock breadcrumb %}
 
     {% block secondary_navbar %}{% endblock secondary_navbar %}
diff --git a/scipost_django/scipost/templates/scipost/index2.html b/scipost_django/scipost/templates/scipost/index2.html
index fe4a34987..bf2ae4076 100644
--- a/scipost_django/scipost/templates/scipost/index2.html
+++ b/scipost_django/scipost/templates/scipost/index2.html
@@ -3,6 +3,9 @@
 {% load render_bundle from webpack_loader %}
 {% load static %}
 
+{% block navbar %}
+  {% include 'scipost/navbar2.html' %}
+{% endblock %}
 
 {% block headsup %}
   {{ block.super }}
diff --git a/scipost_django/scipost/templates/scipost/navbar2.html b/scipost_django/scipost/templates/scipost/navbar2.html
new file mode 100644
index 000000000..07ca5f1b6
--- /dev/null
+++ b/scipost_django/scipost/templates/scipost/navbar2.html
@@ -0,0 +1,153 @@
+{% load request_filters %}
+{% load static %}
+{% load scipost_extras %}
+{% load journals_extras %}
+{% load user_groups %}
+
+{% is_active_fellow request.user as is_active_fellow %}
+
+
+
+
+<nav class="navbar navbar-expand-lg main-nav">
+  <div class="container">
+    <button class="navbar-toggler p-0 border-0" type="button" data-bs-toggle="collapse" data-bs-target="#main-navbar" aria-label="Navbar toggler">
+      <span class="navbar-toggler-icon">{% include 'bi/list.html' %}</span>
+    </button>
+    <div class="collapse navbar-collapse mt-lg-0 mt-3" id="main-navbar">
+      <ul class="navbar-nav me-auto">
+
+        <li class="nav-item{% if request.path == '/home2' %} active{% endif %}">
+          <a href="{% url 'scipost:index2' %}" class="nav-link" aria-label="SciPost Home">
+            <span class="d-none d-lg-inline-block" aria-hidden="true" style="min-width: 16px;">{% include 'bi/house-fill.html' %}</span>
+            <span class="d-lg-none d-inline-block">Home</span>
+          </a>
+        </li>
+
+	<li class="nav-item{% if 'portal' in request.path %} active{% endif %}">
+          <a href="{% url 'scipost:portal' %}" class="nav-link" aria-label="Portal">
+            <span class="d-none d-lg-inline-block" aria-hidden="true" style="min-width: 16px;">{% include 'bi/person-workspace.html' %}</span>
+            <span class="d-lg-none d-inline-block">Academic portal</span>
+          </a>
+        </li>
+
+
+        <li class="nav-item dropdown">
+          <a class="nav-link dropdown-toggle" href="#" id="AboutDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"  data-trigger="hover">
+            <span class="d-none d-lg-inline-block" aria-hidden="true" style="min-width: 16px;">{% include 'bi/question-square-fill.html' %}</span>
+            <span class="d-lg-none d-inline-block">About Scipost</span>
+	  </a>
+          <div class="dropdown-menu" aria-labelledby="AboutDropdown">
+	    <div class="dropdown-item">
+	      <a href="{% url 'scipost:contact' %}">Contact us</a>
+	    </div>
+            <div class="dropdown-item">
+              <a href="{% url 'scipost:about' %}">About SciPost</a>
+            </div>
+
+            <div class="dropdown-item">
+              <a href="{% url 'scipost:foundation' %}">The Foundation</a>
+            </div>
+
+            <div class="dropdown-item">
+	      <a href="{% url 'careers:jobopenings' %}">Careers&#64;SciPost</a>
+            </div>
+
+            <div class="dropdown-divider"></div>
+
+            <div class="dropdown-item">
+              <a href="{% url 'scipost:FAQ' %}">FAQ</a>
+            </div>
+
+            <div class="dropdown-item">
+              <a href="{% url 'news:news' %}">News</a>
+            </div>
+
+            <div class="dropdown-item">
+              <a href="{% url 'scipost:feeds' %}">Feeds</a>
+            </div>
+
+            <div class="dropdown-divider"></div>
+
+            <div class="dropdown-item">
+              <a href="{% url 'finances:business_model' %}">Our Business Model</a>
+            </div>
+
+            <div class="dropdown-item">
+              <a href="{% url 'organizations:organizations' %}">Organizations<br/><span class="small">benefitting from our activities</span></a>
+            </div>
+
+            <div class="dropdown-item">
+              <a href="{% url 'sponsors:sponsors' %}">Sponsors</a>
+            </div>
+
+            <div class="dropdown-item">
+              <a href="{% url 'finances:finances' %}">Finances</a>
+            </div>
+
+          </div>
+        </li>
+
+      </ul>
+
+      <hr class="lg d-lg-none">
+
+      <ul class="navbar-nav me-0">
+        {% if user.is_authenticated %}
+          <li class="nav-item dropdown">
+            <a class="nav-link dropdown-toggle" href="#" id="PersonalDropdown" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"  data-trigger="hover">
+              Logged in as {% if user.last_name %}{% if user.contributor %}{{ user.contributor.profile.get_title_display }} {% endif %}{{ user.first_name }} {{ user.last_name }}{% else %}{{ user.username }}{% endif %}</a>
+
+            {% if request.user.contributor and not request.user.contributor.is_currently_available %}
+              <button type="button" class="btn btn-link p-0 text-warning" data-bs-toggle="tooltip" data-bs-title="You are currently unavailable.<br>Check your availability on your Personal Page if this should not be the case." data-bs-html="true">{% include 'bi/exclamation-triangle-fill.html' %}</button>
+              &nbsp;
+            {% endif %}
+            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="PersonalDropdown">
+              {% if user.contributor %}
+                <div class="dropdown-item">
+                  <a href="{% url 'scipost:personal_page' %}">Personal Page</a>
+                </div>
+                {% if is_active_fellow %}
+                  <div class="dropdown-item">
+                    <a href="{% url 'submissions:pool' %}">Submissions Pool</a>
+                  </div>
+                {% endif %}
+              {% endif %}
+              {% if perms.scipost.can_view_production %}
+                <div class="dropdown-item">
+                  <a href="{% url 'production:production' %}">Production</a>
+                </div>
+              {% endif %}
+              {% if perms.scipost.can_manage_organizations or user.org_contact %}
+                <div class="dropdown-item">
+                  <a href="{% url 'organizations:dashboard' %}">Orgs dashboard</a>
+                </div>
+              {% endif %}
+	      <div class="dropdown-divider"></div>
+	      <div class="dropdown-item">
+		<a href="{% url 'forums:forums' %}">Forums and Meetings</a>
+	      </div>
+              <div class="dropdown-divider"></div>
+	      <div class="dropdown-item">
+		<a href="{% url 'helpdesk:helpdesk' %}">Helpdesk</a>
+	      </div>
+              <div class="dropdown-divider"></div>
+              <div class="dropdown-item">
+                <a href="{% url 'scipost:logout' %}?next={{ request.path }}">Logout</a>
+              </div>
+            </div>
+          </li>
+
+	  <li class="nav-item">
+	    &emsp;<a href="{% url 'helpdesk:ticket_create' %}" target="_blank" class="nav-link"><span style="font-size: 80%;" data-bs-toggle="tooltip" data-bs-html="true" title="Notice something wrong?<br/>Open a support ticket">{% include 'bi/sticky-fill.html' %}</span></a>
+	  </li>
+
+        {% else %}
+          <li class="nav-item{% if request.path == '/login/' %} active{% endif %}">
+            <a class="nav-link" href="{% url 'scipost:login' %}?next={{request.path}}">Login or register</a>
+          </li>
+        {% endif %}
+      </ul>
+    </div>
+  </div>
+</nav>
diff --git a/scipost_django/scipost/templates/scipost/portal/portal.html b/scipost_django/scipost/templates/scipost/portal/portal.html
index b72b54ee2..5402f3892 100644
--- a/scipost_django/scipost/templates/scipost/portal/portal.html
+++ b/scipost_django/scipost/templates/scipost/portal/portal.html
@@ -3,6 +3,9 @@
 {% load render_bundle from webpack_loader %}
 {% load static %}
 
+{% block navbar %}
+  {% include 'scipost/navbar2.html' %}
+{% endblock %}
 
 {% block body_class %}{{ block.super }} homepage{% endblock %}
 
diff --git a/scipost_django/templates/bi/person-workspace.html b/scipost_django/templates/bi/person-workspace.html
new file mode 100644
index 000000000..14756bf62
--- /dev/null
+++ b/scipost_django/templates/bi/person-workspace.html
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-person-workspace" viewBox="0 0 16 16">
+  <path d="M4 16s-1 0-1-1 1-4 5-4 5 3 5 4-1 1-1 1H4Zm4-5.95a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/>
+  <path d="M2 1a2 2 0 0 0-2 2v9.5A1.5 1.5 0 0 0 1.5 14h.653a5.373 5.373 0 0 1 1.066-2H1V3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v9h-2.219c.554.654.89 1.373 1.066 2h.653a1.5 1.5 0 0 0 1.5-1.5V3a2 2 0 0 0-2-2H2Z"/>
+</svg>
diff --git a/scipost_django/templates/bi/question-square-fill.html b/scipost_django/templates/bi/question-square-fill.html
new file mode 100644
index 000000000..29b68a5ef
--- /dev/null
+++ b/scipost_django/templates/bi/question-square-fill.html
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-question-square-fill" viewBox="0 0 16 16">
+  <path d="M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm3.496 6.033a.237.237 0 0 1-.24-.247C5.35 4.091 6.737 3.5 8.005 3.5c1.396 0 2.672.73 2.672 2.24 0 1.08-.635 1.594-1.244 2.057-.737.559-1.01.768-1.01 1.486v.105a.25.25 0 0 1-.25.25h-.81a.25.25 0 0 1-.25-.246l-.004-.217c-.038-.927.495-1.498 1.168-1.987.59-.444.965-.736.965-1.371 0-.825-.628-1.168-1.314-1.168-.803 0-1.253.478-1.342 1.134-.018.137-.128.25-.266.25h-.825zm2.325 6.443c-.584 0-1.009-.394-1.009-.927 0-.552.425-.94 1.01-.94.609 0 1.028.388 1.028.94 0 .533-.42.927-1.029.927z"/>
+</svg>
-- 
GitLab