Skip to content

Commit 5dd4433

Browse files
committed
Change front end to support directory URLs
1 parent 326f60e commit 5dd4433

File tree

3 files changed

+72
-16
lines changed

3 files changed

+72
-16
lines changed

src/main/resources/static/js/main.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
requirejs.config({
2424
baseUrl: '/bower_components',
2525
paths: {
26-
'jquery': 'jquery/dist/jquery.min',
26+
'jquery': 'jquery/dist/jquery.min'
2727
}
2828
});
2929

@@ -43,7 +43,7 @@ require(['jquery'],
4343
*/
4444
require(['jquery'],
4545
function ($) {
46-
var generalPattern = "\\/([A-Za-z0-9_.-]+)\\/([A-Za-z0-9_.-]+)\\/?(?:tree|blob)\\/([^/]+)(?:\\/(.+\\.cwl))$";
46+
var generalPattern = "\\/([A-Za-z0-9_.-]+)\\/([A-Za-z0-9_.-]+)\\/?(?:(?:tree|blob)\\/([^/]+)\\/?(.*)?)?$";
4747
var githubPattern = new RegExp("^https?:\\/\\/github\\.com" + generalPattern);
4848
var gitlabPattern = new RegExp("^https?:\\/\\/gitlab\\.com" + generalPattern);
4949
var gitPattern = new RegExp("^((git|ssh|http(s)?)|(git@[\\w\\.]+))(:(//)?)([\\w\\.@\\:/\\-~]+)(\\.git)(/)?$");
@@ -76,24 +76,25 @@ require(['jquery'],
7676
* Validate form before submit
7777
*/
7878
$('#add').submit(function() {
79-
var pathPattern = new RegExp("^\\/?([^\\/]*\\/)*[^\\/]+\\.cwl$");
8079
var input = $("#url").val();
8180
if (gitPattern.test(input)) {
82-
var success = true;
83-
if (!$("#branch").val()) {
84-
addWarning("branch", "You must provide a branch name for the workflow");
85-
success = false;
86-
}
87-
if (!$("#path").val()) {
88-
addWarning("path", "You must provide a path to the workflow");
89-
success = false;
90-
} else if (!pathPattern.test($("#path").val())) {
91-
addWarning("path", "Must be a valid path from the root to a .cwl workflow");
92-
success = false;
81+
var success = false;
82+
if (input.startsWith("ssh") || input.startsWith("git@")) {
83+
addWarning("url", "SSH is not supported as a protocol, please provide a HTTPS URL to clone");
84+
} else {
85+
success = true;
86+
if (!$("#branch").val()) {
87+
addWarning("branch", "You must provide a branch name for the workflow");
88+
success = false;
89+
}
90+
if (!$("#path").val()) {
91+
addWarning("path", "You must provide a path to the workflow or a directory of workflows");
92+
success = false;
93+
}
9394
}
9495
return success;
9596
} else if (!githubPattern.test(input) && !gitlabPattern.test(input)) {
96-
addWarning("url", "Must be a URL to a workflow on Gitlab or Github, or a Git repository URL");
97+
addWarning("url", "Must be a URL to a workflow or directory of workflows on Gitlab or Github, or a Git repository URL");
9798
return false;
9899
}
99100
});

src/main/resources/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h1>Common Workflow Language Viewer</h1>
4848
<hr/>
4949

5050
<h2>Workflow URL</h2>
51-
<p>Provide a Github, Gitlab or Git repository link to the workflow here</p>
51+
<p>Provide a Github, Gitlab or Git repository link to the workflow (or directory of workflows) here</p>
5252
<div class="alert alert-grey">
5353
<strong>Don't know what to view?</strong> Try these from <i>common-workflow-language/workflows</i>:
5454
<a class="example" href="https://github.com/common-workflow-language/workflows/tree/master/workflows/compile/compile1.cwl">compile</a>,
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing,
14+
~ software distributed under the License is distributed on an
15+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
~ KIND, either express or implied. See the License for the
17+
~ specific language governing permissions and limitations
18+
~ under the License.
19+
-->
20+
21+
<html xmlns:th="http://www.thymeleaf.org">
22+
<head>
23+
<meta charset="UTF-8" />
24+
<meta name="viewport" content="width=device-width, initial-scale=1" />
25+
<title>Common Workflow Language Viewer</title>
26+
<link rel="stylesheet" type="text/css" th:href="@{/css/main-20170616.css}" href="../static/css/main-20170616.css" />
27+
<link rel="stylesheet" th:href="@{/bower_components/bootstrap/dist/css/bootstrap.min.css}" href="../static/bower_components/bootstrap/dist/css/bootstrap.min.css" />
28+
</head>
29+
<body>
30+
31+
<nav th:replace="fragments/header :: navbar"></nav>
32+
33+
<div class="container">
34+
<div class="row">
35+
<div class="col-md-12" role="main" id="main">
36+
<h1 th:text="'Choose Workflow from ' + ${gitDetails.path}">Choose Workflow</h1>
37+
<div class="alert alert-info">
38+
<p>Multiple CWL files were found, please select the workflow you would like to view below</p>
39+
</div>
40+
<div class="list-group">
41+
<a href="#" class="list-group-item" th:each="workflowOverview : ${workflowOverviews}" th:href="@{${gitDetails.getInternalUrl()} + '/' + ${workflowOverview.fileName}}">
42+
<h4 class="list-group-item-heading" th:text="${workflowOverview.fileName}">ExampleWorkflow.cwl</h4>
43+
<p class="list-group-item-text">
44+
<span th:if="${workflowOverview.label != null}" th:text="${workflowOverview.label}">Label</span>
45+
<i th:if="${workflowOverview.doc != null}" th:text="' - ' + ${workflowOverview.doc}">Doc</i>
46+
</p>
47+
</a>
48+
</div>
49+
</div>
50+
</div>
51+
</div>
52+
53+
<div th:replace="fragments/footer :: copy"></div>
54+
</body>
55+
</html>

0 commit comments

Comments
 (0)