Added directory source to database. Fix wip/publish for subfolders articles
This commit is contained in:
parent
8c313d3366
commit
06946a5c46
|
@ -63,12 +63,14 @@ def manage_check(target):
|
|||
ext_src = os.path.splitext(target)
|
||||
|
||||
# Get uri after articles/ (no starting / in value)
|
||||
global src_post_short_uri, srv_post_short_uri
|
||||
global src_post_short_uri, srv_post_short_uri, direc_src
|
||||
global srv_post_wip_uri, srv_post_www_uri
|
||||
src_post_short_uri = db.uri_file.rsplit(db.domain_articles)[1]
|
||||
srv_post_short_uri = src_post_short_uri.replace(ext_src[1], '.html')
|
||||
srv_post_wip_uri = db.srv_wip + srv_post_short_uri
|
||||
srv_post_www_uri = db.srv_www + srv_post_short_uri
|
||||
direc_src = src_post_short_uri.split("/")[-1]
|
||||
direc_src = src_post_short_uri.rsplit(direc_src)[0]
|
||||
|
||||
# Get sub_uri for HTML
|
||||
global sub_uri
|
||||
|
@ -80,11 +82,11 @@ def manage_check(target):
|
|||
# Set HTTP link for wip and www
|
||||
global http_www, http_wip
|
||||
if srv_post_short_uri.endswith('index.html'):
|
||||
http_www = "%s/"%db.domain_www_url
|
||||
http_wip = '%s/'%db.domain_wip_url
|
||||
http_www = "%s/%s"%(db.domain_www_url, direc_src)
|
||||
http_wip = '%s/%s'%(db.domain_wip_url, direc_src)
|
||||
else:
|
||||
http_www = "%s%s"%(db.domain_www_url, srv_post_short_uri)
|
||||
http_wip = '%s%s'%(db.domain_wip_url, srv_post_short_uri)
|
||||
http_www = "%s/%s"%(db.domain_www_url, srv_post_short_uri)
|
||||
http_wip = '%s/%s'%(db.domain_wip_url, srv_post_short_uri)
|
||||
|
||||
# Start checking processes
|
||||
#-------------------------
|
||||
|
@ -665,6 +667,7 @@ def create_database():
|
|||
'post_wip = "%s"\n'%srv_post_wip_uri + \
|
||||
'post_www = "%s"\n'%srv_post_www_uri + \
|
||||
'\n' + \
|
||||
'direc_src = "%s"\n'%direc_src + \
|
||||
'short_src = "%s"\n'%src_post_short_uri + \
|
||||
'short_srv = "%s"\n'%srv_post_short_uri + \
|
||||
'sub_uri = "%s"\n'%sub_uri + \
|
||||
|
|
|
@ -218,6 +218,7 @@ def create_sidebar(option):
|
|||
except:
|
||||
logs.out("1", 'Sidebar load file', True)
|
||||
|
||||
pub_opts = ('www', 'pub')
|
||||
if option == 'wip': target = db.wip_sidebar
|
||||
elif option == 'www': target = db.www_sidebar
|
||||
elif option == 'pub': target = db.www_sidebar
|
||||
|
@ -272,7 +273,7 @@ def create_sidebar(option):
|
|||
if not os.path.exists(post_wip):
|
||||
logs.out("24", 'in wip: %s'%post_wip, False)
|
||||
continue
|
||||
elif option == 'www':
|
||||
elif option in pub_opts:
|
||||
if not hash_www == hash_chk:
|
||||
logs.out("30", '%s "%s"'%(line, title), False)
|
||||
continue
|
||||
|
@ -296,12 +297,12 @@ def create_sidebar(option):
|
|||
logs.out("35", '"%s": %s'%(title, line), False)
|
||||
|
||||
# Create HTML list for this article
|
||||
link_title = '%s [@%s]'%(about, author)
|
||||
link_title = '%s [%s]'%(about, author)
|
||||
sidebar_list = sidebar_list + \
|
||||
' <li class="sidebar_item">\n' + \
|
||||
' <a class="sidebar_item_link"\n' + \
|
||||
' href="%s">\n' + \
|
||||
' title="%s">\n'%(link_title) + \
|
||||
' href="/%s"\n'%short_srv + \
|
||||
' title="%s">\n'%link_title + \
|
||||
' <h2 class="sidebar_item_title">%s</h2>\n'%title + \
|
||||
' <p class="sidebar_item_about">%s [%s] - %s</p>\n'%(
|
||||
date[0], author, about) + \
|
||||
|
@ -313,8 +314,7 @@ def create_sidebar(option):
|
|||
if not sidebar_has:
|
||||
logs.out('29', '(sidebar): %s'%db.sidebar_load, False)
|
||||
return
|
||||
# Some items, but no one is valid
|
||||
else:
|
||||
else: # Some items, but no one is valid
|
||||
logs.out('28', '(sidebar)', False)
|
||||
return
|
||||
|
||||
|
|
|
@ -81,9 +81,11 @@ def manage_publish(target):
|
|||
#
|
||||
def publish_article():
|
||||
# Copy wip page to www page
|
||||
os.makedirs('%s%s'%(db.srv_www, db.direc_src), exist_ok=True)
|
||||
shutil.copy2(db.post_wip, db.post_www)
|
||||
logs.out("33", db.post_www, False)
|
||||
|
||||
|
||||
# Copy files registred in article
|
||||
for uri in db.uris:
|
||||
f_src = '%s%s'%(db.srv_wip, uri)
|
||||
|
|
|
@ -85,10 +85,6 @@ def manage_wip(target):
|
|||
# Compare and check file
|
||||
if db.hash_wip != db.hash_chk: # Article has changed
|
||||
wip_article(db.uri_file)
|
||||
else:
|
||||
if not os.path.exists(db.post_wip):
|
||||
logs.out("24", '(wip article): %s'%db.post_wip, False)
|
||||
wip_article(db.uri_file)
|
||||
else:
|
||||
logs.out("19", db.date_wip, False)
|
||||
ask = ''
|
||||
|
@ -142,6 +138,7 @@ def wip_article(target):
|
|||
#print(html.main_page)
|
||||
|
||||
# Create wip file
|
||||
os.makedirs('%s%s'%(db.srv_wip, db.direc_src), exist_ok=True)
|
||||
tyto.set_file(db.post_wip, 'New', html.main_page)
|
||||
logs.out("33", db.post_wip, False)
|
||||
|
||||
|
|
Loading…
Reference in New Issue