Commit ae96abed authored by Denis Salem's avatar Denis Salem
Browse files

Fix pattern processing within included files

parent 234bf8f6
......@@ -160,6 +160,7 @@ cd # version 1.0.0 Last minute edition :p
DONE | Semantic-web features.
DONE | Theme must have it's own yaml configuration.
DONE | Reorganize themes dependencies in setup.
DONE | Fix pattern processing within included file.
TODO | Fix Tessellation CSS
WIP | Add relevant templates for themes.
WIP | Client-side search engine.
......
......@@ -26,6 +26,25 @@ h1
math
{display:block;}
.venc_info_box, .venc_warning_box {
background-color: #91A8D0;
color: white;
display: block;
padding: 1em;
padding-left: 26px;
margin-top: 1em;
margin-bottom: 1em;
font-style: italic;
background-image: url('VenC_info_icon1.png');
background-repeat: no-repeat;
background-position: center left;
}
.venc_warning_box {
background-image: url('VenC_warning_icon1.png');
background-color: #F7CAC9;
}
/***************/
/* H E A D E R */
/***************/
......
......@@ -22,10 +22,12 @@
<img id="banner" src=".:GetRelativeOrigin:..:GetBlogMetadataIfExists::header_image::{value}:." alt=".:GetBlogName:." title=".:GetBlogName:." />
</a>
</h1>
.:IfCategories::
<h2>CATEGORIES</h2>
<div id="categories">
.:TreeForBlogCategories::<ul>::<li><a href="{path}" title="{count} publications">{value}</a>::</li>::</ul>:.
</div>
:.
<h2 id="archivesHeader">ARCHIVES</h2>
<ul id="archives">.:ForBlogDates::<li><a href="{path}" title="{count} publications">{value}</a></li>:: :.</ul>
<div id="__VENC_LOADING__"></div>
......
......@@ -3,5 +3,6 @@ info:
override:
columns: 1
nsfw_image: 'VenC-nsfw.png'
dependencies: ['VenC-Infinite-Scroll-1.1.0.js']
dependencies: ['VenC-Infinite-Scroll-1.1.0.js', 'VenC_nsfw.png', 'VenC_info_icon1.png', 'VenC_warning_icon1.png']
......@@ -30,7 +30,6 @@ blog_configuration = get_blog_configuration()
class VenCServer(http.server.CGIHTTPRequestHandler):
def __init__(self, request, client_address, server):
print(client_address)
super().__init__(request, client_address, server)
def do_GET(self):
......
......@@ -181,7 +181,17 @@ class DataStore:
"count": node.count,
"weight": node.weight
})
def if_categories(self, argv):
if self.entries_per_categories != []:
return argv[0]
else:
try:
return argv[1]
except:
return ''
def root_site_to_jsonld(self):
self.root_as_jsonld = {
"@context": "http://schema.org",
......
......@@ -77,7 +77,7 @@ def get_embed_content(providers, argv):
def get_venc_version(argv):
return venc_version
""" Need to handle missing args in case of unknown number of args """
def set_color(argv):
return "<span style=\"color: "+('::'.join(argv[1:]))+";\">"+argv[0]+"</span>"
......
......@@ -64,6 +64,7 @@ class PatternsMap():
"Chapters" : datastore.get_chapters
},
"extra": {
"IfCategories": datastore.if_categories,
"GetEmbedContent": datastore.wrapper_embed_content,
"GetGenerationTimestamp": datastore.get_generation_timestamp,
"CodeHighlight" : code_highlight.highlight,
......
......@@ -159,12 +159,15 @@ class ProcessedString():
self.string = string
self.ressource = ressource
self.process_escapes = process_escapes
self.keep_appart_from_markup_indexes = list()
self.keep_appart_from_markup_inc = 0
self.bop, self.bcp = [], []
self.backup = None
def do_again(self):
self.__init__(self.string, self.ressource, self.process_escapes)
def restore(self):
self.open_pattern_pos, self.close_pattern_pos, self.len_open_pattern_pos, self.len_close_pattern_pos, self.string = self.backup
self.backup = None
......@@ -230,11 +233,14 @@ class Processor():
self.ressource = ''
self.blacklist = []
self.keep_appart_from_markup = []
self.include_file_called = False
# Run any pattern and catch exception nicely
def run_pattern(self, pattern, argv):
try: # Should be refactored, Create a base PatternException
output = self.functions[pattern](argv)
if pattern == "IncludeFile":
self.include_file_called = True
except KeyError as e:
output = self.handle_error(
......@@ -327,6 +333,7 @@ class Processor():
self.dictionary[symbol] = value
def process(self, pre_processed, escape=False, safe_process=False):
extra_processing_required = []
op, cp, lo, lc, string = pre_processed.open_pattern_pos, pre_processed.close_pattern_pos, pre_processed.len_open_pattern_pos, pre_processed.len_close_pattern_pos, pre_processed.string
if safe_process and pre_processed.backup == None:
pre_processed.backup = (list(op), list(cp), lo, lc, str(pre_processed.string))
......@@ -363,6 +370,9 @@ class Processor():
self.run_pattern(current_pattern, fields[1:]),
escape
)
if self.include_file_called:
extra_processing_required.append(pre_processed.keep_appart_from_markup_indexes[-1])
self.include_file_called = False
elif current_pattern == "SetColor":
new_chunk = pre_processed.keep_appart_from_markup_indexes_append(
......@@ -401,3 +411,9 @@ class Processor():
pre_processed.len_open_pattern_pos, pre_processed.len_close_pattern_pos, pre_processed.open_pattern_pos, pre_processed.close_pattern_pos = lo, lc, op, cp
pre_processed.string = string
self.process(pre_processed, escape, safe_process)
for extra in extra_processing_required:
index, paragraphe, new_chunk = extra
extra_pre_processed = ProcessedString(new_chunk, pre_processed.ressource, pre_processed.process_escapes)
self.process(extra_pre_processed, escape, safe_process)
pre_processed.keep_appart_from_markup_indexes[index] = (index, paragraphe, extra_pre_processed.string)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment