diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py
index a696173..4c126c9 100644
--- a/src/var/lib/tyto/program/check.py
+++ b/src/var/lib/tyto/program/check.py
@@ -597,7 +597,7 @@ def check_files(line, ln, stats_files_uniq):
log.append_f(post_logs,msg_log,1)
Post_Err = True
else:
- file_uri = '/%s'%(file_uri)
+ file_uri = '/%s'%file_uri
# Current or custom URI
else:
@@ -632,7 +632,7 @@ def check_images(line, ln, stats_images_uniq):
# Create variable array
image_nbr = 'image_%s'%stats_images_uniq
- image_name = line.split('image:')[1].lstrip()
+ image_name = line.split('image:')[1].lstrip().rsplit(' ')[0]
image_uri = headers.rsplit('\n')[ln].lstrip()
image_alt = headers.rsplit('\n')[ln+1].lstrip()
@@ -657,19 +657,19 @@ def check_images(line, ln, stats_images_uniq):
# Check value in article
image_page = '_image:%s'%image_name
- if not image_page in article.rsplit('\n'):
+ if not image_page in article:
msg_log = 'Unused "%s" for marker "image:" in article"'%image_page
- log.append_f(post_logs,msg_log,1)
+ log.append_f(post_logs, msg_log, 1)
Post_Err = True
# Check URI value (exists and where)
# Set HTML value in DB
if image_uri.startswith('@'):
image_uri = image_uri.replace('@','')
- gen_image = '%s%s'%(domain.domain_images,image_uri)
+ gen_image = '%s%s'%(domain.domain_images, image_uri)
if not os.path.exists(gen_image):
msg_log = 'Unused file for marker "imagee:" in %s'%gen_image
- log.append_f(post_logs,msg_log,1)
+ log.append_f(post_logs, msg_log, 1)
Post_Err = True
else:
image_uri = '/images/%s'%image_uri
@@ -677,20 +677,20 @@ def check_images(line, ln, stats_images_uniq):
# From Root articles (www/ in web)
elif image_uri.startswith('/'):
image_uri = image_uri[1:len(image_uri)] # No need first / to check
- usr_file = '%s%s'%(domain.domain_articles,image_uri)
+ usr_file = '%s%s'%(domain.domain_articles, image_uri)
if not os.path.exists(usr_file):
msg_log = 'Unused file for marker "image:" in %s'%usr_file
- log.append_f(post_logs,msg_log,1)
+ log.append_f(post_logs, msg_log, 1)
Post_Err = True
else:
- image_uri = '/%s'%(image_uri)
+ image_uri = '/%s'%image_uri
# Current or custom URI
else:
usr_file = '%s%s'%(domain.domain_articles,image_uri)
if not os.path.exists(usr_file):
msg_log = 'Unused file for marker "file:" in %s'%usr_file
- log.append_f(post_logs,msg_log,1)
+ log.append_f(post_logs, msg_log, 1)
Post_Err = True
if Post_Err: return
diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py
index bfbd6e9..9c82352 100644
--- a/src/var/lib/tyto/program/wip.py
+++ b/src/var/lib/tyto/program/wip.py
@@ -94,13 +94,15 @@ def manage_wip(file_post, Force):
wip_begin_markers(wip_html.rsplit('\n'))
wip_titles( wip_html.rsplit('\n'))
wip_words_markers(wip_html)
- wip_files_links(wip_html)
- if anchors > 0: wip_anchors( wip_html)
- if abbrs_u > 0: wip_abbrs( wip_html)
+
+ if files_u > 0: wip_files_links(wip_html)
+ if images_u > 0: wip_images( wip_html)
+ if anchors > 0: wip_anchors( wip_html)
+ if abbrs_u > 0: wip_abbrs( wip_html)
# After all, convert protected contents
- if links_u > 0: wip_links( wip_html)
- if quotes > 0: wip_quotes( wip_html.rsplit('\n'))
+ if links_u > 0: wip_links( wip_html)
+ if quotes > 0: wip_quotes( wip_html.rsplit('\n'))
# Get Legacy contents from base64 markers
convert_all_b64(wip_html.rsplit('\n'))
@@ -108,8 +110,8 @@ def manage_wip(file_post, Force):
print('> Article HTML:')
print(wip_html)
- print('> Article with Tabs:')
- tab_article(wip_html.rsplit('\n'))
+ #print('> Article with Tabs:')
+ #tab_article(wip_html.rsplit('\n'))
@@ -440,9 +442,10 @@ def quote_data(line):
return line.split(' ', 1)[1].lstrip()
-#
-# Convert files_links
-#
+#=========================#
+# Convert files_links #
+# from header "file: xxx" # #
+#-------------------------#
def wip_files_links(article):
global wip_html
@@ -463,6 +466,91 @@ def wip_files_links(article):
wip_html = article
+#==========================#
+# Convert images #
+# from header "image: xxx" #
+# Get parameters from line # #
+#--------------------------#
+def wip_images(article):
+ global wip_html
+
+ wip_html = ''
+ image_fmt = ''
+ img_style = '%s' # %(wh_style) style="..." if width and/or height
+
+ all_vars = set(globals())
+
+ for var in all_vars:
+ if var.startswith('image_'):
+ image = globals()[var]
+
+ # Search in article lines for _image:
+ for line in article.rsplit('\n'):
+ if not line.startswith('_image:'):
+ if wip_html: wip_html = '%s\n%s'%(wip_html, line)
+ else : wip_html = line
+
+ elif line.startswith('_image:%s'%image[0]):
+ width = height = set_css = target = ''
+ image_html = ''
+ wh_style = '' # width and/or height parameters
+
+ # Get parameters and set values for this marker
+ image_params = (line.rsplit(' '))
+ for param in image_params:
+ # CSS
+ if param.startswith('c='):
+ set_css = param.rsplit('=')[1]
+
+ # Width
+ elif param.startswith('w='):
+ width = param.rsplit('=')[1]
+ if not width: width = ''
+ elif width.isdigit():
+ width = 'width:%spx;'%width
+ else:
+ wspl = re.match(r"([0-9]+)([a-z]+)",width,re.I).groups()
+ width = 'width:%s;'%width
+
+ # Height
+ elif param.startswith('h='):
+ height = param.rsplit('=')[1]
+ if not height: height = ''
+ elif height.isdigit():
+ height = 'height:%spx;'%height
+ else:
+ hspl = re.match(r"([0-9]+)([a-z]+)",height,re.I).groups()
+ height = 'height:%s;'%height
+
+ # Target
+ elif param.startswith('t='):
+ target = param.rsplit('=')[1]
+ if not target: target = image[1]
+
+ # Check values and construct HTML
+ if not set_css: set_css = domain.domain_css
+ if width and height: wh_style = 'style="%s%s" '%(width,height)
+ elif width : wh_style = 'style="%s" '%width
+ elif height : wh_style = 'style="%s" '%height
+
+ image_html = image_fmt%(set_css,
+ image[2], image[2],
+ img_style%wh_style,
+ image[1]
+ )
+
+ # Create Target link if t=
+ if target:
+ line = '%s'%(
+ set_css, target, image_html)
+
+ else:
+ line = image_html
+
+ if wip_html: wip_html = '%s\n%s'%(wip_html, line)
+ else : wip_html = line
+
+
#=========================#
# Done when command check #
# - convert_bcodes() #