mirror of
https://github.com/seejohnrun/haste-server.git
synced 2024-11-22 04:31:21 +00:00
Nicer page titles
This commit is contained in:
parent
d69839b2fb
commit
f935ac56c2
2 changed files with 11 additions and 3 deletions
|
@ -13,7 +13,7 @@ DocumentHandler.prototype.handleGet = function(key, response) {
|
||||||
if (DocumentHandler.documents[key]) {
|
if (DocumentHandler.documents[key]) {
|
||||||
winston.verbose('retrieved document', { key: key });
|
winston.verbose('retrieved document', { key: key });
|
||||||
response.writeHead(200, { 'content-type': 'application/json' });
|
response.writeHead(200, { 'content-type': 'application/json' });
|
||||||
response.end(JSON.stringify({ data: DocumentHandler.documents[key] }));
|
response.end(JSON.stringify({ data: DocumentHandler.documents[key], key: key }));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
winston.warn('document not found', { key: key });
|
winston.warn('document not found', { key: key });
|
||||||
|
|
|
@ -102,7 +102,11 @@ heist.prototype.loadDocument = function(key) {
|
||||||
_this.doc.load(key, function(ret) {
|
_this.doc.load(key, function(ret) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
_this.$code.html(ret.value);
|
_this.$code.html(ret.value);
|
||||||
_this.setTitle(ret.language ? ret.language : 'unknown');
|
var title = ret.key;
|
||||||
|
if (ret.language) {
|
||||||
|
title += ' - ' + ret.language;
|
||||||
|
}
|
||||||
|
_this.setTitle(title);
|
||||||
_this.$textarea.val('').hide();
|
_this.$textarea.val('').hide();
|
||||||
_this.$box.show();
|
_this.$box.show();
|
||||||
}
|
}
|
||||||
|
@ -127,7 +131,11 @@ heist.prototype.lockDocument = function() {
|
||||||
this.doc.save(this.$textarea.val(), function(ret) {
|
this.doc.save(this.$textarea.val(), function(ret) {
|
||||||
if (ret) {
|
if (ret) {
|
||||||
_this.$code.html(ret.value);
|
_this.$code.html(ret.value);
|
||||||
_this.setTitle(ret.language ? ret.language : 'unknown');
|
var title = ret.key;
|
||||||
|
if (ret.language) {
|
||||||
|
title += ' - ' + ret.language;
|
||||||
|
}
|
||||||
|
_this.setTitle(title);
|
||||||
window.history.pushState(null, _this.appName + '-' + ret.key, '/' + ret.key);
|
window.history.pushState(null, _this.appName + '-' + ret.key, '/' + ret.key);
|
||||||
_this.$textarea.val('').hide();
|
_this.$textarea.val('').hide();
|
||||||
_this.$box.show();
|
_this.$box.show();
|
||||||
|
|
Loading…
Reference in a new issue