git ssb

30+

cel / git-ssb-web



Commit 938ec32c4cb0a8be01d3db6338e3fd585eb1b3ff

Sort items in rev menu

Prevent items from getting mixed up and the same group appearing more than once
Charles Lehner committed on 3/27/2016, 5:01:35 PM
Parent: d5e0970d64c9af2207d041e9b6c2196ce7ec2fe9

Files changed

index.jschanged
package.jsonchanged
index.jsView
@@ -286,13 +286,8 @@
286286 'git-update': true,
287287 'issue': true
288288 }
289289
290-var refLabels = {
291- heads: 'Branches',
292- tags: 'Tags'
293-}
294-
295290 var imgMimes = {
296291 png: 'image/png',
297292 jpeg: 'image/jpeg',
298293 jpg: 'image/jpeg',
@@ -923,35 +918,24 @@
923918
924919 /* Repo tree */
925920
926921 function revMenu(repo, currentName) {
927- var currentGroup
928- return cat([
929- pull.once('<select name="rev" onchange="this.form.submit()">'),
930- pull(
931- repo.refs(),
932- pull.map(function (ref) {
933- var m = ref.name.match(/^refs\/([^\/]*)\/(.*)$/) || [,, ref.name]
934- var group = m[1]
935- var name = m[2]
936-
937- var optgroup = (group === currentGroup) ? '' :
938- (currentGroup ? '</optgroup>' : '') +
939- '<optgroup label="' + (refLabels[group] || group) + '">'
940- currentGroup = group
941- var selected = (name == currentName) ? ' selected="selected"' : ''
942- var htmlName = escapeHTML(name)
943- return optgroup +
944- '<option value="' + htmlName + '"' + selected + '>' +
945- htmlName + '</option>'
946- })
947- ),
948- readOnce(function (cb) {
949- cb(null, currentGroup ? '</optgroup>' : '')
950- }),
951- pull.once('</select> ' +
952- '<noscript><input type="submit" value="Go" /></noscript>')
953- ])
922+ return readOnce(function (cb) {
923+ repo.getRefNames(true, function (err, refs) {
924+ if (err) return cb(err)
925+ cb(null, '<select name="rev" onchange="this.form.submit()">' +
926+ Object.keys(refs).map(function (group) {
927+ return '<optgroup label="' + group + '">' +
928+ refs[group].map(function (name) {
929+ var htmlName = escapeHTML(name)
930+ return '<option value="' + htmlName + '"' +
931+ (name == currentName ? ' selected="selected"' : '') +
932+ '>' + htmlName + '</option>'
933+ }).join('') + '</optgroup>'
934+ }).join('') +
935+ '</select><noscript> <input type="submit" value="Go"/></noscript>')
936+ })
937+ })
954938 }
955939
956940 function renderRepoLatest(repo, rev) {
957941 return readOnce(function (cb) {
package.jsonView
@@ -6,9 +6,9 @@
66 "dependencies": {
77 "asyncmemo": "^0.1.0",
88 "multicb": "^1.2.1",
99 "pull-cat": "^1.1.8",
10- "pull-git-repo": "^0.2.2",
10+ "pull-git-repo": "^0.2.5",
1111 "pull-paramap": "^1.1.2",
1212 "pull-stream": "^3.1.0",
1313 "ssb-client": "^3.0.1",
1414 "ssb-config": "^1.1.0",

Built with git-ssb-web