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

View file

@ -182,7 +182,8 @@ _booleanparams = {
'force': 'force rendering HTML', 'force': 'force rendering HTML',
'nosync': 'skip sync to live server', 'nosync': 'skip sync to live server',
'debug': 'set logging to debug level', '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(): for k, v in _booleanparams.items():

View file

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

View file

@ -50,23 +50,10 @@
</ul> </ul>
</nav> </nav>
<div> <div id="header-forms">
<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>
{% for action in site.potentialAction %} {% for action in site.potentialAction %}
{% if 'SearchAction' == action['@type'] %} {% 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"> <label for="qsub">
<input type="submit" value="search" id="qsub" name="qsub" /> <input type="submit" value="search" id="qsub" name="qsub" />
<svg width="16" height="16"> <svg width="16" height="16">

20
templates/bye.txt Normal file
View file

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

View file

@ -46,28 +46,16 @@ main p {
margin: 1em 0; margin: 1em 0;
} }
h1 { h1 {
border-bottom: 4px double #999;
text-transform:uppercase; text-transform:uppercase;
text-align: center; text-align: center;
padding-bottom: 1em; padding-bottom: 1em;
} }
article > footer > dl > dt,
h2 {
border-bottom: 1px solid #999;
}
article > footer > dl > dt,
h3,
hr { hr {
border-bottom: 1px dotted #999; border-bottom: 1px dotted #999;
} }
h4 {
border-bottom: 1px dashed #999;
}
svg { svg {
transform: rotate(0deg); transform: rotate(0deg);
fill: currentColor; fill: currentColor;
@ -81,7 +69,7 @@ body > svg {
a { a {
color: #f90; color: #f90;
text-decoration: none; text-decoration: none;
border-bottom: 1px solid transparent; border-bottom: 1px none #f90;
} }
a:hover { a:hover {
@ -151,16 +139,21 @@ input {
color: #ccc; color: #ccc;
} }
.hidden, .theme, .hidden,
.theme input, input[type=submit] { .theme input, input[type=submit] {
display: none; display: none;
} }
.theme {
margin: 0 0.3em 0 0;
}
.theme input + label { .theme input + label {
color: #f90; color: #f90;
cursor: pointer; cursor: pointer;
border-bottom: 3px solid transparent; border-bottom: 3px solid transparent;
padding-bottom: 0.1em; padding-bottom: 0.1em;
margin-left:0.6em;
} }
.theme input:hover + label, .theme input:hover + label,
@ -288,6 +281,18 @@ article > header {
margin: 0; 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 { main ul {
margin-left: 2em; margin-left: 2em;
} }
@ -355,4 +360,4 @@ body > img {
right: 0; right: 0;
width: 10em; width: 10em;
height: auto; height: auto;
} }

View file

@ -1,7 +1,8 @@
var DEFAULT_THEME = 'dark'; var DEFAULT_THEME = 'dark';
var ALT_THEME = 'light'; var ALT_THEME = 'light';
var STORAGE_KEY = 'theme'; var STORAGE_KEY = 'theme';
var colorscheme = document.getElementsByName('colorscheme'); var colorscheme = [];
var mql = window.matchMedia('(prefers-color-scheme: ' + ALT_THEME + ')');
function indicateTheme(mode) { function indicateTheme(mode) {
for(var i = colorscheme.length; i--; ) { for(var i = colorscheme.length; i--; ) {
@ -53,21 +54,43 @@ function autoTheme(e) {
indicateTheme(mode); indicateTheme(mode);
} }
var mql = window.matchMedia('(prefers-color-scheme: ' + ALT_THEME + ')'); function doTheme() {
autoTheme(mql); var themeform = document.createElement('form');
mql.addListener(autoTheme); 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'; var test = 'ping';
try { try {
localStorage.setItem(test, test); localStorage.setItem(test, test);
localStorage.removeItem(test); localStorage.removeItem(test);
for(var i = colorscheme.length; i--; ) { doTheme();
colorscheme[i].onclick = setTheme;
}
var themeforms = document.getElementsByClassName(STORAGE_KEY);
for(var i = themeforms.length; i--; ) {
themeforms[i].style.display = 'inline-block';
}
} catch(e) { } catch(e) {
console.log('localStorage is not available, manual theme switching is disabled'); console.log('localStorage is not available, manual theme switching is disabled');
} }