git ssb

16+

Dominic / patchbay



Commit 5db5f5879a68ea7da4a9376e6e95b8ef07522e10

Merge pull request #66 from ssbc/mixstyle-refactor

Mixstyle refactor
mix irving authored on 1/1/2017, 2:06:45 AM
GitHub committed on 1/1/2017, 2:06:45 AM
Parent: 787f858837541c7b94531c9b98603402cfb7f06b
Parent: 706e99a769b070931c21d59e78030c60a37afc48

Files changed

modules_basic/about.jschanged
modules_basic/about.mcsschanged
modules_basic/message-author.jschanged
modules_basic/message-author.mcsschanged
modules_basic/message-backlinks.jschanged
modules_basic/message.jschanged
modules_basic/message.mcsschanged
modules_basic/post.jschanged
modules_basic/thread.jschanged
modules_basic/timestamp.jschanged
modules_basic/timestamp.mcsschanged
modules_basic/message-backlinks.mcssadded
modules_core/index.jschanged
modules_core/style-mixins.jsadded
modules_extra/git.jschanged
package.jsonchanged
get-style-for-module.jsadded
modules_basic/about.jsView
@@ -1,8 +1,7 @@
1-var fs = require('fs')
2-var Path = require('path')
3-var h = require('../h')
4-var when = require('@mmckegg/mutant/when')
1 +const getStyleForModule = require('../get-style-for-module')
2 +const h = require('../h')
3 +const when = require('@mmckegg/mutant/when')
54
65 exports.needs = {
76 blob_url: 'first',
87 markdown: 'first'
@@ -17,9 +16,9 @@
1716 exports.create = function (api) {
1817 return {
1918 message_content,
2019 message_content_mini,
21- mcss: () => fs.readFileSync(Path.join(__dirname, 'about.mcss'), 'utf8')
20 + mcss: getStyleForModule(__filename)
2221 }
2322
2423 function message_content (msg) {
2524 if (msg.value.content.type !== 'about') return
modules_basic/about.mcssView
@@ -5,9 +5,9 @@
55 section {
66 header {
77 a {
88 -target {
9- color: green
9 +
1010 }
1111 -name {
1212
1313 }
modules_basic/message-author.jsView
@@ -1,8 +1,7 @@
1-var fs = require('fs')
2-var Path = require('path')
3-var h = require('../h')
4-var when = require('@mmckegg/mutant/when')
1 +const getStyleForModule = require('../get-style-for-module')
2 +const h = require('../h')
3 +const when = require('@mmckegg/mutant/when')
54
65 exports.needs = {
76 avatar_link: 'first',
87 avatar_image: 'first',
@@ -17,9 +16,9 @@
1716
1817 exports.create = function (api) {
1918 return {
2019 message_author,
21- mcss: () => fs.readFileSync(Path.join(__dirname, 'message-author.mcss'))
20 + mcss: getStyleForModule(__filename)
2221 }
2322
2423 function message_author (msg, opts = {}) {
2524 var { size = 'small' } = opts
modules_basic/message-author.mcssView
@@ -1,12 +1,38 @@
11 MessageAuthor {
22 display: flex
33 flex-direction: column
44
5 + section {
6 + -image {
7 + margin-bottom: .3rem
8 + }
9 +
10 + -name {
11 + max-width: 7rem
12 + a { $text-primary }
13 + }
14 +
15 + -timestamp {
16 +
17 + }
18 + }
19 +
520 -mini {
621 flex-direction: row
722
823 section {
9- margin-right: 1rem;
24 + margin-right: .5rem
25 +
26 + -name {
27 + position: initial
28 + left: initial
29 + min-width: 6.5rem
30 + max-width: none
31 + }
32 +
33 + -timestamp {
34 +
35 + }
1036 }
1137 }
1238 }
modules_basic/message-backlinks.jsView
@@ -1,8 +1,19 @@
1-exports.gives = 'message_backlinks'
1 +const getStyleForModule = require('../get-style-for-module')
2 +const h = require('../h')
23
4 +exports.gives = {
5 + message_backlinks: true,
6 + mcss: true
7 +}
8 +
39 exports.create = function (api) {
4- return function (msg) {
10 + return {
11 + message_backlinks,
12 + mcss: getStyleForModule(__filename)
13 + }
14 +
15 + function message_backlinks (msg) {
516 var links = []
617 for(var k in CACHE) {
718 var _msg = CACHE[k]
819 if(Array.isArray(_msg.content.mentions)) {
@@ -10,7 +21,19 @@
1021 if(_msg.content.mentions[i].link == msg.key)
1122 links.push(k)
1223 }
1324 }
14- return links
25 +
26 + if (links.length === 0) return null
27 +
28 + return h('MessageBacklinks', [
29 + h('header', 'backlinks:'),
30 + h('ul', links.map(function (link) {
31 + return h('li', [
32 + h('a -backlink', {
33 + href: `#${link}`
34 + }, link)
35 + ])
36 + }))
37 + ])
1538 }
1639 }
modules_basic/message.jsView
@@ -1,21 +1,20 @@
1-var fs = require('fs')
2-var Path = require('path')
3-var pull = require('pull-stream')
4-var u = require('../util')
5-var h = require('../h')
1 +const getStyleForModule = require('../get-style-for-module')
2 +const pull = require('pull-stream')
3 +const u = require('../util')
4 +const h = require('../h')
65
76 exports.needs = {
87 avatar_name: 'first',
98 avatar_link: 'first',
10- message_meta: 'map',
119 message_action: 'map',
12- message_link: 'first',
10 + message_author: 'first',
1311 message_backlinks: 'first',
14- message_author: 'first',
1512 message_content: 'first',
1613 message_content_mini: 'first',
17- message_footer: 'first'
14 + message_title: 'first',
15 + message_link: 'first',
16 + message_meta: 'map',
1817 }
1918
2019 exports.gives = {
2120 message_render: true,
@@ -24,9 +23,9 @@
2423
2524 exports.create = function (api) {
2625 return {
2726 message_render,
28- mcss: () => fs.readFileSync(Path.join(__dirname, 'message.mcss'))
27 + mcss: getStyleForModule(__filename)
2928 }
3029
3130 function message_render (msg, sbot) {
3231 var content = api.message_content_mini(msg)
@@ -41,8 +40,9 @@
4140 tabindex: '0'
4241 }
4342 }, [
4443 h('header.author', api.message_author(msg)),
44 + h('section.title', api.message_title(msg)),
4545 h('section.meta', api.message_meta(msg)),
4646 h('section.content', content),
4747 h('section.action', api.message_action(msg)),
4848 h('footer.backlinks', api.message_backlinks(msg))
modules_basic/message.mcssView
@@ -1,31 +1,48 @@
11 Message {
2- padding-top: 1em
3- padding-bottom: 1em
2 + padding: 1rem .5rem 1rem 7.5rem
43 border-top: solid 1px gainsboro
4 + min-height: 5rem
55
6- -mini {
7- padding-top: 0.25rem
8- padding-bottom: 0.25rem
6 + position: relative
7 + display: flex
8 + flex-direction: row
9 + flex-wrap: wrap
10 + justify-content: flex-end
11 +
12 + header.author {
13 + position: absolute
14 + left: .5rem
915 }
1016
11- header.author {
12- float: left
13- display: flex
14- flex-direction: column
17 + section.title {
18 + flex-grow: 1
19 + font-size: .9rem
1520 }
1621
1722 section.meta {
18- float: right
23 + display: flex
24 + a {
25 + margin-left: .2rem
26 + $text-subtle
27 + }
28 +
29 + input{
30 + margin-right: 0
31 + order: 99
32 + }
1933 }
2034
2135 section.content {
36 + flex-basis: 100%
37 +
2238 (img) {
2339 max-width: 100%
2440 }
2541 }
2642
2743 section.action {
44 + flex-basis: 100%
2845 display: flex
2946 justify-content: flex-end
3047
3148 a {
@@ -35,5 +52,27 @@
3552
3653 footer.backlinks {
3754
3855 }
56 +
57 +
58 + -mini {
59 + padding: .25rem .5rem
60 + min-height: inherit
61 +
62 + header.author {
63 + order: 0
64 + position: initial
65 + left: initial
66 + }
67 +
68 + section.content {
69 + order: 1
70 + flex-basis: initial
71 + flex-grow: 1
72 + }
73 +
74 + section.meta {
75 + order: 2
76 + }
77 + }
3978 }
modules_basic/post.jsView
@@ -11,22 +11,30 @@
1111 //
1212
1313 exports.needs = { message_link: 'first', markdown: 'first' }
1414
15-exports.gives = 'message_content'
15 +exports.gives = {
16 + message_content: true,
17 + message_title: true
18 +}
1619
1720 exports.create = function (api) {
18- return function (data) {
21 + return {
22 + message_content,
23 + message_title
24 + }
25 +
26 + function message_content (data) {
1927 if(!data.value.content || !data.value.content.text) return
2028
21- var root = data.value.content.root
22- var re = !root ? null : h('span', 're: ', api.message_link(root))
23-
2429 return h('div',
25- re,
2630 api.markdown(data.value.content)
2731 )
32 + }
2833
34 + function message_title (data) {
35 + var root = data.value.content && data.value.content.root
36 + return !root ? null : h('span', 're: ', api.message_link(root))
2937 }
3038 }
3139
3240
modules_basic/thread.jsView
@@ -120,10 +120,10 @@
120120 meta.root = thread[0].value.content.root || thread[0].key
121121 meta.channel = thread[0].value.content.channel
122122
123123 var recps = thread[0].value.content.recps
124- var private = thread[0].value.private
125- if(private) {
124 + var priv = thread[0].value['private']
125 + if(priv) {
126126 if(recps)
127127 meta.recps = recps
128128 else
129129 meta.recps = [thread[0].value.author, self_id]
modules_basic/timestamp.jsView
@@ -1,8 +1,7 @@
1-var fs = require('fs')
2-var Path = require('path')
3-var h = require('../h')
4-var human = require('human-time')
1 +const getStyleForModule = require('../get-style-for-module')
2 +const h = require('../h')
3 +const human = require('human-time')
54
65 exports.needs = {}
76
87 exports.gives = {
@@ -17,14 +16,14 @@
1716 }, 60e3)
1817
1918 return {
2019 timestamp,
21- mcss: () => fs.readFileSync(Path.join(__dirname, 'timestamp.mcss'))
20 + mcss: getStyleForModule(__filename)
2221 }
2322
2423 function updateTimestampEl (el) {
2524 var timestamp = Number(el.getAttribute('data-timestamp'))
26- var display = human(new Date(timestamp))
25 + var display = human(new Date(timestamp)).replace(/minutes/, 'mins')
2726 el.querySelector('a').firstChild.nodeValue = display
2827 return el
2928 }
3029
modules_basic/timestamp.mcssView
@@ -1,5 +1,7 @@
11 Timestamp {
22 a {
3-
3 + $text-subtle
4 + font-size: .8rem
45 }
56 }
7 +
modules_basic/message-backlinks.mcssView
@@ -1,0 +1,14 @@
1 +MessageBacklinks {
2 + header {
3 +
4 + }
5 + ul {
6 + li {
7 + a {
8 + -backlink {
9 +
10 + }
11 + }
12 + }
13 + }
14 +}
modules_core/index.jsView
@@ -7,7 +7,8 @@
77 "menu.js": require('./menu.js'),
88 "message-confirm.js": require('./message-confirm.js'),
99 "tabs.js": require('./tabs.js'),
1010 "sbot.js": require('./sbot.js'),
11 + "style-mixins.js": require('./style-mixins.js'),
1112 "styles.js": require('./styles.js')
1213 }
1314
modules_core/style-mixins.jsView
@@ -1,0 +1,22 @@
1 +
2 +const mixins = `
3 + $text-primary {
4 + color: black
5 + }
6 +
7 + $text-subtle {
8 + color: gray
9 + }
10 +`
11 +
12 +module.exports = {
13 + gives: {
14 + mcss: true
15 + },
16 + create: function (api) {
17 + return {
18 + mcss: () => mixins
19 + }
20 + }
21 +}
22 +
modules_extra/git.jsView
@@ -33,9 +33,10 @@
3333
3434 exports.gives = {
3535 message_action: true,
3636 message_meta: true,
37- message_content: true
37 + message_content: true,
38 + message_title: true
3839 }
3940
4041
4142 var self_id = require('../keys').id
@@ -301,10 +302,8 @@
301302 if(c.type === 'git-repo') {
302303 var branchesT, tagsT, openIssuesT, closedIssuesT, openPRsT, closedPRsT
303304 var forksT
304305 var div = h('div',
305- h('p', 'git repo ', repoName(msg.key)),
306- c.upstream ? h('p', 'fork of ', repoLink(c.upstream)) : '',
307306 h('p', h('code', 'ssb://' + msg.key)),
308307 h('div.git-table-wrapper', {style: {'max-height': '12em'}},
309308 h('table',
310309 branchesT = tableRows(h('tr',
@@ -409,9 +408,8 @@
409408 }
410409
411410 if(c.type === 'git-update') {
412411 return [
413- h('p', 'pushed to ', repoLink(c.repo)),
414412 c.refs ? h('ul', Object.keys(c.refs).map(function (ref) {
415413 var rev = c.refs[ref]
416414 return h('li',
417415 shortRefName(ref) + ': ',
@@ -449,25 +447,54 @@
449447 }
450448
451449 if(c.type === 'issue') {
452450 return h('div',
453- h('p', 'opened issue on ', repoLink(c.project)),
454451 c.title ? h('h4', c.title) : '',
455452 api.markdown(c)
456453 )
457454 }
458455
459456 if(c.type === 'pull-request') {
460457 return h('div',
461- h('p', 'opened pull-request ',
462- 'to ', repoLink(c.repo), ':', c.branch, ' ',
463- 'from ', repoLink(c.head_repo), ':', c.head_branch),
464458 c.title ? h('h4', c.title) : '',
465459 api.markdown(c)
466460 )
467461 }
468462 },
469463
464 + message_title: function (msg) {
465 + var c = msg.value.content
466 +
467 + if(c.type === 'git-repo') {
468 + return h('div', [
469 + h('p', 'git repo ', repoName(msg.key)),
470 + c.upstream ? h('p', 'fork of ', repoLink(c.upstream)) : ''
471 + ])
472 + }
473 +
474 + if(c.type === 'git-update') {
475 + return h('p', 'pushed to ', repoLink(c.repo))
476 + }
477 +
478 + if(c.type === 'issue-edit' || (c.type === 'post' && c.text === '')) {
479 + return h('div', [
480 + c.issue ? renderIssueEdit(c) : null,
481 + c.issues ? c.issues.map(renderIssueEdit) : null
482 + ])
483 + }
484 +
485 + if(c.type === 'issue') {
486 + return h('p', 'opened issue on ', repoLink(c.project))
487 + }
488 +
489 + if(c.type === 'pull-request') {
490 + return h('p', 'opened pull-request ', [
491 + 'to ', repoLink(c.repo), ':', c.branch, ' ',
492 + 'from ', repoLink(c.head_repo), ':', c.head_branch
493 + ])
494 + }
495 + },
496 +
470497 message_meta: function (msg, sbot) {
471498 var type = msg.value.content.type
472499 if (type === 'issue' || type === 'pull-request') {
473500 var el = h('em', '...')
@@ -515,5 +542,4 @@
515542 }
516543 }
517544 }
518545
519-
package.jsonView
@@ -12,8 +12,9 @@
1212 "brfs": "^1.4.3",
1313 "cont": "^1.0.3",
1414 "dataurl-": "^0.1.0",
1515 "depject": "^3.0.0",
16 + "es2040": "^1.2.4",
1617 "hjson": "^2.0.3",
1718 "human-time": "0.0.1",
1819 "hypercombo": "0.1.0",
1920 "hypercrop": "^1.0.1",
@@ -67,9 +68,10 @@
6768 "indexhtmlify": "^1.3.1"
6869 },
6970 "browserify": {
7071 "transform": [
71- "brfs"
72 + "brfs",
73 + "es2040"
7274 ]
7375 },
7476 "scripts": {
7577 "lite": "mkdir -p build && browserify index.js | indexhtmlify --title patchbay > build/index.html",
get-style-for-module.jsView
@@ -1,0 +1,8 @@
1 +const fs = require('fs')
2 +
3 +module.exports = (filename) => () => {
4 + const mcssPath = filename.replace(/js$/, 'mcss')
5 +
6 + return fs.readFileSync(mcssPath, 'utf8')
7 +}
8 +

Built with git-ssb-web