diff options
Diffstat (limited to 'app/templates/editor.html')
-rw-r--r-- | app/templates/editor.html | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/app/templates/editor.html b/app/templates/editor.html new file mode 100644 index 0000000..217eefe --- /dev/null +++ b/app/templates/editor.html @@ -0,0 +1,91 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:py="http://genshi.edgewall.org/"> +<head> + <meta charset="UTF-8" /> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> + <title>Editor</title> + <link rel="stylesheet" href="/static/css/main.css" type="text/css" /> + <link rel="stylesheet" href="/static/css/sugar-theme/jquery-ui-1.8.16.sugar.css" /> + <script src="/static/js/jquery-1.6.2.js" type="text/javascript"></script> + <script src="/static/js/jquery-ui-1.8.16.sugar.min.js" type="text/javascript"></script> + <script src="/static/js/websdk-1.js" type="text/javascript"></script> +<!-- <script src="js/jquery-plugins/json.js" type="text/javascript"></script> + <script src="js/jquery-plugins/jquery.hotkeys-0.7.8.js" type="text/javascript"></script> + <script src="js/jquery-plugins/jquery.intercept.js" type="text/javascript"></script> --> +</head> +<body> +<script src="/static/js/ace/ace-uncompressed.js" type="text/javascript" charset="utf-8"></script> +<script src="/static/js/ace/theme-twilight.js" type="text/javascript" charset="utf-8"></script> +<script py:if="mode" src="/static/js/ace/mode-${mode}.js" type="text/javascript" charset="utf-8"></script> +<pre id="editor">$content</pre> +<div id="editor-sidebar" class="bling"> +<div class="file"> + <img src="/static/icons/${icon}" /><br/> + ${absdir}/<br/> + <strong>${basename}</strong><br/> +</div> +<div id="result"></div> +<hr /> +<form id="saveform" action="/save" method="post"> +<input type="hidden" name="filename" id="filename" value="$filename" /> +<input type="hidden" name="directory" id="directory" value="$directory" /> +<input type="hidden" name="content" id="content" value="ñññ" /> +<!--input type="button" class="btn" value="Browse" onclick='location.href="/files/$directory"' /--> +<br/> +<input type="submit" value="Save file" /><br/> +<input type="button" class="btn" value="Delete file" onclick='location.href="/delete/${filename}"' /> +<!-- save a magic cookie for security here TODO --> +<input type="button" class="btn" value="Return" onclick='location.href="/help"' /> +<!--input type="button" class="btn" value="edit wysiwyg" onclick='top.location.href=top.location.href+"&editor=wysiwyg"' /--> +</form> +</div> +<script> + /* attach a submit handler to the form */ + $("#saveform").submit(function(event) { + + /* stop form from submitting normally */ + event.preventDefault(); + + /* get some values from elements on the page: */ + var form = $( this ), + cont = form.find( 'input[name="content"]' ).val(), + file = form.find( 'input[name="filename"]' ).val(), + dir = form.find( 'input[name="directory"]' ).val(), + url = form.attr( 'action' ); + + /* Send the data using post and put the results in a div */ + $.post( url, { content: cont, filename: file, directory: dir }, + function( data ) { + // var content = $( data ).find( '#content' ); + $( "#result" ).empty().append( data ); + $( "#result" ).show().fadeOut(5000); + } + ); + }); + +document.ready = function() { + var aceEditor = ace.edit("editor"); + aceEditor.setTheme("ace/theme/twilight"); + document.getElementById('editor').style.fontSize='14px'; + aceEditor.getSession().setUseSoftTabs(true); + // we can assume we're on unix + aceEditor.getSession().setNewLineMode("unix"); + + if ("${mode}"!="") { + var thisMode = require("ace/mode/${mode}").Mode; + aceEditor.getSession().setMode(new thisMode()); + } + + function dispatch() { + var c = $('#content'); + c.val(aceEditor.getSession().getValue()); + } + dispatch() + + aceEditor.getSession().on('change', dispatch); + $('.bling').slideDown("slow"); +}; +</script> +</body> +</html> |