1 | {{def shortcut(combo, description): |
---|
2 | return XML('<li><span class="teletype-text">%s</span><span>%s</span></li>' % (combo, description)) |
---|
3 | }} |
---|
4 | |
---|
5 | <form action="{{=URL('edit', args=filename)}}" method="post" name="editform" id="editform" class="form-inline row-fluid"> |
---|
6 | <div class="span12 well well-small"> |
---|
7 | <label class="">{{=T('Save file:')}}</label> |
---|
8 | <a value="save" title="{{=T('Save file: %s', filename)}}" href="#" name="save" onclick="return doClickSave();" class="icon saveicon" style="background-image: -webkit-linear-gradient(top,white,#E6E6E6);">{{=IMG(_src=URL('static', 'images/save_icon.png'), _alt=T('Save'))}}</a> |
---|
9 | <label class="">{{=T('Saved file hash:')}}</label> |
---|
10 | <input type="input" name="file_hash" value="{{=file_hash}}" class="input-long uneditable-input" readonly="readonly"/> |
---|
11 | <label>{{=T('Last saved on:')}}</label> |
---|
12 | <input type="input" name="saved_on" value="{{=saved_on}}" class="input-normal uneditable-input" readonly="readonly"/> |
---|
13 | {{if filetype=='python':}} |
---|
14 | {{=A(SPAN(T('toggle breakpoint')), |
---|
15 | _value="breakpoint", _name="breakpoint", |
---|
16 | _onclick="return doToggleBreakpoint('%s','%s://%s%s',null);" % (filename, |
---|
17 | request.env['wsgi_url_scheme'], request.env['http_host'], |
---|
18 | URL(c='debug', f='toggle_breakpoint')), |
---|
19 | _class="button special btn btn-inverse")}} |
---|
20 | {{pass}} |
---|
21 | {{if view_link:}} |
---|
22 | {{=button(view_link, T('try view'))}} |
---|
23 | {{pass}} |
---|
24 | {{if functions or edit_controller:}} |
---|
25 | <p class="formfield"> |
---|
26 | {{if functions:}} |
---|
27 | <span style="text-align:left;" class="exposed"> |
---|
28 | {{=B(T('exposes:'))}} {{=XML(b', '.join([A(f,_target="_blank", _href=URL(a=app,c=controller,f=f)).xml() for f in functions]))}} |
---|
29 | </span> |
---|
30 | {{if editviewlinks:}}<br/> |
---|
31 | {{=B(T('edit views:'))}} |
---|
32 | {{=XML(b', '.join([v.xml() for v in editviewlinks]))}} |
---|
33 | {{pass}} |
---|
34 | {{pass}} |
---|
35 | {{if edit_controller:}} |
---|
36 | {{=B(T('edit controller:'))}} |
---|
37 | {{=A(request.args[2]+'.py', _class="editor_filelink", _target="_blank", _href=edit_controller)}} |
---|
38 | {{pass}} |
---|
39 | </p> |
---|
40 | {{pass}} |
---|
41 | </div> |
---|
42 | |
---|
43 | <textarea style=" height:100%; direction:ltr;" id="textarea_{{=id}}" class="input-block-level" name="data" >{{=data}}</textarea> |
---|
44 | <script> |
---|
45 | var editor = CodeMirror.fromTextArea(document.getElementById("textarea_{{=id}}"),{ |
---|
46 | {{if filetype=='html':}} |
---|
47 | mode : "text/html", |
---|
48 | profile: 'xhtml', |
---|
49 | {{else:}} |
---|
50 | mode: { name: '{{=filetype}}'{{if filetype=='python':}},version: 2,singleLineStringErrors: false, {{pass}} }, |
---|
51 | {{pass}} |
---|
52 | lineNumbers: {{=editor_settings['linenumbers']}}, |
---|
53 | indentUnit: {{=editor_settings['tabwidth']}}, |
---|
54 | indentWithTabs: {{=editor_settings['indentwithtabs']}}, |
---|
55 | tabSize: {{=editor_settings['tabwidth']}}, |
---|
56 | styleActiveLine: {{=editor_settings['highlightline']}}, |
---|
57 | autoCloseTags: {{=editor_settings['closetag']}}, |
---|
58 | theme: "{{=editor_settings['theme']}}", |
---|
59 | lineWrapping: true, |
---|
60 | foldGutter: {{=editor_settings['codefolding']}}, |
---|
61 | gutters: ["CodeMirror-linenumbers", "breakpoints", "CodeMirror-foldgutter"], |
---|
62 | keyMap: "{{=editor_settings['editor']}}", |
---|
63 | matchBrackets: true, |
---|
64 | autofocus: false, |
---|
65 | height: "350px", |
---|
66 | showTrailingSpace: true |
---|
67 | }); |
---|
68 | |
---|
69 | editor.on("gutterClick", function(cm, n, gutter) { |
---|
70 | if (gutter !== "breakpoints" ) return; |
---|
71 | var info = cm.lineInfo(n); |
---|
72 | cm.setGutterMarker(n, "breakpoints", info.gutterMarkers ? null : makeMarker()); |
---|
73 | sel = {start: n, end: n, data: ''}; |
---|
74 | doToggleBreakpoint({{=XML("'%s','%s://%s%s'" % (filename, |
---|
75 | request.env['wsgi_url_scheme'], request.env['http_host'], |
---|
76 | URL(c='debug', f='toggle_breakpoint')))}}, sel); |
---|
77 | }); |
---|
78 | function makeMarker() { |
---|
79 | var marker = document.createElement("div"); |
---|
80 | marker.style.color = "#822"; |
---|
81 | marker.innerHTML = "●"; |
---|
82 | marker.className = "breakpoint"; |
---|
83 | return marker; |
---|
84 | } |
---|
85 | |
---|
86 | {{if filetype in ('html', 'javascript', 'css'):}} |
---|
87 | // must be here or break emmet/zencoding |
---|
88 | CodeMirror.defaults.extraKeys["Ctrl-S"] = |
---|
89 | function(instance) { |
---|
90 | doClickSave();}; |
---|
91 | CodeMirror.defaults.extraKeys["Tab"] = "indentMore"; |
---|
92 | CodeMirror.defaults.extraKeys["Ctrl-F11"] = function(cm) { |
---|
93 | cm.setOption("fullScreen", !cm.getOption("fullScreen")); |
---|
94 | }, |
---|
95 | CodeMirror.defaults.extraKeys["Shift-Esc"] = function(cm) { |
---|
96 | if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); |
---|
97 | } |
---|
98 | {{pass}} |
---|
99 | {{if filetype=='python':}} |
---|
100 | // must be here or break emmet/zencoding for python |
---|
101 | CodeMirror.defaults.extraKeys["Ctrl-S"] = |
---|
102 | function(instance) { |
---|
103 | doClickSave();}; |
---|
104 | CodeMirror.defaults.extraKeys["Ctrl-Space"] = "autocomplete"; |
---|
105 | CodeMirror.defaults.extraKeys["Tab"] = "indentMore"; |
---|
106 | CodeMirror.defaults.extraKeys["Shift-Tab"] = "indentLess"; |
---|
107 | CodeMirror.defaults.extraKeys["Ctrl-F11"] = function(cm) { |
---|
108 | cm.setOption("fullScreen", !cm.getOption("fullScreen")); |
---|
109 | }, |
---|
110 | CodeMirror.defaults.extraKeys["Shift-Esc"] = function(cm) { |
---|
111 | if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false); |
---|
112 | } |
---|
113 | //for autocomplete |
---|
114 | CodeMirror.commands.autocomplete = function(cm) { |
---|
115 | CodeMirror.showHint(cm, CodeMirror.pythonHint); |
---|
116 | } |
---|
117 | {{pass}} |
---|
118 | CodeMirror.defaults.extraKeys["Ctrl-/"] = "toggleComment"; |
---|
119 | store_changes_function = function(instance, changeObj) { |
---|
120 | jQuery(instance).data('saved', false); |
---|
121 | instance.off("change", store_changes_function); |
---|
122 | } |
---|
123 | editor.on("change", store_changes_function); |
---|
124 | // save the editor as textarea data attribute |
---|
125 | jQuery("#{{=id}} textarea").data('editor', editor); |
---|
126 | var hlLine = editor.addLineClass(0, "background", "activeline"); |
---|
127 | window.mirror = editor; //backward compatibility |
---|
128 | set_font(editor, current_font_incr); |
---|
129 | doListBreakpoints({{=XML("'%s','%s://%s%s'" % (filename, |
---|
130 | request.env['wsgi_url_scheme'], request.env['http_host'], |
---|
131 | URL(c='debug', f='list_breakpoints')))}}, editor); |
---|
132 | |
---|
133 | // TODO move it in a separated file |
---|
134 | CodeMirror.defineExtension("centerOnCursor", function(limit) { |
---|
135 | var coords = this.cursorCoords(null, "local"); |
---|
136 | if (this.getScrollerElement().clientHeight === 0 && limit !== 10) { |
---|
137 | if (limit === undefined) limit = 1; |
---|
138 | else limit += 1; |
---|
139 | editor = this; |
---|
140 | setTimeout(function() {editor.centerOnCursor()}, 100); |
---|
141 | return; |
---|
142 | } |
---|
143 | clientHeight = (this.getScrollerElement().clientHeight / 2) |
---|
144 | this.scrollTo(null, (coords.top + coords.bottom)/2 - 10); |
---|
145 | }); |
---|
146 | CodeMirror.commands.save = function () { |
---|
147 | doClickSave(); |
---|
148 | } |
---|
149 | </script> |
---|
150 | |
---|
151 | <div class="editor-bar-bottom" style="margin-top:9px;"> |
---|
152 | <a class="editbutton btn" href="{{=URL('edit', args=request.args, vars={'restore':True})}}" id="restore">{{=T('restore')}}</a> |
---|
153 | {{=T('currently saved or')}} |
---|
154 | <a class="editbutton btn" href="{{=URL('edit', args=request.args, vars={'revert':True})}}" id="revert">{{=T('revert')}}</a> |
---|
155 | {{=T('to previous version.')}} |
---|
156 | </div> |
---|
157 | <br/> |
---|
158 | </form> |
---|