Skip to content

Commit 381cf40

Browse files
authored
Fix indentation and remove all spaces on otherwise empty lines
Whenever an empty line is replaced with an empty line with spaces, it will make the `git diff` views in terminals and GitHub UI cluttered. The indentation in .js files were inconsistent and this commit also fixes that.
1 parent 8c99a9d commit 381cf40

File tree

2 files changed

+39
-62
lines changed

2 files changed

+39
-62
lines changed

_static/link_gen/link.js

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ function generateRegularUrl(hubUrl, urlPath, repoUrl, branch, compressed, source
55
var url = new URL(hubUrl);
66

77
url.searchParams.set('repo', repoUrl);
8-
98
if(compressed) {
109
url.searchParams.set('content_provider', source);
1110
}
12-
1311
if (urlPath) {
1412
url.searchParams.set('urlpath', urlPath);
1513
}
@@ -19,7 +17,6 @@ function generateRegularUrl(hubUrl, urlPath, repoUrl, branch, compressed, source
1917
} else if(source == "git"){
2018
url.searchParams.set('branch', "main");
2119
}
22-
2320
if (!url.pathname.endsWith('/')) {
2421
url.pathname += '/'
2522
}
@@ -35,11 +32,9 @@ function generateCanvasUrl(hubUrl, urlPath, repoUrl, branch, compressed, source)
3532
var nextUrlParams = new URLSearchParams();
3633

3734
nextUrlParams.append('repo', repoUrl);
38-
3935
if(compressed) {
40-
nextUrlParams.append('content_provider', source);
36+
nextUrlParams.append('content_provider', source);
4137
}
42-
4338
if (urlPath) {
4439
nextUrlParams.append('urlpath', urlPath);
4540
}
@@ -71,9 +66,8 @@ function generateBinderUrl(hubUrl, userName, repoName, branch, urlPath,
7166
nextUrlParams.append('repo', contentRepoUrl);
7267

7368
if(compressed) {
74-
nextUrlParams.append('content_provider', source);
69+
nextUrlParams.append('content_provider', source);
7570
}
76-
7771
if (urlPath) {
7872
nextUrlParams.append('urlpath', urlPath);
7973
}
@@ -132,17 +126,14 @@ function changeTab(div) {
132126
var env_repo = document.getElementById("env-repo");
133127
var id = div.id;
134128
var form = document.getElementById('linkgenerator');
135-
136129
clearLinks();
137130
if (id.includes("binder")) {
138131
hub.placeholder = "https://mybinder.org";
139132
hub.value = "https://mybinder.org";
140133
hub_help_text.hidden = true;
141134
hub.labels[0].innerHTML = "BinderHub URL";
142-
143135
env_repo_group.style.display = '';
144136
env_repo.disabled = false;
145-
146137
} else {
147138
hub.placeholder = "https://hub.example.com";
148139
hub.value = "";
@@ -164,37 +155,36 @@ function changeTab(div) {
164155
*/
165156
function generateCloneDirectoryName(gitCloneUrl) {
166157
if(gitCloneUrl.slice(-1) == "/")
167-
gitCloneUrl = gitCloneUrl.slice(0,-1);
158+
gitCloneUrl = gitCloneUrl.slice(0,-1);
168159
var lastPart = gitCloneUrl.split('/').slice(-1)[0];
169160
return lastPart.split(':').slice(-1)[0].replace(/(\.git|\.bundle)?/, '');
170161
}
171162

172163
function handleSource(args){
173-
source = args["source"];
174-
branch = "";
175-
compressed = true;
176-
sourceUrl ="";
177-
if(source == "git"){
178-
sourceUrl = args["contentRepoUrl"];
179-
branch = args["contentRepoBranch"];
180-
compressed = false;
181-
} else if(source == "googledrive"){
182-
sourceUrl = args["driveUrl"];
183-
} else if(source == "dropbox"){
184-
sourceUrl = args["dropUrl"];
185-
} else if(source == "generic_web"){
186-
sourceUrl = args["webUrl"];
187-
}
188-
return {
189-
"branch": branch,
190-
"sourceUrl": sourceUrl,
191-
"compressed": compressed
192-
}
164+
source = args["source"];
165+
branch = "";
166+
compressed = true;
167+
sourceUrl ="";
168+
if(source == "git"){
169+
sourceUrl = args["contentRepoUrl"];
170+
branch = args["contentRepoBranch"];
171+
compressed = false;
172+
} else if(source == "googledrive"){
173+
sourceUrl = args["driveUrl"];
174+
} else if(source == "dropbox"){
175+
sourceUrl = args["dropUrl"];
176+
} else if(source == "generic_web"){
177+
sourceUrl = args["webUrl"];
178+
}
179+
return {
180+
"branch": branch,
181+
"sourceUrl": sourceUrl,
182+
"compressed": compressed
183+
}
193184
}
194185

195186
function displayLink() {
196187
var form = document.getElementById('linkgenerator');
197-
198188
form.classList.add('was-validated');
199189
if (form.checkValidity()) {
200190
var hubUrl = document.getElementById('hub').value;
@@ -209,13 +199,12 @@ function displayLink() {
209199
var appName = form.querySelector('input[name="app"]:checked').value;
210200
var activeTab = document.querySelector(".nav-link.active").id;
211201
var source = form.querySelector('input[name="source"]:checked').value;
212-
213202
if (appName === 'custom') {
214203
var urlPath = document.getElementById('urlpath').value;
215204
} else {
216205
var repoName = generateCloneDirectoryName(contentRepoUrl);
217206
if(source !== "git"){
218-
repoName = ""
207+
repoName = ""
219208
}
220209
var urlPath;
221210
if (activeTab === "tab-auth-binder") {
@@ -226,12 +215,12 @@ function displayLink() {
226215
}
227216
}
228217
args = {
229-
"source": source,
230-
"contentRepoUrl": contentRepoUrl,
231-
"contentRepoBranch": contentRepoBranch,
232-
"driveUrl": driveUrl,
233-
"dropUrl": dropUrl,
234-
"webUrl": webUrl
218+
"source": source,
219+
"contentRepoUrl": contentRepoUrl,
220+
"contentRepoBranch": contentRepoBranch,
221+
"driveUrl": driveUrl,
222+
"dropUrl": dropUrl,
223+
"webUrl": webUrl
235224
}
236225
config = handleSource(args)
237226
if (activeTab === "tab-auth-default") {
@@ -279,13 +268,13 @@ function populateFromQueryString() {
279268
}
280269

281270
function hideShowByClassName(cls, hideShow){
282-
[].forEach.call(document.querySelectorAll(cls), function (el) {
283-
el.style.display = hideShow;
284-
setDisabled = (hideShow == 'none')
285-
$(el).find("input").each(function(){
286-
$(this).prop("disabled", setDisabled);
271+
[].forEach.call(document.querySelectorAll(cls), function (el) {
272+
el.style.display = hideShow;
273+
setDisabled = (hideShow == 'none')
274+
$(el).find("input").each(function(){
275+
$(this).prop("disabled", setDisabled);
276+
});
287277
});
288-
});
289278
}
290279

291280

@@ -317,7 +306,6 @@ function render() {
317306
var form = document.getElementById('linkgenerator');
318307
var appName = form.querySelector('input[name="app"]:checked').value;
319308

320-
321309
if (appName == 'custom') {
322310
document.getElementById('urlpath').disabled = false;
323311
document.getElementById('filepath').disabled = true;
@@ -354,7 +342,6 @@ function main() {
354342
);
355343
}
356344
)
357-
358345
document.querySelectorAll('#linkgenerator input[type="text"], #linkgenerator input[type="url"]').forEach(
359346
function (element) {
360347
element.addEventListener('input', render);
@@ -373,7 +360,6 @@ function main() {
373360
}
374361
}
375362

376-
377363
// Do an initial render, to make sure our disabled / enabled properties are correctly set
378364
displaySource();
379365
render();

link.html

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ <h1>nbgitpuller link generator<a class="headerlink" href="#nbgitpuller-link-gene
221221
</small>
222222
</div>
223223
</div>
224-
225224
<div class="form-group row source-env" id="env-repo-group" style="display:none">
226225
<label for="env-repo" class="col-sm-2 col-form-label">Git Environment Repository URL</label>
227226
<div class="col-sm-6">
@@ -252,7 +251,6 @@ <h1>nbgitpuller link generator<a class="headerlink" href="#nbgitpuller-link-gene
252251
</div>
253252
</div>
254253
</div>
255-
256254
<div class="form-group row" id="app-source">
257255
<div class="col-sm-2 col-form-label">
258256
<label for="app" class=>Notebook Source</label>
@@ -286,9 +284,6 @@ <h1>nbgitpuller link generator<a class="headerlink" href="#nbgitpuller-link-gene
286284
</div>
287285
</div>
288286
</div>
289-
290-
291-
292287
<div class="form-group row source source-git" id="content-repo-group">
293288
<label for="content-repo" class="col-sm-2 col-form-label">Git Content Repository URL</label>
294289
<div class="col-sm-6">
@@ -305,9 +300,9 @@ <h1>nbgitpuller link generator<a class="headerlink" href="#nbgitpuller-link-gene
305300
</div>
306301
<input name="content-branch" id="content-branch" type="text" placeholder="main" aria-label="Branch Name" aria-describedby="content-branch-prepend-label">
307302
<small id="default-content-message" class="form-text text-muted">
308-
If left blank, the default branch of your repository is used. Also note, Github now names the default branch <code>main</code> instead of <code>master</code> on
309-
<a href="https://github.blog/changelog/2020-10-01-the-default-branch-for-newly-created-repositories-is-now-main/">
310-
new GitHub repositories</a>
303+
If left blank, the default branch of your repository is used. Also note, Github now names the default branch <code>main</code> instead of <code>master</code> on
304+
<a href="https://github.blog/changelog/2020-10-01-the-default-branch-for-newly-created-repositories-is-now-main/">
305+
new GitHub repositories</a>
311306
</small>
312307
</div>
313308
</div>
@@ -323,7 +318,6 @@ <h1>nbgitpuller link generator<a class="headerlink" href="#nbgitpuller-link-gene
323318
</div>
324319
</div>
325320
</div>
326-
327321
<div class="form-group row source source-dropbox">
328322
<label for="drop-url" class="col-sm-2 col-form-label">Dropbox Shared Link</label>
329323
<div class="col-sm-10">
@@ -334,7 +328,6 @@ <h1>nbgitpuller link generator<a class="headerlink" href="#nbgitpuller-link-gene
334328
</div>
335329
</div>
336330
</div>
337-
338331
<div class="form-group row source source-generic-web">
339332
<label for="generic-web-url" class="col-sm-2 col-form-label">Public URL to archive</label>
340333
<div class="col-sm-10">
@@ -345,7 +338,6 @@ <h1>nbgitpuller link generator<a class="headerlink" href="#nbgitpuller-link-gene
345338
</div>
346339
</div>
347340
</div>
348-
349341
<div class="form-group row" id="filepath-container">
350342
<label for="filepath" class="col-sm-2 col-form-label">File to open</label>
351343
<div class="col-sm-10">
@@ -356,7 +348,6 @@ <h1>nbgitpuller link generator<a class="headerlink" href="#nbgitpuller-link-gene
356348
</small>
357349
</div>
358350
</div>
359-
360351
<div class="form-group row" id="app-container">
361352
<div class="col-sm-2 col-form-label">
362353
<label for="app" class=>Application to Open</label>

0 commit comments

Comments
 (0)