form: rss items max used with feed file creation. wip/publish: keep modification time files (for RSS)
This commit is contained in:
parent
eda5d7f6fc
commit
b0d409f849
|
@ -99,6 +99,7 @@ domain_values = \
|
|||
'www_footer',
|
||||
'www_rss',
|
||||
'domain_rss',
|
||||
'domain_rssitems',
|
||||
'domain_footer_about',
|
||||
'domain_active',
|
||||
)
|
||||
|
@ -166,13 +167,13 @@ else:
|
|||
# Conditions from command line #
|
||||
# Get some post settings fom uri #
|
||||
#--------------------------------#
|
||||
# Domain must be valid
|
||||
domain.domain_needed()
|
||||
|
||||
if args.target \
|
||||
and args.action in args.pass_db \
|
||||
and not args.target in args.pass_targets:
|
||||
|
||||
# Domain must be valid
|
||||
domain.domain_needed()
|
||||
|
||||
uri_file = '%s/%s'%(in_dir, args.target)
|
||||
uri_id = tyto.get_filesum(uri_file, False)
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
from datetime import datetime
|
||||
import os, sys, locale, importlib
|
||||
|
||||
import logs, db, tyto, html
|
||||
|
||||
|
||||
|
@ -83,6 +84,7 @@ def create_domain(target):
|
|||
except KeyboardInterrupt:
|
||||
print('')
|
||||
logs.out("255", '', True)
|
||||
|
||||
if ask:
|
||||
if not ask.startswith(valid_url):
|
||||
logs.out("2", '"%s" -> http(s)://...'%ask, True)
|
||||
|
@ -235,6 +237,26 @@ def create_domain(target):
|
|||
tyto.set_file(db.domain_conf, False, set_f)
|
||||
|
||||
|
||||
# RSS/Atom max items
|
||||
#-------------------
|
||||
try: domain_rssitems = db.domain_rssitems
|
||||
except: domain_rssitems = "100"
|
||||
|
||||
ask = ''
|
||||
try:
|
||||
ask = input(' ├ Atom/RSS items to show ? {%s} '%domain_rssitems)
|
||||
except KeyboardInterrupt:
|
||||
print('')
|
||||
logs.out("255", '', True)
|
||||
|
||||
if ask:
|
||||
if not ask.isdigit(): logs.out("3", ask, True)
|
||||
domain_rssitems = ask
|
||||
|
||||
set_f = 'domain_rssitems = "%s"'%domain_rssitems
|
||||
tyto.set_file(db.domain_conf, False, set_f)
|
||||
|
||||
|
||||
# Get title domain
|
||||
#-----------------
|
||||
try: domain_title = db.domain_title
|
||||
|
@ -246,6 +268,7 @@ def create_domain(target):
|
|||
except KeyboardInterrupt:
|
||||
print('')
|
||||
logs.out("255", '', True)
|
||||
|
||||
if ask: domain_title = ask
|
||||
elif not domain_title: logs.out("255", '', True)
|
||||
if '"' in domain_title:
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#**********************************************************************
|
||||
|
||||
import os, sys, shutil, importlib
|
||||
from pathlib import Path
|
||||
|
||||
import logs, args, db, html, tyto, domain, stats, rss
|
||||
|
||||
#==============================#
|
||||
|
@ -160,34 +162,40 @@ def publish_template(option):
|
|||
# Option 'all' to publish again, based on DB #
|
||||
#--------------------------------------------#
|
||||
def publish_all(option):
|
||||
# Ask or show what to do
|
||||
tyto.process_all('Publish')
|
||||
|
||||
# Sort by newer articles (created by last check)
|
||||
db_articles = sorted(Path(db.articles_db).iterdir(),
|
||||
key=os.path.getmtime
|
||||
)
|
||||
|
||||
# Load domain configuration DB
|
||||
option = args.target
|
||||
found = False
|
||||
for post_db in os.listdir(db.articles_db):
|
||||
if post_db.endswith('.conf'):
|
||||
# Load DB
|
||||
post_db = '%s%s'%(db.articles_db, post_db)
|
||||
exec(open(post_db).read(),globals())
|
||||
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
|
||||
importlib.reload(db)
|
||||
for post_db in db_articles:
|
||||
if not str(post_db).endswith('.conf'): continue
|
||||
|
||||
# Load DB
|
||||
exec(open(post_db).read(),globals())
|
||||
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
|
||||
importlib.reload(db)
|
||||
|
||||
if not db.hash_wip: continue
|
||||
if option == "again" and not db.sync_srvs: continue
|
||||
if option == "newer" and not db.old_www: continue
|
||||
|
||||
print(':> [%s] - %s'%(db.title, db.post_src))
|
||||
if db.old_chk:
|
||||
logs.out("9", '', False)
|
||||
continue
|
||||
if not db.hash_wip: continue
|
||||
if option == "again" and not db.sync_srvs: continue
|
||||
if option == "newer" and not db.old_www: continue
|
||||
|
||||
print(':> [%s] - %s'%(db.title, db.post_src))
|
||||
if db.old_chk:
|
||||
logs.out("9", '', False)
|
||||
continue
|
||||
|
||||
check_to_publish('all')
|
||||
if err_pub: continue
|
||||
|
||||
found = True
|
||||
publish_article()
|
||||
|
||||
check_to_publish('all')
|
||||
if err_pub: continue
|
||||
|
||||
found = True
|
||||
publish_article()
|
||||
|
||||
if not found:
|
||||
logs.out("28", '(publish)', True)
|
||||
else:
|
||||
|
|
|
@ -58,14 +58,19 @@ def create_feed():
|
|||
reverse=True
|
||||
)
|
||||
rss_item = False
|
||||
nbr_item = 0
|
||||
# Loop published articles. Get databases of articles
|
||||
for post_db in db_articles:
|
||||
if not str(post_db).endswith('.conf'): continue
|
||||
|
||||
# Load DB
|
||||
exec(open(post_db).read(),globals())
|
||||
if not hash_www or hash_chk != hash_www: continue
|
||||
|
||||
rss_item = True
|
||||
nbr_item += 1
|
||||
if nbr_item > int(db.domain_rssitems): break
|
||||
|
||||
set_f = \
|
||||
'%s\n'%set_f + \
|
||||
'\n <item>\n' + \
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#**********************************************************************
|
||||
|
||||
import os, re, sys, shutil, importlib
|
||||
from pathlib import Path
|
||||
|
||||
import args, logs, db, tyto, html, domain, stats
|
||||
|
||||
|
||||
|
@ -79,30 +81,36 @@ def manage_wip(target):
|
|||
# Option 'all' to wip again, based on DB #
|
||||
#----------------------------------------#
|
||||
def wip_all(process):
|
||||
# Ask or show what to do
|
||||
tyto.process_all('Wip')
|
||||
|
||||
# Sort by newer articles (created by last check)
|
||||
db_articles = sorted(Path(db.articles_db).iterdir(),
|
||||
key=os.path.getmtime
|
||||
)
|
||||
|
||||
# Load domain configuration DB
|
||||
option = args.target
|
||||
found = False
|
||||
for post_db in os.listdir(db.articles_db):
|
||||
if post_db.endswith('.conf'):
|
||||
# Load DB
|
||||
post_db = '%s%s'%(db.articles_db, post_db)
|
||||
exec(open(post_db).read(),globals())
|
||||
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
|
||||
importlib.reload(db)
|
||||
|
||||
if not db.hash_wip: continue
|
||||
if option == "again" and db.old_wip: continue
|
||||
if option == "newer" and not db.old_wip: continue
|
||||
|
||||
print(':> [%s] - %s'%(db.title, db.post_src))
|
||||
if db.old_chk:
|
||||
logs.out("9", '', False)
|
||||
continue
|
||||
|
||||
found = True
|
||||
wip_article(db.post_src)
|
||||
for post_db in db_articles:
|
||||
if not str(post_db).endswith('.conf'): continue
|
||||
|
||||
# Load DB
|
||||
exec(open(post_db).read(),globals())
|
||||
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
|
||||
importlib.reload(db)
|
||||
|
||||
if not db.hash_wip: continue
|
||||
if option == "again" and db.old_wip: continue
|
||||
if option == "newer" and not db.old_wip: continue
|
||||
|
||||
print(':> [%s] - %s'%(db.title, db.post_src))
|
||||
if db.old_chk:
|
||||
logs.out("9", '', False)
|
||||
continue
|
||||
|
||||
found = True
|
||||
wip_article(db.post_src)
|
||||
|
||||
if not found: logs.out("28", '(wip)', True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue