diff --git a/client/css/main.css b/client/css/main.css
index 4e00500a..db8fcfa6 100644
--- a/client/css/main.css
+++ b/client/css/main.css
@@ -83,6 +83,13 @@ nav ul li img {
vertical-align: top; /* fix ghost margin under the image */
}
+nav.plain-nav ul li {
+ display: block;
+}
+nav.plain-nav ul li a {
+ display: inline;
+}
+
nav.text-nav {
margin: 1em 0;
}
diff --git a/client/css/users.css b/client/css/users.css
index c28f5dcc..7abbd7cc 100644
--- a/client/css/users.css
+++ b/client/css/users.css
@@ -36,3 +36,27 @@
#login .buttons a {
margin-left: 1em;
}
+
+#user {
+ width: 30em;
+}
+#user .text-nav {
+ margin-bottom: 1.5em;
+}
+#user-summary img {
+ width: 6em;
+ margin: 0 1.5em 1.5em 0;
+ float: left;
+}
+#user-summary div {
+ clear: both;
+}
+#user-summary .basic-info {
+ list-style-type: none;
+ margin: 0;
+}
+#user-summary nav {
+ float: left;
+ width: 45%;
+ margin-right: 1em;
+}
diff --git a/client/html/home.hbs b/client/html/home.hbs
index 3c7bcf93..6f428ff5 100644
--- a/client/html/home.hbs
+++ b/client/html/home.hbs
@@ -1,5 +1,5 @@
{{name}}
-
+
diff --git a/client/html/user.hbs b/client/html/user.hbs
new file mode 100644
index 00000000..d4fe6f95
--- /dev/null
+++ b/client/html/user.hbs
@@ -0,0 +1,12 @@
+
+
+
diff --git a/client/html/user_edit.hbs b/client/html/user_edit.hbs
new file mode 100644
index 00000000..bf3be1e2
--- /dev/null
+++ b/client/html/user_edit.hbs
@@ -0,0 +1,3 @@
+
+ Placeholder for account settings form
+
diff --git a/client/html/user_summary.hbs b/client/html/user_summary.hbs
new file mode 100644
index 00000000..7519f502
--- /dev/null
+++ b/client/html/user_summary.hbs
@@ -0,0 +1,29 @@
+
+
+
+ - Registered: {{reltime this.user.creationTime}}
+ - Last seen: {{reltime this.user.lastLoginTime}}
+ - Rank: {{toLowerCase this.user.rankName}}
+
+
+
+
+
+ {{#if this.isPrivate}}
+
+ {{/if}}
+
+
diff --git a/client/js/controllers/users_controller.js b/client/js/controllers/users_controller.js
index 9390e2ae..b7d3e2b9 100644
--- a/client/js/controllers/users_controller.js
+++ b/client/js/controllers/users_controller.js
@@ -18,10 +18,13 @@ class UsersController {
page('/users', () => { this.listUsersRoute(); });
page(
'/user/:name',
- (ctx, next) => { this.showUserRoute(ctx.params.name); });
+ (ctx, next) => { this.loadUserRoute(ctx, next); },
+ (ctx, next) => { this.showUserRoute(ctx, next); });
page(
'/user/:name/edit',
- (ctx, next) => { this.editUserRoute(ctx.params.name); });
+ (ctx, next) => { this.loadUserRoute(ctx, next); },
+ (ctx, next) => { this.editUserRoute(ctx, next); });
+ page.exit('/user/', (ctx, next) => { this.user = null; });
}
listUsersRoute() {
@@ -57,22 +60,42 @@ class UsersController {
});
}
- showUserRoute(name) {
- if (api.isLoggedIn() && name == api.userName) {
+ loadUserRoute(ctx, next) {
+ if (ctx.state.user) {
+ next();
+ } else if (this.user && this.user.name == ctx.params.name) {
+ ctx.state.user = this.user;
+ next();
+ } else {
+ api.get('/user/' + ctx.params.name).then(response => {
+ ctx.state.user = response.user;
+ ctx.save();
+ this.user = response.user;
+ next();
+ }).catch(response => {
+ this.userView.empty();
+ this.userView.notifyError(response.description);
+ });
+ }
+ }
+
+ _show(user, section) {
+ const isPrivate = api.isLoggedIn() && user.name == api.userName;
+ if (isPrivate) {
topNavController.activate('account');
} else {
topNavController.activate('users');
}
- this.userView.empty();
- api.get('/user/' + name).then(response => {
- this.userView.render({user: response.user});
- }).catch(response => {
- this.userView.notifyError(response.description);
- });
+ this.userView.render({
+ user: user, section: section, isPrivate: isPrivate});
}
- editUserRoute(user) {
- topNavController.activate('users');
+ showUserRoute(ctx, next) {
+ this._show(ctx.state.user, 'summary');
+ }
+
+ editUserRoute(ctx, next) {
+ this._show(ctx.state.user, 'edit');
}
}
diff --git a/client/js/util/handlebars-helpers.js b/client/js/util/handlebars-helpers.js
index 8d121d51..03eb7f1a 100644
--- a/client/js/util/handlebars-helpers.js
+++ b/client/js/util/handlebars-helpers.js
@@ -3,13 +3,13 @@
const handlebars = require('handlebars');
const misc = require('./misc.js');
-handlebars.registerHelper('reltime', function(options) {
+handlebars.registerHelper('reltime', function(time) {
return new handlebars.SafeString(
- '