Compare commits
4 commits
fa8ac8c9d8
...
304d9f4b7a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
304d9f4b7a | ||
|
|
c33b4a0b66 | ||
|
|
a41c8939ab | ||
|
|
ccbaa079d3 |
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
persons/
|
||||||
|
*.json
|
||||||
|
*.yml
|
||||||
|
*.png
|
||||||
|
!screenshot.png
|
||||||
|
jquery*
|
||||||
21
index.html
21
index.html
|
|
@ -1,5 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Mappersons</title>
|
<title>Mappersons</title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
|
||||||
|
|
@ -70,8 +71,15 @@
|
||||||
<script src="jquery-ui.js"></script>
|
<script src="jquery-ui.js"></script>
|
||||||
<script>
|
<script>
|
||||||
Date.prototype.getWeek = function () {
|
Date.prototype.getWeek = function () {
|
||||||
var onejan = new Date(this.getFullYear(), 0, 1);
|
var d = new Date(Date.UTC(this.getFullYear(), this.getMonth(), this.getDate()));
|
||||||
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
|
// Set to nearest Thursday: current date + 4 - current day number
|
||||||
|
// Make Sunday's day number 7
|
||||||
|
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
|
||||||
|
// Get first day of year
|
||||||
|
var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
|
||||||
|
// Calculate full weeks to nearest Thursday
|
||||||
|
var weekNo = Math.ceil((((d - yearStart) / 86400000) + 1) / 7);
|
||||||
|
return weekNo
|
||||||
}
|
}
|
||||||
// Set initial date to current calendar week and year
|
// Set initial date to current calendar week and year
|
||||||
// Initialize slider with current calendar week and year
|
// Initialize slider with current calendar week and year
|
||||||
|
|
@ -95,9 +103,12 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
slide: function (event, ui) {
|
slide: function (event, ui) {
|
||||||
// ToDo: handle year change
|
var cur_date = new Date();
|
||||||
var curweek = ui.value;
|
var week = cur_date.getWeek();
|
||||||
var curyear = year;
|
var delta = parseInt(ui.value) - week;
|
||||||
|
cur_date.setDate(cur_date.getDate() + 7 * delta);
|
||||||
|
var curweek = cur_date.getWeek();
|
||||||
|
var curyear = cur_date.getFullYear();
|
||||||
if (map.hasLayer(markerLayer)) {
|
if (map.hasLayer(markerLayer)) {
|
||||||
markerLayer.clearLayers();
|
markerLayer.clearLayers();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import json
|
||||||
import yaml
|
import yaml
|
||||||
from PIL import Image, ImageDraw, ImageFilter
|
from PIL import Image, ImageDraw, ImageFilter
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
def circular_mask(img):
|
def circular_mask(img):
|
||||||
center_x = int(img.width / 2)
|
center_x = int(img.width / 2)
|
||||||
|
|
@ -57,7 +58,6 @@ def create_circle(image_paths):
|
||||||
|
|
||||||
# Cut out a circle from each image
|
# Cut out a circle from each image
|
||||||
circular_images = [circular_mask(img) for img in shrunk_images]
|
circular_images = [circular_mask(img) for img in shrunk_images]
|
||||||
circular_images[-1].save('circle.png')
|
|
||||||
if len(circular_images) == 1:
|
if len(circular_images) == 1:
|
||||||
circular_images[0].save(output_path)
|
circular_images[0].save(output_path)
|
||||||
return
|
return
|
||||||
|
|
@ -82,7 +82,6 @@ def create_circle(image_paths):
|
||||||
def generateWeek(week, persons, locations, output_path=Path('.')):
|
def generateWeek(week, persons, locations, output_path=Path('.')):
|
||||||
loc = {}
|
loc = {}
|
||||||
for person in persons:
|
for person in persons:
|
||||||
print(person)
|
|
||||||
if week in person['weeks'].keys():
|
if week in person['weeks'].keys():
|
||||||
cur_name = person['name']
|
cur_name = person['name']
|
||||||
cur_image = person['image']
|
cur_image = person['image']
|
||||||
|
|
@ -101,10 +100,7 @@ def generateWeek(week, persons, locations, output_path=Path('.')):
|
||||||
w,y = week.split('/')
|
w,y = week.split('/')
|
||||||
json_file = "cw_%s_%s.json" % (w,y)
|
json_file = "cw_%s_%s.json" % (w,y)
|
||||||
for cur_loc, cur_persons in loc.items():
|
for cur_loc, cur_persons in loc.items():
|
||||||
print(cur_loc)
|
|
||||||
print(cur_persons)
|
|
||||||
png_file = "%s_%s_%s.png" % (cur_loc.lower(),w,y)
|
png_file = "%s_%s_%s.png" % (cur_loc.lower(),w,y)
|
||||||
[print(x) for x in cur_persons]
|
|
||||||
image_paths = [("persons/%s" % x['image']) for n,x in cur_persons.items()]
|
image_paths = [("persons/%s" % x['image']) for n,x in cur_persons.items()]
|
||||||
img = create_circle(image_paths)
|
img = create_circle(image_paths)
|
||||||
img.save(output_path / Path(png_file))
|
img.save(output_path / Path(png_file))
|
||||||
|
|
@ -121,14 +117,18 @@ def generateWeek(week, persons, locations, output_path=Path('.')):
|
||||||
"anchor": [x//2 for x in img.size],
|
"anchor": [x//2 for x in img.size],
|
||||||
"popup": popup
|
"popup": popup
|
||||||
})
|
})
|
||||||
print()
|
|
||||||
with open(output_path / Path(json_file),"w") as j:
|
with open(output_path / Path(json_file),"w") as j:
|
||||||
json.dump(week_json, j)
|
json.dump(week_json, j)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
before = 4
|
||||||
|
after = 12
|
||||||
with open("persons.yml","r") as fp:
|
with open("persons.yml","r") as fp:
|
||||||
persons = yaml.safe_load(fp)
|
persons = yaml.safe_load(fp)
|
||||||
with open("locations.yml","r") as fp:
|
with open("locations.yml","r") as fp:
|
||||||
locations = yaml.safe_load(fp)
|
locations = yaml.safe_load(fp)
|
||||||
generateWeek('21/2023', persons, locations)
|
|
||||||
generateWeek('22/2023', persons, locations)
|
start = datetime.now() -timedelta(weeks=before)
|
||||||
|
for i in range(before+1+after):
|
||||||
|
cur_date = start + timedelta(weeks=i)
|
||||||
|
generateWeek(cur_date.strftime("%V/%G"), persons, locations)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue