Commit dd8cb3ef authored by maik alms's avatar maik alms

Add editor

parent 1d4b3964
......@@ -28,7 +28,7 @@ function Init() {
handle[_Config.root + "page/"] = {callback: requestHandlers.Page, cache: true};
handle[_Config.root + "ajax/"] = {callback: requestHandlers.Ajax, cache: false};
handle[_Config.root + "rss.xml"] = {callback: requestHandlers.RSS, cache: true};
handle[_Config.root + "edit"] = {callback: requestHandlers.Edit, cache: true};
server.Start(handle, router.Route, domain);
}
......@@ -52,10 +52,6 @@ default:
break;
}
if (_Cluster.isMaster) {
if (_cache && _Config.ClearCacheOnStart) {
......
<!DOCTYPE html>
<head>
<meta charset="UTF-8"/>
<meta name="description" content="Compilenix's Blog"/>
<meta name="author" content="Compilenix"/>
<link rel="alternate" type="application/rss+xml" title="RSS-Feed" href="/rss.xml"/>
<link type="text/css" rel="stylesheet" href="//cdn.compilenix.org/google-code-prettify/prettify.css"/>
<script type="text/javascript" src="//cdn.compilenix.org/ace-builds/src-min/ace.js"></script>
<title>Compilenix's Blog</title>
<style>
@font-face {
font-family: Ubuntu;
src: url("//cdn.compilenix.org/fonts/ubuntu-font-family-0.80/Ubuntu-R.ttf") format("truetype");
}
@font-face {
font-family: Ubuntu;
font-weight: bold;
src: url("//cdn.compilenix.org/fonts/ubuntu-font-family-0.80/Ubuntu-B.ttf") format("truetype");
}
* {
font-family: Ubuntu, Tahoma, Verdana, sans-serif, serif;
transition: 200ms;
word-break: break-word;
}
pre, code {
font-family: Lucida, Consolas, Courier, Verdana;
}
a {
text-decoration: none;
}
a:hover, a:focus {
color: #0AF;
}
#edit {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
</style>
</head>
<body onload="prettyPrint()">
<h1><a href="/" style="color:black">Compilenix's Blog</a></h1>
<div id='edit'>
test
</div>
<script type="text/javascript">
var editor = ace.edit("edit");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");
</script>
</body>
</html>
......@@ -7,3 +7,4 @@ exports.Post = require('./requestHandlers/Post.js').Post;
exports.RSS = require('./requestHandlers/RSS.js').RSS;
exports.Page = require('./requestHandlers/Page.js').Page;
exports.Ajax = require('./requestHandlers/Ajax.js').Ajax;
exports.Edit = require('./requestHandlers/Edit.js').Edit;
......@@ -24,20 +24,27 @@ function Ajax(request, response, write_cache) {
switch (post.action) {
case 'postlist':
ret = postList();
response.setContentType('application/json');
break;
case 'getpost':
ret = getPost(post);
response.setContentType('application/json');
break;
case 'writepost':
ret = writePost(post);
response.setContentType('application/json');
break;
case 'previewpost':
ret = previewPost(post);
response.setContentType('text/html');
break;
default:
ret = '{}';
response.setContentType('application/json');
break;
}
response.setContent(ret);
response.setContentType('application/json');
response.setResponseCode(200);
response.send()
});
......@@ -62,8 +69,15 @@ function getPost(post) {
}
}
function writePost(request) {
function writePost(post) {
}
function previewPost(post) {
if (post.content) {
return _helper.getPage(post.content);
}
return '';
}
function checkApiKey(key) {
......
function Edit(request, response, write_cache) {
response.setResponseCode(200);
response.setContent(_fs.readFileSync(_Config.FileEditor|| "editor.html", 'utf8'));
if (write_cache) {
_cache.add(request, response.getContent(), response.getContentType(), response.getResponseCode());
response.setLastModified(_cache.getLastModified(request));
}
response.send();
return true;
}
exports.Edit = Edit;
......@@ -55,8 +55,7 @@ _responseWrapper.prototype.send = function () {
"Server": this.serverVersion,
"Cache-Control": "max-age=" + this.expires,
"Last-Modified": this.lastModified,
"Expires": _rfc822Date(new Date(Date.now() + this.expires)),
"ETag": this.eTag
"Expires": _rfc822Date(new Date(Date.now() + this.expires))
});
this.response.end(this.data);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment