share specific images with url

This commit is contained in:
Q
2023-09-28 19:32:34 +03:00
parent 3f69c63638
commit 907fd1f03e
4 changed files with 171 additions and 123 deletions

View File

@@ -1,4 +1,4 @@
__version__ = "20230928.0" __version__ = "20230928.1"
def get_version(): def get_version():

View File

@@ -252,7 +252,7 @@ Released : 20110306
<div id="page-bgtop"> <div id="page-bgtop">
<div id="page-bgbtm"> <div id="page-bgbtm">
<div id="content"> <div id="content">
<div class="post"> <div class="post" id="post_intro">
<div class="entry intro"> <div class="entry intro">
{intro} {intro}
</div> </div>
@@ -281,14 +281,14 @@ Released : 20110306
image = urllib.parse.quote(image) image = urllib.parse.quote(image)
if self.video_match.match(image): if self.video_match.match(image):
return """ return """
<div class="post"> <div class="post" id="post_{image}">
<div class="navigation">&nbsp;</div> <div class="navigation">&nbsp;</div>
<div class="image_wrapper center"><a href="{image}"> <div class="image_wrapper center"><a href="{image}">
<video class=post_image controls preload="metadata"> <video class=post_image controls preload="metadata">
<source src="{image}" type="video/mp4" > <source src="{image}" type="video/mp4" >
</video> </video>
</a></div> </a></div>
<div class="meta"><div class="name">{title}</div></div> <div class="meta"><div class="post_title" id="title_{image}">{title}</div></div>
<div style="clear: both;">&nbsp;</div> <div style="clear: both;">&nbsp;</div>
<div class="entry">{content}</div> <div class="entry">{content}</div>
</div>""".format( </div>""".format(
@@ -296,12 +296,12 @@ Released : 20110306
) )
return """ return """
<div class="post"> <div class="post" id="post_{image}">
<div class="navigation">&nbsp;</div> <div class="navigation">&nbsp;</div>
<div class="image_wrapper center"><a href="{image}"> <div class="image_wrapper center"><a href="{image}">
<img loading=lazy class=post_image src="{med_dir}/{image}.jpg"> <img loading=lazy class=post_image src="{med_dir}/{image}.jpg">
</a></div> </a></div>
<div class="meta"><div class="name">{title}</div></div> <div class="meta"><div class="post_title" id="title_{image}">{title}</div></div>
<div style="clear: both;">&nbsp;</div> <div style="clear: both;">&nbsp;</div>
<div class="entry">{content}</div> <div class="entry">{content}</div>
</div>""".format( </div>""".format(

View File

@@ -1,4 +1,3 @@
/* /*
Design by TEMPLATED Design by TEMPLATED
http://templated.co http://templated.co
@@ -39,7 +38,9 @@ body {
overflow-x: hidden; overflow-x: hidden;
} }
h1, h2, h3 { h1,
h2,
h3 {
margin: 0; margin: 0;
padding: 0; padding: 0;
font-weight: normal; font-weight: normal;
@@ -58,21 +59,22 @@ h3 {
font-size: 1.6em; font-size: 1.6em;
} }
p, ul, ol { p,
ul,
ol {
margin-top: 0; margin-top: 0;
line-height: 180%; line-height: 180%;
} }
ul, ol { ul,
} ol {}
a { a {
text-decoration: none; text-decoration: none;
color: var(--links); color: var(--links);
} }
a:hover { a:hover {}
}
#wrapper { #wrapper {
width: 100vw; width: 100vw;
@@ -100,7 +102,8 @@ a:hover {
color: #000000; color: #000000;
} }
#logo h1, #logo p { #logo h1,
#logo p {
margin: 0; margin: 0;
padding: 0; padding: 0;
color: var(--subtitle-text); color: var(--subtitle-text);
@@ -142,6 +145,7 @@ a:hover {
margin: 0 auto; margin: 0 auto;
padding: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;
} }
@media only screen and (max-width: 800px) { @media only screen and (max-width: 800px) {
#page { #page {
width: 100vw; width: 100vw;
@@ -152,8 +156,7 @@ a:hover {
padding: 20px 0px; padding: 20px 0px;
} }
#page-bgbtm { #page-bgbtm {}
}
/* Content */ /* Content */
@@ -168,11 +171,9 @@ a:hover {
padding-top: 2px; padding-top: 2px;
} }
.post-bgtop { .post-bgtop {}
}
.post-bgbtm { .post-bgbtm {}
}
.post .title { .post .title {
height: 38px; height: 38px;
@@ -195,16 +196,22 @@ a:hover {
font-weight: bold; font-weight: bold;
} }
.post .meta .name { .post .meta .post_title {
display: inline; display: inline;
} }
.post .meta .posted { .post_title {
cursor: pointer;
} }
.post .meta a { .post_title:hover {
color: var(--links);
} }
.post .meta .posted {}
.post .meta a {}
.post .entry { .post .entry {
padding: 0px 5px 20px 5px; padding: 0px 5px 20px 5px;
text-align: justify; text-align: justify;
@@ -229,6 +236,7 @@ a:hover {
max-width: calc(100vw - 128px); max-width: calc(100vw - 128px);
display: inline; display: inline;
} }
@media only screen and (max-width: 800px) { @media only screen and (max-width: 800px) {
.post_image { .post_image {
max-height: calc(100vh - 2px); max-height: calc(100vh - 2px);
@@ -243,16 +251,19 @@ a:hover {
height: 27px; height: 27px;
float: right; float: right;
} }
@media only screen and (max-width: 800px) { @media only screen and (max-width: 800px) {
.navigation { .navigation {
display: none; display: none;
} }
} }
.navigation_button { .navigation_button {
cursor: pointer; cursor: pointer;
margin-left: 10px; margin-left: 10px;
box-shadow: 4px 4px 5px var(--button-shadow); box-shadow: 4px 4px 5px var(--button-shadow);
} }
.navigation_button:hover { .navigation_button:hover {
cursor: pointer; cursor: pointer;
box-shadow: 2px 2px 2px var(--button-shadow); box-shadow: 2px 2px 2px var(--button-shadow);

View File

@@ -11,6 +11,7 @@ r(function() {
defaultScroll = typeof document.body.dataset.scroll === "string" ? document.body.dataset.scroll : "smooth"; defaultScroll = typeof document.body.dataset.scroll === "string" ? document.body.dataset.scroll : "smooth";
create_nav(); create_nav();
document.onkeydown = keyboard_entry; document.onkeydown = keyboard_entry;
scroll_by_url();
}); });
function create_nav() { function create_nav() {
@@ -29,6 +30,12 @@ function create_nav() {
navis[i].appendChild(create_button("down", navis[i + 1], i + 1)); navis[i].appendChild(create_button("down", navis[i + 1], i + 1));
} }
} }
let titles = document.getElementsByClassName("post_title");
for (let i = 0; i < navis.length; i++) {
titles[i].onclick = function() {
scroll_to(this.parentElement.parentElement);
}
}
} }
function create_button(direction, to, next) { function create_button(direction, to, next) {
@@ -38,9 +45,7 @@ function create_button(direction, to, next) {
button.src = ".mirva/arrow_" + direction + ".png"; button.src = ".mirva/arrow_" + direction + ".png";
button.classList.add("navigation_button"); button.classList.add("navigation_button");
button.onclick = function() { button.onclick = function() {
to.parentElement.scrollIntoView({ scroll_to(to.parentElement);
behavior: defaultScroll
});
current = next; current = next;
}; };
container.appendChild(button); container.appendChild(button);
@@ -111,6 +116,53 @@ function get_position() {
} }
} }
function scroll_to(element) {
/* Scroll smooth, if no frequent keypress */
if (scrollTimer) {
element.scrollIntoView({
behavior: "auto"
});
clearTimeout(scrollTimer);
} else {
element.scrollIntoView({
behavior: defaultScroll
});
}
scrollTimer = setTimeout(function() {
scrollTimer = null;
},
1200
);
if (element.id.substring(0, 5) == 'post_') {
set_url_arg(element.id.substring(5));
}
}
function set_url_arg(i) {
window.history.replaceState('', document.head.title, `?i=${i}`);
}
function get_url_arg() {
let url = new URL(window.location.href);
return url.searchParams.get('i');
}
function scroll_by_url() {
let name = get_url_arg();
if (name) {
let element = document.getElementById(`post_${name}`);
if (element) {
// Just to be sure..
setTimeout(function() {
scroll_to(element);
}, 1250);
setTimeout(function() {
scroll_to(element);
}, 10);
}
}
}
function keyboard_entry(ev) { function keyboard_entry(ev) {
let kC = ev.keyCode; let kC = ev.keyCode;
let ctrlDown = ev.ctrlKey || ev.metaKey; let ctrlDown = ev.ctrlKey || ev.metaKey;
@@ -142,20 +194,5 @@ function keyboard_entry(ev) {
} }
current = Math.max(0, current); current = Math.max(0, current);
current = Math.min(posts.length - 1, current); current = Math.min(posts.length - 1, current);
/* Scroll smooth, if no frequent keypress */ scroll_to(posts[current].parentElement)
if (scrollTimer) {
posts[current].parentElement.scrollIntoView({
behavior: "auto"
});
clearTimeout(scrollTimer);
} else {
posts[current].parentElement.scrollIntoView({
behavior: defaultScroll
});
}
scrollTimer = setTimeout(function() {
scrollTimer = null;
},
1200
);
} }