Commit 78521e90 authored by Denis Salem's avatar Denis Salem
Browse files

make GetRelativeOrigin Escapable, introduce non printable char to be replaced...

make GetRelativeOrigin Escapable, introduce non printable char to be replaced by relative origin in special cases
parent 26f3f088
......@@ -8,17 +8,20 @@ title: Motifs super globaux
Ces motifs sont généralement disponibles quelque soit le contexte et
sont définis dans blog_configuration.yaml.
- .:Escape:: .:GetAuthorName:. ::EndEscape:. : Retourne le nom de l'auteur du blog.
- .:Escape:: .:GetBlogName:. ::EndEscape:.: Retourne le titre du blog.
- .:Escape:: .:GetBlogDescription:. ::EndEscape:. : Retourne la description du blog.
- .:Escape:: .:GetBlogKeywords:. ::EndEscape:. : Retourne les mots clefs décrivant le blog.
- .:Escape:: .:GetAuthorDescription:. ::EndEscape:. : Retourne la description de l'auteur du blog.
- .:Escape:: .:GetBlogLicense:. ::EndEscape:. : Retourne la licence appliquée au contenu du blog.
- .:Escape:: .:GetBlogURL:. ::EndEscape:. : Retourne l'URL du blog.
- .:Escape:: .:GetBlogLanguage:. ::EndEscape:. : Retourne le language du blog.
- .:Escape:: .:GetAuthorEmail:. ::EndEscape:. : Retourne l'adresse email de l'auteur du blog.
- .:Escape:: blablabla.:GetRelativeOrigin:. ::EndEscape:. : Retourne le chemin relatif de la racine du blog.
- .:Escape:: .:GetRelativeLocation:. ::EndEscape:. : Retourne le répertoire courant relativement à la racine du blog.
- __.:Escape:: .:GetAuthorName:. ::EndEscape:.__ : Retourne le nom de l'auteur du blog.
- __.:Escape:: .:GetBlogName:. ::EndEscape:.__ : Retourne le titre du blog.
- __.:Escape:: .:GetBlogDescription:. ::EndEscape:.__ : Retourne la description du blog.
- __.:Escape:: .:GetBlogKeywords:. ::EndEscape:.__ : Retourne les mots clefs décrivant le blog.
- __.:Escape:: .:GetAuthorDescription:. ::EndEscape:.__ : Retourne la description de l'auteur du blog.
- __.:Escape:: .:GetBlogLicense:. ::EndEscape:.__ : Retourne la licence appliquée au contenu du blog.
- __.:Escape:: .:GetBlogURL:. ::EndEscape:.__ : Retourne l'URL du blog.
- __.:Escape:: .:GetBlogLanguage:. ::EndEscape:.__ : Retourne le language du blog.
- __.:Escape:: .:GetAuthorEmail:. ::EndEscape:.__ : Retourne l'adresse email de l'auteur du blog.
- __.:Escape:: .:GetRelativeOrigin:. ::EndEscape:.__ : Retourne le chemin relatif de la racine du blog.
- __.:Escape:: .:GetRelativeLocation:. ::EndEscape:.__ : Retourne le répertoire courant relativement à la racine du blog.
.:GetRelativeOrigin:.
.:GetRelativeLocation:.
Vous pouvez également définir vos propres variables en rajoutant des
champs au fichier de configuration blog_configuration.yaml. Par exemple
......
......@@ -22,7 +22,7 @@ En outre, voilà ce que VenC propose:
- Possibilité de désactiver des fils de publications spécifique.
- Possibilité de définir des sous répertoires par type de fils de publications.
- Possibilité d'ajouter des métadonnés au blog et aux publications.
- Publication chronologique ascendante ou descendante.
- Publication trié par ordre chronologique ou par métadonné. Ordre ascendant ou descendant.
- Flux ATOM et/ou RSS pour chaque fils de publications.
- Permaliens.
- Serveur HTTP simple.
......
......@@ -191,7 +191,7 @@ class DataStore:
self.blog_archives.append({
"value":node.value,
"path": ".:GetRelativeOrigin:."+sub_folders+node.value,
"path": "\x1a"+sub_folders+node.value,
"count": node.count,
"weight": node.weight
})
......@@ -333,7 +333,7 @@ class DataStore:
"name":self.blog_configuration["author_name"]
}
blog_url = self.blog_configuration["blog_url"]
entry_url = '/'.join(entry.url.split('/')[:-1]).replace(".:GetRelativeOrigin:.", self.blog_configuration["blog_url"]+'/')
entry_url = '/'.join(entry.url.split('/')[:-1]).replace("\x1a", self.blog_configuration["blog_url"]+'/')
filename = "entry"+str(entry.id)+".jsonld"
doc = {
"@context": "http://schema.org",
......@@ -346,7 +346,7 @@ class DataStore:
"inLanguage" : self.blog_configuration["blog_language"],
"author" : authors if authors != [] else self.blog_configuration["author_name"],
"publisher" : publisher,
"url" : entry.url.replace(".:GetRelativeOrigin:.", self.blog_configuration["blog_url"]+"/"),
"url" : entry.url.replace("\x1a", self.blog_configuration["blog_url"]+"/"),
"breadcrumb" : {
"itemListElement": [{
"@type": "ListItem",
......@@ -393,7 +393,7 @@ class DataStore:
# Setup categories as jsonld if any
for category in entry.categories_leaves:
complete_path = category["path"].replace('.:GetRelativeOrigin:.','')
complete_path = category["path"].replace('\x1a','')
path = ''
for sub_path in complete_path.split('/')[:-1]:
path += sub_path+'/'
......@@ -443,7 +443,7 @@ class DataStore:
output += io.format(**{
"index": sub_chapter.index,
"title": sub_chapter.entry.title,
"path": ".:GetRelativeOrigin:."+path,
"path": "\x1a"+path,
"level": level
})
output += self.build_html_chapters(argv, sub_chapter.sub_chapters, level+1)
......@@ -633,7 +633,7 @@ class DataStore:
return self.html_blog_archives[key]
def get_root_page(self, argv):
return ".:GetRelativeOrigin:."+self.blog_configuration["path"]["index_file_name"].format(**{"page_number":''})
return "\x1a"+self.blog_configuration["path"]["index_file_name"].format(**{"page_number":''})
def build_html_categories_tree(self, opening_node, opening_branch, closing_branch, closing_node, tree):
output_string = opening_node
......
......@@ -143,7 +143,7 @@ class Entry:
sf = paths["entries_sub_folders"].format(**params)
if encoding == '':
self.sub_folder = unidecode.unidecode(sf).replace(' ','-').replace('\'','-')+'/' if sf != '' else ''
self.url = ".:GetRelativeOrigin:."+self.sub_folder
self.url = "\x1a"+self.sub_folder
if self.sub_folder == '' or paths["entry_file_name"] != "index.html":
self.url += unidecode.unidecode(
paths["entry_file_name"].format(**params)
......@@ -152,13 +152,13 @@ class Entry:
else:
try:
self.sub_folder = urllib.parse.quote(sf, encoding=encoding)+'/' if sf != '' else ''
self.url = ".:GetRelativeOrigin:."+self.sub_folder
self.url = "\x1a"+self.sub_folder
if self.sub_folder == '' or paths["entry_file_name"] != "index.html":
self.url += urllib.parse.quote(paths["entry_file_name"].format(**params), encoding=encoding)
except UnicodeEncodeError as e:
self.url = ".:GetRelativeOrigin:."+self.sub_folder+paths["entry_file_name"].format(**params)
self.url = "\x1a"+self.sub_folder+paths["entry_file_name"].format(**params)
notify("\"{0}\": ".format(sf+paths["entry_file_name"].format(**params))+str(e), color="YELLOW")
......@@ -169,7 +169,7 @@ class Entry:
for category in self.raw_categories:
category_leaf = category.split(' > ')[-1].strip()
if len(category_leaf) != 0:
category_leaf_path = ".:GetRelativeOrigin:."
category_leaf_path = "\x1a"
for sub_category in category.split(' > '):
category_leaf_path +=sub_category.strip()+'/'
......
......@@ -58,12 +58,12 @@ def build_categories_tree(entry_index, input_list, output_tree, output_leaves, m
try:
if encoding == '':
root[-1].path = ".:GetRelativeOrigin:."+unidecode.unidecode(path).replace(' ','-')
root[-1].path = "\x1a"+unidecode.unidecode(path).replace(' ','-')
else:
root[-1].path = ".:GetRelativeOrigin:."+urllib.parse.quote(path, encoding=encoding)
root[-1].path = "\x1a"+urllib.parse.quote(path, encoding=encoding)
except UnicodeEncodeError as e:
root[-1].path = ".:GetRelativeOrigin:."+path
root[-1].path = "\x1a"+path
notify("\"{0}\": ".format(root[-1].path)+str(e), color="YELLOW")
root = root[-1].childs
......
......@@ -36,7 +36,7 @@ class CodeHighlight:
def get_style_sheets(self, argv=list()):
output = str()
for filename in self._includes.keys():
output += "<link rel=\"stylesheet\" href=\".:GetRelativeOrigin:."+filename+"\" type=\"text/css\" />\n"
output += "<link rel=\"stylesheet\" href=\"\x1a"+filename+"\" type=\"text/css\" />\n"
return output
......
......@@ -105,6 +105,7 @@ class PatternsMap():
"IfInLastPage" : "if_in_last_page",
"IfInEntryID" : "if_in_entry_id",
"GetRelativeLocation" : "get_relative_location",
"GetRelativeOrigin" : "get_relative_origin",
"GetNextPage" : "get_next_page",
"GetPreviousPage" : "get_previous_page",
"ForPages" : "for_pages",
......
......@@ -404,7 +404,7 @@ class Processor():
fields = [field.strip() for field in string[vop+2:vcp].split("::") if field != '']
current_pattern = fields[0]
if (not current_pattern in ["GetRelativeOrigin","Escape"]) and (not current_pattern in self.blacklist):
if (not current_pattern == "Escape") and (not current_pattern in self.blacklist):
if current_pattern in self.keep_appart_from_markup and not no_markup:
new_chunk = pre_processed.keep_appart_from_markup_indexes_append(
True,
......@@ -439,7 +439,7 @@ class Processor():
op.pop(i)
cp.pop(j)
elif current_pattern in ["GetRelativeOrigin", "Escape"]:
elif current_pattern == "Escape":
op.pop(i)
cp.pop(j)
......
......@@ -93,6 +93,9 @@ class Thread:
# Must be called in child class
def get_relative_location(self, argv):
return self.export_path[5:]
def get_relative_origin(self, argv):
return self.relative_origin
# Must be called in child class
def organize_entries(self, entries):
......@@ -276,7 +279,7 @@ class Thread:
'w',
encoding="utf-8"
)
stream.write(output)
stream.write(output.replace("\x1a", self.relative_origin))
stream.close()
def pre_iteration(self):
......@@ -303,7 +306,7 @@ class Thread:
self.output += current_source.string
self.footer.restore()
self.write_file(self.output.replace(".:GetRelativeOrigin:.", self.relative_origin), self.page_number)
self.write_file(self.output.replace("\x1a",self.relative_origin), self.page_number)
self.page_number += 1
self.current_page = self.page_number
......@@ -364,7 +367,7 @@ class Thread:
'w',
encoding="utf-8"
)
stream.write(output.replace(".:GetRelativeOrigin:.", self.relative_origin))
stream.write(output.replace("\x1a", self.relative_origin))
stream.close()
else:
......
Supports Markdown
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