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

feat: adding a sidebar for easier navigation #164

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
127 changes: 127 additions & 0 deletions src/wikmd/static/css/wiki.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,130 @@ div.html-integration{
.mermaid {
text-align: center;
}

.wmd-main {
grid-area:main;
}


@media (min-width: 768px) {
.wmd-main {
display:grid;
gap:inherit;
grid-template-areas:"intro" "toc" "content";
grid-template-rows:auto auto 1fr;
}
}
@media (min-width: 992px) {
.wmd-main {
grid-template-areas:"intro toc" "content toc";
grid-template-columns:4fr 1fr;
grid-template-rows:auto 1fr;
}
}

@media (min-width: 768px) {
.wmd-layout {
display:grid;
gap:1.5rem;
grid-template-areas:"sidebar main";
grid-template-columns:1fr 3fr;
}
}
@media (min-width: 992px) {
.wmd-layout {
grid-template-columns:1fr 5fr;
}
}

.wmd-sidebar {
grid-area:sidebar;
}
.wmd-main {
grid-area:main;
}

@media (max-width: 991.98px) {
.wmd-sidebar {
width: 100%;
}
}
.wmd-sidebar .active {
border-radius: 5px;
}

.wmd-sidebar ul {
list-style-type: none;
padding-left: 0.5rem;
}

.wmd-links {
overflow:auto;
font-weight:600;
}

@media (min-width: 768px) {
.wmd-links {
position:-webkit-sticky;
/*! position:sticky; *//*! top:5rem; *//*! display:block !important; */height:calc(100vh - 7rem);
padding-left:.25rem;
margin-left:-.25rem;
overflow-y:auto;
}
}
@media (max-width: 767.98px) {
.wmd-links>ul {
padding:1.5rem .75rem;
background-color:#f8f9fa;
border-bottom:1px solid #e9ecef;
}
}

.wmd-links a {
padding:.1875rem .5rem;
margin-top:.125rem;
margin-left:1.25rem;
color: var(--txt-light);
text-decoration:none;
}

.wmd-links .btn {
padding:.25rem .5rem;
font-weight:600;
color: var(--txt-light);
background-color:transparent;
border:0;
}

.wmd-links .btn::before {
width:1.25em;
line-height:0;
content:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='rgba%28128,128,128,1%29' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M5 14l6-6-6-6'/%3e%3c/svg%3e");
transition:transform 0.35s ease;
transform-origin:.5em 50%
}

.wmd-links .btn:hover,
.wmd-links .btn:focus {
color: var(--txt-light);
background-color:rgba(121,82,179,0.1);
}

.wmd-links .btn[aria-expanded="true"] {
color:rgba(0,0,0,1);
font-style: oblique;
}

.wmd-links .btn[aria-expanded="true"]::before {
transform:rotate(90deg)
}
.wmd-links .active {
font-weight:600;
color: var(--txt-light);
}
.wmd-links a:hover,
.wmd-links a:focus {
color: var(--txt-light);
background-color:rgba(121,82,179,0.1);
}

25 changes: 25 additions & 0 deletions src/wikmd/static/css/wiki.dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,29 @@ div.html-integration{
.link-dark:hover,
.link-dark {
color: var(--txt-dark);
}

.wmd-links a {
color: var(--txt-dark);
}

.wmd-links .btn {
color: var(--txt-dark);
}

.wmd-links .btn:hover,
.wmd-links .btn:focus {
color: var(--txt-dark);
}

.wmd-links .btn[aria-expanded="true"] {
color: var(--txt-dark)
}

.wmd-links .active {
color: var(--txt-dark)
}
.wmd-links a:hover,
.wmd-links a:focus {
color: var(--txt-dark);
}
38 changes: 20 additions & 18 deletions src/wikmd/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,34 @@
<!-- Page -->
<div>

<div class="container-xxl my-md-4 wmd-layout ">

{% include 'sidebar.html'%}
<!-- Content -->
<div class="container mt-3">
<div class="container wmd-main">
{% block content %}

{% endblock %}
</div>
</div>

<!-- Footer -->
<footer class="d-flex flex-wrap justify-content-center py-3 my-4 mx-2 border-top">
<ul class="nav d-flex list-unstyled">
<li class="ms-2">
<!-- Footer -->
<footer class="d-flex flex-wrap justify-content-center py-3 my-4 mx-2 border-top">
<ul class="nav d-flex list-unstyled">
<li class="ms-2">

<a class="text-muted text-center" href="https://github.com/Linbreux/wikmd">
<a class="text-muted text-center" href="https://github.com/Linbreux/wikmd">

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-github">
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
</a>
</li>
<li class="ms-2">
<span class="text-muted">© 2024 wikmd</span>
</li>
</ul>
</footer>
</div>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-github">
<path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
</a>
</li>
<li class="ms-2">
<span class="text-muted">© 2023 wikmd</span>
</li>
</ul>
</footer>


<!-- Scripts -->
Expand All @@ -163,7 +166,6 @@
{% endblock %}

{% for plug in system.plugins %}{% if plug.add_script is defined %}{{plug.add_script()|safe}}{% endif%}{%endfor%}

</body>

</html>
53 changes: 26 additions & 27 deletions src/wikmd/templates/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,32 @@
{% endblock %}

{% block content %}
<h1 class="title">{% if folder %}
<a class="folder" style="{% if system.darktheme %} color:whitesmoke {% else %} color:#222326 {% endif %}"
href="/list/{{ folder }}">{{ folder }}</a>/
{% endif %}
{{ title }}
<a class="nostyle" style="float:right; padding-right:10px" data-bs-target="#removeModal" data-bs-toggle="modal" href="#removeModal">
<button class="btn btn-danger my-2 my-sm-0" type="submit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
<path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
</svg>
Delete
</button>
</a>
<a class="nostyle" style="float:right; padding-right:10px" href="/edit/{% if folder %}{{ folder }}/{% endif %}{{ title }}">
<button class="btn btn-primary my-2 my-sm-0" type="submit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
</svg>
Edit
</button>
</a>

</h1>
{{ info|safe }}
<hr>
<nav class="navbar">
<div class="container-fluid">
<a class="navbar-brand fs-1 text-reset">{{ title }}</a>
<div class="d-flex">
<a href="/edit/{% if folder %}{{ folder }}/{% endif %}{{ title }}">
<button class="btn btn-primary mx-2" type="submit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
</svg>
Edit
</button>
</a>
<a data-bs-target="#removeModal" data-bs-toggle="modal" href="#removeModal">
<button class="btn btn-danger mx-2" type="submit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
<path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
</svg>
Delete
</button>
</a>
</div>
</div>
</nav>
<p>{{ info|safe }}</p>
<p>{{ modif }}</p>
<div>

Expand Down
31 changes: 19 additions & 12 deletions src/wikmd/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

{%block content%}

<a class="nostyle" style="float:right; padding-right:10px" href="/edit/homepage">
<button class="btn btn-primary my-2 my-sm-0" type="submit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
</svg>
Edit Homepage
</button>
</a>

{{homepage|safe}}

<nav class="navbar">
<div class="container-fluid">
<a class="navbar-brand fs-1 text-reset">{{ title }}</a>
<div class="d-flex">
<a href="/edit/homepage">
<button class="btn btn-primary my-2 my-sm-0" type="submit">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
</svg>
Edit
</button>
</a>
</div>
</div>
</nav>
<p>
{{homepage|safe}}
</p>
{%endblock%}
8 changes: 4 additions & 4 deletions src/wikmd/templates/list_files.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<h2><b>{{ folder }}</b> ALL FILES</h2>
<ul class="list-group list-group-flush h5">
<li class="list-group-item"><i class="bi bi-folder pe-3"></i><i><a class="link-dark text-decoration-none" href="../">..</a></i></li>
{% for i in list %}
{% for i in list.children %}
<li class="list-group-item">
{% if i.folder != "" and i.folder != folder %}
<i class="bi bi-folder pe-3"></i><a class="link-dark fst-italic" href="/list/{{ i.folder }}/">{{ i.folder }}/ </a>
{% if i.children %}
<i class="bi bi-folder pe-3"></i><a class="link-dark fst-italic" href="/list/{{ i.url }}/">{{ i.name }}/ </a>
{% else %}
<i class="bi bi-file-earmark-text pe-3"></i><a class="link-dark text-decoration-none" href="/{{ i.url }}">{{ i.doc }}</a>
<i class="bi bi-file-earmark-text pe-3"></i><a class="link-dark text-decoration-none" href="/{{ i.url }}">{{ i.name }}</a>
{% endif %}
</li>
{% endfor %}
Expand Down
40 changes: 40 additions & 0 deletions src/wikmd/templates/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% macro build_element(item) -%}
{% if item.name == "wiki" %}
{# Skip the root folder #}
<ul class="list-unstyled fw-normal pb-1">
{% for child in item.children %}
<li>
{{ build_element(child) }}
</li>
{% endfor %}
</ul>

{% else %}
{% if item.children %}
<button class="btn d-inline-flex align-items-center rounded" type="button" data-bs-toggle="collapse"
data-bs-target="#collapse{{ item.id }}"
aria-expanded="{{ "true" if request.path.startswith("/" + item.url) else "false" }}"
aria-controls="collapse{{ item.id }}">{{ item.name }}</button>
<div class="collapse {{ "show" if request.path.startswith("/" + item.url) else "" }}" id="collapse{{ item.id }}">
<ul class="list-unstyled fw-normal pb-1">
{% for child in item.children %}
<li>
{{ build_element(child) }}
</li>
{% endfor %}
</ul>
</div>
{% else %}
<a class="d-inline-flex align-items-center rounded {% if request.path == "/" + item.url %} active {% endif %}" href="/{{ item.url }}">{{ item.name }}</a>
{% endif %}
{% endif %}
{%- endmacro %}


{% block content %}
<aside class="wmd-sidebar ">
<nav id="sidebarMenu" class="wmd-links d-none d-md-block">
{{ build_element(file_list) }}
</nav>
</aside>
{% endblock %}
Loading
Loading