mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-03-20 04:20:00 +01:00
Adds markdown preview rendering. Adds markdown type and icons.
This commit is contained in:
parent
298d2e2efd
commit
9c1142bd02
@ -18,6 +18,7 @@ It profits from these great projects:
|
||||
[jQuery.mousewheel](http://github.com/brandonaaron/jquery-mousewheel) (MIT),
|
||||
[jQuery.qrcode](http://larsjung.de/qrcode/) (MIT),
|
||||
[jQuery.scrollpanel](http://larsjung.de/scrollpanel/) (MIT),
|
||||
[markdown-js](http://github.com/evilstreak/markdown-js) (MIT),
|
||||
[Modernizr](http://www.modernizr.com) (MIT/BSD),
|
||||
[modulejs](http://larsjung.de/modulejs/) (MIT),
|
||||
[Moment.js](http://momentjs.com) (MIT),
|
||||
@ -25,7 +26,6 @@ It profits from these great projects:
|
||||
[Underscore.js](http://underscorejs.org) (MIT)
|
||||
|
||||
|
||||
|
||||
## Build
|
||||
|
||||
A prebuilt package can be found on the [project page](http://larsjung.de/h5ai/). If you want to build
|
||||
@ -52,6 +52,8 @@ Run `makejs -t` to list all possible targets.
|
||||
* improves filter (now ignorecase, now only checks if chars in right order)
|
||||
* adds keyboard support to image preview (space, enter, backspace, left, right, up, down, f, esc)
|
||||
* adds text file preview and highlighting with [SyntaxHighlighter](http://alexgorbatchev.com/SyntaxHighlighter/) (keys: left, right, esc)
|
||||
* adds Markdown preview
|
||||
* adds new type and icon `markdown`
|
||||
* changes language code `gr` to `el`
|
||||
* adds localization for filter placeholder
|
||||
* adds `hu` translation by [Rodolffo](http://github.com/Rodolffo)
|
||||
|
@ -13,7 +13,7 @@
|
||||
<link rel="apple-touch-icon" type="image/png" href="/_h5ai/images/h5ai-48x48.png">
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Ubuntu:400;Ubuntu+Mono:400">
|
||||
<link rel="stylesheet" href="/_h5ai/css/styles.css">
|
||||
<script src="/_h5ai/js/modernizr.min.js"></script>
|
||||
<script src="/_h5ai/js/modernizr.js"></script>
|
||||
</head>
|
||||
<body id="h5ai-main">
|
||||
<div id="topbar" class="clearfix">
|
||||
|
@ -180,7 +180,8 @@ var H5AI_CONFIG = {
|
||||
|
||||
/*
|
||||
* Show text file preview on click.
|
||||
* "types" maps file types to SyntaxHighligher brushes.
|
||||
* "types" maps file types to SyntaxHighligher brushes. Special case: "markdown" will
|
||||
* be rendered to HTML.
|
||||
*
|
||||
* For available brushes see http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/
|
||||
*/
|
||||
@ -191,6 +192,7 @@ var H5AI_CONFIG = {
|
||||
"copying": "plain",
|
||||
"css": "css",
|
||||
"install": "plain",
|
||||
"markdown": "plain",
|
||||
"readme": "plain",
|
||||
"script": "shell",
|
||||
"text": "plain",
|
||||
@ -310,6 +312,7 @@ var H5AI_CONFIG = {
|
||||
"js": [".js", ".json"],
|
||||
"log": [".log", "changelog"],
|
||||
"makefile": [".pom", "build.xml", "pom.xml"],
|
||||
"markdown": [".markdown", ".md"],
|
||||
"package": [],
|
||||
"pdf": [".pdf"],
|
||||
"php": [".php"],
|
||||
@ -330,7 +333,7 @@ var H5AI_CONFIG = {
|
||||
"sql": [],
|
||||
"tar": [".tar"],
|
||||
"tex": [".tex"],
|
||||
"text": [".diff", ".markdown", ".md", ".patch", ".text", ".txt"],
|
||||
"text": [".diff", ".patch", ".text", ".txt"],
|
||||
"tiff": [".tiff"],
|
||||
"unknown": [],
|
||||
"vcal": [".vcal"],
|
||||
|
@ -32,6 +32,28 @@
|
||||
border-right: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
&.markdown {
|
||||
font-size: 16px;
|
||||
padding: 8px 24px;
|
||||
|
||||
a, a:active, a:visited {
|
||||
color: #2080FF;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
color: #68A9FF;
|
||||
}
|
||||
}
|
||||
|
||||
pre, code {
|
||||
font-family: "Ubuntu Mono", monospace;
|
||||
}
|
||||
code {
|
||||
color: #393;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pv-txt-close {
|
||||
|
BIN
src/_h5ai/icons/16x16/markdown.png
Normal file
BIN
src/_h5ai/icons/16x16/markdown.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 627 B |
BIN
src/_h5ai/icons/48x48/markdown.png
Normal file
BIN
src/_h5ai/icons/48x48/markdown.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 2.6 KiB |
@ -13,7 +13,7 @@
|
||||
<link rel="apple-touch-icon" type="image/png" href="/_h5ai/images/h5ai-48x48.png">
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Ubuntu:400,700">
|
||||
<link rel="stylesheet" href="/_h5ai/css/styles.css">
|
||||
<script src="/_h5ai/js/modernizr.min.js"></script>
|
||||
<script src="/_h5ai/js/modernizr.js"></script>
|
||||
</head>
|
||||
<body id="h5ai-info">
|
||||
<h1>h5ai</h1>
|
||||
|
@ -4,6 +4,13 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
|
||||
var defaults = {
|
||||
enabled: false,
|
||||
types: {
|
||||
authors: 'plain',
|
||||
copying: 'plain',
|
||||
css: 'css',
|
||||
install: 'plain',
|
||||
markdown: 'plain',
|
||||
readme: 'plain',
|
||||
script: 'shell',
|
||||
text: 'plain',
|
||||
js: 'js'
|
||||
}
|
||||
@ -14,7 +21,7 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
|
||||
template = '<div id="pv-txt-overlay" class="noSelection">' +
|
||||
'<div id="pv-txt-close" />' +
|
||||
'<div id="pv-txt-content">' +
|
||||
'<pre id="pv-txt-text" class="brush: js" />' +
|
||||
'<div id="pv-txt-text" />' +
|
||||
'</div>' +
|
||||
'<div id="pv-txt-bottombar" class="clearfix">' +
|
||||
'<ul id="pv-txt-buttons">' +
|
||||
@ -30,27 +37,34 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
|
||||
'</div>',
|
||||
|
||||
templateText = '<pre id="pv-txt-text" />',
|
||||
templateMarkdown = '<div id="pv-txt-text" class="markdown" />',
|
||||
|
||||
currentEntries = [],
|
||||
currentIdx = 0,
|
||||
|
||||
loadSyntaxhighlighter = function (callback) {
|
||||
loadScript = function (url, globalId, callback) {
|
||||
|
||||
var id = 'SyntaxHighlighter';
|
||||
|
||||
if (window[id]) {
|
||||
callback(window[id]);
|
||||
if (window[globalId]) {
|
||||
callback(window[globalId]);
|
||||
} else {
|
||||
$.ajax({
|
||||
url: allsettings.h5aiAbsHref + 'js/syntaxhighlighter.js',
|
||||
url: url,
|
||||
dataType: 'script',
|
||||
complete: function () {
|
||||
|
||||
callback(window[id]);
|
||||
callback(window[globalId]);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
loadSyntaxhighlighter = function (callback) {
|
||||
|
||||
loadScript(allsettings.h5aiAbsHref + 'js/syntaxhighlighter.js', 'SyntaxHighlighter', callback);
|
||||
},
|
||||
loadMarkdown = function (callback) {
|
||||
|
||||
loadScript(allsettings.h5aiAbsHref + 'js/markdown.js', 'markdown', callback);
|
||||
},
|
||||
|
||||
adjustSize = function () {
|
||||
|
||||
@ -109,15 +123,29 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/resource',
|
||||
|
||||
$text.fadeOut(100, function () {
|
||||
|
||||
var $nText = $(templateText).hide().addClass('toolbar: false; brush:').addClass(settings.types[current.type] || 'plain').text(content);
|
||||
var $nText;
|
||||
|
||||
$text.replaceWith($nText);
|
||||
loadSyntaxhighlighter(function (sh) {
|
||||
if (current.type === 'markdown') {
|
||||
$nText = $(templateMarkdown).hide();
|
||||
$text.replaceWith($nText);
|
||||
|
||||
if (sh) {
|
||||
sh.highlight({}, $nText[0]);
|
||||
}
|
||||
});
|
||||
loadMarkdown(function (md) {
|
||||
|
||||
if (md) {
|
||||
$nText.html(md.toHTML(content));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$nText = $(templateText).hide().addClass('toolbar: false; brush:').addClass(settings.types[current.type] || 'plain').text(content);
|
||||
$text.replaceWith($nText);
|
||||
|
||||
loadSyntaxhighlighter(function (sh) {
|
||||
|
||||
if (sh) {
|
||||
sh.highlight({}, $nText[0]);
|
||||
}
|
||||
});
|
||||
}
|
||||
$nText.fadeIn(200);
|
||||
|
||||
adjustSize();
|
||||
|
1616
src/_h5ai/js/lib/markdown-0.4.0.js
Normal file
1616
src/_h5ai/js/lib/markdown-0.4.0.js
Normal file
File diff suppressed because it is too large
Load Diff
2
src/_h5ai/js/markdown.js
Normal file
2
src/_h5ai/js/markdown.js
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
// @include "lib/markdown-0.4.0.js"
|
2
src/_h5ai/js/modernizr.js
Normal file
2
src/_h5ai/js/modernizr.js
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
// @include "lib/modernizr-2.6.1.min.js"
|
@ -14,7 +14,7 @@
|
||||
<link rel="apple-touch-icon" type="image/png" href="/_h5ai/images/h5ai-48x48.png">
|
||||
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Ubuntu:400;Ubuntu+Mono:400">
|
||||
<link rel="stylesheet" href="/_h5ai/css/styles.css">
|
||||
<script src="/_h5ai/js/modernizr.min.js"></script>
|
||||
<script src="/_h5ai/js/modernizr.js"></script>
|
||||
</head>
|
||||
<body id="h5ai-main">
|
||||
<div id="topbar" class="clearfix">
|
||||
|
Loading…
x
Reference in New Issue
Block a user