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

done with audio

parent a53927ff
......@@ -119,7 +119,7 @@
DONE | Quit gracefully when ftp timeout error.
DONE | add entry preview / full content.
DONE | Support for video.
TODO | Support for audio.
DONE | Support for audio.
TODO | Add relevant templates for themes.
TODO | Add categories tree in entry.
TODO | Reorganize themes dependencies in setup (adding default templates, scripts, and pages to include).
......
<audio controls style="width: 100%">
{source}
Your browser does not support the audio element.
</audio>
......@@ -118,7 +118,7 @@ def export_blog(argv=list()):
if param[0] != "_": # marker to detect field names we do not want to replace
datastore.blog_configuration[param] = themes_descriptor[argv[0]][param]
theme = Theme(theme_folder)
theme = Theme(theme_folder, non_contextual_pattern_names)
# Set up of non-contextual patterns
......
......@@ -29,7 +29,10 @@ themes_descriptor = {
}
class Theme:
def __init__(self, theme_folder):
def __init__(self, theme_folder, non_contextual_pattern_names):
non_contextual_pattern_names["video"] = self.get_video
non_contextual_pattern_names["audio"] = self.get_audio
try:
self.header = PreProcessor(open(theme_folder+"chunks/header.html",'r').read())
self.footer = PreProcessor(open(theme_folder+"chunks/footer.html",'r').read())
......@@ -38,6 +41,30 @@ class Theme:
self.entry = EntryWrapper(open(theme_folder+"chunks/entry.html",'r').read(), "entry.html")
self.rss_entry = EntryWrapper(open(theme_folder+"chunks/rssEntry.html",'r').read(),"rssEntry.html")
self.audio = open(theme_folder+"chunks/audio.html",'r').read()
self.video = open(theme_folder+"chunks/video.html",'r').read()
except FileNotFoundError as e:
die(messages.file_not_found.format(str(e.filename)))
def get_media(self, media_type, argv):
source = ""
for ext in argv[1].split(','):
# Set media once, and get complete path later.
source += str("<source src=\".:GetRelativeOrigin:.{0}.{1}\" type=\""+media_type+"/{1}\">\n").format(argv[0].strip(), ext.strip())
f = {}
f["source"] = source
f["poster"] = ""
if media_type == "video":
f["poster"] = argv[2].strip()
return getattr(self, media_type).format(**f)
def get_audio(self, argv):
return self.get_media("audio", argv)
def get_video(self, argv):
return self.get_media("video", argv)
......@@ -37,29 +37,9 @@ def include_file(argv):
except FileNotFoundError:
raise PatternInvalidArgument("path", filename, messages.file_not_found.format(filename))
def video(argv):
source = ""
for ext in argv[1].split(','):
# Set media once, and get complete path later.
source += "<source src=\".:GetRelativeOrigin:.{0}.{1}\" type=\"video/{1}\">\n".format(argv[0].strip(), ext.strip())
f = {
"source" : source,
"poster" : argv[2].strip()
}
template = open('theme/chunks/video.html','r').read()
try:
return template.format(**f)
except Exception as e:
print(e, template)
return template
non_contextual_pattern_names = {
"GetVenCVersion" : get_venc_version,
"IncludeFile" : include_file,
"video" : video
"IncludeFile" : include_file
}
......@@ -208,7 +208,7 @@ class Processor():
output = self.handle_error(
messages.file_not_found.format(e.filename),
",;"+pattern+";;"+";;".join(argv)+";,",
error_origin = e.filename
error_origin = [e.filename ]
)
return str(output)
......@@ -273,7 +273,7 @@ class Processor():
to_remove = list()
for index in pre_processed.patterns_index:
current_pattern = pre_processed.sub_strings[index][2:-2].split('::')[0]
if current_pattern in ["CodeHighlight", "Latex2MathML","IncludeFile"]:
if current_pattern in ["CodeHighlight", "Latex2MathML","IncludeFile","audio","video"]:
pre_processed.keep_appart_from_markup_index.append(index)
if not current_pattern in self.blacklist:
......
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