git ssb

1+

bencevans / ssb-news



Commit a2cedde098e0580bb46ca8ac1946939cc48fac90

user page

Ben Evans committed on 11/7/2018, 6:41:30 PM
Parent: bb1d879ac72e9462c12547ce70a4ccba104a1066

Files changed

src/server.jschanged
src/views/user.jschanged
src/server.jsView
@@ -45,8 +45,15 @@
4545 const dom = app.toString(req.url, Object.assign({}, state, { story }))
4646 res.end(dom)
4747 })
4848 })
49 + } else if (req.url.match(/^\/user\/(.+)/)) {
50 + const userKey = decodeURIComponent(req.url.match(/^\/user\/(.+)/)[1])
51 + getUserAbout(sbot, userKey, (err, user) => {
52 + if (err) throw err
53 + const dom = app.toString(req.url, Object.assign({}, state, { user }))
54 + res.end(dom)
55 + })
4956 } else if (req.method === 'POST' && req.url === '/new') {
5057 body(req, (err, form) => {
5158 if (err) { throw err }
5259 news.publish(form, (err, msg) => {
@@ -64,5 +71,7 @@
6471 }
6572 })
6673
6774 server.listen(3000)
75 +
76 + console.log('Listening on http://127.0.0.1:3000')
6877 }
src/views/user.jsView
@@ -1,9 +1,36 @@
11 const html = require('choo/html')
2 +const header = require('./header')
23
34 module.exports = function userView (state) {
45 return html`
5- <body>
6- user
7- </body>
6 + <body class="sans-serif">
7 +
8 + <link rel="stylesheet" href="https://unpkg.com/reset-css@4.0.1/reset.css"/>
9 + <link rel="stylesheet" href="https://unpkg.com/tachyons@4.10.0/css/tachyons.min.css"/>
10 +
11 + <style>
12 +
13 + .voters {
14 + width: 40px;
15 + float:left;
16 + text-align: center;
17 + }
18 +
19 + .vote {
20 +
21 + }
22 + </style>
23 +
24 + ${header(state)}
25 +
26 + <div class="pa3 pa4-ns" style="padding-bottom: 0">
27 + id: ${state.user.id}<br/>
28 + name: ${state.user.name}<br/>-----------------<br/><br/>
29 + <pre>${state.user.description}</pre>
30 + </div>
31 +
32 +
33 +
34 + </body>
835 `
936 }

Built with git-ssb-web