git ssb

30+

cel / git-ssb-web



Commit d8d91897d0c44285ae7ccb5b03126e763dc8b38b

Add protocol dropdown menu for clone url field

%WIwdx/Oi+KipNNZS+edxrfGVgjpQCyuR1v+kmZ7aI0A=.sha256
cel committed on 10/18/2016, 11:51:56 PM
Parent: 65ac73cee50224c636df9b3bf0b66f7ba991a640

Files changed

lib/repos/index.jschanged
static/styles.csschanged
lib/repos/index.jsView
@@ -181,12 +181,27 @@
181181
182182 R.renderRepoPage = function (req, repo, page, branch, titleTemplate, body) {
183183 var self = this
184184 var gitUrl = 'ssb://' + repo.id
185- var gitLink = '<input class="clone-url" readonly="readonly" ' +
186- 'value="' + gitUrl + '" size="45" ' +
187- 'onclick="this.select()"/>'
185 + var host = req.headers.host || '127.0.0.1:7718'
186 + var path = '/' + encodeURIComponent(repo.id)
187 + var httpUrl = 'http://' + encodeURI(host) + path
188188 var digsPath = [repo.id, 'digs']
189 + var cloneUrls = '<span class="clone-urls">' +
190 + '<select class="custom-dropdown clone-url-protocol" ' +
191 + 'onchange="this.nextSibling.value=this.value;this.nextSibling.select()">' +
192 + '<option selected="selected" value="' + gitUrl + '">SSB</option>' +
193 + '<option class="http-clone-url" value="' + httpUrl + '">HTTP</option>' +
194 + '</select>' +
195 + '<input class="clone-url" readonly="readonly" ' +
196 + 'value="ssb://' + repo.id + '" size="45" ' +
197 + 'onclick="this.select()"/>' +
198 + '<script>' +
199 + 'var httpOpt = document.querySelector(".http-clone-url")\n' +
200 + 'if (location.protocol === "https:") httpOpt.text = "HTTPS"\n' +
201 + 'httpOpt.value = location.origin + "' + path + '"\n' +
202 + '</script>' +
203 + '</span>'
189204
190205 var done = multicb({ pluck: 1, spread: true })
191206 self.web.getRepoName(repo.feed, repo.id, done())
192207 self.web.about.getName(repo.feed, done())
@@ -243,9 +258,9 @@
243258 [[repo.id, 'activity'], req._t('Activity'), 'activity'],
244259 [[repo.id, 'commits', branch||''], req._t('Commits'), 'commits'],
245260 [[repo.id, 'issues'], req._t('Issues'), 'issues'],
246261 [[repo.id, 'pulls'], req._t('PullRequests'), 'pulls']
247- ], page, gitLink)),
262 + ], page, cloneUrls)),
248263 body
249264 ])))
250265 })
251266 })
static/styles.cssView
@@ -220,17 +220,25 @@
220220 .name-checkbox:not(:checked) ~ .name-btn {
221221 display: none;
222222 }
223223
224 +.clone-urls {
225 + white-space: nowrap;
226 + float: right;
227 +}
228 +
229 +select.custom-dropdown.clone-url-protocol {
230 + border-radius: 0.5rem 0 0 0.5rem;
231 + width: 5rem;
232 +}
233 +
224234 .clone-url {
225- font-size: small;
226- border: none;
227- border-radius: 4px;
228- float: right;
235 + font-size: 1rem;
236 + border: 1px #e1e1e1 solid;
237 + border-radius: 0 0.5rem 0.5rem 0;
229238 margin: 0;
230- margin-top: 0.2rem;
231- padding: 0 0.4rem;
232- max-width: 50%;
239 + padding: .1rem;
240 + width: 18rem;
233241
234242 background-color: #eaeaea;
235243 color: #6f6f6f;
236244 }

Built with git-ssb-web