Skip to content

Commit 0fb4129

Browse files
committed
Add title for workspace
1 parent 99f53a6 commit 0fb4129

File tree

7 files changed

+58
-5
lines changed

7 files changed

+58
-5
lines changed

editor/core/application.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var Q = require("q");
55
var Application = require("hr.app");
66
var GridView = require("hr.gridview");
77

8+
var workspace = require("./workspace");
9+
810
// Define base application
911
var CodeboxApplication = Application.extend({
1012
el: null,
@@ -24,6 +26,7 @@ var CodeboxApplication = Application.extend({
2426
},
2527

2628
render: function() {
29+
this.head.title(workspace.get('title'));
2730
return this.ready();
2831
},
2932

editor/core/workspace.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
var Workspace = require("../models/workspace");
2+
3+
module.exports = new Workspace();

editor/main.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var app = require("./core/application");
1212
var commands = require("./core/commands");
1313
var packages = require("./core/packages");
1414
var user = require("./core/user");
15+
var workspace = require("./core/workspace");
1516
var users = require("./core/users");
1617
var settings = require("./core/settings");
1718
var dialogs = require("./utils/dialogs");
@@ -27,6 +28,7 @@ window.codebox = {
2728
require: codeboxRequire,
2829
app: app,
2930
user: user,
31+
workspace: workspace,
3032
root: new File(),
3133
settings: settings
3234
};
@@ -48,10 +50,15 @@ commands.register({
4850
// Start running the applications
4951
logger.log("start application");
5052
Q.delay(500)
51-
.then(codebox.user.whoami.bind(codebox.user))
52-
.then(codebox.root.stat.bind(codebox.root, "./"))
53-
.then(settings.load.bind(settings))
54-
.then(users.listAll.bind(users))
53+
.then(function() {
54+
return Q.all([
55+
codebox.user.whoami(),
56+
codebox.root.stat('./'),
57+
codebox.workspace.about(),
58+
settings.load(),
59+
users.listAll()
60+
]);
61+
})
5562
.then(function() {
5663
return packages.loadAll()
5764
.fail(function(err) {

editor/models/workspace.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var Q = require("q");
2+
var _ = require("hr.utils");
3+
var Model = require("hr.model");
4+
var logger = require("hr.logger")("workspace");
5+
6+
var rpc = require("../core/rpc");
7+
8+
var Workspace = Model.extend({
9+
defaults: {
10+
id: "",
11+
title: ""
12+
},
13+
14+
// Identify the workspace
15+
about: function() {
16+
var that = this;
17+
18+
return rpc.execute("codebox/about")
19+
.then(function(data) {
20+
return that.set(data);
21+
})
22+
.thenResolve(that);
23+
},
24+
});
25+
26+
module.exports = Workspace;

lib/configs/default.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ module.exports = function(options) {
1414
// Root folder
1515
'root': process.cwd(),
1616

17+
// Workspace title
18+
'title': "Codebox",
19+
1720
// Workspace id
1821
'id': null,
1922

lib/services/codebox.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ var fs = require("fs");
22
var path = require("path");
33
var pkg = require("../../package.json");
44

5+
var workspace = require('../workspace');
6+
57
// About this current version
68
var about = function(args) {
79
return {
10+
'id': workspace.config('id'),
11+
'title': workspace.config('title'),
812
'version': pkg.version
913
};
1014
};

lib/workspace.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ var events = require('./events');
66
var logger = require('./utils/logger')("workspace");
77

88
var root = null;
9+
var _config = {};
910

1011
// Init the workspace
1112
var init = function(config) {
13+
_config = config;
1214
root = path.resolve(config.root);
1315

1416
logger.log("Working on ", root);
@@ -38,5 +40,10 @@ module.exports = {
3840
init: init,
3941
path: getPath,
4042
relative: relativePath,
41-
root: function() { return root; }
43+
root: function() { return root; },
44+
config: function(str) {
45+
return str.split('.').reduce(function(obj, i) {
46+
return obj[i];
47+
}, _config);
48+
}
4249
};

0 commit comments

Comments
 (0)