git ssb

30+

cel / git-ssb-web



Commit ce71e1c407bebc7126b4f8c8176a26a153eeab35

spike into using very early pull-hyperscript

mix irving committed on 10/20/2016, 12:17:14 PM
Parent: e29d62252ebe485a58bec4fc24bb76d0913626a2

Files changed

.gitignorechanged
index.jschanged
lib/repos/index.jschanged
.gitignoreView
@@ -1,2 +1,2 @@
11 node_modules
2-
2 +npm-debug.log
index.jsView
@@ -412,8 +412,9 @@
412412 else if (err) {
413413 ended = true
414414 cb(null, self.renderError(err))
415415 } else
416 + console.log("DATA", data) // pull-hyperscript is currently outputting .. a function?
416417 cb(null, data)
417418 })
418419 }
419420 }
lib/repos/index.jsView
@@ -12,8 +12,9 @@
1212 var forms = require('../forms')
1313 var ssbRef = require('ssb-ref')
1414 var zlib = require('zlib')
1515 var toPull = require('stream-to-pull-stream')
16 +var h = require('pull-hyperscript') // NB currently only on git-ssb
1617
1718 module.exports = function (web) {
1819 return new RepoRoutes(web)
1920 }
@@ -35,25 +36,8 @@
3536 u.readObjectString(obj, cb)
3637 })
3738 }
3839
39-function table(props) {
40- return function (read) {
41- return cat([
42- pull.once('<table' + (props ? ' ' + props : '') + '>'),
43- pull(
44- read,
45- pull.map(function (row) {
46- return row ? '<tr>' + row.map(function (cell, i) {
47- return '<td>' + cell + '</td>'
48- }).join('') + '</tr>' : ''
49- })
50- ),
51- pull.once('</table>')
52- ])
53- }
54-}
55-
5640 function ul(props) {
5741 return function (read) {
5842 return cat([
5943 pull.once('<ul' + (props ? ' ' + props : '') + '>'),
@@ -504,29 +488,53 @@
504488 }).concat(last).join(' / ')
505489 }
506490
507491 function renderRepoTree(req, repo, rev, path) {
492 + var source = repo.readDir(rev,path)
508493 var pathLinks = path.length === 0 ? '' :
509494 ': ' + linkPath([repo.id, 'tree'], [rev].concat(path))
495 +
510496 return cat([
511497 pull.once(pathLinks ? '<div class="fileLocation">' + req._t('Files') + pathLinks + '</div>' : ''),
512- pull(
513- repo.readDir(rev, path),
514- pull.map(function (file) {
515- var type = (file.mode === 040000) ? 'tree' :
516- (file.mode === 0160000) ? 'commit' : 'blob'
517- if (type == 'commit')
518- return [
519- '<span title="' + req._t('gitCommitLink') + '">🖈</span>',
520- '<span title="' + u.escape(file.id) + '">' +
521- u.escape(file.name) + '</span>']
522- var filePath = [repo.id, type, rev].concat(path, file.name)
523- return ['<i>' + (type == 'tree' ? '📁' : '📄') + '</i>',
524- u.link(filePath, file.name)]
525- }),
526- table('class="files w-100"')
498 +
499 + h('table', {class: 'test'},
500 + h('tr', {}, pull(
501 + pull.values(['yes', null,'non']),
502 + pull.filter(Boolean),
503 + pull.map(val => h('td', {}, val))
504 + ))
527505 )
528506 ])
507 + // Problem here with the pull-map
508 +
509 + //h('table', {class: "files w-100"}, sourceMap(source, file =>
510 + //h('tr', [
511 + //h('td', {}, 'yes'),
512 + //h('td', {}, 'no')
513 + ////h('td', [
514 + ////h('i', fileType(file))
515 + ////]),
516 + ////h('td', [
517 + ////'cat'
518 + ////u.link(filePath(file), file.name)
519 + ////])
520 + //])
521 + //))
522 +
523 + function fileIcon(file) {
524 + return fileType(file) === 'tree' ? '📁' : '📄'
525 + }
526 +
527 + function filePath(file) {
528 + var type = fileType(file)
529 + return [repo.id, type, rev].concat(path, file.name)
530 + }
531 +
532 + function fileType(file) {
533 + if (file.mode === 040000) return 'tree'
534 + else if (file.mode === 0160000) return 'commit'
535 + else return 'blob'
536 + }
529537 }
530538
531539 /* Repo readme */
532540

Built with git-ssb-web