all repos — nasg @ 85eb8324ed9d921f627380f5f6fcc324d9c3ad49

Merge pull request #1 from danger89/master

Improve readme & fix several failures during run-time (errors)
Peter Molnar github@petermolnar.net
Wed, 10 Apr 2019 08:19:52 +0000
commit

85eb8324ed9d921f627380f5f6fcc324d9c3ad49

parent

5c39f7e57acea7bc5b007d4e69e9301ecf2cb410

3 files changed, 85 insertions(+), 8 deletions(-)

jump to
M README.mdREADME.md

@@ -61,6 +61,65 @@ - search - uses and SQLite DB which is populated by Python on build

- fallback - 404 handler to do redirects/gones, gets populated with an array of both - micropub - a micropub endpoint that accepts micropub content and puts the incoming payload into a json file, nothing else +## Deploy + +### Requirements + +For Debian based distributions, install the packages: +* python3 +* python3-pip +* pandoc + +`sudo apt install python3 python3-pip pandoc` + +Install pipenv via pip: + +`sudo pip3 install pipenv` + +Install the pip dependency packages by using the Pipfile by running: + +`pipenv install` + +### Prepare + +Create a local base directory where your contents will be put into. Eg: + +`~/MyWebsite` + +Create the following directories within your base directory directory: `www`, `nasg/templates`, `content/home`. + +Copy the templates from the `templates` directory to the `~/MyWebsite/nasg/templates` directory. + +Create a new file within the root directory called `keys.py` with the following content: + +```python +webmentionio = { + 'domain': 'yourdomain.com', + 'token': 'token', + 'secret': 'secret' +} + +telegraph = { + 'token': 'token' +} + +zapier = { + 'zapier': 'secret' +} +``` + +Add an `index.md` file to the `~/MyWebsite/content/home` directory. + +Finally, change the [settings.py](settings.py) file, like the `base` path and `syncserver` etc. to your needs. + +### Run + +Execute within the root folder: + +`./run` + +For more info, see: `./run -h`. + ## Functionalities based on file extensions/names - **entry_name/index.md**: main entry (YAML + Multimarkdown)
M nasg.pynasg.py

@@ -1711,7 +1711,10 @@ return years

@property def mtime(self): - return self[self.sortedkeys[0]].published.timestamp + if len (self.sortedkeys) > 0: + return self[self.sortedkeys[0]].published.timestamp + else: + return 0 @property def rssfeedfpath(self):

@@ -1759,7 +1762,10 @@ s = sorted(

[self[k].dt for k in self.sortedkeys[start:end]], reverse=True ) - return s[0] + if len(s) > 0: + return s[0] # Timestamp in seconds since epoch + else: + return 0 @property def ctmplvars(self):

@@ -2071,10 +2077,11 @@ def renderfile(self):

return os.path.join(settings.paths.get('build'), 'sitemap.txt') async def render(self): - if self.mtime >= sorted(self.values())[-1]: - return - with open(self.renderfile, 'wt') as f: - f.write("\n".join(sorted(self.keys()))) + if len(self) > 0: + if self.mtime >= sorted(self.values())[-1]: + return + with open(self.renderfile, 'wt') as f: + f.write("\n".join(sorted(self.keys()))) class WebmentionIO(object):
M pandoc.pypandoc.py

@@ -57,15 +57,26 @@ conv_from = '%s+%s' % (

conv_from, '+'.join(self.in_options) ) - + + is_pandoc_version2 = False + try: + version = subprocess.check_output(['pandoc', '-v']) + if version.startswith(b'pandoc 2'): + is_pandoc_version2 = True + except OSError: + print("Error: pandoc is not installed!") + cmd = [ 'pandoc', '-o-', conv_to, conv_from, - '--quiet', '--no-highlight' ] + if is_pandoc_version2: + # Only pandoc v2 and higher support quiet param + cmd.append('--quiet') + if self.columns: cmd.append(self.columns)