working scroll, nicer share button
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
__version__ = "20230928.1"
|
__version__ = "20230929.0"
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
|
|||||||
@@ -280,33 +280,32 @@ Released : 20110306
|
|||||||
def get_post(self, image, title, content):
|
def get_post(self, image, title, content):
|
||||||
image = urllib.parse.quote(image)
|
image = urllib.parse.quote(image)
|
||||||
if self.video_match.match(image):
|
if self.video_match.match(image):
|
||||||
return """
|
insert = """
|
||||||
<div class="post" id="post_{image}">
|
|
||||||
<div class="navigation"> </div>
|
|
||||||
<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>
|
"""
|
||||||
<div class="meta"><div class="post_title" id="title_{image}">{title}</div></div>
|
else:
|
||||||
<div style="clear: both;"> </div>
|
insert = """
|
||||||
<div class="entry">{content}</div>
|
<img loading=lazy class=post_image src="{med_dir}/{image}.jpg">
|
||||||
</div>""".format(
|
"""
|
||||||
image=image, title=title, content=content
|
return (
|
||||||
)
|
"""
|
||||||
|
|
||||||
return """
|
|
||||||
<div class="post" id="post_{image}">
|
<div class="post" id="post_{image}">
|
||||||
<div class="navigation"> </div>
|
<div class="navigation"> </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">
|
"""
|
||||||
|
+ insert
|
||||||
|
+ """
|
||||||
</a></div>
|
</a></div>
|
||||||
<div class="meta"><div class="post_title" id="title_{image}">{title}</div></div>
|
<div class="meta">
|
||||||
|
<div class="post_share"></div>
|
||||||
|
<div class="post_title">{title}</div>
|
||||||
|
</div>
|
||||||
<div style="clear: both;"> </div>
|
<div style="clear: both;"> </div>
|
||||||
<div class="entry">{content}</div>
|
<div class="entry">{content}</div>
|
||||||
</div>""".format(
|
</div>"""
|
||||||
image=image, title=title, content=content, med_dir=self.medium_dir
|
).format(image=image, title=title, content=content, med_dir=self.medium_dir)
|
||||||
)
|
|
||||||
|
|
||||||
def is_created_with_mirva(self):
|
def is_created_with_mirva(self):
|
||||||
with open("index.html", "rt") as fp:
|
with open("index.html", "rt") as fp:
|
||||||
@@ -338,6 +337,7 @@ Released : 20110306
|
|||||||
"arrow_down.png",
|
"arrow_down.png",
|
||||||
"mirva.ico",
|
"mirva.ico",
|
||||||
"mirva.js",
|
"mirva.js",
|
||||||
|
"share.svg",
|
||||||
):
|
):
|
||||||
if os.path.exists(os.path.join(self.resource_dir, f)):
|
if os.path.exists(os.path.join(self.resource_dir, f)):
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -196,16 +196,26 @@ a:hover {}
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post .meta .post_title {
|
.post .meta .post_title,
|
||||||
|
.post_share {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post_title {
|
.post_share {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.post_title:hover {
|
.post_share {
|
||||||
color: var(--links);
|
vertical-align: top;
|
||||||
|
margin-right: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post_share A IMG {
|
||||||
|
filter: brightness(75%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.post_share A IMG:hover {
|
||||||
|
filter: invert(47%) sepia(97%) saturate(1043%) hue-rotate(359deg) brightness(101%) contrast(105%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.post .meta .posted {}
|
.post .meta .posted {}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ let currentScrolled = -1;
|
|||||||
let scrollTimer = null;
|
let scrollTimer = null;
|
||||||
let scrollEventTimer = null;
|
let scrollEventTimer = null;
|
||||||
let defaultScroll = "smooth";
|
let defaultScroll = "smooth";
|
||||||
|
let loadTime = new Date();
|
||||||
|
|
||||||
function r(f) {
|
function r(f) {
|
||||||
/in/.test(document.readyState) ? setTimeout('r(' + f + ')', 9) : f()
|
/in/.test(document.readyState) ? setTimeout('r(' + f + ')', 9) : f()
|
||||||
@@ -18,7 +19,7 @@ function create_nav() {
|
|||||||
let navis = document.getElementsByClassName("navigation");
|
let navis = document.getElementsByClassName("navigation");
|
||||||
for (let i = 0; i < navis.length; i++) {
|
for (let i = 0; i < navis.length; i++) {
|
||||||
if (i == navis.length - 1) {
|
if (i == navis.length - 1) {
|
||||||
navis[i].appendChild(create_button("up", navis[0], 0));
|
navis[i].appendChild(create_button("up", document.body, 0));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (navis[i - 1]) {
|
if (navis[i - 1]) {
|
||||||
@@ -30,11 +31,21 @@ 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");
|
let shares = document.getElementsByClassName("post_share");
|
||||||
for (let i = 0; i < navis.length; i++) {
|
for (let i = 0; i < shares.length; i++) {
|
||||||
titles[i].onclick = function() {
|
let name = shares[i].parentElement.parentElement.id.substring(5);
|
||||||
|
shares[i].onclick = function(event) {
|
||||||
scroll_to(this.parentElement.parentElement);
|
scroll_to(this.parentElement.parentElement);
|
||||||
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
|
let button = document.createElement('img');
|
||||||
|
button.src = ".mirva/share.svg";
|
||||||
|
let link = document.createElement('a');
|
||||||
|
let url = window.location.href.split('?')[0] + `?i=${name}`
|
||||||
|
link.href = url;
|
||||||
|
link.title = "Link to this image: " + url;
|
||||||
|
link.appendChild(button);
|
||||||
|
shares[i].appendChild(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,6 +54,7 @@ function create_button(direction, to, next) {
|
|||||||
container.classList.add("float_" + direction);
|
container.classList.add("float_" + direction);
|
||||||
let button = document.createElement('img');
|
let button = document.createElement('img');
|
||||||
button.src = ".mirva/arrow_" + direction + ".png";
|
button.src = ".mirva/arrow_" + direction + ".png";
|
||||||
|
button.title = to == document.body ? "Top of page" : `Move ${direction}`;
|
||||||
button.classList.add("navigation_button");
|
button.classList.add("navigation_button");
|
||||||
button.onclick = function() {
|
button.onclick = function() {
|
||||||
scroll_to(to.parentElement);
|
scroll_to(to.parentElement);
|
||||||
@@ -61,7 +73,6 @@ function is_visible(el, type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_position() {
|
function get_position() {
|
||||||
let intro = document.getElementsByClassName("intro");
|
let intro = document.getElementsByClassName("intro");
|
||||||
for (let i = 0; i < intro.length; i++) {
|
for (let i = 0; i < intro.length; i++) {
|
||||||
@@ -116,6 +127,16 @@ function get_position() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function find_by_name(name) {
|
||||||
|
let posts = document.getElementsByClassName("image_wrapper");
|
||||||
|
for (let i = 0; i < posts.length; i++) {
|
||||||
|
if (posts[i].parentElement.id.substring(5) == name) {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
function scroll_to(element) {
|
function scroll_to(element) {
|
||||||
/* Scroll smooth, if no frequent keypress */
|
/* Scroll smooth, if no frequent keypress */
|
||||||
if (scrollTimer) {
|
if (scrollTimer) {
|
||||||
@@ -148,17 +169,24 @@ function get_url_arg() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function scroll_by_url() {
|
function scroll_by_url() {
|
||||||
|
// Find the image, and scroll to it. With Lazy loading it seems to
|
||||||
|
// escape sometimes..
|
||||||
let name = get_url_arg();
|
let name = get_url_arg();
|
||||||
if (name) {
|
if (name) {
|
||||||
let element = document.getElementById(`post_${name}`);
|
let element = document.getElementById(`post_${name}`);
|
||||||
|
let index = find_by_name(name);
|
||||||
if (element) {
|
if (element) {
|
||||||
// Just to be sure..
|
// Just to be sure..
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
// Try for 10 seconds.
|
||||||
|
if (new Date() - loadTime > 10000) {
|
||||||
|
return
|
||||||
|
}
|
||||||
scroll_to(element);
|
scroll_to(element);
|
||||||
}, 1250);
|
if (get_position().current != index) {
|
||||||
setTimeout(function() {
|
scroll_by_url();
|
||||||
scroll_to(element);
|
}
|
||||||
}, 10);
|
}, 310);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +220,6 @@ function keyboard_entry(ev) {
|
|||||||
});
|
});
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
current = Math.max(0, current);
|
current = Math.min(posts.length - 1, Math.max(0, current));
|
||||||
current = Math.min(posts.length - 1, current);
|
|
||||||
scroll_to(posts[current].parentElement)
|
scroll_to(posts[current].parentElement)
|
||||||
}
|
}
|
||||||
|
|||||||
1
mirva/resources/share.svg
Normal file
1
mirva/resources/share.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" ?><svg height="16" id="svg2" version="1.1" width="16" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:svg="http://www.w3.org/2000/svg"><defs id="defs4"/><g id="layer1" transform="translate(0,-1036.3622)"><path d="m -22.410713,-3.3303571 a 2.3660715,2.3660715 0 1 1 -4.732143,0 2.3660715,2.3660715 0 1 1 4.732143,0 z" id="path2985" style="fill:#ffffff;fill-opacity:1;stroke:none" transform="matrix(0.84528301,0,0,0.84528301,33.943395,1042.1773)"/><path d="m -22.410713,-3.3303571 a 2.3660715,2.3660715 0 1 1 -4.732143,0 2.3660715,2.3660715 0 1 1 4.732143,0 z" id="path2985-1" style="fill:#ffffff;fill-opacity:1;stroke:none" transform="matrix(0.84528301,0,0,0.84528301,33.943395,1052.1773)"/><path d="m -22.410713,-3.3303571 a 2.3660715,2.3660715 0 1 1 -4.732143,0 2.3660715,2.3660715 0 1 1 4.732143,0 z" id="path2985-1-7" style="fill:#ffffff;fill-opacity:1;stroke:none" transform="matrix(0.84528301,0,0,0.84528301,23.943395,1047.1773)"/><path d="M 13,3 3,8 13,13" id="path3791" style="fill:none;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" transform="translate(0,1036.3622)"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user