From c91e6160feda360c17797d11124a1ae555605ee3 Mon Sep 17 00:00:00 2001 From: ilvalle Date: Thu, 17 Oct 2013 15:25:12 +0200 Subject: [PATCH 1/4] initial editor cleanup and html fix --- applications/admin/models/0.py | 20 ----- .../admin/views/default.mobile/edit.html | 11 +-- .../admin/views/default/amy_ajax.html | 77 ------------------- applications/admin/views/default/edit_js.html | 8 +- .../admin/views/default/editor_settings.html | 27 ++++--- 5 files changed, 21 insertions(+), 122 deletions(-) delete mode 100644 applications/admin/views/default/amy_ajax.html diff --git a/applications/admin/models/0.py b/applications/admin/models/0.py index e91ea5cd..a6cc1940 100644 --- a/applications/admin/models/0.py +++ b/applications/admin/models/0.py @@ -8,26 +8,6 @@ WEB2PY_VERSION_URL = WEB2PY_URL + '/examples/default/version' # the user-interface feature that allows you to edit files in your web # browser. -## Default editor (to change editor you need web2py.admin.editors.zip) -## old editors like 'ace' or 'edit_area' or 'amy' are no longer supported -TEXT_EDITOR = 'codemirror' - -## Editor Color scheme (only for ace) -TEXT_EDITOR_THEME = ( - "chrome", "clouds", "clouds_midnight", "cobalt", "crimson_editor", "dawn", - "dreamweaver", "eclipse", "idle_fingers", "kr_theme", "merbivore", - "merbivore_soft", "monokai", "mono_industrial", "pastel_on_dark", - "solarized_dark", "solarized_light", "textmate", "tomorrow", - "tomorrow_night", "tomorrow_night_blue", "tomorrow_night_bright", - "tomorrow_night_eighties", "twilight", "vibrant_ink")[0] - -## Editor Keyboard bindings (only for ace and codemirror) -TEXT_EDITOR_KEYBINDING = '' # 'emacs' or 'vi' - -### edit_area only -# The default font size, measured in 'points'. The value must be an integer > 0 -FONT_SIZE = 10 - # Displays the editor in full screen mode. The value must be 'true' or 'false' FULL_SCREEN = 'false' diff --git a/applications/admin/views/default.mobile/edit.html b/applications/admin/views/default.mobile/edit.html index c31bb0f9..58e5eeb0 100644 --- a/applications/admin/views/default.mobile/edit.html +++ b/applications/admin/views/default.mobile/edit.html @@ -5,11 +5,8 @@ return XML('
  • %s %s
  • ' % (combo, description)) }} -{{if TEXT_EDITOR == 'amy':}} -{{include 'default/amy_ajax.html'}} -{{else:}} -{{pass}} + {{block sectionclass}}edit {{filename}}{{end}} @@ -41,11 +38,7 @@ jQuery(document).ready(function(){ {{=T('Saved file hash:')}} {{=T('Last saved on:')}} - {{if TEXT_EDITOR=='amy':}} - - {{else:}} - {{pass}}
    diff --git a/applications/admin/views/default/amy_ajax.html b/applications/admin/views/default/amy_ajax.html deleted file mode 100644 index 718d27ed..00000000 --- a/applications/admin/views/default/amy_ajax.html +++ /dev/null @@ -1,77 +0,0 @@ - - - -{{if request.args[1]=="views":}} - -{{else:}} - -{{pass}} - - - - diff --git a/applications/admin/views/default/edit_js.html b/applications/admin/views/default/edit_js.html index 3239d930..7562d108 100644 --- a/applications/admin/views/default/edit_js.html +++ b/applications/admin/views/default/edit_js.html @@ -137,7 +137,7 @@
    - {{if TEXT_EDITOR == 'codemirror' and filetype=='html':}} + {{if filetype=='html':}}

    {{=T('Key bindings for ZenCoding Plugin')}}

      {{=shortcut('Ctrl+S', T('Save via Ajax'))}} @@ -150,15 +150,15 @@ {{=shortcut('Shift-Ctrl-R / Shift-Cmd-Option-F', T('Replace All'))}} {{=shortcut('Tab', T('Expand Abbreviation'))}}
    - {{elif TEXT_EDITOR == 'codemirror':}} + {{else:}}

    {{=T("Key bindings")}}

      {{=shortcut('Ctrl+S', T('Save via Ajax'))}} {{=shortcut('Ctrl+F11', T('Toggle Fullscreen'))}} {{=shortcut('Shift+Esc', T('Exit Fullscreen'))}} {{if filetype=='python':}} - {{=shortcut('Ctrl-Space', T('Autocomplete Python Code'))}} - {{pass}} + {{=shortcut('Ctrl-Space', T('Autocomplete Python Code'))}} + {{pass}} {{=shortcut('Ctrl-F / Cmd-F', T('Start searching'))}} {{=shortcut('Ctrl-G / Cmd-G', T('Find Next'))}} {{=shortcut('Shift-Ctrl-G / Shift-Cmd-G', T('Find Previous'))}} diff --git a/applications/admin/views/default/editor_settings.html b/applications/admin/views/default/editor_settings.html index 3dda4bbe..7f35fd87 100644 --- a/applications/admin/views/default/editor_settings.html +++ b/applications/admin/views/default/editor_settings.html @@ -9,18 +9,21 @@ {{editors = ['default', 'vim', 'emacs']}} {{closetag = ['true', 'false']}}
      -
      - -
      {{=SELECT(themes, value=editor_settings['theme'], _name="theme" )}}
      - -
      {{=SELECT(editors, value=editor_settings['editor'], _name="editor" )}}
      - -
      {{=SELECT(closetag, value=editor_settings['closetag'], _name="closetag" )}}
      -
      -
      -
      -
      - +
      + +
      {{=SELECT(themes, value=editor_settings['theme'], _name="theme" )}}
      +
      +
      + +
      {{=SELECT(editors, value=editor_settings['editor'], _name="editor" )}}
      +
      +
      + +
      {{=SELECT(closetag, value=editor_settings['closetag'], _name="closetag" )}}
      +
      +
      +
      +
      - - - - -{{block sectionclass}}edit {{filename}}{{end}} - -{{if functions:}} -

      - - {{=B(T('exposes:'))}}{{=XML(', '.join([A(f,_href=URL(a=app,c=controller,f=f)).xml() for f in functions]))}} - - {{if editviewlinks:}}
      - {{=B(T('edit views:'))}} - {{=XML(', '.join([v.xml() for v in editviewlinks]))}} - {{pass}} -

      + +{{cm=URL('static%s' % (response.static_version and '/_' + response.static_version or ''),'codemirror')}} + + + + + +{{if editor_settings['editor'] != 'default':}}{{pass}} + + + + + + + + + + + + + + + + + + + + +
      {{=XML(plain_html)}}
      From f4fc9875971272564e5c8e91ac0e1d731005a2e0 Mon Sep 17 00:00:00 2001 From: ilvalle Date: Thu, 17 Oct 2013 16:20:06 +0200 Subject: [PATCH 3/4] editor cleanup (second pass) --- applications/admin/controllers/default.py | 11 +-- applications/admin/models/0.py | 16 ---- .../admin/views/default.mobile/amy_ajax.html | 77 ------------------- 3 files changed, 1 insertion(+), 103 deletions(-) delete mode 100644 applications/admin/views/default.mobile/amy_ajax.html diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 64d3aec5..5963d260 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -571,16 +571,7 @@ def edit(): if not(request.ajax) and not(is_mobile): # return the scaffolding, the rest will be through ajax requests response.title = T('Editing %s') % app - editarea_preferences = {} - editarea_preferences['FONT_SIZE'] = '10' - editarea_preferences['FULL_SCREEN'] = 'false' - editarea_preferences['ALLOW_TOGGLE'] = 'true' - editarea_preferences['REPLACE_TAB_BY_SPACES'] = '4' - editarea_preferences['DISPLAY'] = 'onload' - for key in editarea_preferences: - if key in globals(): - editarea_preferences[key] = globals()[key] - return response.render ('default/edit.html', dict(app=request.args[0], editor_settings=preferences, editarea_preferences=editarea_preferences)) + return response.render ('default/edit.html', dict(app=request.args[0], editor_settings=preferences)) # show settings tab and save prefernces if 'settings' in request.vars: diff --git a/applications/admin/models/0.py b/applications/admin/models/0.py index a6cc1940..669ffd27 100644 --- a/applications/admin/models/0.py +++ b/applications/admin/models/0.py @@ -8,22 +8,6 @@ WEB2PY_VERSION_URL = WEB2PY_URL + '/examples/default/version' # the user-interface feature that allows you to edit files in your web # browser. -# Displays the editor in full screen mode. The value must be 'true' or 'false' -FULL_SCREEN = 'false' - -# Display a check box under the editor to allow the user to switch -# between the editor and a simple -# HTML text area. The value must be 'true' or 'false' -ALLOW_TOGGLE = 'true' - -# Replaces tab characters with space characters. -# The value can be 'false' (meaning that tabs are not replaced), -# or an integer > 0 that specifies the number of spaces to replace a tab with. -REPLACE_TAB_BY_SPACES = 4 - -# Toggle on/off the code editor instead of textarea on startup -DISPLAY = "onload" or "later" - # if demo mode is True then admin works readonly and does not require login DEMO_MODE = False diff --git a/applications/admin/views/default.mobile/amy_ajax.html b/applications/admin/views/default.mobile/amy_ajax.html deleted file mode 100644 index 718d27ed..00000000 --- a/applications/admin/views/default.mobile/amy_ajax.html +++ /dev/null @@ -1,77 +0,0 @@ - - - -{{if request.args[1]=="views":}} - -{{else:}} - -{{pass}} - - - - From 037b499cb22b09e07c02134f73f19da2d36aefcf Mon Sep 17 00:00:00 2001 From: ilvalle Date: Thu, 17 Oct 2013 16:32:22 +0200 Subject: [PATCH 4/4] correct editor's mode when editing javascript --- applications/admin/controllers/default.py | 2 +- applications/admin/views/default/edit_js.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 5963d260..51faf83a 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -606,7 +606,7 @@ def edit(): elif filename[-4:] == '.css': filetype = 'css' elif filename[-3:] == '.js': - filetype = 'js' + filetype = 'javascript' else: filetype = 'html' diff --git a/applications/admin/views/default/edit_js.html b/applications/admin/views/default/edit_js.html index 7562d108..8096fbd9 100644 --- a/applications/admin/views/default/edit_js.html +++ b/applications/admin/views/default/edit_js.html @@ -78,7 +78,7 @@ return marker; } - {{if filetype in ('html', 'js', 'css'):}} + {{if filetype in ('html', 'javascript', 'css'):}} // must be here or break emmet/zencoding CodeMirror.defaults.extraKeys["Ctrl-S"] = function(instance) {