pandoc.cgi and hybrid editor working in oooooooo.io

master
Andre Castro 8 years ago
parent cd2c25ec84
commit 45f151af79

@ -57,7 +57,8 @@ if method == "POST":
if from_format == None: if from_format == None:
from_format = guess_format_from_filename(f.filename) from_format = guess_format_from_filename(f.filename)
tmp = NTF(delete=False) # tmp = NTF(delete=False)
tmp = open('pandoc.tmp','wb')
bytes = 0 bytes = 0
while True: while True:
data = f.file.read() data = f.file.read()
@ -76,7 +77,10 @@ if method == "POST":
print print
# p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT) # p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT)
# print p # print p
p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format, tmp.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if to_format is 'icml':
p = subprocess.Popen([PANDOC, '--from', 'docx', '--to', to_format,'-s', '/home/andre/public_html/oooooooooo.io/cgi-bin/pandoc.tmp'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
p = subprocess.Popen([PANDOC, '--from', 'docx', '--to', to_format, '/home/andre/public_html/oooooooooo.io/cgi-bin/pandoc.tmp', '--atx-headers'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate() out, err = p.communicate()
print out print out
@ -86,7 +90,7 @@ if method == "POST":
print print
print u"<span style='font-family:monospace'>An error occurred, pandoc said: {0}</span>".format(e.output).format("utf-8") print u"<span style='font-family:monospace'>An error occurred, pandoc said: {0}</span>".format(e.output).format("utf-8")
tmp.unlink(tmp.name) # tmp.unlink(tmp.name)
################################### ###################################
# FORM/TEXT INPUT # FORM/TEXT INPUT
@ -101,7 +105,11 @@ if method == "POST":
print print
# p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT) # p = subprocess.check_output('pandoc --from {0} --to {1} "{2}"'.format(ffrom, to, tmp.name), shell=True, stderr=subprocess.STDOUT)
# print p # print p
p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if to_format == 'icml':
p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format , '-s'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
p = subprocess.Popen([PANDOC, '--from', from_format, '--to', to_format, '--atx-headers' ], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate(text) out, err = p.communicate(text)
print out print out

Binary file not shown.

@ -64,7 +64,7 @@
<script src="lib/jquery.min.js"></script> <script src="lib/jquery.min.js"></script>
<script src="lib/jquery-ui/jquery-ui.min.js"></script> <script src="lib/jquery-ui/jquery-ui.min.js"></script>
<script src="/lib/ace-builds/src/ace.js" type="text/javascript" charset="utf-8"></script> <script src="lib/ace-builds/src/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/frames.js"></script> <script src="lib/frames.js"></script>
<script src="lib/dropzone/dropzone.js"></script> <script src="lib/dropzone/dropzone.js"></script>
<script src="hybrid.js"></script> <script src="hybrid.js"></script>

@ -50,7 +50,7 @@ aa_frames("#split");
var editor = ace.edit($("#editortext").get(0)); var editor = ace.edit($("#editortext").get(0));
editor.setTheme("ace/theme/chrome"); editor.setTheme("ace/theme/chrome");
editor.setHighlightActiveLine(false); editor.setHighlightActiveLine(false);
editor.setShowInvisibles(true); editor.setShowInvisibles(false);
editor.getSession().setMode("ace/mode/markdown"); editor.getSession().setMode("ace/mode/markdown");
editor.getSession().setUseWrapMode(true); editor.getSession().setUseWrapMode(true);

Loading…
Cancel
Save