'.format(TABLE_NAME, html);
+ }
+ }
+
+ function getLines(text) {
+ if (text.length === 0) return [];
+ return text.split(/\r\n|\r|\n/g);
+ }
+
+}(window));
\ No newline at end of file
diff --git a/muk_web_preview_text/static/src/js/text.js b/muk_web_preview_text/static/src/js/text.js
new file mode 100644
index 0000000..2a1e5f2
--- /dev/null
+++ b/muk_web_preview_text/static/src/js/text.js
@@ -0,0 +1,124 @@
+/**********************************************************************************
+*
+* Copyright (C) 2017 MuK IT GmbH
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as
+* published by the Free Software Foundation, either version 3 of the
+* License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see .
+*
+**********************************************************************************/
+
+odoo.define('muk_preview_markdown.PreviewContentText', function (require) {
+"use strict";
+
+var core = require('web.core');
+var ajax = require('web.ajax');
+var utils = require('web.utils');
+var session = require('web.session');
+
+var registry = require('muk_preview.registry');
+
+var AbstractPreviewContent = require('muk_preview.AbstractPreviewContent');
+
+var QWeb = core.qweb;
+var _t = core._t;
+
+var PreviewContentText = AbstractPreviewContent.extend({
+ events: _.extend({}, AbstractPreviewContent.prototype.events, {
+ 'change .code-lang': '_onLanguageChange',
+ }),
+ template: "muk_preview.PreviewContentText",
+ cssLibs: [
+ '/muk_web_preview_text/static/lib/highlight/styles/default.css',
+ ],
+ jsLibs: [
+ '/muk_web_preview_text/static/lib/highlight/highlight.pack.js',
+ '/muk_web_preview_text/static/lib/highlight_line_numbers/highlight_line_numbers.js',
+ ],
+ willStart: function() {
+ var def = $.ajax({
+ url: this.url,
+ dataType: "text",
+ }).fail(function(jqXHR, textStatus) {
+ console.error(textStatus);
+ }).done(function(text) {
+ this.text = text;
+ }.bind(this));
+ return $.when(this._super.apply(this, arguments), def);
+ },
+ renderPreviewContent: function() {
+ this.$codeBlock = this.$('.code-view');
+ this.$codeLang = this.$('.code-lang');
+ this._setTextLanguage();
+ this.$codeLang.select2();
+ $.each(this.$codeBlock.attr('class').split(" "), function (i, cls) {
+ if(this.$(".code-lang option[value='" + cls + "']").val()) {
+ this.$codeLang.val(cls).trigger("change");
+ }
+ }.bind(this));
+ return this._super.apply(this, arguments);
+ },
+ _onLanguageChange: function(event) {
+ if(event.val === 'default') {
+ this._setTextLanguage();
+ } else {
+ this._setTextLanguage(event.val);
+ }
+ },
+ _setTextLanguage: function (language) {
+ this.$codeBlock.removeClass();
+ this.$codeBlock.addClass('code-view');
+ if(language) {
+ this.$codeBlock.addClass(language);
+ }
+ this.$codeBlock.text(this.text);
+ hljs.highlightBlock(this.$codeBlock[0]);
+ hljs.lineNumbersBlock(this.$codeBlock[0]);
+ },
+ downloadable: true,
+ printable: true,
+});
+
+_.each([
+ 'abc', 'acgi', 'aip', 'asm', 'asp', 'c', 'c', 'c++', 'cc', 'cc', 'com', 'conf',
+ 'cpp', 'csh', 'css', 'cxx', 'def', 'el', 'etx', 'f', 'f', 'f77', 'f90', 'f90',
+ 'flx', 'for', 'for', 'g', 'h', 'h', 'hh', 'hh', 'hlb', 'htc', 'htm', 'html',
+ 'htmls', 'htt', 'htx', 'idc', 'jav', 'jav', 'java', 'java', 'js', 'js', 'ksh',
+ 'list', 'log', 'lsp', 'lst', 'lsx', 'm', 'm', 'mar', 'mcf', 'p', 'pas', 'pl',
+ 'pl', 'pm', 'py', 'rexx', 'rt', 'rt', 'rtf', 'rtx', 's', 'scm', 'scm', 'sdml',
+ 'sgm', 'sgm', 'sgml', 'sgml', 'sh', 'shtml', 'shtml', 'spc', 'ssi', 'talk', 'tcl',
+ 'tcsh', 'text', 'tsv', 'txt', 'uil', 'uni', 'unis', 'uri', 'uris', 'uu', 'uue',
+ 'vcs', 'wml', 'wmls', 'wsc', 'xml', 'zsh', 'less', 'aj', 'cbl', 'cs', 'coffee',
+ 'go', 'groovy', 'sc', 'js', 'json',
+], function(extension) {
+ registry.add(extension, PreviewContentText);
+ registry.add("." + extension, PreviewContentText);
+});
+_.each([
+ 'text/vnd.abc', 'text/html', 'text/x-audiosoft-intra', 'text/x-asm', 'text/asp', 'text/plain',
+ 'text/x-c', 'text/x-script.csh', 'text/css', 'text/x-script.elisp', 'text/x-setext', 'text/x-fortran',
+ 'text/vnd.fmi.flexstor', 'text/x-h', 'text/x-script', 'text/x-component', 'text/webviewhtml',
+ 'text/x-java-source', 'text/javascript', 'text/ecmascript', 'text/x-script.ksh', 'text/x-script.lisp',
+ 'text/x-la-asf', 'text/x-m', 'text/mcf', 'text/x-pascal', 'text/pascal', 'text/x-script.perl',
+ 'text/x-script.perl-module', 'text/x-script.phyton', 'text/x-script.rexx', 'text/richtext',
+ 'text/vnd.rn-realtext', 'text/x-script.guile', 'text/x-script.scheme', 'text/sgml', 'text/x-sgml',
+ 'text/x-script.sh', 'text/x-server-parsed-html', 'text/x-speech', 'text/x-script.tcl',
+ 'text/x-script.tcsh', 'text/tab-separated-values', 'text/x-uil', 'text/uri-list', 'text/x-uuencode',
+ 'text/x-vcalendar', 'text/vnd.wap.wml', 'text/vnd.wap.wmlscript', 'text/scriplet', 'text/xml',
+ 'text/x-script.zsh', 'text/javascript', 'application/javascript', 'application/json',
+], function(mimetype) {
+ registry.add(mimetype, PreviewContentText);
+});
+
+return PreviewContentText;
+
+});
diff --git a/muk_web_preview_text/static/src/scss/text.scss b/muk_web_preview_text/static/src/scss/text.scss
new file mode 100644
index 0000000..539c943
--- /dev/null
+++ b/muk_web_preview_text/static/src/scss/text.scss
@@ -0,0 +1,63 @@
+/**********************************************************************************
+*
+* Copyright (C) 2017 MuK IT GmbH
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as
+* published by the Free Software Foundation, either version 3 of the
+* License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see .
+*
+**********************************************************************************/
+
+.mk_preview_text {
+ width: 100%;
+ height: 100%;
+ padding: 1rem;
+ pre {
+ padding-top: 0;
+ padding-bottom: 0;
+ }
+ .code-lang {
+ width: 100%;
+ height: 32px;
+ top: 5px;
+ }
+ .code-view {
+ padding-top: 0;
+ padding-bottom: 0;
+ }
+ td.hljs-ln-numbers {
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ text-align: center;
+ color: #ccc;
+ border-right: 1px solid #CCC;
+ vertical-align: top;
+ padding-right: 5px;
+ }
+
+ td.hljs-ln-code {
+ padding-left: 10px;
+ }
+}
+
+@media print {
+ .mk_preview_text {
+ .hljs-ln-numbers {
+ display: none ! important;
+ }
+ }
+}
+
diff --git a/muk_web_preview_text/static/src/xml/text.xml b/muk_web_preview_text/static/src/xml/text.xml
new file mode 100644
index 0000000..aed194e
--- /dev/null
+++ b/muk_web_preview_text/static/src/xml/text.xml
@@ -0,0 +1,190 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/muk_web_preview_text/template/assets.xml b/muk_web_preview_text/template/assets.xml
new file mode 100644
index 0000000..9dc3cae
--- /dev/null
+++ b/muk_web_preview_text/template/assets.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file