Merge pull request #1 from danger89/master

Improve readme & fix several failures during run-time (errors)
This commit is contained in:
Peter Molnar 2019-04-10 08:19:52 +00:00 committed by GitHub
commit 85eb8324ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 85 additions and 8 deletions

View file

@ -61,6 +61,65 @@ How it works
- 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)

View file

@ -1711,7 +1711,10 @@ class Category(dict):
@property
def mtime(self):
if len (self.sortedkeys) > 0:
return self[self.sortedkeys[0]].published.timestamp
else:
return 0
@property
def rssfeedfpath(self):
@ -1759,7 +1762,10 @@ class Category(dict):
[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,6 +2077,7 @@ class Sitemap(dict):
return os.path.join(settings.paths.get('build'), 'sitemap.txt')
async def render(self):
if len(self) > 0:
if self.mtime >= sorted(self.values())[-1]:
return
with open(self.renderfile, 'wt') as f:

View file

@ -58,14 +58,25 @@ class Pandoc(str):
'+'.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)