Merge pull request #1 from danger89/master
Improve readme & fix several failures during run-time (errors)
This commit is contained in:
commit
85eb8324ed
3 changed files with 85 additions and 8 deletions
59
README.md
59
README.md
|
@ -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)
|
||||
|
|
19
nasg.py
19
nasg.py
|
@ -1711,7 +1711,10 @@ class Category(dict):
|
|||
|
||||
@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 @@ 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,10 +2077,11 @@ class Sitemap(dict):
|
|||
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):
|
||||
|
|
15
pandoc.py
15
pandoc.py
|
@ -57,15 +57,26 @@ class Pandoc(str):
|
|||
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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue