git ssb

30+

cel / git-ssb-web



Commit 6839527655b266fe0e7ea9e840a892514428e492

Add repo fork button

Charles Lehner committed on 4/4/2016, 10:43:54 PM
Parent: ffa2c61fc246f99bb8e6115e732fbce4bfdd80d4

Files changed

index.jschanged
index.jsView
@@ -509,18 +509,33 @@
509509 if (err) return cb(null, serveError(err, 400))
510510 if (!data) return cb(null, serveError(new Error('No data'), 400))
511511
512512 switch (data.action) {
513+ case 'repo':
514+ if (data.fork != null) {
515+ var repoId = data.id
516+ if (!repoId) return cb(null,
517+ serveError(new Error('Missing repo id'), 400))
518+ ssbGit.createRepo(ssb, {upstream: repoId},
519+ function (err, repo) {
520+ if (err) return cb(null, serveError(err))
521+ cb(null, serveRedirect(encodeLink(repo.id)))
522+ })
523+ } else if (data.vote != null) {
524+ // fallthrough
525+ } else {
526+ return cb(null, serveError(new Error('Unknown action'), 400))
527+ }
528+
513529 case 'vote':
514- var voteValue = +data.vote || 0
530+ var voteValue = +data.value || 0
515531 if (!data.id)
516532 return cb(null, serveError(new Error('Missing vote id'), 400))
517533 var msg = schemas.vote(data.id, voteValue)
518534 return ssb.publish(msg, function (err) {
519535 if (err) return cb(null, serveError(err))
520536 cb(null, serveRedirect(req.url))
521537 })
522- return
523538
524539 case 'repo-name':
525540 if (!data.name)
526541 return cb(null, serveError(new Error('Missing name'), 400))
@@ -1039,14 +1054,18 @@
10391054 '<button class="btn" ' +
10401055 (isPublic ? 'disabled="disabled"' : ' type="submit"') + '>' +
10411056 '<i>โœŒ</i> ' + (!isPublic && upvoted ? 'Undig' : 'Dig') +
10421057 '</button>' +
1043- (isPublic ? '' : '<input type="hidden" name="vote" value="' +
1058+ (isPublic ? '' : '<input type="hidden" name="value" value="' +
10441059 (upvoted ? '0' : '1') + '">' +
1045- '<input type="hidden" name="action" value="vote">' +
1060+ '<input type="hidden" name="action" value="repo">' +
10461061 '<input type="hidden" name="id" value="' +
10471062 escapeHTML(repo.id) + '">') + ' ' +
1048- '<strong>' + link(digsPath, votes.upvotes) + '</strong>' +
1063+ '<strong>' + link(digsPath, votes.upvotes) + '</strong> ' +
1064+ (isPublic ? '' :
1065+ '<button class="btn" type="submit" name="fork">' +
1066+ '<i>โ‘‚</i> Fork' +
1067+ '</button>') +
10491068 '</form>' +
10501069 renderNameForm(!isPublic, repo.id, repoName, 'repo-name', null,
10511070 'Rename the repo',
10521071 '<h2>' + link([repo.feed], authorName) + ' / ' +

Built with git-ssb-web