From ab668674f4275d06f231e357a3bb206e38588a51 Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Sat, 16 Jun 2018 16:55:02 +0000 Subject: [PATCH] - new panorama special case on image resizing - new .dist config --- config.ini.dist | 94 +++-- nasg.py | 25 +- router.py | 8 + shared.py | 1 + templates/style-dark.css | 800 --------------------------------------- 5 files changed, 91 insertions(+), 837 deletions(-) delete mode 100644 templates/style-dark.css diff --git a/config.ini.dist b/config.ini.dist index 8ce0586..e1a882a 100644 --- a/config.ini.dist +++ b/config.ini.dist @@ -1,7 +1,7 @@ [common] base = ~/ domain = domain.com -build = ~/public +build = ~/web files = files [dirs] @@ -11,12 +11,13 @@ files = ${common:base}/${common:files} static = ${common:base}/static var = ${common:base}/var archive = ${common:base}/archive +comment = ${common:base}/comment [archive] favorite = ${dirs:archive}/favorite [photo] -regex = your_regex_artist +regex = (author name) watermark = ${dirs:tmpl}/watermark.png default = 720 @@ -24,7 +25,7 @@ default = 720 ;90 = s ;360 = m 720 = z -1920 = b +1280 = b [crop] ;90 = true @@ -32,51 +33,92 @@ default = 720 [var] searchdb = ${dirs:var}/s.sqlite webmentiondb = ${dirs:var}/webmention.sqlite -redirects = ${dirs:var}/redirects.tsv -gone = ${dirs:var}/gone.tsv +redirects = ${dirs:content}/redirects.tsv +gone = ${dirs:content}/gone.tsv tokendb = ${dirs:var}/tokens.json cache = ${dirs:var}/cache [site] -title = Yet another static site +title = url = https://${common:domain} lang = en domains = ${common:domain} -websuburl = https://example.superfeedr.com/ +feed = feed +appendwith = author websub + +[tip_label] +paypal = PayPal +monzo = Monzo (UK) + +[tip_value] +paypal = £3 +monzo = £3 + +[tip_url] +paypal = https://paypal.me/username/3GBP +monzo = https://monzo.me/username/3 + +[websub] +hub = https://hubname.superfeedr.com/ [display] pagination = 12 +norender = page [licence] default = by-nc-nd [author] -name = Your Name -email = your_email +name = Author Name +email = author@domain.com url = ${site:url} avatar = ${site:url}/avatar.jpg -gpg = GPG long key -donateurl = https://paypal.me/yourname/3GBP -appendwith = socials - -[socials] -flickr = https://www.flickr.com/people/your_flickr_handle -github = https://github.com/your_github_handle +gpg = pgp.asc +sip = sip.account@domain.com +xmpp = xmpp.account@domain.com +flickr = flickr username +github = github username +icq = ICQ username +telegram = Telegram username [api_flickr] -api_key = api_key -api_secret = api_secret -username = username +api_key = +api_secret = +username = [api_500px] -api_key = api_key -api_secret = api_secret +api_key = +api_secret = [api_tumblr] -api_key = api_key -api_secret = api_secret +api_key = +api_secret = [api_deviantart] -api_key = api_key -api_secret = api_secret -username = username +api_key = +api_secret = +username = + +[listener] +host = 127.0.0.1 +port = 8008 + +[api_telegram] +api_token = +chat_id = + +[api_spotify] +api_key = +api_secret = + +[api_lastfm] +api_key = +api_secret = +username = +logfile = ${dirs:archive}/lastfm.csv + +[api_twitter] +api_key = +api_secret = +username = +userid = diff --git a/nasg.py b/nasg.py index ee08975..8bef524 100644 --- a/nasg.py +++ b/nasg.py @@ -1166,17 +1166,20 @@ class WebImage(object): def _intermediate_dimension(self, size, width, height, crop=False): """ Calculate intermediate resize dimension and return a tuple of width, height """ - size = int(size) - if (width > height*3): - size = int(size * 0.6) - # panorama - if (height <= size): - h = height - else: - h = size - w = int(float(h / height) * width) - elif (width > height and not crop) \ - or (width < height and crop): + ratio = max(width, height) / min(width, height) + horizontal = True if (width / height) >= 1 else False + + # panorama: reverse "horizontal" because the limit should be on + # the shorter side, not the longer, and make it a bit smaller, than + # the actual limit + # 2.39 is the wide angle cinematic view: anything wider, than that + # is panorama land + if ratio > 2.4 and not crop: + size = int(size*0.6) + horizontal = not horizontal + + if (horizontal and not crop) \ + or (not horizontal and crop): w = size h = int(float(size / width) * height) else: diff --git a/router.py b/router.py index 68bb24b..ea0409d 100644 --- a/router.py +++ b/router.py @@ -71,6 +71,14 @@ if __name__ == '__main__': async def micropub(request): return sanic.response.text("Not Implemented", status=501) + @app.route("/micropub-auth", methods=["POST", "GET"]) + async def micropub_auth(request): + return sanic.response.text("Not Implemented", status=501) + + @app.route("/micropub-token", methods=["POST", "GET"]) + async def micropub_token(request): + return sanic.response.text("Not Implemented", status=501) + @app.route("/webmention", methods=["POST"]) async def webmention(request): source = request.form.get('source') diff --git a/shared.py b/shared.py index eb8d385..87d8007 100644 --- a/shared.py +++ b/shared.py @@ -433,6 +433,7 @@ class SearchDB(BaseDB): return False def search_by_query(self, query): + query = query.replace('-', ' + ') logging.info("query is: %s", query) ret = {} cursor = self.db.cursor() diff --git a/templates/style-dark.css b/templates/style-dark.css deleted file mode 100644 index 96e735c..0000000 --- a/templates/style-dark.css +++ /dev/null @@ -1,800 +0,0 @@ -* { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -html, body, div, span, -h1, h2, h3, h4, h5, h6, -a, p, blockquote, pre, cite, code, -del, em, ins, strong, sub, sup, tt, b, u, i, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, details, -figure, figcaption, img, -footer, header, hgroup, -menu, nav, section, summary, -time, audio, video { - margin: 0; - padding: 0; - border: 0; - font: inherit; - vertical-align: baseline; -} - -article, aside, details, figcaption, figure, -footer, header, hgroup, menu, nav, section { - display: block; -} - -html, body { - min-height: 100%; - font-size:20px; - line-height: 1.3em; - font-family: "Liberation Sans", "Helvetica Neue", "Roboto", "Helvetica", sans-serif; - font-weight: normal; - color: #ccc; - text-shadow: 1px 1px 1px rgba(0,0,0,0.004); - background-color: #222; -} - -html { - position: relative; -} - -html, -.content-header, -.content-footer { - background-color: #111; - color: #bbb; -} - -a { - color: #eee; - text-decoration:none; -} - -a:hover { - color: #fff; -} - -b, strong { - font-weight:bold; -} - -em { - font-style: italic; -} - -p { - padding: 0.6em 0; -} - -li { - margin-left: 1.3em; -} - -ul li { - line-height: 1.6em; -} - -li p { - margin:0; - padding: 0; -} - -blockquote { - margin: 0.6em; - padding-left: 0.6em; - border-left: 4px solid #999; - color: #999; -} - -table { - border-collapse: collapse; - border-spacing: 0; - width: 100%; -} - -td, th { - padding: 0.3em; - border: 1px solid #111; - text-align:left; -} - -th { - font-weight: bold; -} - -th, -tr:nth-child(odd) { - background-color: #333; -} -tr:nth-child(even) { - background-color: #444; -} - -.content-header a, -.content-header a:hover, -.content-footer a, -.content-footer a:hover, -.footnoteRef a, -pre code, -.h-review h2, -input, -.reactions h2, -.replies h2, -.syndication h2, -hr { - border: none; -} - -hr { - display: block; - height: 1px; - border-top: 1px solid #444; - margin: 1em 0; - clear:both; -} - -h1, h2, h3, h4, h5, h6, dt { - font-weight:bold; - clear:both; -} - -h1, h2, h3, h4, h5, h6 { - margin: 1.3em 0 0.3em 0; - padding: 0 0 0.3em 0; -} - -h1 { - font-size: 1.2em; - margin-top: 0; -} - -h2 { - font-size: 1.1em; - border-bottom: 2px solid #999; -} - -h3 { - font-size: 1em; - border-bottom: 1px dotted #777; - -} - -.icon { - transform: rotate(0deg); - width: 16px; - height: 16px; - display: inline-block; - fill: currentColor; - overflow: visible; - vertical-align:middle; -} - -code, -pre { - font-family: "Courier New", "Courier", monospace; - font-size: 0.8em; - color: limegreen; - background-color: #222; - border: 1px solid #666; - direction: ltr; - text-align: left; - tab-size: 2; -} - -pre { - overflow: auto; - padding: 0.3em; -} - -code { - padding: 0.1em; -} - -code.sourceCode span.al { color: limegreen; } -code.sourceCode span.at { color: limegreen; } -code.sourceCode span.bn { color: limegreen; } -code.sourceCode span.bu { color: limegreen; } -code.sourceCode span.cf { color: limegreen; } -code.sourceCode span.ch { color: limegreen; } -code.sourceCode span.co { color: gray; } -code.sourceCode span.dt { color: limegreen; } -code.sourceCode span.dv { color: limegreen; } -code.sourceCode span.er { color: limegreen; } -code.sourceCode span.ex { color: orange; } -code.sourceCode span.fl { color: limegreen; } -code.sourceCode span.fu { color: orange; } -code.sourceCode span.im { color: limegreen; } -code.sourceCode span.kw { color: cyan; } -code.sourceCode span.op { color: limegreen; } -code.sourceCode span.ot { color: limegreen; } -code.sourceCode span.pp { color: limegreen; } -code.sourceCode span.sc { color: limegreen; } -code.sourceCode span.ss { color: limegreen; } -code.sourceCode span.st { color: magenta; } -code.sourceCode span.va { color: turquoise; } - -.limit, -.content-body { - max-width: 72ch; - margin: 0 auto; -} - -.siteinfo { - line-height: 1.4em; - font-size: 0.9em; - padding: 1em; - font-style: italic; - color: #999; -} - -.footnotes ol li { - margin-bottom: 0.3em; -} - -.footnoteRef, -.footnoteRef:hover { - border: 0; - white-space: nowrap; -} - -.footnoteRef sup { - vertical-align: baseline; - position: relative; - top: -0.3em; - font-size: 0.8em; - margin-right: 0.1em; -} - -.footnoteRef sup:before, -.footnoteRef sup:after { - color: #33c; -} - -.comments ol .u-repost-of, -.footnotes ol li a { - display: inline-block; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - vertical-align: top; - max-width: 80%; -} - -.footnotes ol li a[href^="#"] { - margin: 0 0 0 0.6em; - max-width: 20%; - font-size: 0.6em; -} - -.footnotes ol li a[href^="#"]:after { - content: "back to text"; - margin: 0 0 0 0.2em; - color: #666; -} - -.footnotes ol li a[href^="#"]:hover:after { - color: #ccc; -} - -.content-header a, -.content-footer a { - color: #cccccc; -} - -.content-header a:hover, -.content-footer a:hover { - color: #fefefe; -} - -.content-footer { - margin-top: 2em; - padding: 1.6em 0; - text-align: center; -} - -.content-footer * { - color: #999; - display: inline-block; -} - -.content-footer a { - color: #999; -} - -.content-footer a:hover { - color: #eee; -} - -.content-footer img { - width: 1em; - margin: 0 0.3em 0em 0; -} - -.content-footer dl { - font-size: 0.86em; -} - - -.content-footer dl dd, -.content-footer dl dt,{ - display:inline-block; -} - -.content-footer dl dd:after { - content: '\00B7'; - margin: 0 0.3em; -} - -.content-footer dl dd:last-of-type:after { - content: ''; - display: none; - visibility: hidden; -} - -input { - vertical-align:middle; - border-bottom: 3px solid #aaa; - background-color: transparent; - color: #ccc; - height: 1.6em; - width: 6em; - font-size: 0.8em; -} - -input.search-submit { - width: 3em; - cursor: pointer; -} - -input:focus, -input.search-submit:hover { - border-bottom: 3px solid #fff; - color: #fff; -} - -.search-form { - display: block; - padding: 0.3em 0.1em; - text-align: center; -} - -.content-navigation ul { - list-style-type: none; - margin: 0; - padding: 0; - text-align:center; -} - -.content-navigation ul li { - margin:0; - padding: 0.3em 0.3em 0.3em 0; - display: inline-block; - text-align: center; -} - -.content-navigation ul li a { - display:block; - padding:0 0.2em; - font-weight: bold; - border-bottom: 3px solid transparent; - text-align: center; - font-size: 0.7em; -} - -.content-navigation ul li a svg { - display:block; - margin: auto; -} - -.content-navigation ul li a.active { - border-bottom: 3px solid #ccc; -} - -.content-navigation ul li a:hover { - border-bottom: 3px solid #fefefe; -} - -.h-feed h2 { - margin-bottom: 1em; -} - -.h-feed .h-entry { - margin: 0 1em; -} - -.h-feed .h-entry h3 { - font-size: 0.9em; -} - -.h-feed .h-entry .e-summary, -.h-feed .h-entry .e-content { - font-size: 0.8em; -} - -.h-feed .h-entry .e-content { - margin-bottom: 3em; -} - -.h-entry.singular { - padding: 0 0.6em; - font-size: 0.9em; -} - -.h-entry .e-content a, -.h-entry .e-summary a { - color:#5193D4; -} - -.h-entry a:hover { - color:#71B3F4; -} - -.h-entry.singular h1 { - margin: 2em 0 1em 0; -} - -.h-entry.singular footer { - margin: 2em 0; - font-size: 0.9em; -} - -.h-entry.singular footer p { - padding: 0.3em 0; - display: inline-block; - color: #aaa; -} - -.h-entry.singular footer a { - color: #ccc; -} - -.h-entry.singular footer a:hover { - color: #eee; -} - -.h-entry.singular footer dd { - margin: 0 0 1em 0; -} - -.h-entry.singular footer img { - width: 1em; - height: auto; -} - -.donation ul, -.donation li { - list-style-type: none; -} - -.donation li { - margin: 0.6em 0.6em 0.6em 0; - display: inline-block; -} - -.donation p { - line-height: 1.2em; -} - -.donation li a { - display: inline-block; - border: 1px dashed #933; - padding: 0.6em 1em; - background-color: #111; - width: 16em; -} - -.donation .method { - margin-left: 0.6em; -} - -.donation li a:hover { - border: 1px solid #933; - color: #fff; -} - -figure { - margin: 1em 0; - position:relative; - overflow: hidden; -} - -figure figcaption { - padding: 0.3em 0; - text-align: center; -} - -.exif { - font-size: 0.8em; -} - -figcaption .alt, -figcaption .author, -.h-feed figcaption, -.content-footer h2, -.reactions dl dt, -.reactions dl ul time, -.hide, -.exif dt { - display: none; - visibility: hidden; -} - -.exif dd { - display: inline-block; - margin: 0 0.6em 0 0; -} - -.exif .icon { - margin: 0 0.2em; - width: 1em; - vertical-align:text-bottom; -} - - -.adaptimg { - display: block; - max-height: 98vh; - max-width: 100%; - width:auto; - height:auto; - margin: 0 auto; - padding: 0; - border: 1px solid #000; -} - -.follow { - cursor:pointer; - display:block; - text-align:right; - margin: 0.6em 0; - font-size: 0.8em; -} - -.follow a, -.pagination a { - padding: 0 0 0.3em 0; - border-bottom: 3px solid #999; -} - -.follow a:hover, -.pagination a:hover { - border-bottom-color: #fff; -} - -.pagination ul { - text-align:center; - list-style-type: none; -} - -.pagination li { - display:inline-block; -} - -.pagination a, -.pagination span { - padding: 0.3em; -} - -.w25, -.w33 { - display: inline-block; - height: auto; -} - -.w33 { - width: 32%; -} -.w25 { - width: 24%; -} - -.search-section { - margin-bottom: 1em; -} - -.search-section summary { - border-bottom: 2px solid #999; - padding: 0.3em 0; - font-weight: bold; -} - -.search-section li { - margin: 1em 0.6em; -} - -.replies { - font-size: 0.9em; -} - -.replies ol { - margin: 0 0 0 1em; -} - -.replies li { - margin: 0 0 1em 0; -} - -.replies li .source { - display: block; -} - -.reactions dl ul, -.reactions dl ul li { - list-style-type: none; - margin: 0; -} - -.h-review { - padding: 1em; - border: 2px dotted #999; - margin: 1em 0; -} - -.h-review h2 { - margin: 0; -} - -.h-review p { - line-height: 1.2em; - margin: 0; - padding: 0.3em 0; -} - -.h-review .rating { - font-size: 0.9em; -} - -.h-review .rating .best, -.h-review .rating .value { - color: #fff; - font-weight: bold; -} - -@media all and (min-width: 56em) { - - .content-navigation ul li a { - font-size: 0.9em; - } - .content-navigation ul li a svg { - display:inline-block; - } - - .search-form, - .content-navigation { - display:inline-block; - } - - .search-form { - float:right; - margin: 0.1em; - } -} - - -@media print { - * { - background-color: #fff !important; - color: #222; - } - - html, body { - font-size: 11pt !important; - text-shadow: unset !important; - font-family: Helvetica, sans-serif !important; - } - - @page { - margin: 0.6in 0.5in; - } - - .limit, - .content-body { - max-width: 100% !important; - margin: 0 !important; - } - - h1, h2, h3, h4, h5, h6 { - page-break-after: avoid; - } - - h3, - a, - .footnotes ol li a, - .h-feed .h-entry, - code, - pre { - border: none; - } - - p, li, blockquote, figure, .footnotes { - page-break-inside: avoid !important; - } - - a { - color: #000; - } - - td, th { - border: 1pt solid #666; - } - - .content-note, - .content-header, - .content-footer, - video, - audio, - .footnotes ol li a[href^="#"], - .footnotes ol li a[href^="#"]:after, - .exif svg, - .donation, - .noprint { - display:none; - visibility: hidden; - } - - .footnotes ol li a { - display: block; - overflow: visible; - white-space: normal; - } - - code, pre { - max-width: 96%; - color: #222; - word-break: break-all; - word-wrap: break-word; - white-space: pre-wrap; - overflow:initial; - page-break-inside: enabled; - font-family: "Courier", "Courier New", monospace !important; - } - - pre { - border: 1pt dotted #666; - padding: 0.6em; - } - - code.sourceCode span { color: black; } - code.sourceCode span.al { color: black; } - code.sourceCode span.at { color: black; } - code.sourceCode span.bn { color: black; } - code.sourceCode span.bu { color: black; } - code.sourceCode span.cf { color: black; } - code.sourceCode span.ch { color: black; } - code.sourceCode span.co { color: darkgray; } - code.sourceCode span.dt { color: black; } - code.sourceCode span.dv { color: black; } - code.sourceCode span.er { color: black; } - code.sourceCode span.ex { color: darkorange; } - code.sourceCode span.fl { color: black; } - code.sourceCode span.fu { color: darkorange; } - code.sourceCode span.im { color: black; } - code.sourceCode span.kw { color: darkcyan; } - code.sourceCode span.op { color: black; } - code.sourceCode span.ot { color: black; } - code.sourceCode span.pp { color: black; } - code.sourceCode span.sc { color: black; } - code.sourceCode span.ss { color: black; } - code.sourceCode span.st { color: magenta; } - code.sourceCode span.va { color: darkturquoise; } - - figcaption { - font-size: 0.9em; - } - - .adaptimg { - max-height: 35vh; - max-width: 90vw; - outline: none; - border: 1px solid #000; - } - - .h-feed .h-entry { - page-break-after:always; - } -}