- url / error cleanup in Home

- 'noping' setting to create ping files, but don't actually send webmentions
- watermark size back to older setting
- changed sharpend in unsharp mask settings
- added is_photos setting which applies if all images are photos
This commit is contained in:
Peter Molnar 2019-04-10 09:27:37 +01:00
parent 9eccd3e683
commit 1f4a864d59
7 changed files with 97 additions and 52 deletions

25
nasg.py
View file

@ -244,6 +244,10 @@ class Webmention(object):
async def send(self):
if self.exists:
return
elif settings.args.get('noping'):
self.save("noping entry at %" %(arrow.now()))
return
telegraph_url = 'https://telegraph.p3k.io/webmention'
telegraph_params = {
'token': '%s' % (keys.telegraph.get('token')),
@ -1233,7 +1237,7 @@ class WebImage(object):
else:
exif[ekey] = maybe
break
return exif
return struct(exif)
def _maybe_watermark(self, img):
if not self.is_photo:
@ -1244,14 +1248,12 @@ class WebImage(object):
return img
with wand.image.Image(filename=wmarkfile) as wmark:
w = self.height * 0.2
h = wmark.height * (w / wmark.width)
if self.width > self.height:
w = self.width * 0.3
h = wmark.height * (w / wmark.width)
x = self.width - w - (self.width * 0.01)
y = self.height - h - (self.height * 0.01)
else:
w = self.height * 0.24
h = wmark.height * (w / wmark.width)
x = self.width - h - (self.width * 0.01)
y = self.height - w - (self.height * 0.01)
@ -1396,9 +1398,9 @@ class WebImage(object):
thumb.compression_quality = 88
thumb.unsharp_mask(
radius=1,
sigma=0.5,
amount=0.7,
threshold=0.5
sigma=1,
amount=0.5,
threshold=0.1
)
thumb.format = 'pjpeg'
@ -1650,6 +1652,13 @@ class Category(dict):
def sortedkeys(self):
return list(sorted(self.keys(), reverse=True))
@property
def is_photos(self):
r = True
for i in self.values():
r = r & i.is_photo
return r
@property
def is_paginated(self):
if self.name in settings.flat:

View file

@ -182,7 +182,8 @@ _booleanparams = {
'force': 'force rendering HTML',
'nosync': 'skip sync to live server',
'debug': 'set logging to debug level',
'quiet': 'show only errors'
'quiet': 'show only errors',
'noping': 'don\'t send webmentions but save a dummy that it was done'
}
for k, v in _booleanparams.items():

View file

@ -24,7 +24,7 @@
{% for category, post in posts %}
<section>
<h2>in:
<a href="{{ category.url|relurl(baseurl) }}/">
<a href="{{ category.url|relurl(baseurl) }}">
<svg width="16" height="16"><use xlink:href="#icon-{{ category.name }}" /></svg>
{{ category.name }}
</a>

View file

@ -50,23 +50,10 @@
</ul>
</nav>
<div>
<form class="theme" aria-hidden="true">
<svg width="16" height="16">
<use xlink:href="#icon-contrast"></use>
</svg>
<span>
<input name="colorscheme" value="dark" id="darkscheme" type="radio">
<label for="darkscheme">dark</label>
</span>
<span>
<input name="colorscheme" value="light" id="lightscheme" type="radio">
<label for="lightscheme">light</label>
</span>
</form>
<div id="header-forms">
{% for action in site.potentialAction %}
{% if 'SearchAction' == action['@type'] %}
<form role="search" method="get" action="{{ action.url|relurl(baseurl) }}">
<form id="search" role="search" method="get" action="{{ action.url|relurl(baseurl) }}">
<label for="qsub">
<input type="submit" value="search" id="qsub" name="qsub" />
<svg width="16" height="16">

20
templates/bye.txt Normal file
View file

@ -0,0 +1,20 @@
███████╗███████╗███████╗ ██╗ ██╗ ██████╗ ██╗ ██╗
██╔════╝██╔════╝██╔════╝ ╚██╗ ██╔╝██╔═══██╗██║ ██║
███████╗█████╗ █████╗ ╚████╔╝ ██║ ██║██║ ██║
╚════██║██╔══╝ ██╔══╝ ╚██╔╝ ██║ ██║██║ ██║
███████║███████╗███████╗ ██║ ╚██████╔╝╚██████╔╝
╚══════╝╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═════╝
███████╗██████╗ █████╗ ██████╗███████╗
██╔════╝██╔══██╗██╔══██╗██╔════╝██╔════╝
███████╗██████╔╝███████║██║ █████╗
╚════██║██╔═══╝ ██╔══██║██║ ██╔══╝
███████║██║ ██║ ██║╚██████╗███████╗
╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
██████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗
██╔════╝██╔═══██╗██║ ██║██╔══██╗██╔═══██╗╚██╗ ██╔╝
██║ ██║ ██║██║ █╗ ██║██████╔╝██║ ██║ ╚████╔╝
██║ ██║ ██║██║███╗██║██╔══██╗██║ ██║ ╚██╔╝
╚██████╗╚██████╔╝╚███╔███╔╝██████╔╝╚██████╔╝ ██║
╚═════╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═════╝ ╚═╝

View file

@ -47,27 +47,15 @@ main p {
}
h1 {
border-bottom: 4px double #999;
text-transform:uppercase;
text-align: center;
padding-bottom: 1em;
}
article > footer > dl > dt,
h2 {
border-bottom: 1px solid #999;
}
article > footer > dl > dt,
h3,
hr {
border-bottom: 1px dotted #999;
}
h4 {
border-bottom: 1px dashed #999;
}
svg {
transform: rotate(0deg);
fill: currentColor;
@ -81,7 +69,7 @@ body > svg {
a {
color: #f90;
text-decoration: none;
border-bottom: 1px solid transparent;
border-bottom: 1px none #f90;
}
a:hover {
@ -151,16 +139,21 @@ input {
color: #ccc;
}
.hidden, .theme,
.hidden,
.theme input, input[type=submit] {
display: none;
}
.theme {
margin: 0 0.3em 0 0;
}
.theme input + label {
color: #f90;
cursor: pointer;
border-bottom: 3px solid transparent;
padding-bottom: 0.1em;
margin-left:0.6em;
}
.theme input:hover + label,
@ -288,6 +281,18 @@ article > header {
margin: 0;
}
.h-feed aside a,
.h-feed article a,
body > nav > ul > li a {
border-bottom: 1px solid rgba(255, 153, 0, 0.5);
}
.h-feed aside a:hover,
.h-feed article a:hover,
body > nav > ul > li a:hover {
border-bottom: 1px solid #eee;
}
main ul {
margin-left: 2em;
}

View file

@ -1,7 +1,8 @@
var DEFAULT_THEME = 'dark';
var ALT_THEME = 'light';
var STORAGE_KEY = 'theme';
var colorscheme = document.getElementsByName('colorscheme');
var colorscheme = [];
var mql = window.matchMedia('(prefers-color-scheme: ' + ALT_THEME + ')');
function indicateTheme(mode) {
for(var i = colorscheme.length; i--; ) {
@ -53,21 +54,43 @@ function autoTheme(e) {
indicateTheme(mode);
}
var mql = window.matchMedia('(prefers-color-scheme: ' + ALT_THEME + ')');
autoTheme(mql);
mql.addListener(autoTheme);
function doTheme() {
var themeform = document.createElement('form');
themeform.className = "theme";
themeform.innerHTML='<svg width="16" height="16"><use xlink:href="#icon-contrast"></use></svg>';
document.getElementById("header-forms").insertBefore(themeform, document.getElementById("search"));
var schemes = ["dark", "light"];
for (var i = 0; i < schemes.length; i++) {
var span = document.createElement('span');
themeform.appendChild(span);
var input = document.createElement('input');
input.name = 'colorscheme';
input.type = 'radio';
input.id = schemes[i] + input.name;
input.value = schemes[i];
span.appendChild(input);
var label = document.createElement('label');
label.htmlFor = input.id;
label.innerHTML = schemes[i];
span.appendChild(label);
}
colorscheme = document.getElementsByName('colorscheme');
for(var i = colorscheme.length; i--; ) {
colorscheme[i].onclick = setTheme;
}
autoTheme(mql);
mql.addListener(autoTheme);
}
var test = 'ping';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
for(var i = colorscheme.length; i--; ) {
colorscheme[i].onclick = setTheme;
}
var themeforms = document.getElementsByClassName(STORAGE_KEY);
for(var i = themeforms.length; i--; ) {
themeforms[i].style.display = 'inline-block';
}
doTheme();
} catch(e) {
console.log('localStorage is not available, manual theme switching is disabled');
}