Skip to content

Commit

Permalink
0xlukem/feedback (#66)
Browse files Browse the repository at this point in the history
* fix logic in the index-page.html to show feedback

* quick fix
  • Loading branch information
0xlukem authored Jan 6, 2025
1 parent 04a1adb commit 3ef44e0
Showing 1 changed file with 74 additions and 87 deletions.
161 changes: 74 additions & 87 deletions material-overrides/index-page.html
Original file line number Diff line number Diff line change
@@ -1,121 +1,108 @@
{% extends "main.html" %}

{% block styles %}
{{ super() }}
{{ super() }}
<link rel="stylesheet" href="{{ 'assets/stylesheets/index-page.css' | url }}">
{% endblock %}

{% block content %}

{% macro find_active_page(element, nav) %}
{% for nav_item in element %}
{% if nav_item.active %}
{% if nav_item.is_section %}
<!-- continue to find active page -->
{{ find_active_page(nav_item.children, nav) }}
{% else %}
<!-- render subsection content -->
{% if nav_item.is_page %}
<div class="subsection-wrapper">
{% set description = "" %}
{% for nav_item in element[1:] %}
{% if nav_item.is_section %}
{% set subsection_path = nav_item.children[0].url %}
{% set description = nav_item.children[0].meta.description %}
{% else %}
{% set subsection_path = nav_item.url %}
{% if nav_item.meta %}
{% set description = nav_item.meta.description %}
{% set description = "" %}
{% for nav_item in element[1:] %}
{% if nav_item.is_section %}
{% set subsection_path = nav_item.children[0].url %}
{% set description = nav_item.children[0].meta.description %}
{% else %}
{% set subsection_path = nav_item.url %}
{% if nav_item.meta %}
{% set description = nav_item.meta.description %}
{% endif %}
{% endif %}
{% if ".index" in page.url %}
{% set subsection_path = "/" + subsection_path %}
{% else %}
{% set subsection_path = subsection_path|replace(page.url, '') %}
{% endif %}
{% endif %}
{% if ".index" in page.url %}
{% set subsection_path = "/" + subsection_path %}
{% else %}
{% set subsection_path = subsection_path|replace(page.url, '') %}
{% endif %}

<div class="card">
<a href="{{ subsection_path }}">
<h2 class="title">{{ nav_item.title }}</h2>
{% if not description == "" %}
<p class="description">{{ description }}</p>
{% else %}
{% if nav_item.is_link %}
{% if '#' in nav_item.url %}
{% set nav_item_url = nav_item.url.split('#')[0] %}
{% else %}
{% set nav_item_url = nav_item.url %}
{% endif %}
<div class="card">
<a href="{{ subsection_path }}">
<h2 class="title">{{ nav_item.title }}</h2>
{% if description != "" %}
<p class="description">{{ description }}</p>
{% else %}
{% if nav_item.is_link %}
{% if '#' in nav_item.url %}
{% set nav_item_url = nav_item.url.split('#')[0] %}
{% else %}
{% set nav_item_url = nav_item.url %}
{% endif %}

{% if nav_item_url.startswith('/') %}
{% set nav_item_url = nav_item_url[1:] %}
{% endif %}
{% if nav_item_url.startswith('/') %}
{% set nav_item_url = nav_item_url[1:] %}
{% endif %}

{% for nav_child in nav.children %}
{{ find_desc_for_linked_pages(nav_child, nav_item_url, description) }}
{% endfor %}
{% for nav_child in nav.children %}
{{ find_desc_for_linked_pages(nav_child, nav_item_url, description) }}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
</a>
</div>
{% endfor %}
</a>
</div>
{% endfor %}
</div>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endmacro %}

{% set most_nested_active_element = None %}
{% if element.active == True %}
{{ element }}
{% set most_nested_active_element = element %}
{% endif %}

{% if element.active and element.children %}
{% for child in element.children %}
{% set nested_active_element = find_active_page(child) %}
{% if nested_active_element != none %}
{% set most_nested_active_element = nested_active_element %}
{% macro find_desc_for_linked_pages(nav, nav_item_url, description) %}
{% if nav.is_section %}
{% for nav_item in nav.children %}
{% if nav_item.is_page and nav_item.url in nav_item_url %}
{% if nav_item.url == nav_item_url %}
<p class="description">{{ nav_item.meta.description }}</p>
{% set description = nav_item.meta.description %}
{% endif %}
{% endif %}
{% if description == "" %}
{{ find_desc_for_linked_pages(nav_item, nav_item_url, description) }}
{% endif %}
{% endfor %}
{% endif %}
{% endmacro %}

{% macro find_desc_for_linked_pages(nav, nav_item_url, description) %}
{% if nav.is_section %}
{% for nav_item in nav.children %}
{% if nav_item.is_page and nav_item.url in nav_item_url %}
{% if nav_item.url == nav_item_url %}
<p class="description">{{ nav_item.meta.description }}</p>
{% set description = nav_item.meta.description %}
{% endif %}
{% endif %}
{% if description == "" %}
{{ find_desc_for_linked_pages(nav_item, nav_item_url, description) }}
{% block content %}

{% set insert_marker = ':::INSERT_IN_THIS_SECTION:::' %}
{% if insert_marker in page.content %}
{% set parts = page.content.split(insert_marker) %}
{% set dynamic_html %}
<div class="subsection-page">
{% if nav|length > 1 %}
{% for nav_item in nav %}
{% if nav_item.is_section and nav_item.active %}
{{ find_active_page(nav_item.children, nav_item) }}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endmacro %}

{% set insert_marker = ':::INSERT_IN_THIS_SECTION:::' %}
{% if insert_marker in page.content %}
{% set parts = page.content.split(insert_marker) %}
{% set dynamic_html %}
<div class="subsection-page">
{% if nav|length > 1 %}
{% for nav_item in nav %}
{% if nav_item.is_section and nav_item.active %}
{{ find_active_page(nav_item.children, nav_item) }}
{% endif %}
{% endfor %}
{% endif %}
</div>
{% endset %}
{% set modified_content = parts[0] | safe + (dynamic_html | safe) + parts[1] | safe %}
{{ modified_content | safe }}
{% else %}
{{ page.content | safe }}
{% endif %}
</div>
{% endset %}
{% set modified_content = parts[0] | safe + (dynamic_html | safe) + parts[1] | safe %}
{{ modified_content | safe }}
{% else %}
{{ page.content | safe }}
{% endif %}


<div class="md-content__feedback">
{% include "partials/feedback.html" %}
</div>
{% endblock %}

0 comments on commit 3ef44e0

Please sign in to comment.