From 327d6fb8d865b6333304188f9b58268b7ecef6ce Mon Sep 17 00:00:00 2001 From: lifei6671 Date: Tue, 7 Aug 2018 17:19:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:1=E3=80=81=E4=BF=AE=E5=A4=8D=E6=97=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82=202=E3=80=81=E6=96=B0=E5=A2=9E=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E4=BB=A3=E7=A0=81=E7=9D=80=E8=89=B2=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=203=E3=80=81=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/command.go | 41 ++++++++++++++-- commands/daemon/daemon.go | 2 + conf/app.conf.example | 11 ++++- conf/enumerate.go | 1 + controllers/BaseController.go | 1 + controllers/LabelController.go | 18 +++---- models/AttachmentModel.go | 4 ++ ...tachment_result.go => AttachmentResult.go} | 0 models/{base.go => Base.go} | 0 models/{dashboard.go => Dashboard.go} | 0 models/DocumentModel.go | 8 ++-- models/LabelModel.go | 6 +++ static/css/markdown.preview.css | 44 ++++++++++-------- static/editor.md/css/editormd.css | 3 -- static/editor.md/css/editormd.preview.css | 3 -- static/editor.md/editormd.amd.js | 32 +++++++++---- static/editor.md/editormd.js | 25 ++++++---- static/editor.md/lib/highlight/blueprint.png | Bin 0 -> 343 bytes .../lib}/highlight/highlight.js | 0 .../highlight/highlightjs-line-numbers.min.js | 0 .../lib}/highlight/languages/1c.js | 0 .../lib}/highlight/languages/abnf.js | 0 .../lib}/highlight/languages/accesslog.js | 0 .../lib}/highlight/languages/actionscript.js | 0 .../lib}/highlight/languages/ada.js | 0 .../lib}/highlight/languages/apache.js | 0 .../lib}/highlight/languages/applescript.js | 0 .../lib}/highlight/languages/arduino.js | 0 .../lib}/highlight/languages/armasm.js | 0 .../lib}/highlight/languages/asciidoc.js | 0 .../lib}/highlight/languages/aspectj.js | 0 .../lib}/highlight/languages/autohotkey.js | 0 .../lib}/highlight/languages/autoit.js | 0 .../lib}/highlight/languages/avrasm.js | 0 .../lib}/highlight/languages/awk.js | 0 .../lib}/highlight/languages/axapta.js | 0 .../lib}/highlight/languages/bash.js | 0 .../lib}/highlight/languages/basic.js | 0 .../lib}/highlight/languages/bnf.js | 0 .../lib}/highlight/languages/brainfuck.js | 0 .../lib}/highlight/languages/cal.js | 0 .../lib}/highlight/languages/capnproto.js | 0 .../lib}/highlight/languages/ceylon.js | 0 .../lib}/highlight/languages/clean.js | 0 .../lib}/highlight/languages/clojure-repl.js | 0 .../lib}/highlight/languages/clojure.js | 0 .../lib}/highlight/languages/cmake.js | 0 .../lib}/highlight/languages/coffeescript.js | 0 .../lib}/highlight/languages/coq.js | 0 .../lib}/highlight/languages/cos.js | 0 .../lib}/highlight/languages/cpp.js | 0 .../lib}/highlight/languages/crmsh.js | 0 .../lib}/highlight/languages/crystal.js | 0 .../lib}/highlight/languages/cs.js | 0 .../lib}/highlight/languages/csp.js | 0 .../lib}/highlight/languages/css.js | 0 .../lib}/highlight/languages/d.js | 0 .../lib}/highlight/languages/dart.js | 0 .../lib}/highlight/languages/delphi.js | 0 .../lib}/highlight/languages/diff.js | 0 .../lib}/highlight/languages/django.js | 0 .../lib}/highlight/languages/dns.js | 0 .../lib}/highlight/languages/dockerfile.js | 0 .../lib}/highlight/languages/dos.js | 0 .../lib}/highlight/languages/dsconfig.js | 0 .../lib}/highlight/languages/dts.js | 0 .../lib}/highlight/languages/dust.js | 0 .../lib}/highlight/languages/ebnf.js | 0 .../lib}/highlight/languages/elixir.js | 0 .../lib}/highlight/languages/elm.js | 0 .../lib}/highlight/languages/erb.js | 0 .../lib}/highlight/languages/erlang-repl.js | 0 .../lib}/highlight/languages/erlang.js | 0 .../lib}/highlight/languages/excel.js | 0 .../lib}/highlight/languages/fix.js | 0 .../lib}/highlight/languages/flix.js | 0 .../lib}/highlight/languages/fortran.js | 0 .../lib}/highlight/languages/fsharp.js | 0 .../lib}/highlight/languages/gams.js | 0 .../lib}/highlight/languages/gauss.js | 0 .../lib}/highlight/languages/gcode.js | 0 .../lib}/highlight/languages/gherkin.js | 0 .../lib}/highlight/languages/glsl.js | 0 .../lib}/highlight/languages/go.js | 0 .../lib}/highlight/languages/golo.js | 0 .../lib}/highlight/languages/gradle.js | 0 .../lib}/highlight/languages/groovy.js | 0 .../lib}/highlight/languages/haml.js | 0 .../lib}/highlight/languages/handlebars.js | 0 .../lib}/highlight/languages/haskell.js | 0 .../lib}/highlight/languages/haxe.js | 0 .../lib}/highlight/languages/hsp.js | 0 .../lib}/highlight/languages/htmlbars.js | 0 .../lib}/highlight/languages/http.js | 0 .../lib}/highlight/languages/inform7.js | 0 .../lib}/highlight/languages/ini.js | 0 .../lib}/highlight/languages/irpf90.js | 0 .../lib}/highlight/languages/java.js | 0 .../lib}/highlight/languages/javascript.js | 0 .../lib}/highlight/languages/json.js | 0 .../lib}/highlight/languages/julia.js | 0 .../lib}/highlight/languages/kotlin.js | 0 .../lib}/highlight/languages/lasso.js | 0 .../lib}/highlight/languages/ldif.js | 0 .../lib}/highlight/languages/less.js | 0 .../lib}/highlight/languages/lisp.js | 0 .../highlight/languages/livecodeserver.js | 0 .../lib}/highlight/languages/livescript.js | 0 .../lib}/highlight/languages/lsl.js | 0 .../lib}/highlight/languages/lua.js | 0 .../lib}/highlight/languages/makefile.js | 0 .../lib}/highlight/languages/markdown.js | 0 .../lib}/highlight/languages/mathematica.js | 0 .../lib}/highlight/languages/matlab.js | 0 .../lib}/highlight/languages/maxima.js | 0 .../lib}/highlight/languages/mel.js | 0 .../lib}/highlight/languages/mercury.js | 0 .../lib}/highlight/languages/mipsasm.js | 0 .../lib}/highlight/languages/mizar.js | 0 .../lib}/highlight/languages/mojolicious.js | 0 .../lib}/highlight/languages/monkey.js | 0 .../lib}/highlight/languages/moonscript.js | 0 .../lib}/highlight/languages/nginx.js | 0 .../lib}/highlight/languages/nimrod.js | 0 .../lib}/highlight/languages/nix.js | 0 .../lib}/highlight/languages/nsis.js | 0 .../lib}/highlight/languages/objectivec.js | 0 .../lib}/highlight/languages/ocaml.js | 0 .../lib}/highlight/languages/openscad.js | 0 .../lib}/highlight/languages/oxygene.js | 0 .../lib}/highlight/languages/parser3.js | 0 .../lib}/highlight/languages/perl.js | 0 .../lib}/highlight/languages/pf.js | 0 .../lib}/highlight/languages/php.js | 0 .../lib}/highlight/languages/pony.js | 0 .../lib}/highlight/languages/powershell.js | 0 .../lib}/highlight/languages/processing.js | 0 .../lib}/highlight/languages/profile.js | 0 .../lib}/highlight/languages/prolog.js | 0 .../lib}/highlight/languages/protobuf.js | 0 .../lib}/highlight/languages/puppet.js | 0 .../lib}/highlight/languages/purebasic.js | 0 .../lib}/highlight/languages/python.js | 0 .../lib}/highlight/languages/q.js | 0 .../lib}/highlight/languages/qml.js | 0 .../lib}/highlight/languages/r.js | 0 .../lib}/highlight/languages/rib.js | 0 .../lib}/highlight/languages/roboconf.js | 0 .../lib}/highlight/languages/rsl.js | 0 .../lib}/highlight/languages/ruby.js | 0 .../lib}/highlight/languages/ruleslanguage.js | 0 .../lib}/highlight/languages/rust.js | 0 .../lib}/highlight/languages/scala.js | 0 .../lib}/highlight/languages/scheme.js | 0 .../lib}/highlight/languages/scilab.js | 0 .../lib}/highlight/languages/scss.js | 0 .../lib}/highlight/languages/smali.js | 0 .../lib}/highlight/languages/smalltalk.js | 0 .../lib}/highlight/languages/sml.js | 0 .../lib}/highlight/languages/sqf.js | 0 .../lib}/highlight/languages/sql.js | 0 .../lib}/highlight/languages/stan.js | 0 .../lib}/highlight/languages/stata.js | 0 .../lib}/highlight/languages/step21.js | 0 .../lib}/highlight/languages/stylus.js | 0 .../lib}/highlight/languages/subunit.js | 0 .../lib}/highlight/languages/swift.js | 0 .../lib}/highlight/languages/taggerscript.js | 0 .../lib}/highlight/languages/tap.js | 0 .../lib}/highlight/languages/tcl.js | 0 .../lib}/highlight/languages/tex.js | 0 .../lib}/highlight/languages/thrift.js | 0 .../lib}/highlight/languages/tp.js | 0 .../lib}/highlight/languages/twig.js | 0 .../lib}/highlight/languages/typescript.js | 0 .../lib}/highlight/languages/vala.js | 0 .../lib}/highlight/languages/vbnet.js | 0 .../lib}/highlight/languages/vbscript-html.js | 0 .../lib}/highlight/languages/vbscript.js | 0 .../lib}/highlight/languages/verilog.js | 0 .../lib}/highlight/languages/vhdl.js | 0 .../lib}/highlight/languages/vim.js | 0 .../lib}/highlight/languages/x86asm.js | 0 .../lib}/highlight/languages/xl.js | 0 .../lib}/highlight/languages/xml.js | 0 .../lib}/highlight/languages/xquery.js | 0 .../lib}/highlight/languages/yaml.js | 0 .../lib}/highlight/languages/zephir.js | 0 .../lib}/highlight/styles/agate.css | 0 .../lib}/highlight/styles/androidstudio.css | 0 .../lib}/highlight/styles/arduino-light.css | 0 .../lib}/highlight/styles/arta.css | 0 .../lib}/highlight/styles/ascetic.css | 0 .../highlight/styles/atelier-cave-dark.css | 0 .../highlight/styles/atelier-cave-light.css | 0 .../highlight/styles/atelier-dune-dark.css | 0 .../highlight/styles/atelier-dune-light.css | 0 .../highlight/styles/atelier-estuary-dark.css | 0 .../styles/atelier-estuary-light.css | 0 .../highlight/styles/atelier-forest-dark.css | 0 .../highlight/styles/atelier-forest-light.css | 0 .../highlight/styles/atelier-heath-dark.css | 0 .../highlight/styles/atelier-heath-light.css | 0 .../styles/atelier-lakeside-dark.css | 0 .../styles/atelier-lakeside-light.css | 0 .../highlight/styles/atelier-plateau-dark.css | 0 .../styles/atelier-plateau-light.css | 0 .../highlight/styles/atelier-savanna-dark.css | 0 .../styles/atelier-savanna-light.css | 0 .../highlight/styles/atelier-seaside-dark.css | 0 .../styles/atelier-seaside-light.css | 0 .../styles/atelier-sulphurpool-dark.css | 0 .../styles/atelier-sulphurpool-light.css | 0 .../lib}/highlight/styles/atom-one-dark.css | 0 .../lib}/highlight/styles/atom-one-light.css | 0 .../lib}/highlight/styles/brown-paper.css | 0 .../lib}/highlight/styles/brown-papersq.png | Bin .../lib}/highlight/styles/codepen-embed.css | 0 .../lib}/highlight/styles/color-brewer.css | 0 .../lib}/highlight/styles/darcula.css | 0 .../lib}/highlight/styles/dark.css | 0 .../lib}/highlight/styles/darkula.css | 0 .../lib}/highlight/styles/default.css | 0 .../lib}/highlight/styles/docco.css | 0 .../lib}/highlight/styles/dracula.css | 0 .../lib}/highlight/styles/far.css | 0 .../lib}/highlight/styles/foundation.css | 0 .../lib}/highlight/styles/github-gist.css | 0 .../lib}/highlight/styles/github.css | 0 .../lib}/highlight/styles/googlecode.css | 0 .../lib}/highlight/styles/grayscale.css | 0 .../lib}/highlight/styles/gruvbox-dark.css | 0 .../lib}/highlight/styles/gruvbox-light.css | 0 .../lib}/highlight/styles/hopscotch.css | 0 .../lib}/highlight/styles/hybrid.css | 0 .../lib}/highlight/styles/idea.css | 0 .../lib}/highlight/styles/ir-black.css | 0 .../lib}/highlight/styles/kimbie.dark.css | 0 .../lib}/highlight/styles/kimbie.light.css | 0 .../lib}/highlight/styles/magula.css | 0 .../lib}/highlight/styles/mono-blue.css | 0 .../lib}/highlight/styles/monokai-sublime.css | 0 .../lib}/highlight/styles/monokai.css | 0 .../lib}/highlight/styles/obsidian.css | 0 .../lib}/highlight/styles/ocean.css | 0 .../lib}/highlight/styles/paraiso-dark.css | 0 .../lib}/highlight/styles/paraiso-light.css | 0 .../lib}/highlight/styles/pojoaque.css | 0 .../lib}/highlight/styles/pojoaque.jpg | Bin .../lib}/highlight/styles/purebasic.css | 0 .../lib}/highlight/styles/qtcreator_dark.css | 0 .../lib}/highlight/styles/qtcreator_light.css | 0 .../lib}/highlight/styles/railscasts.css | 0 .../lib}/highlight/styles/rainbow.css | 0 .../lib}/highlight/styles/school-book.css | 0 .../lib}/highlight/styles/school-book.png | Bin .../lib}/highlight/styles/solarized-dark.css | 0 .../lib}/highlight/styles/solarized-light.css | 0 .../lib}/highlight/styles/sunburst.css | 0 .../highlight/styles/tomorrow-night-blue.css | 0 .../styles/tomorrow-night-bright.css | 0 .../styles/tomorrow-night-eighties.css | 0 .../lib}/highlight/styles/tomorrow-night.css | 0 .../lib}/highlight/styles/tomorrow.css | 0 .../lib}/highlight/styles/vs.css | 0 .../lib}/highlight/styles/xcode.css | 0 .../lib}/highlight/styles/xt256.css | 0 .../lib}/highlight/styles/zenburn.css | 0 static/js/blog.js | 1 + static/js/editor.js | 2 - static/js/kancloud.js | 2 +- static/js/markdown.js | 2 + views/blog/index.tpl | 15 ++---- views/blog/manage_edit.tpl | 7 ++- views/document/default_read.tpl | 8 ++-- views/document/html_edit_template.tpl | 6 +-- views/document/markdown_edit_template.tpl | 5 +- views/document/new_html_edit_template.tpl | 10 ++-- views/label/index.tpl | 2 + views/label/list.tpl | 1 - 280 files changed, 162 insertions(+), 98 deletions(-) rename models/{attachment_result.go => AttachmentResult.go} (100%) rename models/{base.go => Base.go} (100%) rename models/{dashboard.go => Dashboard.go} (100%) create mode 100644 static/editor.md/lib/highlight/blueprint.png rename static/{ => editor.md/lib}/highlight/highlight.js (100%) rename static/{ => editor.md/lib}/highlight/highlightjs-line-numbers.min.js (100%) rename static/{ => editor.md/lib}/highlight/languages/1c.js (100%) rename static/{ => editor.md/lib}/highlight/languages/abnf.js (100%) rename static/{ => editor.md/lib}/highlight/languages/accesslog.js (100%) rename static/{ => editor.md/lib}/highlight/languages/actionscript.js (100%) rename static/{ => editor.md/lib}/highlight/languages/ada.js (100%) rename static/{ => editor.md/lib}/highlight/languages/apache.js (100%) rename static/{ => editor.md/lib}/highlight/languages/applescript.js (100%) rename static/{ => editor.md/lib}/highlight/languages/arduino.js (100%) rename static/{ => editor.md/lib}/highlight/languages/armasm.js (100%) rename static/{ => editor.md/lib}/highlight/languages/asciidoc.js (100%) rename static/{ => editor.md/lib}/highlight/languages/aspectj.js (100%) rename static/{ => editor.md/lib}/highlight/languages/autohotkey.js (100%) rename static/{ => editor.md/lib}/highlight/languages/autoit.js (100%) rename static/{ => editor.md/lib}/highlight/languages/avrasm.js (100%) rename static/{ => editor.md/lib}/highlight/languages/awk.js (100%) rename static/{ => editor.md/lib}/highlight/languages/axapta.js (100%) rename static/{ => editor.md/lib}/highlight/languages/bash.js (100%) rename static/{ => editor.md/lib}/highlight/languages/basic.js (100%) rename static/{ => editor.md/lib}/highlight/languages/bnf.js (100%) rename static/{ => editor.md/lib}/highlight/languages/brainfuck.js (100%) rename static/{ => editor.md/lib}/highlight/languages/cal.js (100%) rename static/{ => editor.md/lib}/highlight/languages/capnproto.js (100%) rename static/{ => editor.md/lib}/highlight/languages/ceylon.js (100%) rename static/{ => editor.md/lib}/highlight/languages/clean.js (100%) rename static/{ => editor.md/lib}/highlight/languages/clojure-repl.js (100%) rename static/{ => editor.md/lib}/highlight/languages/clojure.js (100%) rename static/{ => editor.md/lib}/highlight/languages/cmake.js (100%) rename static/{ => editor.md/lib}/highlight/languages/coffeescript.js (100%) rename static/{ => editor.md/lib}/highlight/languages/coq.js (100%) rename static/{ => editor.md/lib}/highlight/languages/cos.js (100%) rename static/{ => editor.md/lib}/highlight/languages/cpp.js (100%) rename static/{ => editor.md/lib}/highlight/languages/crmsh.js (100%) rename static/{ => editor.md/lib}/highlight/languages/crystal.js (100%) rename static/{ => editor.md/lib}/highlight/languages/cs.js (100%) rename static/{ => editor.md/lib}/highlight/languages/csp.js (100%) rename static/{ => editor.md/lib}/highlight/languages/css.js (100%) rename static/{ => editor.md/lib}/highlight/languages/d.js (100%) rename static/{ => editor.md/lib}/highlight/languages/dart.js (100%) rename static/{ => editor.md/lib}/highlight/languages/delphi.js (100%) rename static/{ => editor.md/lib}/highlight/languages/diff.js (100%) rename static/{ => editor.md/lib}/highlight/languages/django.js (100%) rename static/{ => editor.md/lib}/highlight/languages/dns.js (100%) rename static/{ => editor.md/lib}/highlight/languages/dockerfile.js (100%) rename static/{ => editor.md/lib}/highlight/languages/dos.js (100%) rename static/{ => editor.md/lib}/highlight/languages/dsconfig.js (100%) rename static/{ => editor.md/lib}/highlight/languages/dts.js (100%) rename static/{ => editor.md/lib}/highlight/languages/dust.js (100%) rename static/{ => editor.md/lib}/highlight/languages/ebnf.js (100%) rename static/{ => editor.md/lib}/highlight/languages/elixir.js (100%) rename static/{ => editor.md/lib}/highlight/languages/elm.js (100%) rename static/{ => editor.md/lib}/highlight/languages/erb.js (100%) rename static/{ => editor.md/lib}/highlight/languages/erlang-repl.js (100%) rename static/{ => editor.md/lib}/highlight/languages/erlang.js (100%) rename static/{ => editor.md/lib}/highlight/languages/excel.js (100%) rename static/{ => editor.md/lib}/highlight/languages/fix.js (100%) rename static/{ => editor.md/lib}/highlight/languages/flix.js (100%) rename static/{ => editor.md/lib}/highlight/languages/fortran.js (100%) rename static/{ => editor.md/lib}/highlight/languages/fsharp.js (100%) rename static/{ => editor.md/lib}/highlight/languages/gams.js (100%) rename static/{ => editor.md/lib}/highlight/languages/gauss.js (100%) rename static/{ => editor.md/lib}/highlight/languages/gcode.js (100%) rename static/{ => editor.md/lib}/highlight/languages/gherkin.js (100%) rename static/{ => editor.md/lib}/highlight/languages/glsl.js (100%) rename static/{ => editor.md/lib}/highlight/languages/go.js (100%) rename static/{ => editor.md/lib}/highlight/languages/golo.js (100%) rename static/{ => editor.md/lib}/highlight/languages/gradle.js (100%) rename static/{ => editor.md/lib}/highlight/languages/groovy.js (100%) rename static/{ => editor.md/lib}/highlight/languages/haml.js (100%) rename static/{ => editor.md/lib}/highlight/languages/handlebars.js (100%) rename static/{ => editor.md/lib}/highlight/languages/haskell.js (100%) rename static/{ => editor.md/lib}/highlight/languages/haxe.js (100%) rename static/{ => editor.md/lib}/highlight/languages/hsp.js (100%) rename static/{ => editor.md/lib}/highlight/languages/htmlbars.js (100%) rename static/{ => editor.md/lib}/highlight/languages/http.js (100%) rename static/{ => editor.md/lib}/highlight/languages/inform7.js (100%) rename static/{ => editor.md/lib}/highlight/languages/ini.js (100%) rename static/{ => editor.md/lib}/highlight/languages/irpf90.js (100%) rename static/{ => editor.md/lib}/highlight/languages/java.js (100%) rename static/{ => editor.md/lib}/highlight/languages/javascript.js (100%) rename static/{ => editor.md/lib}/highlight/languages/json.js (100%) rename static/{ => editor.md/lib}/highlight/languages/julia.js (100%) rename static/{ => editor.md/lib}/highlight/languages/kotlin.js (100%) rename static/{ => editor.md/lib}/highlight/languages/lasso.js (100%) rename static/{ => editor.md/lib}/highlight/languages/ldif.js (100%) rename static/{ => editor.md/lib}/highlight/languages/less.js (100%) rename static/{ => editor.md/lib}/highlight/languages/lisp.js (100%) rename static/{ => editor.md/lib}/highlight/languages/livecodeserver.js (100%) rename static/{ => editor.md/lib}/highlight/languages/livescript.js (100%) rename static/{ => editor.md/lib}/highlight/languages/lsl.js (100%) rename static/{ => editor.md/lib}/highlight/languages/lua.js (100%) rename static/{ => editor.md/lib}/highlight/languages/makefile.js (100%) rename static/{ => editor.md/lib}/highlight/languages/markdown.js (100%) rename static/{ => editor.md/lib}/highlight/languages/mathematica.js (100%) rename static/{ => editor.md/lib}/highlight/languages/matlab.js (100%) rename static/{ => editor.md/lib}/highlight/languages/maxima.js (100%) rename static/{ => editor.md/lib}/highlight/languages/mel.js (100%) rename static/{ => editor.md/lib}/highlight/languages/mercury.js (100%) rename static/{ => editor.md/lib}/highlight/languages/mipsasm.js (100%) rename static/{ => editor.md/lib}/highlight/languages/mizar.js (100%) rename static/{ => editor.md/lib}/highlight/languages/mojolicious.js (100%) rename static/{ => editor.md/lib}/highlight/languages/monkey.js (100%) rename static/{ => editor.md/lib}/highlight/languages/moonscript.js (100%) rename static/{ => editor.md/lib}/highlight/languages/nginx.js (100%) rename static/{ => editor.md/lib}/highlight/languages/nimrod.js (100%) rename static/{ => editor.md/lib}/highlight/languages/nix.js (100%) rename static/{ => editor.md/lib}/highlight/languages/nsis.js (100%) rename static/{ => editor.md/lib}/highlight/languages/objectivec.js (100%) rename static/{ => editor.md/lib}/highlight/languages/ocaml.js (100%) rename static/{ => editor.md/lib}/highlight/languages/openscad.js (100%) rename static/{ => editor.md/lib}/highlight/languages/oxygene.js (100%) rename static/{ => editor.md/lib}/highlight/languages/parser3.js (100%) rename static/{ => editor.md/lib}/highlight/languages/perl.js (100%) rename static/{ => editor.md/lib}/highlight/languages/pf.js (100%) rename static/{ => editor.md/lib}/highlight/languages/php.js (100%) rename static/{ => editor.md/lib}/highlight/languages/pony.js (100%) rename static/{ => editor.md/lib}/highlight/languages/powershell.js (100%) rename static/{ => editor.md/lib}/highlight/languages/processing.js (100%) rename static/{ => editor.md/lib}/highlight/languages/profile.js (100%) rename static/{ => editor.md/lib}/highlight/languages/prolog.js (100%) rename static/{ => editor.md/lib}/highlight/languages/protobuf.js (100%) rename static/{ => editor.md/lib}/highlight/languages/puppet.js (100%) rename static/{ => editor.md/lib}/highlight/languages/purebasic.js (100%) rename static/{ => editor.md/lib}/highlight/languages/python.js (100%) rename static/{ => editor.md/lib}/highlight/languages/q.js (100%) rename static/{ => editor.md/lib}/highlight/languages/qml.js (100%) rename static/{ => editor.md/lib}/highlight/languages/r.js (100%) rename static/{ => editor.md/lib}/highlight/languages/rib.js (100%) rename static/{ => editor.md/lib}/highlight/languages/roboconf.js (100%) rename static/{ => editor.md/lib}/highlight/languages/rsl.js (100%) rename static/{ => editor.md/lib}/highlight/languages/ruby.js (100%) rename static/{ => editor.md/lib}/highlight/languages/ruleslanguage.js (100%) rename static/{ => editor.md/lib}/highlight/languages/rust.js (100%) rename static/{ => editor.md/lib}/highlight/languages/scala.js (100%) rename static/{ => editor.md/lib}/highlight/languages/scheme.js (100%) rename static/{ => editor.md/lib}/highlight/languages/scilab.js (100%) rename static/{ => editor.md/lib}/highlight/languages/scss.js (100%) rename static/{ => editor.md/lib}/highlight/languages/smali.js (100%) rename static/{ => editor.md/lib}/highlight/languages/smalltalk.js (100%) rename static/{ => editor.md/lib}/highlight/languages/sml.js (100%) rename static/{ => editor.md/lib}/highlight/languages/sqf.js (100%) rename static/{ => editor.md/lib}/highlight/languages/sql.js (100%) rename static/{ => editor.md/lib}/highlight/languages/stan.js (100%) rename static/{ => editor.md/lib}/highlight/languages/stata.js (100%) rename static/{ => editor.md/lib}/highlight/languages/step21.js (100%) rename static/{ => editor.md/lib}/highlight/languages/stylus.js (100%) rename static/{ => editor.md/lib}/highlight/languages/subunit.js (100%) rename static/{ => editor.md/lib}/highlight/languages/swift.js (100%) rename static/{ => editor.md/lib}/highlight/languages/taggerscript.js (100%) rename static/{ => editor.md/lib}/highlight/languages/tap.js (100%) rename static/{ => editor.md/lib}/highlight/languages/tcl.js (100%) rename static/{ => editor.md/lib}/highlight/languages/tex.js (100%) rename static/{ => editor.md/lib}/highlight/languages/thrift.js (100%) rename static/{ => editor.md/lib}/highlight/languages/tp.js (100%) rename static/{ => editor.md/lib}/highlight/languages/twig.js (100%) rename static/{ => editor.md/lib}/highlight/languages/typescript.js (100%) rename static/{ => editor.md/lib}/highlight/languages/vala.js (100%) rename static/{ => editor.md/lib}/highlight/languages/vbnet.js (100%) rename static/{ => editor.md/lib}/highlight/languages/vbscript-html.js (100%) rename static/{ => editor.md/lib}/highlight/languages/vbscript.js (100%) rename static/{ => editor.md/lib}/highlight/languages/verilog.js (100%) rename static/{ => editor.md/lib}/highlight/languages/vhdl.js (100%) rename static/{ => editor.md/lib}/highlight/languages/vim.js (100%) rename static/{ => editor.md/lib}/highlight/languages/x86asm.js (100%) rename static/{ => editor.md/lib}/highlight/languages/xl.js (100%) rename static/{ => editor.md/lib}/highlight/languages/xml.js (100%) rename static/{ => editor.md/lib}/highlight/languages/xquery.js (100%) rename static/{ => editor.md/lib}/highlight/languages/yaml.js (100%) rename static/{ => editor.md/lib}/highlight/languages/zephir.js (100%) rename static/{ => editor.md/lib}/highlight/styles/agate.css (100%) rename static/{ => editor.md/lib}/highlight/styles/androidstudio.css (100%) rename static/{ => editor.md/lib}/highlight/styles/arduino-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/arta.css (100%) rename static/{ => editor.md/lib}/highlight/styles/ascetic.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-cave-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-cave-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-dune-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-dune-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-estuary-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-estuary-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-forest-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-forest-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-heath-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-heath-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-lakeside-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-lakeside-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-plateau-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-plateau-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-savanna-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-savanna-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-seaside-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-seaside-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-sulphurpool-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atelier-sulphurpool-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atom-one-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/atom-one-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/brown-paper.css (100%) rename static/{ => editor.md/lib}/highlight/styles/brown-papersq.png (100%) rename static/{ => editor.md/lib}/highlight/styles/codepen-embed.css (100%) rename static/{ => editor.md/lib}/highlight/styles/color-brewer.css (100%) rename static/{ => editor.md/lib}/highlight/styles/darcula.css (100%) rename static/{ => editor.md/lib}/highlight/styles/dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/darkula.css (100%) rename static/{ => editor.md/lib}/highlight/styles/default.css (100%) rename static/{ => editor.md/lib}/highlight/styles/docco.css (100%) rename static/{ => editor.md/lib}/highlight/styles/dracula.css (100%) rename static/{ => editor.md/lib}/highlight/styles/far.css (100%) rename static/{ => editor.md/lib}/highlight/styles/foundation.css (100%) rename static/{ => editor.md/lib}/highlight/styles/github-gist.css (100%) rename static/{ => editor.md/lib}/highlight/styles/github.css (100%) rename static/{ => editor.md/lib}/highlight/styles/googlecode.css (100%) rename static/{ => editor.md/lib}/highlight/styles/grayscale.css (100%) rename static/{ => editor.md/lib}/highlight/styles/gruvbox-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/gruvbox-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/hopscotch.css (100%) rename static/{ => editor.md/lib}/highlight/styles/hybrid.css (100%) rename static/{ => editor.md/lib}/highlight/styles/idea.css (100%) rename static/{ => editor.md/lib}/highlight/styles/ir-black.css (100%) rename static/{ => editor.md/lib}/highlight/styles/kimbie.dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/kimbie.light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/magula.css (100%) rename static/{ => editor.md/lib}/highlight/styles/mono-blue.css (100%) rename static/{ => editor.md/lib}/highlight/styles/monokai-sublime.css (100%) rename static/{ => editor.md/lib}/highlight/styles/monokai.css (100%) rename static/{ => editor.md/lib}/highlight/styles/obsidian.css (100%) rename static/{ => editor.md/lib}/highlight/styles/ocean.css (100%) rename static/{ => editor.md/lib}/highlight/styles/paraiso-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/paraiso-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/pojoaque.css (100%) rename static/{ => editor.md/lib}/highlight/styles/pojoaque.jpg (100%) rename static/{ => editor.md/lib}/highlight/styles/purebasic.css (100%) rename static/{ => editor.md/lib}/highlight/styles/qtcreator_dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/qtcreator_light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/railscasts.css (100%) rename static/{ => editor.md/lib}/highlight/styles/rainbow.css (100%) rename static/{ => editor.md/lib}/highlight/styles/school-book.css (100%) rename static/{ => editor.md/lib}/highlight/styles/school-book.png (100%) rename static/{ => editor.md/lib}/highlight/styles/solarized-dark.css (100%) rename static/{ => editor.md/lib}/highlight/styles/solarized-light.css (100%) rename static/{ => editor.md/lib}/highlight/styles/sunburst.css (100%) rename static/{ => editor.md/lib}/highlight/styles/tomorrow-night-blue.css (100%) rename static/{ => editor.md/lib}/highlight/styles/tomorrow-night-bright.css (100%) rename static/{ => editor.md/lib}/highlight/styles/tomorrow-night-eighties.css (100%) rename static/{ => editor.md/lib}/highlight/styles/tomorrow-night.css (100%) rename static/{ => editor.md/lib}/highlight/styles/tomorrow.css (100%) rename static/{ => editor.md/lib}/highlight/styles/vs.css (100%) rename static/{ => editor.md/lib}/highlight/styles/xcode.css (100%) rename static/{ => editor.md/lib}/highlight/styles/xt256.css (100%) rename static/{ => editor.md/lib}/highlight/styles/zenburn.css (100%) diff --git a/commands/command.go b/commands/command.go index c5d67a29..fe9ab12e 100644 --- a/commands/command.go +++ b/commands/command.go @@ -43,7 +43,7 @@ func RegisterDataBase() { if err == nil { orm.DefaultTimeLoc = location } else { - beego.Error("加载时区配置信息失败,请检查是否存在ZONEINFO环境变量:", err) + beego.Error("加载时区配置信息失败,请检查是否存在ZONEINFO环境变量->", err) } port := beego.AppConfig.String("db_port") @@ -51,7 +51,7 @@ func RegisterDataBase() { dataSource := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true&loc=%s", username, password, host, port, database, url.QueryEscape(timezone)) if err := orm.RegisterDataBase("default", "mysql", dataSource); err != nil { - beego.Error("注册默认数据库失败:", err) + beego.Error("注册默认数据库失败->", err) os.Exit(1) } } else if adapter == "sqlite3" { @@ -67,7 +67,7 @@ func RegisterDataBase() { err := orm.RegisterDataBase("default", "sqlite3", database) if err != nil { - beego.Error("注册默认数据库失败:", err) + beego.Error("注册默认数据库失败->", err) } } else { beego.Error("不支持的数据库类型.") @@ -252,6 +252,7 @@ func ResolveCommand(args []string) { if err := beego.LoadAppConfig("ini", conf.ConfigurationFile);err != nil { log.Fatal("An error occurred:", err) } + conf.AutoLoadDelay = beego.AppConfig.DefaultInt("config_auto_delay",0) uploads := conf.WorkingDir("uploads") os.MkdirAll(uploads, 0666) @@ -374,6 +375,40 @@ func RegisterCache() { beego.Info("缓存初始化完成.") } +//自动加载配置文件.修改了监听端口号和数据库配置无法自动生效. +func RegisterAutoLoadConfig() { + if conf.AutoLoadDelay > 0 { + ticker := time.NewTicker(time.Second * time.Duration(conf.AutoLoadDelay)) + + go func() { + f,err := os.Stat(conf.ConfigurationFile) + if err != nil { + beego.Error("读取配置文件时出错 ->",err) + return + } + modTime := f.ModTime() + for { + select { + case <-ticker.C: + f,err := os.Stat(conf.ConfigurationFile) + if err != nil { + beego.Error("读取配置文件时出错 ->",err) + break + } + if modTime != f.ModTime() { + if err := beego.LoadAppConfig("ini", conf.ConfigurationFile); err != nil { + beego.Error("An error occurred:", err) + break + } + modTime = f.ModTime() + beego.Info("配置文件已加载") + } + } + } + }() + } +} + func init() { if configPath, err := filepath.Abs(conf.ConfigurationFile); err == nil { diff --git a/commands/daemon/daemon.go b/commands/daemon/daemon.go index 69bfc7cf..c8f4617b 100644 --- a/commands/daemon/daemon.go +++ b/commands/daemon/daemon.go @@ -47,6 +47,8 @@ func (d *Daemon) Run() { commands.RegisterFunction() + commands.RegisterAutoLoadConfig() + beego.ErrorController(&controllers.ErrorController{}) fmt.Printf("MinDoc version => %s\nbuild time => %s\nstart directory => %s\n%s\n", conf.VERSION, conf.BUILD_TIME, os.Args[0], conf.GO_VERSION) diff --git a/conf/app.conf.example b/conf/app.conf.example index 6a16b7db..cd6bfd35 100644 --- a/conf/app.conf.example +++ b/conf/app.conf.example @@ -1,4 +1,4 @@ -appname = godoc +appname = mindoc # httpaddr = 127.0.0.1 httpport = 8181 runmode = dev @@ -10,6 +10,15 @@ baseurl= #默认Session生成Key的秘钥 beegoserversessionkey=123456 +#########代码高亮样式################ +#样式演示地址:https://highlightjs.org/static/demo/ +highlight_style=github + +########配置文件自动加载################## +#大于0时系统会自动检测配置文件是否变动,变动后自动加载并生效,单位是秒。监听端口和数据库配置无效 +config_auto_delay=0 + + ########Session储存方式############## #以文件方式储存 sessionprovider=file diff --git a/conf/enumerate.go b/conf/enumerate.go index 2c9c49dc..7af755c8 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -68,6 +68,7 @@ var ( WorkingDirectory = "./" LogFile = "./runtime/logs" BaseUrl = "" + AutoLoadDelay = 0 ) // app_key diff --git a/controllers/BaseController.go b/controllers/BaseController.go index 49edeb44..f8dbc786 100644 --- a/controllers/BaseController.go +++ b/controllers/BaseController.go @@ -77,6 +77,7 @@ func (c *BaseController) Prepare() { } } } + c.Data["HighlightStyle"] = beego.AppConfig.DefaultString("highlight_style","github") } // SetMember 获取或设置当前登录用户信息,如果 MemberId 小于 0 则标识删除 Session diff --git a/controllers/LabelController.go b/controllers/LabelController.go index 7c4cb2ed..b87fc381 100644 --- a/controllers/LabelController.go +++ b/controllers/LabelController.go @@ -44,18 +44,18 @@ func (c *LabelController) Index() { c.Abort("500") } } - member_id := 0 + memberId := 0 if c.Member != nil { - member_id = c.Member.MemberId + memberId = c.Member.MemberId } - searchResult, totalCount, err := models.NewBook().FindForLabelToPager(labelName, pageIndex, conf.PageSize, member_id) + searchResult, totalCount, err := models.NewBook().FindForLabelToPager(labelName, pageIndex, conf.PageSize, memberId) - if err != nil { - beego.Error(err) - return + if err != nil && err != orm.ErrNoRows { + beego.Error("查询标签时出错 ->", err) + c.ShowErrorPage(500, "查询文档列表时出错") } if totalCount > 0 { - pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize,c.BaseUrl()) + pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl()) c.Data["PageHtml"] = pager.HtmlPages() } else { c.Data["PageHtml"] = "" @@ -74,8 +74,8 @@ func (c *LabelController) List() { labels, totalCount, err := models.NewLabel().FindToPager(pageIndex, pageSize) - if err != nil { - c.ShowErrorPage(50001, err.Error()) + if err != nil && err != orm.ErrNoRows { + c.ShowErrorPage(500, err.Error()) } if totalCount > 0 { pager := pagination.NewPagination(c.Ctx.Request, totalCount, conf.PageSize, c.BaseUrl()) diff --git a/models/AttachmentModel.go b/models/AttachmentModel.go index 3de6d9fc..fe4c9583 100644 --- a/models/AttachmentModel.go +++ b/models/AttachmentModel.go @@ -108,6 +108,10 @@ func (m *Attachment) FindToPager(pageIndex, pageSize int) (attachList []*Attachm _, err = o.QueryTable(m.TableNameWithPrefix()).OrderBy("-attachment_id").Offset(offset).Limit(pageSize).All(&list) if err != nil { + if err == orm.ErrNoRows { + beego.Info("没有查到附件 ->",err) + err = nil + } return } diff --git a/models/attachment_result.go b/models/AttachmentResult.go similarity index 100% rename from models/attachment_result.go rename to models/AttachmentResult.go diff --git a/models/base.go b/models/Base.go similarity index 100% rename from models/base.go rename to models/Base.go diff --git a/models/dashboard.go b/models/Dashboard.go similarity index 100% rename from models/dashboard.go rename to models/Dashboard.go diff --git a/models/DocumentModel.go b/models/DocumentModel.go index 6a952c2f..e1ed426a 100644 --- a/models/DocumentModel.go +++ b/models/DocumentModel.go @@ -180,9 +180,9 @@ func (m *Document) RemoveCache() { func (m *Document) FromCacheById(id int) (*Document, error) { var doc Document - if err := cache.Get("Document.Id."+strconv.Itoa(id), &m); err == nil { + if err := cache.Get("Document.Id."+strconv.Itoa(id), &m); err == nil && m.DocumentId > 0 { m = &doc - beego.Info("从缓存中获取文档信息成功", m.DocumentId) + beego.Info("从缓存中获取文档信息成功 ->", m.DocumentId) return m, nil } @@ -202,8 +202,8 @@ func (m *Document) FromCacheByIdentify(identify string, bookId int) (*Document, key := fmt.Sprintf("Document.BookId.%d.Identify.%s", bookId, identify) - if err := cache.Get(key,m); err == nil { - beego.Info("从缓存中获取文档信息成功", key) + if err := cache.Get(key,m); err == nil && m.DocumentId > 0 { + beego.Info("从缓存中获取文档信息成功 ->", key) return m, nil } diff --git a/models/LabelModel.go b/models/LabelModel.go index 558542af..8bbb6cb1 100644 --- a/models/LabelModel.go +++ b/models/LabelModel.go @@ -4,6 +4,7 @@ import ( "github.com/astaxie/beego/orm" "github.com/lifei6671/mindoc/conf" "strings" + "github.com/astaxie/beego" ) type Label struct { @@ -98,6 +99,11 @@ func (m *Label) FindToPager(pageIndex, pageSize int) (labels []*Label, totalCoun _, err = o.QueryTable(m.TableNameWithPrefix()).OrderBy("-book_number").Offset(offset).Limit(pageSize).All(&labels) + if err == orm.ErrNoRows { + beego.Info("没有查询到标签 ->",err) + err = nil + return + } return } diff --git a/static/css/markdown.preview.css b/static/css/markdown.preview.css index 02b18f33..42d2dbe1 100644 --- a/static/css/markdown.preview.css +++ b/static/css/markdown.preview.css @@ -36,18 +36,6 @@ .editormd-preview-container table tr { background-color: #fff } -.editormd-preview-container code { - padding: .2em 0; - margin-left: 3px; - margin-right: 3px; - background-color: #eee; - border-radius: 3px; - font-size: 1em; - font-family: Consolas,"Liberation Mono",Menlo,Courier,'Microsoft Yahei',monospace; - border: 0; - color: #555; - word-break: break-all; -} /**************TOC*******************/ .markdown-toc{ @@ -56,17 +44,35 @@ } /***********代码样式*****************/ .markdown-body .highlight pre, .markdown-body pre{ - padding: 0; - font-size: 12px; - border-radius:0; - line-height: 1.4em; + padding: 1em; + border: none; + overflow: auto; + line-height: 1.45; + max-height: 35em; + position: relative; + /*background: url(../editor.md/lib/highlight/blueprint.png) #F6F6F6;*/ + -moz-background-size: 30px,30px; + -o-background-size: 30px,30px; + -webkit-background-size: 30px,30px; + background-size: 30px,30px; + border-radius:4px; + word-break:break-all; + word-wrap:break-word; +} +.editormd-preview-container pre.hljs>code { + border-radius: 3px; + font-size: 1.1em; + font-family: "Source Code Pro",Consolas,"Liberation Mono",Menlo,Courier,'Microsoft Yahei',monospace; + border: 0; + word-break: break-all; + overflow-y: auto; overflow-x: hidden; + overflow-wrap: normal; + white-space: inherit } .editormd-preview-container pre.prettyprint, .editormd-html-preview pre.prettyprint { padding: 0; } -.hljs{ - padding: 10px 15px !important; -} + .editormd-preview-container ol.linenums, .editormd-html-preview ol.linenums{ color: #999; } diff --git a/static/editor.md/css/editormd.css b/static/editor.md/css/editormd.css index 73cbfbe0..ac9ba50b 100644 --- a/static/editor.md/css/editormd.css +++ b/static/editor.md/css/editormd.css @@ -3636,7 +3636,6 @@ overflow: auto; font-size: 85%; line-height: 1.45; - background-color: #f7f7f7; border-radius: 3px; } @@ -3657,7 +3656,6 @@ overflow: initial; line-height: inherit; word-wrap: normal; - background-color: transparent; border: 0; } @@ -3865,7 +3863,6 @@ } .editormd-preview-container pre, .editormd-html-preview pre { border: 1px solid #ddd; - background: #f6f6f6; padding: 10px; -webkit-border-radius: 3px; -moz-border-radius: 3px; diff --git a/static/editor.md/css/editormd.preview.css b/static/editor.md/css/editormd.preview.css index 60303304..9a43e7ab 100644 --- a/static/editor.md/css/editormd.preview.css +++ b/static/editor.md/css/editormd.preview.css @@ -2920,7 +2920,6 @@ overflow: auto; font-size: 85%; line-height: 1.45; - background-color: #f7f7f7; border-radius: 3px; } @@ -2941,7 +2940,6 @@ overflow: initial; line-height: inherit; word-wrap: normal; - background-color: transparent; border: 0; } @@ -3149,7 +3147,6 @@ } .editormd-preview-container pre, .editormd-html-preview pre { border: 1px solid #ddd; - background: #f6f6f6; padding: 10px; -webkit-border-radius: 3px; -moz-border-radius: 3px; diff --git a/static/editor.md/editormd.amd.js b/static/editor.md/editormd.amd.js index f3f379ff..c16283f4 100644 --- a/static/editor.md/editormd.amd.js +++ b/static/editor.md/editormd.amd.js @@ -26,7 +26,9 @@ var cmAddonPath = "codemirror/addon/"; var codeMirrorModules = [ - "jquery", "marked", "prettify", + "jquery", "marked", + //"prettify", + "highlight/highlight", "katex", "raphael", "underscore", "flowchart", "jqueryflowchart", "sequenceDiagram", "codemirror/lib/codemirror", @@ -239,6 +241,7 @@ flowChart : false, // flowChart.js only support IE9+ sequenceDiagram : false, // sequenceDiagram.js only support IE9+ previewCodeHighlight : true, + highlightStyle : "github", toolbar : true, // show/hide toolbar toolbarAutoFixed : true, // on window scroll auto fixed position @@ -653,7 +656,10 @@ if (settings.previewCodeHighlight) { - editormd.loadScript(loadPath + "prettify.min", function() { + // editormd.loadScript(loadPath + "prettify.min", function() { + // loadFlowChartOrSequenceDiagram(); + // }); + editormd.loadScript(loadPath + "highlight/highlight", function() { loadFlowChartOrSequenceDiagram(); }); } @@ -1543,11 +1549,16 @@ if (settings.previewCodeHighlight) { - previewContainer.find("pre").addClass("prettyprint linenums"); - - if (typeof prettyPrint !== "undefined") - { - prettyPrint(); + // previewContainer.find("pre").addClass("prettyprint"); + // + // if (typeof prettyPrint !== "undefined") + // { + // prettyPrint(); + // } + if (typeof hljs !== "undefined") { + previewContainer.find('pre').each(function (i, block) { + hljs.highlightBlock(block); + }); } } @@ -4064,8 +4075,11 @@ if (settings.previewCodeHighlight) { - div.find("pre").addClass("prettyprint linenums"); - prettyPrint(); + //div.find("pre").addClass("prettyprint"); + //prettyPrint(); + div.find("pre").each(function (i, block) { + hljs.highlightBlock(block); + }); } if (!editormd.isIE8) diff --git a/static/editor.md/editormd.js b/static/editor.md/editormd.js index ffd7e8b7..e8791238 100644 --- a/static/editor.md/editormd.js +++ b/static/editor.md/editormd.js @@ -580,10 +580,14 @@ editormd.loadScript(loadPath + "marked.min", function() { editormd.$marked = marked; - + + if(!settings.highlightStyle){ + settings.highlightStyle = "github"; + } if (settings.previewCodeHighlight) { - editormd.loadScript(loadPath + "prettify.min", function() { + editormd.loadCSS(loadPath + "highlight/styles/" + settings.highlightStyle); + editormd.loadScript(loadPath + "highlight/highlight", function() { loadFlowChartOrSequenceDiagram(); }); } @@ -1473,12 +1477,15 @@ if (settings.previewCodeHighlight) { - previewContainer.find("pre").addClass("prettyprint linenums"); - - if (typeof prettyPrint !== "undefined") - { - prettyPrint(); - } + // previewContainer.find("pre").addClass("prettyprint"); + // + // if (typeof prettyPrint !== "undefined") + // { + // prettyPrint(); + // } + previewContainer.find("pre").each(function (i, block) { + hljs.highlightBlock(block); + }); } return this; @@ -3994,7 +4001,7 @@ if (settings.previewCodeHighlight) { - div.find("pre").addClass("prettyprint linenums"); + div.find("pre").addClass("prettyprint"); prettyPrint(); } diff --git a/static/editor.md/lib/highlight/blueprint.png b/static/editor.md/lib/highlight/blueprint.png new file mode 100644 index 0000000000000000000000000000000000000000..ea1d136cb6c1285d6a250692dae86cd285491924 GIT binary patch literal 343 zcmV-d0jU0oP)b^_2t_{@)LXfd{vDJ(znna=?D+8=CSWyK9pFar;;{VveK2)20T_T;{g z_t390c#gQF{3Yu--T!(2Iq!Ercxd*gq3>qxOkC=dJu9%8Uh$gz)Z)a!on62F_1@*G zzU`@(=`?>X%v#v}ulr5ruk_nLJ*ltD;5Rld^F7{2vpx0YFi+0&p&MiMeHb5JJ%0w* z{+9dyVb$8d9B0#iH207EO{2bc*ca!i?qfUm?}b}omH9Z|i}#4{a~t&zrW}uYDbJTu pd>Yo8?-SE&@Z|XtEaBITzX7jsYbLNO$ - - - - - - + + - @@ -131,15 +126,11 @@ {{template "widgets/footer.tpl" .}} + - - - - - \ No newline at end of file diff --git a/views/blog/manage_edit.tpl b/views/blog/manage_edit.tpl index 31599e20..90183871 100644 --- a/views/blog/manage_edit.tpl +++ b/views/blog/manage_edit.tpl @@ -15,6 +15,7 @@ window.blogId = {{.Model.BlogId}}; window.blogVersion = {{.Model.Version}}; window.removeAttachURL = "{{urlfor "BlogController.RemoveAttachment" ":id" .Model.BlogId}}"; + window.highlightStyle = "{{.HighlightStyle}}"; @@ -23,11 +24,9 @@ - - - + @@ -28,11 +29,9 @@ - - - + - - - {{/**/}} + @@ -381,8 +380,7 @@ - - +