From dcac1317bfe55dedb6a66848ec5621b84f7e6eeb Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Thu, 20 Sep 2018 12:06:43 +0200 Subject: [PATCH] Rename secondary_navigation to navigation_project And move to _navigation.pug with the other navigations macros. --- src/templates/_macros/_navigation.pug | 58 +++++++++++++++++++++++++++ src/templates/projects/landing.pug | 5 ++- src/templates/projects/view.pug | 5 ++- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/templates/_macros/_navigation.pug b/src/templates/_macros/_navigation.pug index 98dc2b0..143f28b 100644 --- a/src/templates/_macros/_navigation.pug +++ b/src/templates/_macros/_navigation.pug @@ -115,3 +115,61 @@ include ../../../../pillar/src/templates/mixins/components i.pi-flamenco.pr-2 span Flamenco | {% endmacro %} + +| {% macro navigation_project(project, navigation_links, title) %} + +| {% if project.category == 'course' %} +| {% set category_url = url_for('cloud.courses') %} +| {% elif project.category == 'workshop' %} +| {% set category_url = url_for('cloud.workshops') %} +| {% elif project.category == 'film' %} +| {% set category_url = url_for('cloud.open_projects') %} +| {% else %} +| {% set category_url = url_for('main.homepage') %} +| {% endif %} + ++nav-secondary() + | {% if project.url != 'blender-cloud' %} + | {% if not project.is_private %} + li.text-capitalize + a.nav-link.text-muted.px-0(href="{{ category_url }}") + | {% if project.category == 'film' %} + span Open Projects + | {% elif project.category == 'assets' %} + span Libraries + | {% else %} + span {{ project.category }} + | {% endif %} + li.px-1 + i.pi-angle-right + | {% endif %} + + +nav-secondary-link( + class="px-1 font-weight-bold{% if title == 'landing' %} active{% endif %}", + href="{{url_for('projects.view', project_url=project.url, _external=True)}}") + span {{ project.name }} + + | {% endif %} + + | {% for link in navigation_links %} + +nav-secondary-link( + href="{{ link['url'] }}", + class="{% if link['slug'] == title %}active{% endif %}") + span {{ link['label'] }} + | {% endfor %} + + | {% if project.nodes_featured %} + | {# In some cases featured_nodes might might be embedded #} + | {% if '_id' in project.nodes_featured[0] %} + | {% set featured_node_id=project.nodes_featured[0]._id %} + | {% else %} + | {% set featured_node_id=project.nodes_featured[0] %} + | {% endif %} + +nav-secondary-link( + href="{{ url_for('projects.view_node', project_url=project.url, node_id=featured_node_id) }}", + title="Explore {{ project.name }}", + class="{% if title == 'project' %}active{% endif %}") + span Browse + | {% endif %} + +| {% endmacro %} diff --git a/src/templates/projects/landing.pug b/src/templates/projects/landing.pug index 3b0947b..d947e75 100644 --- a/src/templates/projects/landing.pug +++ b/src/templates/projects/landing.pug @@ -1,9 +1,10 @@ | {% extends 'layout.html' %} +| {% from '_macros/_navigation.html' import navigation_project %} + include ../../../../pillar/src/templates/mixins/components | {% set title = 'landing' %} -| {% import 'projects/_macros.html' as projectmacros %} | {% from '_macros/_asset_list_item.html' import asset_list_item %} | {% block page_title %}{{ project.name }}{% endblock%} @@ -81,7 +82,7 @@ link(href="{{ url_for('static_cloud', filename='assets/css/project-main.css') }} | {% endblock %} | {% block navigation_tabs %} -| {{ projectmacros.render_secondary_navigation(project, navigation_links, title) }} +| {{ navigation_project(project, navigation_links, title) }} | {% endblock navigation_tabs %} | {% block body %} diff --git a/src/templates/projects/view.pug b/src/templates/projects/view.pug index 941d207..97239e6 100644 --- a/src/templates/projects/view.pug +++ b/src/templates/projects/view.pug @@ -1,6 +1,6 @@ | {% extends 'layout.html' %} | {% from '_macros/_add_new_menu.html' import add_new_menu %} -| {% from 'projects/_macros.html' import render_secondary_navigation %} +| {% from '_macros/_navigation.html' import navigation_project %} include ../../../../pillar/src/templates/mixins/components @@ -87,7 +87,8 @@ link(href="{{ url_for('static_cloud', filename='assets/css/project-main.css') }} | {% endblock %} | {% block navigation_tabs %} -| {{ render_secondary_navigation(project, navigation_links, title) }} +| {% from '_macros/_navigation.html' import navigation_collection %} +| {{ navigation_project(project, navigation_links, title) }} | {% endblock navigation_tabs %} | {% block body %}