git ssb

30+

cel / git-ssb-web



Commit a282c43eb17a12a9a7d49e9c95560668ec1f08b7

Deprecate issue/pull-request title field

%b9wdyGH54m8uHkONgqFrMEv7/qDNlRKs5umsOh2Mm0I=.sha256
Charles Lehner committed on 7/25/2016, 11:38:08 PM
Parent: c5fd039a4f079653cc7e704ff3e7fac0cf920b7c

Files changed

index.jschanged
lib/about.jschanged
lib/repos/issues.jschanged
lib/repos/pulls.jschanged
lib/util.jschanged
locale/en.jsonchanged
locale/eo.jsonchanged
package.jsonchanged
index.jsView
@@ -292,21 +292,8 @@
292292 if (err) return cb(null, self.serveError(req, err))
293293 cb(null, self.serveRedirect(req, req.url))
294294 })
295295
296- case 'issue-title':
297- if (!data.id)
298- return cb(null, self.serveError(req,
299- new ParamError(req._t('error.MissingId')), 400))
300- if (!data.name)
301- return cb(null, self.serveError(req,
302- new ParamError(req._t('error.MissingName')), 400))
303- var msg = Issues.schemas.edit(data.id, {title: data.name})
304- return self.ssb.publish(msg, function (err) {
305- if (err) return cb(null, self.serveError(req, err))
306- cb(null, self.serveRedirect(req, req.url))
307- })
308-
309296 case 'comment':
310297 if (!data.id)
311298 return cb(null, self.serveError(req,
312299 new ParamError(req._t('error.MissingId')), 400))
@@ -325,9 +312,9 @@
325312 cb(null, self.serveRedirect(req, req.url))
326313 })
327314
328315 case 'new-issue':
329- var msg = Issues.schemas.new(dir, data.title, data.text)
316+ var msg = Issues.schemas.new(dir, data.text)
330317 var mentions = Mentions(data.text)
331318 if (mentions.length)
332319 msg.mentions = mentions
333320 return self.ssb.publish(msg, function (err, msg) {
@@ -336,9 +323,9 @@
336323 })
337324
338325 case 'new-pull':
339326 var msg = PullRequests.schemas.new(dir, data.branch,
340- data.head_repo, data.head_branch, data.title, data.text)
327+ data.head_repo, data.head_branch, data.text)
341328 var mentions = Mentions(data.text)
342329 if (mentions.length)
343330 msg.mentions = mentions
344331 return self.ssb.publish(msg, function (err, msg) {
@@ -619,9 +606,9 @@
619606 }) + '</section>')
620607 })
621608 case 'issue':
622609 case 'pull-request':
623- var issueLink = u.link([msg.key], c.title)
610+ var issueLink = u.link([msg.key], u.messageTitle(msg))
624611 return self.getMsg(c.project, function (err, projectMsg) {
625612 if (err) return cb(null,
626613 self.repos.serveRepoNotFound(req, c.repo, err))
627614 self.getRepoName(projectMsg.author, c.project,
lib/about.jsView
@@ -9,8 +9,9 @@
99
1010 var pull = require('pull-stream')
1111 var cat = require('pull-cat')
1212 var asyncMemo = require('asyncmemo')
13+var u = require('./util')
1314
1415 module.exports = function (sbot, id) {
1516 var getAbout = asyncMemo(getAboutFull, sbot, id)
1617
@@ -28,13 +29,8 @@
2829
2930 return getAbout
3031 }
3132
32-function truncate(str, len) {
33- str = String(str)
34- return str.length < len ? str : str.substr(0, len-1) + '…'
35-}
36-
3733 // Get About info (name and icon) for a feed.
3834 function getAboutFull(sbot, source, dest, cb) {
3935 var info = {}
4036 var target = dest.target || dest
@@ -77,9 +73,9 @@
7773 if (!info.image && c.image)
7874 info.image = c.image.link
7975 }, function (err) {
8076 if (err && err !== true) return cb(err)
81- if (!info.name) info.name = truncate(target, 20)
77+ if (!info.name) info.name = u.truncate(target, 20)
8278 cb(null, info)
8379 })
8480 )
8581
lib/repos/issues.jsView
@@ -88,11 +88,9 @@
8888 return this.repo.renderRepoPage(req, repo, 'issues', null, title, pull.once(
8989 '<h3>' + req._t('issue.New') + '</h3>' +
9090 '<section><form action="" method="post">' +
9191 '<input type="hidden" name="action" value="new-issue">' +
92- '<p><input class="wide-input" name="title" placeholder="' +
93- req._t('issue.Title') + '" size="77" /></p>' +
94- forms.post(req, repo, req._t('Description'), 8) +
92+ forms.post(req, repo, null, 8) +
9593 '<button type="submit" class="btn">' + req._t('Create') + '</button>' +
9694 '</form></section>'))
9795 }
9896
@@ -105,11 +103,9 @@
105103 var newestMsg = {key: issue.id, value: {timestamp: issue.created_at}}
106104 var title = u.escape(issue.title) + ' · %{author}/%{repo}'
107105 return self.repo.renderRepoPage(req, repo, 'issues', null, title, cat([
108106 pull.once(
109- forms.name(req, !self.web.isPublic, issue.id, issue.title,
110- 'issue-title', null, req._t('issue.Rename'),
111- '<h3>' + u.link([issue.id], issue.title) + '</h3>') +
107+ '<h3>' + u.link([issue.id], issue.title) + '</h3>' +
112108 '<code>' + issue.id + '</code>' +
113109 '<section class="collapse">' +
114110 (issue.open
115111 ? '<strong class="issue-status open">' +
@@ -190,13 +186,14 @@
190186 return '<section class="collapse mention-preview">' +
191187 req._t('issue.MentionedIn', {
192188 name: authorLink,
193189 type: type,
194- post: u.link([msg.key], String(c.title || msg.key).substr(0, 140))
190+ post: u.link([msg.key], u.messageTitle(msg))
195191 }) + '</section>'
196192 case 'issue-edit':
197193 return '<section class="collapse">' +
198194 (msg.key == postId ? '<div class="highlight">' : '') +
195+ // handle deprecated rename
199196 (c.title == null ? '' : req._t('issue.Renamed', {
200197 author: authorLink,
201198 type: type,
202199 name: '<q>' + u.escape(c.title) + '</q>'
lib/repos/pulls.jsView
@@ -28,11 +28,9 @@
2828 var page = path[0] || 'activity'
2929 var title = u.escape(pr.title) + ' · %{author}/%{repo}'
3030 return self.repo.renderRepoPage(req, repo, 'pulls', null, title, cat([
3131 pull.once('<div class="pull-request">' +
32- forms.name(req, !self.web.isPublic, pr.id, pr.title,
33- 'issue-title', null, req._t('pullRequest.Rename'),
34- '<h3>' + u.link([pr.id], pr.title) + '</h3>') +
32+ '<h3>' + u.link([pr.id], pr.title) + '</h3>' +
3533 '<code>' + pr.id + '</code>'),
3634 u.readOnce(function (cb) {
3735 var done = multicb({ pluck: 1, spread: true })
3836 var gotHeadRepo = done()
@@ -371,11 +369,9 @@
371369 branch: baseBranch,
372370 head_repo: headRepoId,
373371 head_branch: headBranch
374372 }) +
375- '<input class="wide-input" name="title"' +
376- ' placeholder="' + req._t('Title') + '" size="77"/>' +
377- forms.post(req, repo, req._t('Description'), 8) +
373+ forms.post(req, repo, null, 8) +
378374 '<button type="submit" class="btn open">' +
379375 req._t('Create') + '</button>' +
380376 '</form></section>'
381377 : self.web.isPublic ? ''
lib/util.jsView
@@ -148,4 +148,14 @@
148148
149149 u.sortMsgs = function (descending) {
150150 return u.pullSort(compareMsgs, descending)
151151 }
152+
153+u.truncate = function (str, len) {
154+ str = String(str)
155+ return str.length < len ? str : str.substr(0, len) + '…'
156+}
157+
158+u.messageTitle = function (msg) {
159+ var c = msg.value.content
160+ return u.truncate(c.title || c.text || msg.key, 40)
161+}
locale/en.jsonView
@@ -115,11 +115,8 @@
115115 "Open": "Open",
116116 "Closed": "Closed"
117117 },
118118 "New": "New Issue",
119- "Title": "Issue Title",
120- "Description": "Description",
121- "Rename": "Rename the issue",
122119 "Opened": "%{name} opened this issue on %{datetime}",
123120 "Reopened": "%{name} reopened this %{type}",
124121 "Closed": "%{name} closed this %{type}",
125122 "Mentioned": "%{name} mentioned this %{type}",
@@ -129,9 +126,8 @@
129126 "Close": "Close %{type}",
130127 "Reopen": "Reopen %{type}"
131128 },
132129 "pullRequest": {
133- "Rename": "Rename the pull request",
134130 "WantToMerge": "%{name} wants to merge commits into %{base} from %{head}",
135131 "Discussion": "Discussion",
136132 "New": "New Pull Request"
137133 },
locale/eo.jsonView
@@ -115,11 +115,8 @@
115115 "Open": "Malfermita",
116116 "Closed": "Fermita"
117117 },
118118 "New": "Nova Temo",
119- "Title": "Temo titolo",
120- "Description": "Priskribo",
121- "Rename": "Renomiĝi la temon",
122119 "Opened": "%{name} malfermis tiun temon je %{datetime}",
123120 "Reopened": "%{name} remalfermis tiun %{type}",
124121 "Closed": "%{name} fermis tiun %{type}",
125122 "Mentioned": "%{name} menciis tiun %{type}",
@@ -129,9 +126,8 @@
129126 "Close": "Fermi %{type}",
130127 "Reopen": "Remalfermi %{type}"
131128 },
132129 "pullRequest": {
133- "Rename": "Alinomigado el tiro-petojn",
134130 "WantToMerge": "%{name} volas kunfandi enmetoj en %{base} de %{head}",
135131 "Discussion": "Priparolado",
136132 "New": "Nova Tiro-peto"
137133 },
package.jsonView
@@ -19,14 +19,14 @@
1919 "pull-stream": "^3.1.0",
2020 "ssb-client": "^3.0.1",
2121 "ssb-config": "^1.1.0",
2222 "ssb-git-repo": "^1.8.0",
23- "ssb-issues": "^0.1.4",
23+ "ssb-issues": "^0.2.0",
2424 "ssb-keys": "^5.0.0",
2525 "ssb-marked": "^0.6.0",
2626 "ssb-mentions": "^0.1.0",
2727 "ssb-msg-schemas": "^6.1.0",
28- "ssb-pull-requests": "^0.0.4",
28+ "ssb-pull-requests": "^0.1.0",
2929 "ssb-reconnect": "^0.1.0",
3030 "ssb-ref": "^2.2.2",
3131 "stream-to-pull-stream": "^1.7.0"
3232 },

Built with git-ssb-web