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

done with video

parent d161bc34
......@@ -3,5 +3,5 @@
<h1><a href=".:GetRelativeOrigin:.entry.:GetEntryID:..html">.:GetEntryTitle:.</a></h1>
<p>.:GetEntryDate:.</p>
</div>
.:PreviewIfInThreadElseContent:.
.:GetEntryContent:.
</div>
</div>
<footer id="__VENC_NAVIGATION__">
.:GetPreviousPage:: <a id="previous" href="{0[destinationPageUrl]} "></a>:.
<ul id="pagesList">.:ForPages::5::<li><a href="{0[pageUrl]}">{0[pageNumber]}</a></li>:: . :.</ul>
<ul id="pagesList">.:PagesList::5::<li><a href="{0[pageUrl]}">{0[pageNumber]}</a></li>:: . :.</ul>
.:GetNextPage:: <a id="next" href="{0[destinationPageUrl]} "></a>:.
</footer>
</body>
......
......@@ -118,7 +118,8 @@
DONE | Improve reStructuredText integration with VenC.
DONE | Quit gracefully when ftp timeout error.
DONE | add entry preview / full content.
TODO | Support for video.
DONE | Support for video.
TODO | 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).
......
<video controls poster="{poster}" style="width: 100%;">
{source}
Your browser does not support the video tag.
</video>
......@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with VenC. If not, see <http://www.gnu.org/licenses/>.
import os
from venc2 import venc_version
from venc2.l10n import messages
from venc2.helpers import PatternInvalidArgument
......@@ -36,9 +37,29 @@ 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
"IncludeFile" : include_file,
"video" : video
}
......@@ -204,6 +204,12 @@ class Processor():
error_origin = [".:"+pattern+"::"+"::".join(argv)+":."]
)
except FileNotFoundError as e:
output = self.handle_error(
messages.file_not_found.format(e.filename),
",;"+pattern+";;"+";;".join(argv)+";,",
error_origin = e.filename
)
return str(output)
# Print out notification to user and replace erroneous pattern
......@@ -296,14 +302,14 @@ class Processor():
elif string[i:i+2] == CLOSE_SYMBOL:
close_symbol_pos.append(i)
if len(close_symbol_pos) == len(open_symbol_pos) and len(close_symbol_pos) != 0 and len(open_symbol_pos) != 0:
if open_symbol_pos[0] < close_symbol_pos[-1]:
fields = [field for field in string[open_symbol_pos[0]+2:close_symbol_pos[-1]].split(SEPARATOR) if field != '']
if len(close_symbol_pos) <= len(open_symbol_pos) and len(close_symbol_pos) != 0 and len(open_symbol_pos) != 0:
if open_symbol_pos[-1] < close_symbol_pos[-1]:
fields = [field for field in string[open_symbol_pos[-1]+2:close_symbol_pos[-1]].split(SEPARATOR) if field != '']
if not fields[0] in self.blacklist:
output = self.run_pattern(fields[0], fields[1:])
if escape:
return self.process(
string[:open_symbol_pos[0]]+
string[:open_symbol_pos[-1]]+
cgi.escape(output).encode(
'ascii',
'xmlcharrefreplace'
......@@ -316,7 +322,7 @@ class Processor():
else:
return self.process(
string[:open_symbol_pos[0]]+
string[:open_symbol_pos[-1]]+
str(output)+
string[close_symbol_pos[-1]+2:],
escape
......
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