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>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Mappersons</title>
|
||||
<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>
|
||||
Date.prototype.getWeek = function () {
|
||||
var onejan = new Date(this.getFullYear(), 0, 1);
|
||||
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
|
||||
var d = new Date(Date.UTC(this.getFullYear(), this.getMonth(), this.getDate()));
|
||||
// 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
|
||||
// Initialize slider with current calendar week and year
|
||||
|
|
@ -95,9 +103,12 @@
|
|||
});
|
||||
},
|
||||
slide: function (event, ui) {
|
||||
// ToDo: handle year change
|
||||
var curweek = ui.value;
|
||||
var curyear = year;
|
||||
var cur_date = new Date();
|
||||
var week = cur_date.getWeek();
|
||||
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)) {
|
||||
markerLayer.clearLayers();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import json
|
|||
import yaml
|
||||
from PIL import Image, ImageDraw, ImageFilter
|
||||
from pathlib import Path
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def circular_mask(img):
|
||||
center_x = int(img.width / 2)
|
||||
|
|
@ -57,7 +58,6 @@ def create_circle(image_paths):
|
|||
|
||||
# Cut out a circle from each image
|
||||
circular_images = [circular_mask(img) for img in shrunk_images]
|
||||
circular_images[-1].save('circle.png')
|
||||
if len(circular_images) == 1:
|
||||
circular_images[0].save(output_path)
|
||||
return
|
||||
|
|
@ -82,7 +82,6 @@ def create_circle(image_paths):
|
|||
def generateWeek(week, persons, locations, output_path=Path('.')):
|
||||
loc = {}
|
||||
for person in persons:
|
||||
print(person)
|
||||
if week in person['weeks'].keys():
|
||||
cur_name = person['name']
|
||||
cur_image = person['image']
|
||||
|
|
@ -101,10 +100,7 @@ def generateWeek(week, persons, locations, output_path=Path('.')):
|
|||
w,y = week.split('/')
|
||||
json_file = "cw_%s_%s.json" % (w,y)
|
||||
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)
|
||||
[print(x) for x in cur_persons]
|
||||
image_paths = [("persons/%s" % x['image']) for n,x in cur_persons.items()]
|
||||
img = create_circle(image_paths)
|
||||
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],
|
||||
"popup": popup
|
||||
})
|
||||
print()
|
||||
with open(output_path / Path(json_file),"w") as j:
|
||||
json.dump(week_json, j)
|
||||
|
||||
if __name__ == "__main__":
|
||||
before = 4
|
||||
after = 12
|
||||
with open("persons.yml","r") as fp:
|
||||
persons = yaml.safe_load(fp)
|
||||
with open("locations.yml","r") as 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