git ssb

30+

cel / git-ssb-web



Commit 41e9c1702169d2597b0cda1ca9ef3a452a5aa644

Merge branch 'master' of ssb://%q5d5Du+9WkaSdjc8aJPZm+jMrqgo0tmfR+RcX5ZZ6H4=.sha256 into wordwrap

Ev Bogue committed on 10/25/2016, 8:50:19 PM
Parent: 5111c03432c4d3cfbe1656cb4ebafb6585a821af
Parent: 5da7f6c737d6456f6e702d4a2fa0bee6b9217a5c

Files changed

.gitignorechanged
lib/repos/index.jschanged
lib/util.jschanged
package.jsonchanged
.gitignoreView
@@ -1,2 +1,2 @@
11 node_modules
2-
2 +npm-debug.log
lib/repos/index.jsView
@@ -1,6 +1,7 @@
11 var url = require('url')
22 var pull = require('pull-stream')
3 +var once = pull.once
34 var cat = require('pull-cat')
45 var paramap = require('pull-paramap')
56 var multicb = require('multicb')
67 var JsDiff = require('diff')
@@ -12,8 +13,9 @@
1213 var forms = require('../forms')
1314 var ssbRef = require('ssb-ref')
1415 var zlib = require('zlib')
1516 var toPull = require('stream-to-pull-stream')
17 +var h = require('pull-hyperscript')
1618
1719 module.exports = function (web) {
1820 return new RepoRoutes(web)
1921 }
@@ -35,25 +37,8 @@
3537 u.readObjectString(obj, cb)
3638 })
3739 }
3840
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-
5641 function ul(props) {
5742 return function (read) {
5843 return cat([
5944 pull.once('<ul' + (props ? ' ' + props : '') + '>'),
@@ -504,29 +489,44 @@
504489 }).concat(last).join(' / ')
505490 }
506491
507492 function renderRepoTree(req, repo, rev, path) {
493 + var source = repo.readDir(rev,path)
508494 var pathLinks = path.length === 0 ? '' :
509495 ': ' + linkPath([repo.id, 'tree'], [rev].concat(path))
496 +
497 + var location = once('')
498 + if (path.length !== 0) {
499 + var link = linkPath([repo.id, 'tree'], [rev].concat(path))
500 + location = h('div', {class: 'fileLocation'}, `${req._t('Files')}: ${link}`)
501 + }
502 +
510503 return cat([
511- 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"')
527- )
504 + location,
505 + h('table', {class: "files w-100"}, u.sourceMap(source, file =>
506 + h('tr', [
507 + h('td', [
508 + h('i', fileIcon(file))
509 + ]),
510 + h('td', u.link(filePath(file), file.name))
511 + ])
512 + ))
528513 ])
514 +
515 + function fileIcon(file) {
516 + return fileType(file) === 'tree' ? '📁' : '📄'
517 + }
518 +
519 + function filePath(file) {
520 + var type = fileType(file)
521 + return [repo.id, type, rev].concat(path, file.name)
522 + }
523 +
524 + function fileType(file) {
525 + if (file.mode === 040000) return 'tree'
526 + else if (file.mode === 0160000) return 'commit'
527 + else return 'blob'
528 + }
529529 }
530530
531531 /* Repo readme */
532532
@@ -644,42 +644,46 @@
644644 var id = treeIds[0]
645645 var lastI = treeIds.length - 1
646646 var oldTree = treeIds[0]
647647 var changedFiles = []
648 + var source = GitRepo.diffTrees(repos, treeIds, true)
649 +
648650 return cat([
651 + h('table', u.sourceMap(source, item => {
652 + var filename = u.escape(item.filename = item.path.join('/'))
653 + var oldId = item.id && item.id[0]
654 + var newId = item.id && item.id[lastI]
655 + var oldMode = item.mode && item.mode[0]
656 + var newMode = item.mode && item.mode[lastI]
657 + var action =
658 + !oldId && newId ? req._t('action.added') :
659 + oldId && !newId ? req._t('action.deleted') :
660 + oldMode != newMode ? req._t('action.changedMode', {
661 + old: oldMode.toString(8),
662 + new: newMode.toString(8)
663 + }) : req._t('changed')
664 + if (item.id)
665 + changedFiles.push(item)
666 + var blobsPath = item.id[1]
667 + ? [repos[1].id, 'blob', treeIds[1]]
668 + : [repos[0].id, 'blob', treeIds[0]]
669 + var rawsPath = item.id[1]
670 + ? [repos[1].id, 'raw', treeIds[1]]
671 + : [repos[0].id, 'raw', treeIds[0]]
672 + item.blobPath = blobsPath.concat(item.path)
673 + item.rawPath = rawsPath.concat(item.path)
674 + var fileHref = item.id ?
675 + '#' + encodeURIComponent(item.path.join('/')) :
676 + u.encodeLink(item.blobPath)
677 +
678 + return h('tr', [
679 + h('td', [
680 + h('a', {href: fileHref}, filename)
681 + ]),
682 + h('td', action)
683 + ])
684 + })),
649685 pull(
650- GitRepo.diffTrees(repos, treeIds, true),
651- pull.map(function (item) {
652- var filename = u.escape(item.filename = item.path.join('/'))
653- var oldId = item.id && item.id[0]
654- var newId = item.id && item.id[lastI]
655- var oldMode = item.mode && item.mode[0]
656- var newMode = item.mode && item.mode[lastI]
657- var action =
658- !oldId && newId ? req._t('action.added') :
659- oldId && !newId ? req._t('action.deleted') :
660- oldMode != newMode ? req._t('action.changedMode', {
661- old: oldMode.toString(8),
662- new: newMode.toString(8)
663- }) : req._t('changed')
664- if (item.id)
665- changedFiles.push(item)
666- var blobsPath = item.id[1]
667- ? [repos[1].id, 'blob', treeIds[1]]
668- : [repos[0].id, 'blob', treeIds[0]]
669- var rawsPath = item.id[1]
670- ? [repos[1].id, 'raw', treeIds[1]]
671- : [repos[0].id, 'raw', treeIds[0]]
672- item.blobPath = blobsPath.concat(item.path)
673- item.rawPath = rawsPath.concat(item.path)
674- var fileHref = item.id ?
675- '#' + encodeURIComponent(item.path.join('/')) :
676- u.encodeLink(item.blobPath)
677- return ['<a href="' + fileHref + '">' + filename + '</a>', action]
678- }),
679- table()
680- ),
681- pull(
682686 pull.values(changedFiles),
683687 paramap(function (item, cb) {
684688 var extension = u.getExtension(item.filename)
685689 if (extension in u.imgMimes) {
lib/util.jsView
@@ -1,6 +1,5 @@
11 var pull = require('pull-stream')
2-var catMap = require('pull-cat-map')
32 var paramap = require('pull-paramap')
43 var Highlight = require('highlight.js')
54 var u = exports
65
@@ -40,8 +39,17 @@
4039 })
4140 }
4241 }
4342
43 +u.sourceMap = function sourceMap (source, fn) {
44 + return pull(
45 + source,
46 + pull.filter(Boolean),
47 + pull.map(fn),
48 + pull.flatten()
49 + )
50 +}
51 +
4452 u.escape = function (str) {
4553 return String(str)
4654 .replace(/&/g, '&amp;')
4755 .replace(/</g, '&lt;')
package.jsonView
@@ -1,7 +1,7 @@
11 {
22 "name": "git-ssb-web",
3- "version": "2.2.1",
3 + "version": "2.3.2",
44 "description": "web server for browsing git repos on ssb",
55 "bin": "server.js",
66 "dependencies": {
77 "asyncmemo": "^0.1.0",
@@ -12,16 +12,17 @@
1212 "multicb": "^1.2.1",
1313 "node-polyglot": "^1.0.0",
1414 "pull-cat": "^1.1.8",
1515 "pull-git-pack": "^0.2.0",
16- "pull-git-repo": "^0.6.0",
16 + "pull-git-repo": "^0.6.1",
17 + "pull-hyperscript": "^0.0.4",
1718 "pull-identify-filetype": "^1.1.0",
1819 "pull-many": "^1.0.6",
1920 "pull-paramap": "^1.1.6",
2021 "pull-stream": "^3.1.0",
2122 "ssb-client": "^4.2.1",
2223 "ssb-config": "^2.1.1",
23- "ssb-git-repo": "^2.1.1",
24 + "ssb-git-repo": "^2.3.0",
2425 "ssb-issues": "^0.2.0",
2526 "ssb-keys": "^6.1.1",
2627 "ssb-marked": "^0.6.0",
2728 "ssb-mentions": "^0.1.0",
@@ -30,16 +31,14 @@
3031 "ssb-reconnect": "^0.1.0",
3132 "ssb-ref": "^2.6.1",
3233 "stream-to-pull-stream": "^1.7.2"
3334 },
34- "homepage": "http://git-ssb.celehner.com/%25q5d5Du%2B9WkaSdjc8aJPZm%2BjMrqgo0tmfR%2BRcX5ZZ6H4%3D.sha256",
35 + "homepage": "https://git-ssb.celehner.com/%25q5d5Du%2B9WkaSdjc8aJPZm%2BjMrqgo0tmfR%2BRcX5ZZ6H4%3D.sha256",
36 + "bugs": "https://git-ssb.celehner.com/%25q5d5Du%2B9WkaSdjc8aJPZm%2BjMrqgo0tmfR%2BRcX5ZZ6H4%3D.sha256/issues",
3537 "repository": {
3638 "type": "git",
37- "url": "https://github.com/clehner/git-ssb-web"
39 + "url": "https://git-ssb.celehner.com/%25q5d5Du%2B9WkaSdjc8aJPZm%2BjMrqgo0tmfR%2BRcX5ZZ6H4%3D.sha256"
3840 },
3941 "keywords": [],
40- "author": "Charles Lehner (http://celehner.com/)",
41- "license": "Fair",
42- "bugs": {
43- "url": "https://github.com/clehner/git-ssb-web/issues"
44- }
42 + "author": "Charles Lehner (https://celehner.com/)",
43 + "license": "Fair"
4544 }

Built with git-ssb-web