mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-28 14:04:45 -04:00
Additional text preview modes: none, fixed, markdown.
This commit is contained in:
parent
8b2852ec9d
commit
c8d0f5500e
3 changed files with 25 additions and 36 deletions
|
@ -3,7 +3,7 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
types: ['bmp', 'gif', 'ico', 'image', 'jpg', 'png', 'tiff']
|
types: []
|
||||||
}, allsettings['preview-img']),
|
}, allsettings['preview-img']),
|
||||||
|
|
||||||
preloadImg = function (src, callback) {
|
preloadImg = function (src, callback) {
|
||||||
|
|
|
@ -3,29 +3,7 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
types: {
|
types: {}
|
||||||
authors: 'plain',
|
|
||||||
copying: 'plain',
|
|
||||||
c: 'c',
|
|
||||||
cpp: 'cpp',
|
|
||||||
css: 'css',
|
|
||||||
h: 'c',
|
|
||||||
hpp: 'cpp',
|
|
||||||
install: 'plain',
|
|
||||||
log: 'plain',
|
|
||||||
java: 'java',
|
|
||||||
makefile: 'xml',
|
|
||||||
markdown: 'plain',
|
|
||||||
// php: 'php',
|
|
||||||
python: 'python',
|
|
||||||
readme: 'plain',
|
|
||||||
rb: 'ruby',
|
|
||||||
rtf: 'plain',
|
|
||||||
script: 'shell',
|
|
||||||
text: 'plain',
|
|
||||||
js: 'js',
|
|
||||||
xml: 'xml'
|
|
||||||
}
|
|
||||||
}, allsettings['preview-txt']),
|
}, allsettings['preview-txt']),
|
||||||
|
|
||||||
templateText = '<pre id="pv-txt-text" class="highlighted"/>',
|
templateText = '<pre id="pv-txt-text" class="highlighted"/>',
|
||||||
|
@ -142,7 +120,15 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
|
|
||||||
var $text;
|
var $text;
|
||||||
|
|
||||||
if (currentItem.type === 'markdown') {
|
if (settings.types[currentItem.type] === 'none') {
|
||||||
|
|
||||||
|
$text = $(templateMarkdown).text(textContent);
|
||||||
|
|
||||||
|
} else if (settings.types[currentItem.type] === 'fixed') {
|
||||||
|
|
||||||
|
$text = $(templateText).text(textContent);
|
||||||
|
|
||||||
|
} else if (settings.types[currentItem.type] === 'markdown') {
|
||||||
|
|
||||||
$text = $(templateMarkdown).text(textContent);
|
$text = $(templateMarkdown).text(textContent);
|
||||||
|
|
||||||
|
|
|
@ -214,38 +214,41 @@ Options
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Show text file preview on click.
|
Show text file preview on click.
|
||||||
"types" maps file types to SyntaxHighligher brushes. Special case: "markdown" will
|
"types" maps file types to SyntaxHighligher brushes.
|
||||||
be rendered as HTML.
|
|
||||||
|
|
||||||
For available brushes see http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/
|
For available brushes see http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/
|
||||||
|
|
||||||
|
Additional type are:
|
||||||
|
- "markdown" to render Markdown text
|
||||||
|
- "none" for floating text
|
||||||
|
- "fixed" for fixed width text
|
||||||
|
|
||||||
- types: maps types to brushes
|
- types: maps types to brushes
|
||||||
*/
|
*/
|
||||||
"preview-txt": {
|
"preview-txt": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"types": {
|
"types": {
|
||||||
"authors": "plain",
|
"authors": "fixed",
|
||||||
"copying": "plain",
|
"copying": "fixed",
|
||||||
"c": "c",
|
"c": "c",
|
||||||
"cpp": "cpp",
|
"cpp": "cpp",
|
||||||
"css": "css",
|
"css": "css",
|
||||||
"diff": "diff",
|
"diff": "diff",
|
||||||
"h": "c",
|
"h": "c",
|
||||||
"hpp": "cpp",
|
"hpp": "cpp",
|
||||||
"install": "plain",
|
"install": "fixed",
|
||||||
"log": "plain",
|
"log": "fixed",
|
||||||
"java": "java",
|
"java": "java",
|
||||||
"js": "js",
|
"js": "js",
|
||||||
"json": "js",
|
"json": "js",
|
||||||
"makefile": "xml",
|
"makefile": "xml",
|
||||||
"markdown": "plain",
|
"markdown": "markdown",
|
||||||
// "php": "php",
|
// "php": "php",
|
||||||
"python": "python",
|
"python": "python",
|
||||||
"readme": "plain",
|
"readme": "fixed",
|
||||||
"rb": "ruby",
|
"rb": "ruby",
|
||||||
"rtf": "plain",
|
"rtf": "fixed",
|
||||||
"script": "shell",
|
"script": "shell",
|
||||||
"text": "plain",
|
"text": "fixed",
|
||||||
"xml": "xml"
|
"xml": "xml"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue