This commit is contained in:
Hyunchul Kim 2021-12-01 21:22:18 +09:00
commit 0bf5da8bd1
4 changed files with 48 additions and 23 deletions

View file

@ -17,6 +17,9 @@ from distribusi import fragments
import uuid import uuid
from distribusi.ignore import Ignore from distribusi.ignore import Ignore
import traceback
import json
MIME_TYPE = magic.Magic(mime=True) MIME_TYPE = magic.Magic(mime=True)
ignore = Ignore() ignore = Ignore()
@ -39,9 +42,10 @@ def caption(image):
return caption return caption
def thumbnail(image, name, args): def thumbnail(image, name, args, size=(450,450)):
try: try:
size = (450, 450) # size = (450, 450)
im = Image.open(image) im = Image.open(image)
exif = None exif = None
try: try:
@ -79,6 +83,7 @@ def thumbnail(image, name, args):
"<figure><a href='{}'><img class='thumbnail' src='data:image/jpg;base64,{}'></a><figcaption>{}</figcaption></figure>" "<figure><a href='{}'><img class='thumbnail' src='data:image/jpg;base64,{}'></a><figcaption>{}</figcaption></figure>"
).format(name, data_url, cap) ).format(name, data_url, cap)
except Exception as e: except Exception as e:
traceback.print_exc()
print('Thumbnailer:', e) print('Thumbnailer:', e)
return "<figure><a href='{}'><img src='{}'></a><figcaption>{}</figcaption></figure>".format(name, name, name) return "<figure><a href='{}'><img src='{}'></a><figcaption>{}</figcaption></figure>".format(name, name, name)
@ -198,7 +203,14 @@ def render_dir(args, directory):
if type_ == 'image': if type_ == 'image':
a = FILE_TYPES[type_].format(relative_path, c, c) a = FILE_TYPES[type_].format(relative_path, c, c)
if args.thumbnail: if args.thumbnail:
a = thumbnail(full_path, relative_path, args) thumbconf_path = "./{}/{}".format(root, "thumbconf.json")
size = (450, 450)
if os.path.isfile(thumbconf_path):
with open(thumbconf_path) as json_file:
json_data = json.load(json_file)
size = tuple(json_data['size'])
print("applying thumbconf.json: size: ", size)
a = thumbnail(full_path, relative_path, args, size)
if args.no_filenames: if args.no_filenames:
c = "" c = ""
if args.captions: if args.captions:

View file

@ -18,8 +18,10 @@ html_head_event = """
%s %s
<link rel="stylesheet" type="text/css" href="/src/style/common.css" /> <link rel="stylesheet" type="text/css" href="/src/style/common.css" />
<link rel="stylesheet" type="text/css" href="/src/style/event.css" /> <link rel="stylesheet" type="text/css" href="/src/style/event.css" />
<link rel="stylesheet" type="text/css" href="./style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="/src/scripts/mobileScroll.js"></script> <script src="/src/scripts/mobileScroll.js"></script>
<script src="./main.js"></script>
</head> </head>
<body> <body>
<div> <div>

View file

@ -12,4 +12,5 @@ style.css
404.html 404.html
main.js main.js
.+.alt .+.alt
events events
thumbconf.json

View file

@ -13,26 +13,36 @@ ed_resquest.onload = function() {
event_list = ed_resquest.response; event_list = ed_resquest.response;
console.log(event_list) console.log(event_list)
for (let key in event_list){
console.log(key);
// convert date format( `.` -> `/` ) Object.entries(event_list)
let event = event_list[key];
let date = event.date.split('.'); .sort(function(a, b) {
date.pop(); return a[1].number < b[1].number
let date_str = date.join(' /'); })
let row = document.createElement('div'); .forEach(function(item) {
row.classList.add("event_row") console.log(item);
row.innerHTML = `${date_str} &emsp;&emsp; #${key} ${event.title}`
let link = document.createElement('a'); //
link.href = `${key}/` let key = item[0];
link.appendChild(row) let event = item[1];
document.getElementById("about_wrapper").appendChild(link); // convert date format( `.` -> `/` )
// TODO: add hover effect let date = event.date.split('.');
// TODO: add date.pop();
} let date_str = date.join(' /');
let row = document.createElement('div');
row.classList.add("event_row")
row.innerHTML = `${date_str} &emsp;&emsp; #${key} ${event.title}`
let link = document.createElement('a');
link.href = `${key}/`
link.appendChild(row)
document.getElementById("about_wrapper").appendChild(link);
// TODO: add hover effect
// TODO: add
})
} }