Skip to content

Commit

Permalink
Merge pull request #19 from paulocoutinhox/time-module
Browse files Browse the repository at this point in the history
better time module and send it to template
  • Loading branch information
paulocoutinhox authored Nov 17, 2023
2 parents 4875c6e + 40619b7 commit 8bae7d3
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 97 deletions.
3 changes: 2 additions & 1 deletion modules/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from livereload import Server
from pygemstones.io import file

from modules import assets, config
from modules import assets, config, time

flask_app = None
freezer_app = None
Expand Down Expand Up @@ -66,6 +66,7 @@ def setup():
flask_app.config["FREEZER_DESTINATION"] = config.build_dir

flask_app.jinja_env.globals.update(file=file)
flask_app.jinja_env.globals.update(time=time)
flask_app.jinja_env.globals.update(path=os.path)
flask_app.jinja_env.globals.update(is_debug=is_debug())
flask_app.jinja_env.auto_reload = is_debug()
Expand Down
5 changes: 5 additions & 0 deletions modules/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ def current_time():
# -----------------------------------------------------------------------------
def current_time_ms():
return round(time.time() * 1000)


# -----------------------------------------------------------------------------
def current_time_str():
return time.strftime("%Y-%m-%d %H:%M:%S")
21 changes: 12 additions & 9 deletions templates/pages/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{{ page_container_start() }}

<center>
<figure>
<img width="180" src="/assets/images/logo.png" alt="Logo">
</figure>
<figure>
<img width="180" src="/assets/images/logo.png" alt="Logo">
</figure>
</center>

<br />
Expand All @@ -24,22 +24,25 @@ <h1>About Kaktos</h1>
<br />

<p>
Kaktos is a python static site generator.
Kaktos is a python static site generator.
</p>
<p>
The idea is create a simple static site generator for people that don't need server-side languages and server.
The idea is create a simple static site generator for people that don't need server-side languages and server.
</p>
<p>
Designers can use it too, since it don't need people that know a programming language.
Designers can use it too, since it don't need people that know a programming language.
</p>
<p>
Version: {{ time.current_time_str() }}
</p>

<br />
<br />

<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
<a class="btn btn-outline-secondary btn-lg px-4" href="https://github.com/paulocoutinhox/kaktos">
Learn more
</a>
<a class="btn btn-outline-secondary btn-lg px-4" href="https://github.com/paulocoutinhox/kaktos">
Learn more
</a>
</div>

{{ page_container_end() }}
Expand Down
43 changes: 22 additions & 21 deletions templates/pages/gallery.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<script src="/assets/vendor/magnific-popup/js/magnific-popup.min.js"></script>

