2018-12-03 10:36:10 +00:00
|
|
|
__author__ = "Peter Molnar"
|
2019-01-05 11:55:40 +00:00
|
|
|
__copyright__ = "Copyright 2017-2019, Peter Molnar"
|
2018-12-03 10:36:10 +00:00
|
|
|
__license__ = "apache-2.0"
|
|
|
|
__maintainer__ = "Peter Molnar"
|
|
|
|
__email__ = "mail@petermolnar.net"
|
|
|
|
|
2018-07-20 16:47:25 +01:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import argparse
|
|
|
|
import logging
|
2019-03-22 15:49:24 +00:00
|
|
|
from tempfile import gettempdir
|
2018-07-20 16:47:25 +01:00
|
|
|
|
2019-02-16 00:14:12 +00:00
|
|
|
|
|
|
|
class struct(dict):
|
|
|
|
__getattr__ = dict.get
|
|
|
|
__setattr__ = dict.__setitem__
|
|
|
|
__delattr__ = dict.__delitem__
|
|
|
|
|
|
|
|
|
2018-07-20 16:47:25 +01:00
|
|
|
base = os.path.abspath(os.path.expanduser('~/Projects/petermolnar.net'))
|
2018-11-10 20:49:13 +00:00
|
|
|
syncserver = 'liveserver:/web/petermolnar.net'
|
2018-07-20 16:47:25 +01:00
|
|
|
|
2019-02-07 19:27:15 +00:00
|
|
|
pagination = 42
|
|
|
|
notinfeed = ['note']
|
|
|
|
flat = ['article', 'journal']
|
|
|
|
displaydate = 'YYYY-MM-DD HH:mm'
|
2019-06-24 13:52:44 +01:00
|
|
|
mementostartime = 1561192582
|
2019-02-07 19:27:15 +00:00
|
|
|
|
2019-02-16 00:14:12 +00:00
|
|
|
licence = struct({
|
|
|
|
'article': 'CC-BY-4.0',
|
|
|
|
'journal': 'CC-BY-NC-4.0',
|
|
|
|
'_default': 'CC-BY-NC-ND-4.0'
|
|
|
|
})
|
2019-02-08 23:32:52 +00:00
|
|
|
|
|
|
|
author = struct({
|
2019-02-07 19:27:15 +00:00
|
|
|
"@context": "http://schema.org",
|
|
|
|
"@type": "Person",
|
2019-02-08 23:32:52 +00:00
|
|
|
"image": "https://petermolnar.net/favicon.jpg",
|
2019-02-07 19:27:15 +00:00
|
|
|
"email": "mail@petermolnar.net",
|
|
|
|
"url": "https://petermolnar.net/",
|
2019-02-08 23:32:52 +00:00
|
|
|
"name": "Peter Molnar"
|
|
|
|
})
|
2019-01-21 16:10:27 +00:00
|
|
|
|
2019-02-08 23:32:52 +00:00
|
|
|
site = struct({
|
2019-02-07 19:27:15 +00:00
|
|
|
"@context": "http://schema.org",
|
|
|
|
"@type": "WebSite",
|
|
|
|
"headline": "Peter Molnar",
|
|
|
|
"url": "https://petermolnar.net",
|
|
|
|
"name": "petermolnar.net",
|
|
|
|
"image": "https://petermolnar.net/favicon.ico",
|
2019-02-16 00:14:12 +00:00
|
|
|
"license": "https://spdx.org/licenses/%s.html" % (licence['_default']),
|
2019-05-28 13:27:34 +01:00
|
|
|
"sameAs": [
|
|
|
|
],
|
2019-02-08 23:32:52 +00:00
|
|
|
"author": {
|
|
|
|
"@context": "http://schema.org",
|
|
|
|
"@type": "Person",
|
|
|
|
"image": "https://petermolnar.net/favicon.jpg",
|
|
|
|
"email": "mail@petermolnar.net",
|
|
|
|
"url": "https://petermolnar.net/",
|
|
|
|
"name": "Peter Molnar",
|
|
|
|
"sameAs": [
|
|
|
|
"https://github.com/petermolnar",
|
|
|
|
"https://petermolnar.net/cv.html",
|
|
|
|
"xmpp:mail@petermolnar.net",
|
|
|
|
"https://wa.me/447592011721",
|
|
|
|
"https://t.me/petermolnar",
|
2019-05-28 13:27:34 +01:00
|
|
|
"https://twitter.com/petermolnar"
|
2019-02-08 23:32:52 +00:00
|
|
|
],
|
|
|
|
"follows": "https://petermolnar.net/following.opml"
|
|
|
|
},
|
|
|
|
"publisher": {
|
|
|
|
"@context": "http://schema.org",
|
|
|
|
"@type": "Organization",
|
|
|
|
"logo": {
|
|
|
|
"@context": "http://schema.org",
|
|
|
|
"@type": "ImageObject",
|
|
|
|
"url": "https://petermolnar.net/favicon.jpg"
|
|
|
|
},
|
|
|
|
"url": "https://petermolnar.net/",
|
|
|
|
"name": "petermolnar.net",
|
|
|
|
"email": "webmaster@petermolnar.net"
|
|
|
|
},
|
|
|
|
"potentialAction": [
|
|
|
|
{
|
|
|
|
"@context": "http://schema.org",
|
|
|
|
"@type": "SearchAction",
|
|
|
|
"target": "https://petermolnar.net/search.php?q={q}",
|
|
|
|
"query-input": "required name=q",
|
|
|
|
"url": "https://petermolnar.net/search.php"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"@context": "http://schema.org",
|
|
|
|
"@type": "FollowAction",
|
|
|
|
"url": "https://petermolnar.net/follow/",
|
|
|
|
"name": "follow"
|
2019-02-25 22:40:01 +00:00
|
|
|
},
|
2019-05-28 13:27:34 +01:00
|
|
|
{
|
|
|
|
"@context": "http://schema.org",
|
|
|
|
"@type": "DonateAction",
|
|
|
|
"description": "Monzo",
|
|
|
|
"name": "monzo",
|
|
|
|
"url": "https://monzo.me/petermolnar/",
|
|
|
|
"recipient": author
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"@context": "http://schema.org",
|
|
|
|
"@type": "DonateAction",
|
|
|
|
"description": "Paypal",
|
|
|
|
"name": "paypal",
|
|
|
|
"url": "https://paypal.me/petermolnar/",
|
|
|
|
"recipient": author
|
|
|
|
}
|
2019-02-08 23:32:52 +00:00
|
|
|
]
|
|
|
|
})
|
2019-02-07 19:27:15 +00:00
|
|
|
|
|
|
|
|
2019-01-21 16:10:27 +00:00
|
|
|
menu = {
|
|
|
|
'home': {
|
2019-02-07 19:27:15 +00:00
|
|
|
'url': '%s/' % site['url'],
|
2019-01-21 16:10:27 +00:00
|
|
|
'text': 'home',
|
|
|
|
},
|
|
|
|
'photo': {
|
2019-02-07 19:27:15 +00:00
|
|
|
'url': '%s/category/photo/' % site['url'],
|
2019-01-21 16:10:27 +00:00
|
|
|
'text': 'photos',
|
|
|
|
},
|
|
|
|
'journal': {
|
2019-02-07 19:27:15 +00:00
|
|
|
'url': '%s/category/journal/' % site['url'],
|
2019-01-21 16:10:27 +00:00
|
|
|
'text': 'journal',
|
|
|
|
},
|
|
|
|
'article': {
|
2019-02-07 19:27:15 +00:00
|
|
|
'url': '%s/category/article/' % site['url'],
|
2019-01-21 16:10:27 +00:00
|
|
|
'text': 'IT',
|
|
|
|
},
|
|
|
|
'note': {
|
2019-02-07 19:27:15 +00:00
|
|
|
'url': '%s/category/note/' % site['url'],
|
2019-01-21 16:10:27 +00:00
|
|
|
'text': 'notes'
|
|
|
|
}
|
2018-07-20 16:47:25 +01:00
|
|
|
}
|
|
|
|
|
2019-02-08 23:32:52 +00:00
|
|
|
meta = struct({
|
2018-07-20 16:47:25 +01:00
|
|
|
'webmention': 'https://webmention.io/petermolnar.net/webmention',
|
|
|
|
'pingback': 'https://webmention.io/petermolnar.net/xmlrpc',
|
2018-08-15 11:02:59 +01:00
|
|
|
'hub': 'https://petermolnar.superfeedr.com/',
|
|
|
|
'authorization_endpoint': 'https://indieauth.com/auth',
|
|
|
|
'token_endpoint': 'https://tokens.indieauth.com/token',
|
2018-11-10 20:49:13 +00:00
|
|
|
'micropub': 'https://petermolnar.net/micropub.php',
|
2019-02-07 19:27:15 +00:00
|
|
|
#'microsub': 'https://aperture.p3k.io/microsub/83'
|
2019-02-08 23:32:52 +00:00
|
|
|
})
|
2018-07-20 16:47:25 +01:00
|
|
|
|
2019-02-08 23:32:52 +00:00
|
|
|
paths = struct({
|
2018-07-20 16:47:25 +01:00
|
|
|
'content': os.path.join(base, 'content'),
|
|
|
|
'tmpl': os.path.join(base, 'nasg', 'templates'),
|
|
|
|
'watermark': os.path.join(base, 'nasg', 'templates', 'watermark.png'),
|
|
|
|
'build': os.path.join(base, 'www'),
|
2018-11-10 20:49:13 +00:00
|
|
|
'queue': os.path.join(base, 'queue'),
|
|
|
|
'remotewww': 'web',
|
|
|
|
'remotequeue': 'queue',
|
|
|
|
'micropub': os.path.join(base, 'content', 'note'),
|
2019-01-15 21:28:58 +00:00
|
|
|
'home': os.path.join(base, 'content', 'home', 'index.md'),
|
2019-05-23 09:06:34 +01:00
|
|
|
'category': 'category',
|
|
|
|
'feed': 'feed'
|
|
|
|
})
|
|
|
|
|
|
|
|
filenames = struct({
|
|
|
|
'rss': 'index.xml',
|
|
|
|
'atom': 'atom.xml',
|
|
|
|
'json': 'index.json',
|
|
|
|
'md': 'index.md',
|
|
|
|
'txt': 'index.txt',
|
|
|
|
'html': 'index.html',
|
2019-05-29 20:34:47 +01:00
|
|
|
'gopher': 'gophermap',
|
|
|
|
'oembed_xml': 'oembed.xml',
|
2019-06-24 13:52:44 +01:00
|
|
|
'oembed_json': 'oembed.json',
|
|
|
|
'memento': 'memento.html',
|
|
|
|
'sitemap': 'sitemap.xml'
|
2019-02-08 23:32:52 +00:00
|
|
|
})
|
2018-07-20 16:47:25 +01:00
|
|
|
|
2019-06-13 15:32:13 +01:00
|
|
|
datignore = [
|
|
|
|
'.git',
|
|
|
|
'.dat',
|
|
|
|
'**.php'
|
|
|
|
]
|
|
|
|
|
2019-02-08 23:32:52 +00:00
|
|
|
photo = struct({
|
2018-07-20 16:47:25 +01:00
|
|
|
're_author': re.compile(r'(?:P[eé]ter Moln[aá]r)|(?:Moln[aá]r P[eé]ter)|(?:petermolnar\.(?:eu|net))'),
|
|
|
|
'default': 720,
|
|
|
|
'sizes': {
|
|
|
|
#90 = s
|
|
|
|
#360 = m
|
|
|
|
720: '',
|
|
|
|
1280: '_b',
|
|
|
|
},
|
2019-03-24 15:26:55 +00:00
|
|
|
'earlyyears': 2014
|
2019-02-08 23:32:52 +00:00
|
|
|
})
|
2018-07-20 16:47:25 +01:00
|
|
|
|
2019-05-28 13:27:34 +01:00
|
|
|
#symlinks = {
|
|
|
|
#'files/a-view-from-barbican-1280x720.jpg': 'a-view-from-barbican/a-view-from-barbican_b.jpg',
|
|
|
|
#'files/hills_from_beachy_head-540x226.jpg': 'hills-from-beachy-head/hills-from-beachy-head.jpg',
|
|
|
|
#'files/seven_sisters_from_beachy_head-540x304.jpg': 'seven-sisters-from-beachy-head/seven-sisters-from-beachy-head.jpg',
|
|
|
|
#'files/the_countryside-540x304.jpg': 'the-countryside/the-countryside.jpg',
|
|
|
|
#'files/MGP0538-540x358.jpg': '',
|
|
|
|
#'files/IMGP0539-540x358.jpg': '',
|
|
|
|
#'files/IMGP0538-540x358.jpg': '',
|
|
|
|
#}
|
|
|
|
|
2019-03-22 15:49:24 +00:00
|
|
|
tmpdir = os.path.join(gettempdir(),'nasg')
|
|
|
|
if not os.path.isdir(tmpdir):
|
|
|
|
os.makedirs(tmpdir)
|
2019-02-25 22:40:01 +00:00
|
|
|
|
2018-07-20 16:47:25 +01:00
|
|
|
_parser = argparse.ArgumentParser(description='Parameters for NASG')
|
|
|
|
_booleanparams = {
|
2019-06-13 15:32:13 +01:00
|
|
|
'regenerate': 'force (re)downsizing images',
|
|
|
|
'force': 'force (re)rendering HTML',
|
2019-01-15 21:28:58 +00:00
|
|
|
'debug': 'set logging to debug level',
|
2019-04-10 09:27:37 +01:00
|
|
|
'quiet': 'show only errors',
|
2019-06-13 15:32:13 +01:00
|
|
|
'offline': 'offline mode - no syncing, no querying services, etc.',
|
|
|
|
'noping': 'make dummy webmention entries and don\'t really send them',
|
2019-06-24 13:52:44 +01:00
|
|
|
'noservices': 'skip querying any service but do sync the website',
|
|
|
|
'memento': 'try to fetch mementos from archive.org'
|
2018-07-20 16:47:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for k, v in _booleanparams.items():
|
|
|
|
_parser.add_argument(
|
|
|
|
'--%s' % (k),
|
|
|
|
action='store_true',
|
|
|
|
default=False,
|
|
|
|
help=v
|
|
|
|
)
|
|
|
|
|
|
|
|
args = vars(_parser.parse_args())
|
|
|
|
|
2019-01-15 21:28:58 +00:00
|
|
|
if args.get('debug', False):
|
|
|
|
loglevel = 10
|
|
|
|
elif args.get('quiet', False):
|
|
|
|
loglevel = 40
|
|
|
|
else:
|
|
|
|
loglevel = 20
|
2018-07-20 16:47:25 +01:00
|
|
|
|
2018-11-04 23:27:53 +00:00
|
|
|
logger = logging.getLogger('NASG')
|
2018-08-04 09:30:26 +01:00
|
|
|
logger.setLevel(loglevel)
|
2019-01-15 21:28:58 +00:00
|
|
|
|
2018-08-04 09:30:26 +01:00
|
|
|
console_handler = logging.StreamHandler()
|
2018-11-04 23:27:53 +00:00
|
|
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
|
|
console_handler.setFormatter(formatter)
|
2018-08-04 09:30:26 +01:00
|
|
|
logger.addHandler(console_handler)
|
2019-01-15 21:28:58 +00:00
|
|
|
|
2018-08-04 09:30:26 +01:00
|
|
|
logging.getLogger('asyncio').setLevel(loglevel)
|