form: rss items max used with feed file creation. wip/publish: keep modification time files (for RSS)

This commit is contained in:
Cyrille L 2023-03-17 16:29:40 +01:00
parent eda5d7f6fc
commit b0d409f849
5 changed files with 88 additions and 43 deletions

View File

@ -99,6 +99,7 @@ domain_values = \
'www_footer', 'www_footer',
'www_rss', 'www_rss',
'domain_rss', 'domain_rss',
'domain_rssitems',
'domain_footer_about', 'domain_footer_about',
'domain_active', 'domain_active',
) )
@ -166,13 +167,13 @@ else:
# Conditions from command line # # Conditions from command line #
# Get some post settings fom uri # # Get some post settings fom uri #
#--------------------------------# #--------------------------------#
# Domain must be valid
domain.domain_needed()
if args.target \ if args.target \
and args.action in args.pass_db \ and args.action in args.pass_db \
and not args.target in args.pass_targets: and not args.target in args.pass_targets:
# Domain must be valid
domain.domain_needed()
uri_file = '%s/%s'%(in_dir, args.target) uri_file = '%s/%s'%(in_dir, args.target)
uri_id = tyto.get_filesum(uri_file, False) uri_id = tyto.get_filesum(uri_file, False)

View File

@ -19,6 +19,7 @@
from datetime import datetime from datetime import datetime
import os, sys, locale, importlib import os, sys, locale, importlib
import logs, db, tyto, html import logs, db, tyto, html
@ -83,6 +84,7 @@ def create_domain(target):
except KeyboardInterrupt: except KeyboardInterrupt:
print('') print('')
logs.out("255", '', True) logs.out("255", '', True)
if ask: if ask:
if not ask.startswith(valid_url): if not ask.startswith(valid_url):
logs.out("2", '"%s" -> http(s)://...'%ask, True) 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) 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 # Get title domain
#----------------- #-----------------
try: domain_title = db.domain_title try: domain_title = db.domain_title
@ -246,6 +268,7 @@ def create_domain(target):
except KeyboardInterrupt: except KeyboardInterrupt:
print('') print('')
logs.out("255", '', True) logs.out("255", '', True)
if ask: domain_title = ask if ask: domain_title = ask
elif not domain_title: logs.out("255", '', True) elif not domain_title: logs.out("255", '', True)
if '"' in domain_title: if '"' in domain_title:

View File

@ -18,6 +18,8 @@
#********************************************************************** #**********************************************************************
import os, sys, shutil, importlib import os, sys, shutil, importlib
from pathlib import Path
import logs, args, db, html, tyto, domain, stats, rss import logs, args, db, html, tyto, domain, stats, rss
#==============================# #==============================#
@ -160,15 +162,21 @@ def publish_template(option):
# Option 'all' to publish again, based on DB # # Option 'all' to publish again, based on DB #
#--------------------------------------------# #--------------------------------------------#
def publish_all(option): def publish_all(option):
# Ask or show what to do
tyto.process_all('Publish') 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 # Load domain configuration DB
option = args.target option = args.target
found = False found = False
for post_db in os.listdir(db.articles_db): for post_db in db_articles:
if post_db.endswith('.conf'): if not str(post_db).endswith('.conf'): continue
# Load DB # Load DB
post_db = '%s%s'%(db.articles_db, post_db)
exec(open(post_db).read(),globals()) exec(open(post_db).read(),globals())
args.target = post_src.rsplit('%s/'%db.in_dir)[1] args.target = post_src.rsplit('%s/'%db.in_dir)[1]
importlib.reload(db) importlib.reload(db)

View File

@ -58,14 +58,19 @@ def create_feed():
reverse=True reverse=True
) )
rss_item = False rss_item = False
nbr_item = 0
# Loop published articles. Get databases of articles # Loop published articles. Get databases of articles
for post_db in db_articles: for post_db in db_articles:
if not str(post_db).endswith('.conf'): continue if not str(post_db).endswith('.conf'): continue
# Load DB # Load DB
exec(open(post_db).read(),globals()) exec(open(post_db).read(),globals())
if not hash_www or hash_chk != hash_www: continue if not hash_www or hash_chk != hash_www: continue
rss_item = True rss_item = True
nbr_item += 1
if nbr_item > int(db.domain_rssitems): break
set_f = \ set_f = \
'%s\n'%set_f + \ '%s\n'%set_f + \
'\n <item>\n' + \ '\n <item>\n' + \

View File

@ -18,6 +18,8 @@
#********************************************************************** #**********************************************************************
import os, re, sys, shutil, importlib import os, re, sys, shutil, importlib
from pathlib import Path
import args, logs, db, tyto, html, domain, stats import args, logs, db, tyto, html, domain, stats
@ -79,15 +81,21 @@ def manage_wip(target):
# Option 'all' to wip again, based on DB # # Option 'all' to wip again, based on DB #
#----------------------------------------# #----------------------------------------#
def wip_all(process): def wip_all(process):
# Ask or show what to do
tyto.process_all('Wip') 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 # Load domain configuration DB
option = args.target option = args.target
found = False found = False
for post_db in os.listdir(db.articles_db): for post_db in db_articles:
if post_db.endswith('.conf'): if not str(post_db).endswith('.conf'): continue
# Load DB # Load DB
post_db = '%s%s'%(db.articles_db, post_db)
exec(open(post_db).read(),globals()) exec(open(post_db).read(),globals())
args.target = post_src.rsplit('%s/'%db.in_dir)[1] args.target = post_src.rsplit('%s/'%db.in_dir)[1]
importlib.reload(db) importlib.reload(db)