all repos — nasg @ 1f4a864d594863cf16997c9e89d88db8062bd848

- 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
Peter Molnar hello@petermolnar.eu
Wed, 10 Apr 2019 09:27:37 +0100
commit

1f4a864d594863cf16997c9e89d88db8062bd848

parent

9eccd3e683a40e129ca891d8136a94cc6647d9cb

M nasg.pynasg.py

@@ -244,6 +244,10 @@

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 @@ continue

else: exif[ekey] = maybe break - return exif + return struct(exif) def _maybe_watermark(self, img): if not self.is_photo:

@@ -1244,14 +1248,12 @@ if not os.path.exists(wmarkfile):

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 @@ if self.parent.meta.get('FileType', 'jpeg').lower() == 'jpeg':

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'

@@ -1649,6 +1651,13 @@

@property 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):
M settings.pysettings.py

@@ -182,7 +182,8 @@ 'regenerate': 'force downsizing images',

'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():
M templates/Home.j2.htmltemplates/Home.j2.html

@@ -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>
M templates/base.j2.htmltemplates/base.j2.html

@@ -50,23 +50,10 @@ {% endfor %}

</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">
A templates/bye.txt

@@ -0,0 +1,20 @@

+███████╗███████╗███████╗ ██╗ ██╗ ██████╗ ██╗ ██╗ +██╔════╝██╔════╝██╔════╝ ╚██╗ ██╔╝██╔═══██╗██║ ██║ +███████╗█████╗ █████╗ ╚████╔╝ ██║ ██║██║ ██║ +╚════██║██╔══╝ ██╔══╝ ╚██╔╝ ██║ ██║██║ ██║ +███████║███████╗███████╗ ██║ ╚██████╔╝╚██████╔╝ +╚══════╝╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚═════╝ + +███████╗██████╗ █████╗ ██████╗███████╗ +██╔════╝██╔══██╗██╔══██╗██╔════╝██╔════╝ +███████╗██████╔╝███████║██║ █████╗ +╚════██║██╔═══╝ ██╔══██║██║ ██╔══╝ +███████║██║ ██║ ██║╚██████╗███████╗ +╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ + + ██████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗ +██╔════╝██╔═══██╗██║ ██║██╔══██╗██╔═══██╗╚██╗ ██╔╝ +██║ ██║ ██║██║ █╗ ██║██████╔╝██║ ██║ ╚████╔╝ +██║ ██║ ██║██║███╗██║██╔══██╗██║ ██║ ╚██╔╝ +╚██████╗╚██████╔╝╚███╔███╔╝██████╔╝╚██████╔╝ ██║ + ╚═════╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═════╝ ╚═╝
M templates/style.csstemplates/style.css

@@ -46,26 +46,14 @@ main p {

margin: 1em 0; } -h1 { - border-bottom: 4px double #999; +h1 { 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 {

@@ -81,7 +69,7 @@

a { color: #f90; text-decoration: none; - border-bottom: 1px solid transparent; + border-bottom: 1px none #f90; } a:hover {

@@ -151,16 +139,21 @@ background-color: #333;

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 @@ border: none;

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; }

@@ -355,4 +360,4 @@ bottom: 0;

right: 0; width: 10em; height: auto; -} +}
M templates/themeswitcher.jstemplates/themeswitcher.js

@@ -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 @@ applyTheme(mode);

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'); }