<script>
$(document).ready(function () {
$('.gallery-image').magnificPopup({
type: 'image',
gallery: {
enabled: true
},
$(document).ready(function () {
$('.gallery-image').magnificPopup({
type: 'image',
gallery: {
enabled: true
},
});
});
});
</script>
{% endblock %}

Expand All @@ -26,9 +26,9 @@
{{ page_container_start() }}

<center>
<figure>
<img width="180" src="/assets/images/logo.png" alt="Logo">
</figure>
<figure>
<img width="180" src="/assets/images/logo.png" alt="Logo">
</figure>
</center>

<br />
Expand All @@ -40,23 +40,24 @@ <h1>Gallery</h1>
<br />

<div class="row gallery-container" uk-grid uk-lightbox="animation: slide">
{% for gallery in file.find_dirs(path.join("files", "images", "gallery"), "*") %}
{% for gallery in file.find_dirs(path.join("files", "images", "gallery"), "*") %}

{% for image in file.find_files(gallery, ["*.jpg", "*.png"]) %}
{% for image in file.find_files(gallery, ["*.jpg", "*.png"]) %}

<div class="col-xl-3 col-lg-3 col-md-4 col-sm-6 mb-4 mb-lg-0">
<a href="/assets/images/gallery/{{ path.basename(gallery) }}/{{ path.basename(image) }}" class="gallery-image">
<img src="/assets/images/gallery/{{ path.basename(gallery) }}/{{ path.basename(image) }}" class="rounded mb-4">
</a>
</div>
<div class="col-xl-3 col-lg-3 col-md-4 col-sm-6 mb-4 mb-lg-0">
<a href="/assets/images/gallery/{{ path.basename(gallery) }}/{{ path.basename(image) }}" class="gallery-image">
<img src="/assets/images/gallery/{{ path.basename(gallery) }}/{{ path.basename(image) }}"
class="rounded mb-4">
</a>
</div>

{% endfor %}
{% endfor %}

{% else %}
{% else %}

<strong>No gallery</strong>
<strong>No gallery</strong>

{% endfor %}
{% endfor %}
</div>

<br />
Expand Down
48 changes: 24 additions & 24 deletions templates/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
{{ page_container_start() }}

<div class="px-4 py-5 my-5 text-center">
<h1 class="display-5 fw-bold">Generated with success!</h1>

<br />
<br />
<br />

<figure>
<img width="180" src="/assets/images/logo.png" alt="Logo">
</figure>

<br />
<br />
<br />

<div class="col-lg-6 mx-auto">
<p class="lead mb-4">
It was generated by Kaktos static site generator
</p>

<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
<a class="btn btn-outline-secondary btn-lg px-4" href="https://github.com/paulocoutinhox/kaktos">
Learn more
</a>
<h1 class="display-5 fw-bold">Generated with success!</h1>

<br />
<br />
<br />

<figure>
<img width="180" src="/assets/images/logo.png" alt="Logo">
</figure>

<br />
<br />
<br />

<div class="col-lg-6 mx-auto">
<p class="lead mb-4">
It was generated by Kaktos static site generator
</p>

<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
<a class="btn btn-outline-secondary btn-lg px-4" href="https://github.com/paulocoutinhox/kaktos">
Learn more
</a>
</div>
</div>
</div>

</div>

Expand Down
10 changes: 5 additions & 5 deletions templates/shared/footer.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!-- footer -->
<footer class="footer mt-auto py-3 bg-light">
<div class="container">
<span class="text-muted">
Kaktos by <a href="https://github.com/paulocoutinhox/kaktos">Paulo Coutinho</a>
</span>
</div>
<div class="container">
<span class="text-muted">
Kaktos by <a href="https://github.com/paulocoutinhox/kaktos">Paulo Coutinho</a>
</span>
</div>
</footer>

<!-- others files -->
Expand Down
8 changes: 4 additions & 4 deletions templates/shared/google-analytics.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!-- google analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-G78ENDV04Q"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());

gtag('config', 'G-G78ENDV04Q');
gtag('config', 'G-G78ENDV04Q');
</script>
6 changes: 3 additions & 3 deletions templates/shared/head.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

{%- if page_title %}
{%- set page_title = page_title + " - " + kaktos.config.title -%}
Expand Down Expand Up @@ -184,8 +184,8 @@
{% endif -%}

<link rel="stylesheet"
href="/assets/css/main.css{% if not kaktos.is_debug %}?v={{ kaktos.config.version_css_file }}{% endif %}"
type="text/css" />
href="/assets/css/main.css{% if not kaktos.is_debug %}?v={{ kaktos.config.version_css_file }}{% endif %}"
type="text/css" />

<script src="/assets/vendor/jquery/js/jquery.min.js"></script>
<script src="/assets/vendor/bootstrap/js/bootstrap.min.js"></script>
57 changes: 29 additions & 28 deletions templates/shared/header.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
<!-- header -->
<header>
<!-- navbar -->
<nav class="navbar navbar-expand-md navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="{{ url_for('index') }}">
<img src="/assets/images/logo-mini.png" alt="Logo">
</a>
<!-- navbar -->
<nav class="navbar navbar-expand-md navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="{{ url_for('index') }}">
<img src="/assets/images/logo-mini.png" alt="Logo">
</a>

<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse"
aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse"
aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarCollapse">
<div class="collapse navbar-collapse" id="navbarCollapse">

<ul class="navbar-nav ms-auto mb-2 mb-md-0">
<li class="nav-item">
<a class="nav-link {% if kaktos.path == 'index' %}active{% endif %}" {% if kaktos.path=='index' %}
aria-current="page" {% endif %} href="{{ url_for('index') }}">Home</a>
</li>
<ul class="navbar-nav ms-auto mb-2 mb-md-0">
<li class="nav-item">
<a class="nav-link {% if kaktos.path == 'index' %}active{% endif %}" {% if kaktos.path=='index'
%} aria-current="page" {% endif %} href="{{ url_for('index') }}">Home</a>
</li>

<li class="nav-item">
<a class="nav-link {% if kaktos.path == 'gallery' %}active{% endif %}" {% if kaktos.path=='gallery' %}
aria-current="page" {% endif %} href="{{ url_for('page', path='gallery') }}">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link {% if kaktos.path == 'gallery' %}active{% endif %}" {% if
kaktos.path=='gallery' %} aria-current="page" {% endif %}
href="{{ url_for('page', path='gallery') }}">Gallery</a>
</li>

<li class="nav-item">
<a class="nav-link {% if kaktos.path == 'about' %}active{% endif %}" {% if kaktos.path=='about' %}
aria-current="page" {% endif %} href="{{ url_for('page', path='about') }}">About</a>
</li>
</ul>
<li class="nav-item">
<a class="nav-link {% if kaktos.path == 'about' %}active{% endif %}" {% if kaktos.path=='about'
%} aria-current="page" {% endif %} href="{{ url_for('page', path='about') }}">About</a>
</li>
</ul>

</div>
</div>
</nav>
</div>
</div>
</nav>
</header>
4 changes: 2 additions & 2 deletions templates/shared/macros.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!-- page container start -->
{% macro page_container_start() -%}
<main>
<div class="container">
<div class="container">
{%- endmacro %}

<!-- page container end -->
{% macro page_container_end() -%}
</div>
</div>
</main>
{%- endmacro %}

0 comments on commit 8bae7d3

Please sign in to comment.