openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 591c81a60feb5c05cea6552780e56e80b775d59a
parent 91a3ee5805b028c234beb8902692726ab90823a9
Author: Jan Dankert <devnull@localhost>
Date:   Wed, 20 Dec 2017 01:10:19 +0100

Dem Source-Editor mit dem passenden Syntax-Hightlighting starten.

Diffstat:
modules/cms-core/action/IndexAction.class.php | 158+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/template-engine/components/html/editor/Editor.class.php | 8+++++---
modules/template-engine/components/html/editor/editor.js | 10+++++++++-
script/create-output-files.sh | 8++++++++
themes/default/templates/template/src.tpl.src.xml | 2+-
themes/default/templates/text/value.tpl.src.xml | 28+++++++++++++---------------
6 files changed, 194 insertions(+), 20 deletions(-)

diff --git a/modules/cms-core/action/IndexAction.class.php b/modules/cms-core/action/IndexAction.class.php @@ -310,9 +310,167 @@ class IndexAction extends Action // Inlining of SVG $js[] = OR_THEMES_DIR . 'default/js/svg-injector'; + // OpenRat internal JS $js[] = OR_THEMES_DIR . 'default/js/openrat'; + + // Codemirror Source Editor + $js[] = OR_MODULES_DIR . 'editor/codemirror/lib/codemirror'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/handlebars/handlebars'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/smalltalk/smalltalk'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/php/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/php/php'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/cobol/cobol'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/haskell/haskell'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/mathematica/mathematica'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/pug/pug'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/livescript/livescript'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/yaml-frontmatter/yaml-frontmatter'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/stylus/stylus'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/markdown/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/markdown/markdown'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/jsx/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/jsx/jsx'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/velocity/velocity'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/fortran/fortran'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/mirc/mirc'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/xquery/xquery'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/xquery/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/elm/elm'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/vhdl/vhdl'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/verilog/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/verilog/verilog'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/spreadsheet/spreadsheet'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/coffeescript/coffeescript'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/tiddlywiki/tiddlywiki'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/mumps/mumps'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/eiffel/eiffel'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/webidl/webidl'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/ebnf/ebnf'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/http/http'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/textile/textile'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/textile/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/r/r'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/haml/haml'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/haml/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/ecl/ecl'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/cypher/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/cypher/cypher'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/sieve/sieve'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/soy/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/soy/soy'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/pig/pig'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/apl/apl'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/crystal/crystal'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/clike/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/clike/clike'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/oz/oz'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/modelica/modelica'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/gherkin/gherkin'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/swift/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/swift/swift'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/scheme/scheme'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/idl/idl'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/yaml/yaml'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/vue/vue'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/twig/twig'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/cmake/cmake'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/asciiarmor/asciiarmor'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/pegjs/pegjs'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/solr/solr'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/tiki/tiki'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/slim/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/slim/slim'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/puppet/puppet'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/meta'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/go/go'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/commonlisp/commonlisp'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/rust/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/rust/rust'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/powershell/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/powershell/powershell'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/stex/stex'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/stex/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/q/q'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/htmlembedded/htmlembedded'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/d/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/d/d'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/protobuf/protobuf'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/mscgen/msgenny_test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/mscgen/mscgen_test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/mscgen/mscgen'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/mscgen/xu_test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/django/django'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/toml/toml'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/yacas/yacas'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/dockerfile/dockerfile'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/python/python'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/python/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/vb/vb'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/octave/octave'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/tcl/tcl'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/clojure/clojure'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/sass/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/sass/sass'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/gas/gas'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/sas/sas'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/julia/julia'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/fcl/fcl'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/tornado/tornado'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/asterisk/asterisk'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/sql/sql'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/gfm/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/gfm/gfm'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/mllike/mllike'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/rst/rst'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/ntriples/ntriples'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/sparql/sparql'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/properties/properties'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/rpm/rpm'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/htmlmixed/htmlmixed'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/xml/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/xml/xml'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/ttcn-cfg/ttcn-cfg'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/ttcn/ttcn'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/z80/z80'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/brainfuck/brainfuck'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/forth/forth'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/nginx/nginx'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/javascript/javascript'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/javascript/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/pascal/pascal'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/haxe/haxe'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/perl/perl'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/factor/factor'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/smarty/smarty'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/vbscript/vbscript'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/dylan/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/dylan/dylan'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/asn.1/asn.1'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/ruby/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/ruby/ruby'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/nsis/nsis'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/css/css'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/css/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/css/less_test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/css/gss_test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/css/scss_test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/haskell-literate/haskell-literate'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/mbox/mbox'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/dtd/dtd'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/erlang/erlang'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/turtle/turtle'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/troff/troff'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/jinja2/jinja2'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/diff/diff'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/dart/dart'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/shell/test'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/shell/shell'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/lua/lua'; + $js[] = OR_MODULES_DIR . 'editor/codemirror/mode/groovy/groovy'; + + //$js[] = OR_THEMES_DIR . '../editor/markitup/markitup/jquery.markitup'; //$js[] = OR_THEMES_DIR . '../editor/editor/ckeditor'; //$js[] = OR_THEMES_DIR . '../editor/ace/src-min-noconflict/ace'; diff --git a/modules/template-engine/components/html/editor/Editor.class.php b/modules/template-engine/components/html/editor/Editor.class.php @@ -6,8 +6,10 @@ class EditorComponent extends Component { public $type; public $name; - public $mode='html'; - + public $mode='htmlmixed'; + public $extension=''; + public $mimetype = ''; + protected function begin() { switch( $this->type ) @@ -29,7 +31,7 @@ class EditorComponent extends Component case 'ace': case 'code': - echo '<textarea name="'.$this->htmlvalue($this->name).'" data-mode="'.$this->htmlvalue($this->mode).'" class="editor__code-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; + echo '<textarea name="'.$this->htmlvalue($this->name).'" data-extension="'.$this->htmlvalue($this->extension).'" data-mimetype="'.$this->htmlvalue($this->mimetype).'" data-mode="'.$this->htmlvalue($this->mode).'" class="editor__code-editor"><?php echo ${'.$this->value($this->name).'} ?></textarea>'; break; diff --git a/modules/template-engine/components/html/editor/editor.js b/modules/template-engine/components/html/editor/editor.js @@ -86,8 +86,16 @@ $(document).on('orViewLoaded',function(event, data) { // Codemirror-Editor anzeigen $(event.target).find("textarea.editor__code-editor").each( function() { + var mode = $(this).data('mode'); + + var mimetype = $(this).data('mimetype'); + if(mimetype.length>0) + mode = mimetype; + + var editor = CodeMirror.fromTextArea( this, { - lineNumbers: true + lineNumbers: true, + mode: mode /** settings **/ }) var textareaEl = this; diff --git a/script/create-output-files.sh b/script/create-output-files.sh @@ -17,6 +17,14 @@ for jsfile in `find themes -name "*.js" -not -name "*.min.js"`; do chmod a+rw -v $jsfile.min.js; done +for jsfile in `find modules/editor/codemirror -name "*.js" -not -name "*.min.js"`; do + jsfile="${jsfile%.*}" + echo "JS found: $jsfile" + if [ ! -f $jsfile.min.js ]; then cp -v $jsfile.js $jsfile.min.js; + fi + chmod a+rw -v $jsfile.min.js; +done + for tplfile in `find themes -name "*.src.xml"`; do diff --git a/themes/default/templates/template/src.tpl.src.xml b/themes/default/templates/template/src.tpl.src.xml @@ -5,6 +5,6 @@ <!-- <inputarea rows="25" cols="80" name="src" class="editor"></inputarea> --> - <editor type="code" name="src" mode="html" /> + <editor type="code" name="src" mode="htmlmixed" /> </form> </output> \ No newline at end of file diff --git a/themes/default/templates/text/value.tpl.src.xml b/themes/default/templates/text/value.tpl.src.xml @@ -2,21 +2,19 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"> <form> - <window> - <row> - <column> - <text text="GLOBAL_VALUE"></text> - </column> - <column> - <editor name="value" type="code"></editor> - </column> - </row> - <row> - <column class="act" colspan="2"> - <button type="ok"></button> - </column> - </row> - </window> + <row> + <column> + <text text="GLOBAL_VALUE"></text> + </column> + <column> + <editor name="value" type="code" extension="var:extension" mimetype="var:mimetype"></editor> + </column> + </row> + <row> + <column class="act" colspan="2"> + <button type="ok"></button> + </column> + </row> </form> <focus field="value"></focus> </output> \ No newline at end of file