git ssb

30+

cel / git-ssb-web



Commit fbf41c49a722b764d89e7c44d5baef86a9e6c157

Add current user profile icon to template

Charles Lehner committed on 5/21/2016, 3:32:36 AM
Parent: 7f17070bd0ea7f8d0c5e6ab971e847e2a09e28ce

Files changed

index.jschanged
lib/about.jschanged
static/styles.csschanged
index.jsView
@@ -435,8 +435,9 @@
435435 }
436436 }
437437
438438 G.serveTemplate = function (req, title, code, read) {
439+ var self = this
439440 if (read === undefined)
440441 return this.serveTemplate.bind(this, req, title, code)
441442 var q = req._u.query.q && u.escape(req._u.query.q) || ''
442443 var app = 'git ssb'
@@ -452,17 +453,32 @@
452453 '<link rel=stylesheet href="/static/styles.css"/>',
453454 '<link rel=stylesheet href="/highlight/github.css"/>',
454455 '</head>\n',
455456 '<body>',
456- '<header><form action="/search" method="get">' +
457- '<h1><a href="/">' + app + '' +
458- (appName != 'ssb' ? ' <sub>' + appName + '</sub>' : '') +
459- '</a> ' +
457+ '<header>'
458+ ]),
459+ self.isPublic ? null : u.readOnce(function (cb) {
460+ self.about(self.myId, function (err, about) {
461+ if (err) return cb(err)
462+ cb(null,
463+ '<a href="' + u.encodeLink(this.myId) + '">' +
464+ (about.image ?
465+ '<img class="profile-icon icon-right"' +
466+ ' src="/' + encodeURIComponent(about.image) + '"' +
467+ ' alt="' + u.escape(about.name) + '">' : u.escape(about.name)) +
468+ '</a>')
469+ })
470+ }),
471+ pull.once(
472+ '<form action="/search" method="get">' +
473+ '<h1><a href="/">' + app +
474+ (appName == 'ssb' ? '' : ' <sub>' + appName + '</sub>') +
475+ '</a></h1> ' +
460476 '<input class="search-bar" name="q" size="60"' +
461477 ' placeholder="๐Ÿ”" value="' + q + '" />' +
462- '</h1>',
463- '</form></header>',
464- '<article>']),
478+ '</form>' +
479+ '</header>' +
480+ '<article>'),
465481 this.renderTry(read),
466482 pull.once('<hr/></article></body></html>')
467483 ])
468484 }
lib/about.jsView
@@ -91,9 +91,9 @@
9191 // TODO: give about from source (self) priority over about from owner
9292 if (c.name)
9393 info.name = c.name
9494 if (c.image)
95- info.image = c.image
95+ info.image = c.image.link
9696 }
9797 }, function (err) {
9898 if (err) console.error(err)
9999 })
static/styles.cssView
@@ -35,8 +35,9 @@
3535
3636 header h1 {
3737 font-weight: inherit;
3838 font-size: 1.5em;
39+ display: inline;
3940 }
4041
4142 header h1 :link,
4243 header h1 :visited {
@@ -57,8 +58,19 @@
5758 padding: .25em;
5859 font-size: 10pt;
5960 }
6061
62+.profile-icon {
63+ height: 1.5em;
64+ width: 1.5em;
65+ margin: .5em .5ex 0 .5ex;
66+ border: none;
67+}
68+
69+.icon-right {
70+ float: right;
71+}
72+
6173 /* content */
6274
6375 section {
6476 background-color: white;
@@ -233,9 +245,8 @@
233245 float: right;
234246 font-weight: normal;
235247 display: inline-block;
236248 margin: 0;
237-
238249 }
239250
240251 h2 .user-id {
241252 font-size: 16px;

Built with git-ssb-web