Compare commits
No commits in common. "c25e539a0fee0c5fe07fd6801df280d7da80e532" and "437cbcd73f7efca8ca708ead7bd1fe061f20fc2c" have entirely different histories.
c25e539a0f
...
437cbcd73f
|
@ -373,14 +373,11 @@ def collate(args):
|
||||||
collation_staging_area = args.destdir / 'site' / 'images-staging'
|
collation_staging_area = args.destdir / 'site' / 'images-staging'
|
||||||
collation_staging_area.mkdir(parents=True)
|
collation_staging_area.mkdir(parents=True)
|
||||||
|
|
||||||
collation_area = args.destdir / 'site' / 'images'
|
|
||||||
collation_area.mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
for work_path in extraction_dir.iterdir():
|
for work_path in extraction_dir.iterdir():
|
||||||
work_id = work_path.name
|
work_id = work_path.name
|
||||||
|
|
||||||
work_collation_dir = collation_area / work_id
|
collation_dir = args.destdir / 'site' / 'images' / work_id
|
||||||
if work_collation_dir.exists():
|
if collation_dir.exists():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
virtual = cur.execute("SELECT virtual FROM works WHERE id = ?", (work_id,)).fetchone()
|
virtual = cur.execute("SELECT virtual FROM works WHERE id = ?", (work_id,)).fetchone()
|
||||||
|
@ -392,7 +389,7 @@ def collate(args):
|
||||||
pages_collated = collate_from_paths([hint_map.get(work_id, work_path)], work_staging_dir, 0, [])
|
pages_collated = collate_from_paths([hint_map.get(work_id, work_path)], work_staging_dir, 0, [])
|
||||||
if pages_collated:
|
if pages_collated:
|
||||||
print(f'Collated {pages_collated} pages for {work_id}')
|
print(f'Collated {pages_collated} pages for {work_id}')
|
||||||
work_staging_dir.rename(work_collation_dir)
|
work_staging_dir.rename(collation_dir)
|
||||||
else:
|
else:
|
||||||
if work_staging_dir.is_dir():
|
if work_staging_dir.is_dir():
|
||||||
for f in work_staging_dir.iterdir():
|
for f in work_staging_dir.iterdir():
|
||||||
|
@ -606,16 +603,13 @@ def manual_collate(args):
|
||||||
else:
|
else:
|
||||||
groups = [[extraction_dir / work_id]]
|
groups = [[extraction_dir / work_id]]
|
||||||
|
|
||||||
collation_area = args.destdir / 'site' / 'images'
|
collation_dir = args.destdir / 'site' / 'images' / work_id
|
||||||
collation_area.mkdir(parents=True, exist_ok=True)
|
if collation_dir.exists():
|
||||||
|
if len(list(collation_dir.iterdir())) > 0:
|
||||||
work_collation_dir = collation_area / work_id
|
|
||||||
if work_collation_dir.exists():
|
|
||||||
if len(list(work_collation_dir.iterdir())) > 0:
|
|
||||||
print(f'Collation directory already exists!')
|
print(f'Collation directory already exists!')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
work_collation_dir.rmdir()
|
collation_dir.rmdir()
|
||||||
|
|
||||||
nonexistent = [path for group in (groups + [exclusions]) for path in group if not path.exists()]
|
nonexistent = [path for group in (groups + [exclusions]) for path in group if not path.exists()]
|
||||||
if len(nonexistent) > 0:
|
if len(nonexistent) > 0:
|
||||||
|
@ -643,7 +637,7 @@ def manual_collate(args):
|
||||||
|
|
||||||
if pages_collated:
|
if pages_collated:
|
||||||
print(f'Collated {pages_collated} pages for {work_id}')
|
print(f'Collated {pages_collated} pages for {work_id}')
|
||||||
work_staging_dir.rename(work_collation_dir)
|
work_staging_dir.rename(collation_dir)
|
||||||
else:
|
else:
|
||||||
for f in work_staging_dir.iterdir():
|
for f in work_staging_dir.iterdir():
|
||||||
f.unlink()
|
f.unlink()
|
||||||
|
|
|
@ -8,8 +8,6 @@ html, body {
|
||||||
#controls {
|
#controls {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
animation: 2s linear forwards fade;
|
animation: 2s linear forwards fade;
|
||||||
position: relative;
|
|
||||||
z-index: 300;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes fade {
|
@keyframes fade {
|
||||||
|
@ -64,28 +62,20 @@ html, body {
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.image-container img {
|
#viewer-images {
|
||||||
position: fixed;
|
display: none;
|
||||||
left: 0;
|
}
|
||||||
top: 0;
|
|
||||||
|
#image-container {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
object-fit: contain;
|
background-size: contain;
|
||||||
object-position: 50% 50%;
|
background-repeat: no-repeat;
|
||||||
background-color: #111;
|
background-position: center;
|
||||||
}
|
|
||||||
|
|
||||||
#current-image img {
|
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
#preload-images img {
|
|
||||||
z-index: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#page-num, #duration {
|
#page-num, #duration {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 200;
|
|
||||||
font-size: 14pt;
|
font-size: 14pt;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
@ -120,5 +110,4 @@ html, body {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 400;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +1,31 @@
|
||||||
const PRELOAD_BACKWARD = 2;
|
const PROGRESS_UPDATE_INTERVAL = 50;
|
||||||
const PRELOAD_FORWARD = 8;
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const currentImage = document.getElementById('current-image');
|
const pages = Array.from(document.querySelectorAll('img.viewer-image'));
|
||||||
const preloadImages = document.getElementById('preload-images');
|
|
||||||
|
|
||||||
let currentPage = parseInt(localStorage.getItem(`${WORK_ID}-currentPage`)) || 0;
|
let currentPage = parseInt(localStorage.getItem(`${WORK_ID}-currentPage`)) || 0;
|
||||||
let duration = parseInt(localStorage.getItem(`${WORK_ID}-duration`)) || 10;
|
let duration = parseInt(localStorage.getItem(`${WORK_ID}-duration`)) || 10;
|
||||||
let rtl = (localStorage.getItem(`${WORK_ID}-rtl`) !== "false");
|
|
||||||
let paused = true;
|
let paused = true;
|
||||||
|
let interval;
|
||||||
let elapsed = 0;
|
let elapsed = 0;
|
||||||
let timerLastRun = null;
|
let rtl = (localStorage.getItem(`${WORK_ID}-rtl`) !== "false");
|
||||||
let timerAnimationRequestID = null;
|
|
||||||
|
|
||||||
function requestTimer() {
|
function startTimer() {
|
||||||
timerAnimationRequestID = window.requestAnimationFrame(runTimer);
|
if (interval) {
|
||||||
}
|
clearInterval(interval);
|
||||||
|
|
||||||
function runTimer(now) {
|
|
||||||
if (paused) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
interval = setInterval(
|
||||||
if (timerLastRun === null) {
|
function () {
|
||||||
elapsed = 0;
|
if (paused) {
|
||||||
} else {
|
return;
|
||||||
elapsed += now - timerLastRun;
|
}
|
||||||
}
|
elapsed += PROGRESS_UPDATE_INTERVAL;
|
||||||
timerLastRun = now;
|
if (elapsed >= duration*1000) {
|
||||||
|
changePage(currentPage + 1);
|
||||||
if (elapsed >= duration*1000) {
|
}
|
||||||
changePage(currentPage + 1);
|
updateBar();
|
||||||
elapsed = 0;
|
},
|
||||||
}
|
PROGRESS_UPDATE_INTERVAL,
|
||||||
|
);
|
||||||
updateBar();
|
|
||||||
|
|
||||||
requestTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const progressBar = document.getElementById('progress');
|
const progressBar = document.getElementById('progress');
|
||||||
|
@ -46,54 +34,34 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopTimer() {
|
function stopTimer() {
|
||||||
if (timerAnimationRequestID) {
|
if (interval) {
|
||||||
window.cancelAnimationFrame(timerAnimationRequestID);
|
clearInterval(interval);
|
||||||
timerAnimationRequestID = null;
|
interval = null;
|
||||||
}
|
}
|
||||||
timerLastRun = null;
|
|
||||||
elapsed = 0;
|
elapsed = 0;
|
||||||
updateBar();
|
updateBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
function imageSrc(s) {
|
|
||||||
const img = new Image();
|
|
||||||
img.src = s;
|
|
||||||
return img;
|
|
||||||
}
|
|
||||||
|
|
||||||
function preload() {
|
|
||||||
if (!currentImage.getElementsByTagName('img')[0].complete) {
|
|
||||||
setTimeout(preload, 50);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
preloadImages.replaceChildren(...(
|
|
||||||
IMAGES.slice(
|
|
||||||
Math.max(currentPage - PRELOAD_BACKWARD, 0),
|
|
||||||
currentPage + PRELOAD_FORWARD + 1,
|
|
||||||
).map(imageSrc)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
function changePage(pageNum) {
|
function changePage(pageNum) {
|
||||||
elapsed = 0;
|
elapsed = 0;
|
||||||
updateBar();
|
|
||||||
|
|
||||||
const previous = IMAGES[currentPage];
|
const previous = pages[currentPage];
|
||||||
const current = IMAGES[pageNum];
|
const current = pages[pageNum];
|
||||||
|
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
previous.classList.remove('current');
|
||||||
|
current.classList.add('current');
|
||||||
|
|
||||||
currentPage = pageNum;
|
currentPage = pageNum;
|
||||||
localStorage.setItem(`${WORK_ID}-currentPage`, currentPage);
|
localStorage.setItem(`${WORK_ID}-currentPage`, currentPage);
|
||||||
|
|
||||||
currentImage.replaceChildren(imageSrc(current));
|
const display = document.getElementById('image-container');
|
||||||
|
display.style.backgroundImage = `url("${current.src}")`;
|
||||||
|
|
||||||
document.getElementById('current-page').innerText = (pageNum + 1).toLocaleString();
|
document.getElementById('current-page').innerText = (pageNum + 1).toLocaleString();
|
||||||
|
|
||||||
setTimeout(preload, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const durationDisplay = document.getElementById('duration');
|
const durationDisplay = document.getElementById('duration');
|
||||||
|
@ -108,7 +76,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
stopTimer();
|
stopTimer();
|
||||||
} else {
|
} else {
|
||||||
durationDisplay.style.textDecoration = "";
|
durationDisplay.style.textDecoration = "";
|
||||||
requestTimer();
|
startTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +102,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|
||||||
function exitToWork() {
|
function exitToWork() {
|
||||||
changeDuration(duration, true);
|
changeDuration(duration, true);
|
||||||
if (currentPage === IMAGES.length - 1) {
|
if (currentPage === pages.length - 1) {
|
||||||
localStorage.removeItem(`${WORK_ID}-currentPage`);
|
localStorage.removeItem(`${WORK_ID}-currentPage`);
|
||||||
}
|
}
|
||||||
window.location.href = `../${INDEX}`;
|
window.location.href = `../${INDEX}`;
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
<script>
|
<script>
|
||||||
const WORK_ID = "{{ work['id'] }}";
|
const WORK_ID = "{{ work['id'] }}";
|
||||||
const INDEX = "{{ index() }}";
|
const INDEX = "{{ index() }}";
|
||||||
const IMAGES = [
|
|
||||||
{% for filename in images %}
|
|
||||||
"{{ root() }}/images/{{ work['id'] }}/{{ filename }}",
|
|
||||||
{% endfor %}
|
|
||||||
];
|
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ root() }}/static/viewer.js"></script>
|
<script src="{{ root() }}/static/viewer.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
<div id="viewer-images">
|
||||||
|
{% for filename in images %}
|
||||||
|
<img src="{{ root() }}/images/{{ work['id'] }}/{{ filename }}" class="viewer-image">
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
<div id="progress"></div>
|
<div id="progress"></div>
|
||||||
<div id="page-num">
|
<div id="page-num">
|
||||||
<table>
|
<table>
|
||||||
|
@ -46,6 +46,5 @@
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="image-container" id="current-image"></div>
|
<div id="image-container"></div>
|
||||||
<div class="image-container" id="preload-images"></div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue