aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2018-08-07 19:24:04 +0200
committerFélix Sipma <felix.sipma@no-log.org>2018-08-07 19:24:04 +0200
commit14dd453d56582b2560a2de7778c753514eb5311a (patch)
tree0b7eafe0f85709a815634d8599830adad3d2eb3a
parenta45e288f721ea34ad6af5214e241585072eea209 (diff)
add fournil-holidays.js
-rw-r--r--Makefile18
-rw-r--r--layouts/index.html21
-rw-r--r--static/js/fournil-holidays.js8
3 files changed, 42 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index b03d5cd..9b04e4d 100644
--- a/Makefile
+++ b/Makefile
@@ -13,14 +13,14 @@ css: npm
mkdir -p $(TMP)/css/
mkdir -p $(DIST_STATIC)/css
sass $(STATIC)/scss/fournil.scss > $(TMP)/css/fournil-base.css
- cat \
+ awk 1 \
node_modules/bootstrap/dist/css/bootstrap.css \
node_modules/font-awesome/css/font-awesome.css \
$(TMP)/css/fournil-base.css \
> $(TMP)/css/fournil.css
csso $(TMP)/css/fournil.css --output $(TMP)/css/fournil.min.css
cp $(TMP)/css/fournil.min.css $(DIST_STATIC)/css/
- cat \
+ awk 1 \
node_modules/leaflet/dist/leaflet.css \
> $(TMP)/css/fournil-map.css
csso $(TMP)/css/fournil-map.css --output $(TMP)/css/fournil-map.min.css
@@ -29,19 +29,27 @@ css: npm
js: npm
mkdir -p $(TMP)/js/
mkdir -p $(DIST_STATIC)/js
- cat \
+ awk 1 \
node_modules/jquery/dist/jquery.js \
node_modules/popper.js/dist/umd/popper.js \
node_modules/bootstrap/dist/js/bootstrap.js \
> $(TMP)/js/fournil.js
uglifyjs --compress --mangle -o $(TMP)/js/fournil.min.js $(TMP)/js/fournil.js
cp $(TMP)/js/fournil.min.js $(DIST_STATIC)/js
- cat \
+ awk 1 \
node_modules/leaflet/dist/leaflet.js \
$(STATIC)/js/fournil-map.js \
> $(TMP)/js/fournil-map.js
uglifyjs --compress --mangle -o $(TMP)/js/fournil-map.min.js $(TMP)/js/fournil-map.js
cp $(TMP)/js/fournil-map.min.js $(DIST_STATIC)/js
+ awk 1 \
+ node_modules/moment/moment.js \
+ node_modules/moment/locale/fr.js \
+ node_modules/moment-range/dist/moment-range.js \
+ $(STATIC)/js/fournil-holidays.js \
+ > $(TMP)/js/fournil-holidays.js
+ uglifyjs --compress --mangle -o $(TMP)/js/fournil-holidays.min.js $(TMP)/js/fournil-holidays.js
+ cp $(TMP)/js/fournil-holidays.min.js $(DIST_STATIC)/js
fonts:
mkdir -p $(DIST_STATIC)/fonts
@@ -71,7 +79,7 @@ shopclient: npm
> $(TMP)/js/fournil-shop-client.js
uglifyjs --compress --mangle -o $(TMP)/js/fournil-shop-client.min.js $(TMP)/js/fournil-shop-client.js
cp $(TMP)/js/fournil-shop-client.min.js $(DIST_STATIC)/js
- cat \
+ awk 1 \
node_modules/pikaday/css/pikaday.css \
> $(TMP)/css/fournil-shop-client.css
csso $(TMP)/css/fournil-shop-client.css --output $(TMP)/css/fournil-shop-client.min.css
diff --git a/layouts/index.html b/layouts/index.html
index 9bba506..1b2cafb 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -17,6 +17,24 @@
});
</script>
<script src="{{ "js/fournil-map.min.js" | relURL }}"></script>
+<script src="{{ "js/fournil-holidays.min.js" | relURL }}"></script>
+<script>
+ var holidayranges = ({{ $.Site.Data.fournil.holidays }}).map(function(dr) {
+ return moment.range(dr);
+ }).filter(function(dr) {
+ var drclone = dr.clone();
+ return moment.range(drclone.start.subtract(15, 'days'), drclone.end).contains(moment().hour(0).minute(0).second(0).millisecond(0));
+ });
+ var fournilHolidays = document.getElementById('fournil-holidays');
+ if (holidayranges.length > 0) {
+ var closedranges = [];
+ for (var i = 0; i < holidayranges.length; i++) {
+ closedranges.push(formatRange(holidayranges[i]));
+ }
+ var closedrangesstr = [closedranges.slice(0, -1).join(', '), closedranges.slice(-1)[0]].join(closedranges.length < 2 ? '' : ' et ');
+ fournilHolidays.innerHTML = "Le fournil sera exceptionnellement fermé " + closedrangesstr + ".";
+ }
+</script>
{{ end }}
{{ define "fournil-nav-classes" }} fournil-nologo-nav{{ end }}
@@ -42,6 +60,9 @@
<div class="vertical-align">
<div class="fournil-banner">
{{ .Content }}
+ <h3>
+ <div id="fournil-holidays"></div>
+ </h3>
{{ partial "address.html" . }}
<div id="fournilmap"></div>
</div>
diff --git a/static/js/fournil-holidays.js b/static/js/fournil-holidays.js
new file mode 100644
index 0000000..eb0b2d3
--- /dev/null
+++ b/static/js/fournil-holidays.js
@@ -0,0 +1,8 @@
+window['moment-range'].extendMoment(moment);
+
+moment.locale('fr');
+
+function formatRange(dr) {
+ var formatStart = (dr.start.month() == dr.end.month()) ? "Do" : "Do MMMM";
+ return "<span class=\"font-weight-bold\">du " + dr.start.format(formatStart) + " au " + dr.end.format("Do MMMM") + "</span>"
+};