page builder module started
This commit is contained in:
-19
@@ -1,19 +0,0 @@
|
|||||||
## Features
|
|
||||||
- **Themes**: specify the color scheme in the URL: [default](/2014/3/31/demo-note), [dark](/2014/3/31/demo-note?theme=dark), [solarized light](/2014/3/31/demo-note?theme=solarized-light), [solarized dark](/2014/3/31/demo-note?theme=solarized-dark).
|
|
||||||
- **Fonts**: specify a font (e.g., [Google Web Fonts](http://www.google.com/webfonts/)) for headers and body text in the URL like [this](/8m4l9) or [this](/2014/3/31/demo-note?text-font=monospace&header-font=Courier&text-size=0.7&header-size=1.1).
|
|
||||||
- **Short URLs**: every page (including theme & font options) has its own short url.
|
|
||||||
- **Editing**: if you set a password during publishing, you can edit your note any time later.
|
|
||||||
- **Statistics**: page view counter, publishing and editing date.
|
|
||||||
- **Expiration**: all notes with less than 30 views after the first 30 days will expire.
|
|
||||||
- **Export**: the original markdown content can be displayed in plain text format.
|
|
||||||
- **API**: Integrate the publishing functionality into your editor using the official [NoteHub API](/api).
|
|
||||||
|
|
||||||
## Changelog
|
|
||||||
- **2014-09**: text size setting added ([example](/2014/3/31/demo-note?text-font=monospace&header-font=Courier&text-size=0.7&header-size=1.1))
|
|
||||||
- **2014-07**: deprecated all API versions less than 1.4 & performance improvements.
|
|
||||||
- **2014-03**: note expiration implemented.
|
|
||||||
- **2014-02**: a simple JS-client for API testing [added](/api-test.html).
|
|
||||||
- **2014-01**: [NoteHub API](/api), mobile friendly styling and more.
|
|
||||||
- **2013-03**: new color themes.
|
|
||||||
- **2012-07**: password protection for note editing added.
|
|
||||||
- **2012-06**: NoteHub released as a result of an [experiment](/2012/6/16/how-notehub-is-built).
|
|
||||||
+2
-1
@@ -4,6 +4,7 @@
|
|||||||
"module": "commonjs"
|
"module": "commonjs"
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules",
|
||||||
|
"bin"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -5,6 +5,7 @@
|
|||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"server": "node server.js",
|
"server": "node server.js",
|
||||||
|
"devser": "nodemon server.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -22,6 +23,8 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/chmllr/NoteHub",
|
"homepage": "https://github.com/chmllr/NoteHub",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.13.3"
|
"express": "^4.13.3",
|
||||||
|
"lru-cache": "^2.6.5",
|
||||||
|
"marked": "^0.3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,12 +95,7 @@
|
|||||||
padding-top: 5em;
|
padding-top: 5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1,
|
h1, h2, h3, h4, h5, h6 {
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6 {
|
|
||||||
font-family: Noticia Text, 'Noticia Text', 'PT Serif', 'Georgia';
|
font-family: Noticia Text, 'Noticia Text', 'PT Serif', 'Georgia';
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>NoteHub — %TITLE%</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta content="width=device-width, initial-scale=1.0" name="viewport">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=PT+Serif:700|Noticia+Text:700&subset=latin,cyrillic"
|
||||||
|
rel="stylesheet" type="text/css" />
|
||||||
|
<link href="style.css" rel="stylesheet" type="text/css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<article>
|
||||||
|
%CONTENT%
|
||||||
|
</article>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,17 +1,13 @@
|
|||||||
var express = require('express');
|
var express = require('express');
|
||||||
|
var page = require('./bin/page');
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
/*
|
|
||||||
app.get('/', function (req, res) {
|
|
||||||
res.send('Hello World!');
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
app.use(express.static(__dirname + '/resources/public'));
|
app.use(express.static(__dirname + '/resources/public'));
|
||||||
|
|
||||||
|
app.get('/api', function (req, res) {
|
||||||
|
res.send(page.build("api"));
|
||||||
|
});
|
||||||
|
|
||||||
var server = app.listen(3000, function () {
|
var server = app.listen(3000, function () {
|
||||||
var host = server.address().address;
|
console.log('NoteHub server listening on port %s', server.address().port);
|
||||||
var port = server.address().port;
|
|
||||||
|
|
||||||
console.log('NoteHub server listening at http://%s:%s', host, port);
|
|
||||||
});
|
});
|
||||||
@@ -1 +0,0 @@
|
|||||||
var f = () => console.log("hello world!");
|
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
var LRU = require("lru-cache"),
|
||||||
|
marked = require("marked"),
|
||||||
|
fs = require("fs");
|
||||||
|
|
||||||
|
var CACHE = new LRU(30); // create LRU cache of size 30
|
||||||
|
var template = fs.readFileSync("resources/template.html", "utf-8");
|
||||||
|
var buildHTML = (title, content) => template
|
||||||
|
.replace("%TITLE%", title)
|
||||||
|
.replace("%CONTENT%", content);
|
||||||
|
var apiPage = buildHTML("API", marked(fs.readFileSync("API.md", "utf-8")));
|
||||||
|
|
||||||
|
export var build = id => {
|
||||||
|
if (CACHE.has(id)) return CACHE.get(id);
|
||||||
|
var content = id == "api" ? apiPage : "This is page " + id;
|
||||||
|
CACHE.set(id, content);
|
||||||
|
return content;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user