Compare commits
No commits in common. "304d9f4b7a3532de452d406b3823304c92040f90" and "fa8ac8c9d84066b2f3befb62602c7f31e6669d17" have entirely different histories.
304d9f4b7a
...
fa8ac8c9d8
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -1,6 +0,0 @@
|
||||||
persons/
|
|
||||||
*.json
|
|
||||||
*.yml
|
|
||||||
*.png
|
|
||||||
!screenshot.png
|
|
||||||
jquery*
|
|
||||||
21
index.html
21
index.html
|
|
@ -1,6 +1,5 @@
|
||||||
<!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"
|
||||||
|
|
@ -71,15 +70,8 @@
|
||||||
<script src="jquery-ui.js"></script>
|
<script src="jquery-ui.js"></script>
|
||||||
<script>
|
<script>
|
||||||
Date.prototype.getWeek = function () {
|
Date.prototype.getWeek = function () {
|
||||||
var d = new Date(Date.UTC(this.getFullYear(), this.getMonth(), this.getDate()));
|
var onejan = new Date(this.getFullYear(), 0, 1);
|
||||||
// Set to nearest Thursday: current date + 4 - current day number
|
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
|
||||||
// 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
|
||||||
|
|
@ -103,12 +95,9 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
slide: function (event, ui) {
|
slide: function (event, ui) {
|
||||||
var cur_date = new Date();
|
// ToDo: handle year change
|
||||||
var week = cur_date.getWeek();
|
var curweek = ui.value;
|
||||||
var delta = parseInt(ui.value) - week;
|
var curyear = year;
|
||||||
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,7 +4,6 @@ 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)
|
||||||
|
|
@ -58,6 +57,7 @@ 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,6 +82,7 @@ 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']
|
||||||
|
|
@ -100,7 +101,10 @@ 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))
|
||||||
|
|
@ -117,18 +121,14 @@ 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)
|
||||||
start = datetime.now() -timedelta(weeks=before)
|
generateWeek('22/2023', persons, locations)
|
||||||
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