From 9d4f6ffd8c33d2c31a549de0b1b54b4735191889 Mon Sep 17 00:00:00 2001 From: Samuel ORTION Date: Fri, 19 Aug 2022 07:46:41 +0200 Subject: [PATCH] www: Add version tag to footer --- www/package.json | 1 + www/templates/disks/index.html.twig | 14 +++++++ www/templates/footer.html.twig | 3 ++ www/templates/today/index.html.twig | 63 ++++++++++++++++------------- www/webpack.config.js | 13 +++++- www/yarn.lock | 5 +++ 6 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 www/templates/disks/index.html.twig diff --git a/www/package.json b/www/package.json index e1d0e23..fcf9f13 100644 --- a/www/package.json +++ b/www/package.json @@ -4,6 +4,7 @@ "@symfony/stimulus-bridge": "^3.2.0", "@symfony/webpack-encore": "^3.0.0", "core-js": "^3.23.0", + "git-revision-webpack-plugin": "^5.0.0", "regenerator-runtime": "^0.13.9", "webpack-notifier": "^1.15.0" }, diff --git a/www/templates/disks/index.html.twig b/www/templates/disks/index.html.twig new file mode 100644 index 0000000..33e6ddd --- /dev/null +++ b/www/templates/disks/index.html.twig @@ -0,0 +1,14 @@ +{% block content %} +

{{ "Disk usage"|trans }}

+
+ + {{ disk.device }} + + + {{ disk.usage }} + + + {{ disk.available }} + +
+{% endblock %} diff --git a/www/templates/footer.html.twig b/www/templates/footer.html.twig index d49122c..00f42a7 100644 --- a/www/templates/footer.html.twig +++ b/www/templates/footer.html.twig @@ -9,4 +9,7 @@ Samuel ORTION

+

+ version: v +

\ No newline at end of file diff --git a/www/templates/today/index.html.twig b/www/templates/today/index.html.twig index b69dd5d..95f88af 100644 --- a/www/templates/today/index.html.twig +++ b/www/templates/today/index.html.twig @@ -1,31 +1,38 @@ -{% extends "base.html.twig" %} +{% extends 'base.html.twig' %} {% block content %} -

- {% set today = "now" | date("Y-m-d") %} - {% if today == date %} - {{ "Today's detected species" | trans }} - {% else %} - {{ "Detected species on" | trans }} - {{ date | format_datetime("full", "none") }} - {% endif %} -

- {% set endpoint = "today" %} - {% include "utils/calendar.html.twig" %} - {# Display a list of records if any, else, print message #} - {% if results is defined and results | length > 0 %} - - {% else %} -

{{ "No species detected this day" | trans }}

- {% endif %} +

+ {% set today = 'now'|date('Y-m-d') %} + {% if today == date %} + {{ "Today's detected species"|trans }} + {% else %} + {{ 'Detected species on'|trans }} + {{ date|format_datetime('full', 'none') }} + {% endif %} +

+ {% set endpoint = 'today' %} + {% include 'utils/calendar.html.twig' %} + {# Display a list of records if any, else, print message #} + {% if results is defined and (results|length) > 0 %} + + {% else %} +

+ {{ 'No species detected this day'|trans }} +

+ {% endif %} {% endblock %} diff --git a/www/webpack.config.js b/www/webpack.config.js index 672c56b..8c09f01 100644 --- a/www/webpack.config.js +++ b/www/webpack.config.js @@ -1,4 +1,7 @@ const Encore = require('@symfony/webpack-encore'); +const { DefinePlugin } = require('webpack'); +const { GitRevisionPlugin } = require('git-revision-webpack-plugin'); +const gitRevisionPlugin = new GitRevisionPlugin({lightweightTags: true}); // Manually configure the runtime environment if not already configured yet by the "encore" command. // It's useful when you use tools that rely on webpack.config.js file. @@ -73,6 +76,14 @@ Encore // uncomment if you're having problems with a jQuery plugin //.autoProvidejQuery() -; + + .addPlugin( + new DefinePlugin( + { + VERSION: JSON.stringify(gitRevisionPlugin.version()), + } + ) + ) + ; module.exports = Encore.getWebpackConfig(); diff --git a/www/yarn.lock b/www/yarn.lock index 9793098..736d3a8 100644 --- a/www/yarn.lock +++ b/www/yarn.lock @@ -2365,6 +2365,11 @@ get-stream@^6.0.0: resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== +git-revision-webpack-plugin@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/git-revision-webpack-plugin/-/git-revision-webpack-plugin-5.0.0.tgz#0683a6a110ece618499880431cd89e1eb597b536" + integrity sha512-RptQN/4UKcEPkCBmRy8kLPo5i8MnF8+XfAgFYN9gbwmKLTLx4YHsQw726H+C5+sIGDixDkmGL3IxPA2gKo+u4w== + glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"