more recent changes
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
## usage ##
|
||||
|
||||
### srndv2 unstable ###
|
||||
|
||||
add to nntpchan.json hooks section:
|
||||
|
||||
{
|
||||
@@ -9,3 +11,12 @@ add to nntpchan.json hooks section:
|
||||
"exec": "/path/to/frontend.py"
|
||||
}
|
||||
|
||||
### nntpd ###
|
||||
|
||||
add this to nntpchan.ini
|
||||
|
||||
|
||||
...
|
||||
[frontend]
|
||||
type=exec
|
||||
exec=/path/to/frontend.py
|
||||
|
@@ -1,9 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
import nntpchan
|
||||
from nntpchan import message
|
||||
from nntpchan import db
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
msgid = sys.argv[1]
|
||||
group = sys.argv[2]
|
||||
if nntpchan.addArticle(msgid, group):
|
||||
nntpchan.regenerate(msgid, group)
|
||||
lvl = logging.INFO
|
||||
if 'NNTPCHAN_DEBUG' in os.environ:
|
||||
lvl = logging.DEBUG
|
||||
logging.basicConfig(level=lvl)
|
||||
l = logging.getLogger(__name__)
|
||||
cmd = sys.argv[1]
|
||||
if cmd == 'post':
|
||||
fpath = sys.argv[2]
|
||||
msg = None
|
||||
if not os.path.exists(fpath):
|
||||
print("{} does not exist".format(fpath))
|
||||
exit(1)
|
||||
with open(fpath) as f:
|
||||
msg = message.parse(f)
|
||||
if msg:
|
||||
l.debug("loaded {}".format(fpath))
|
||||
elif cmd == 'newsgroup':
|
||||
if db.allowsNewsgroup(sys.argv[2]):
|
||||
exit(0)
|
||||
else:
|
||||
exit(1)
|
||||
elif cmd == 'msgid':
|
||||
if db.allowsMessage(sys.argv[2]):
|
||||
exit(0)
|
||||
else:
|
||||
exit(1)
|
||||
elif cmd == 'init':
|
||||
db.init()
|
||||
|
11
contrib/frontends/py/nntpchan/config.py
Normal file
11
contrib/frontends/py/nntpchan/config.py
Normal file
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# please edit this file to contain the required information
|
||||
#
|
||||
|
||||
|
||||
""" path to article storage directory """
|
||||
storage = '/path/to/storage/'
|
||||
|
||||
""" database connector url """
|
||||
dburl = 'postgresql://user:password@localhost/database'
|
||||
#dburl = 'sqlite:///path/to/nntpchan.sqlite3'
|
16
contrib/frontends/py/nntpchan/db.py
Normal file
16
contrib/frontends/py/nntpchan/db.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from nntpchan import config
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
def allowsMessage(msgid):
|
||||
return True
|
||||
|
||||
def allowsNewsgroup(group):
|
||||
return True
|
||||
|
||||
|
||||
|
||||
def init():
|
||||
"""
|
||||
initialize db backend
|
||||
"""
|
Reference in New Issue
Block a user