Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional url property to a dependency #347

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class Dependency extends MetadataElement {

String repository

List<Link> links = []

@JsonInclude(JsonInclude.Include.NON_DEFAULT)
int weight

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.spring.initializr.metadata

/**
* @author Dave Syer
*
*/
class Link {

String id

URL url

String description

}
4 changes: 4 additions & 0 deletions initializr-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ initializr:
content:
- name: Web
id: web
links:
- id: rest-guide
url: https://spring.io/guides/gs/rest-service/
description: 'Guide: getting started building a REST service'
description: Full-stack web development with Tomcat and Spring MVC
weight: 100
facets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class DependencyMetadataV21JsonMapper implements DependencyMetadataJsonMapper {
if (dep.repository) {
result.repository = dep.repository
}
if (dep.links) {
result.links = dep.links
}
result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class InitializrMetadataV21JsonMapper extends InitializrMetadataV2JsonMapper {
if (dependency.versionRange) {
content['versionRange'] = dependency.versionRange
}
if (dependency.links) {
content.links = dependency.links
}
content
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ class UiController {
if (d.description) {
result.description = d.description
}
if (d.links) {
result.url = d.links[0].url
result.links = d.links
}
if (d.weight) {
result.weight = d.weight
}
Expand Down
16 changes: 4 additions & 12 deletions initializr-web/src/main/resources/static/css/bootstrap-theme.min.css
100755 → 100644

Large diffs are not rendered by default.

16 changes: 4 additions & 12 deletions initializr-web/src/main/resources/static/css/bootstrap.min.css
100755 → 100644

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions initializr-web/src/main/resources/static/css/spring.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ input[type=text] {
margin-left: 0.2em;
}

.tag a {
color: #ffffff;
}

.advanced {
margin: 1em 0;
}
Expand All @@ -76,6 +80,12 @@ input[type=text] {
display: block;
}

.external-links {
padding: 0;
}
.external-links li {
list-style-type: none;
}
/* autocomplete */

#autocomplete, .twitter-typeahead, .tt-hint {
Expand Down
9 changes: 5 additions & 4 deletions initializr-web/src/main/resources/static/js/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@ $(function () {
}
});
};
var addTag = function (id, name) {
var addTag = function (id, name, url) {
if ($("#starters div[data-id='" + id + "']").length == 0) {
$("#starters").append("<div class='tag' data-id='" + id + "'>" + name +
var link = url ? "<a href='" + url + "'>" + name + "</a>" : name;
$("#starters").append("<div class='tag' data-id='" + id + "'>" + link +
"<button type='button' class='close' aria-label='Close'><span aria-hidden='true'>&times;</span></button></div>");
}
};
Expand Down Expand Up @@ -225,7 +226,7 @@ $(function () {
$("#dependencies input[value='" + suggestion.id + "']").prop('checked', false);
}
else {
addTag(suggestion.id, suggestion.name);
addTag(suggestion.id, suggestion.name, suggestion.url);
$("#dependencies input[value='" + suggestion.id + "']").prop('checked', true);
}
$('#autocomplete').typeahead('val', '');
Expand All @@ -245,7 +246,7 @@ $(function () {
var value = $(this).val()
if ($(this).prop('checked')) {
var results = starters.get(value);
addTag(results[0].id, results[0].name);
addTag(results[0].id, results[0].name, results[0].url);
} else {
removeTag(value);
}
Expand Down
7 changes: 7 additions & 0 deletions initializr-web/src/main/resources/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ <h3>${it.name}</h3>
<label>
<input tabindex="13" type="checkbox" name="style" value="${it.id}">${it.name}
<p class="help-block">${it.description}</p>
<% if (it.links) { %>
<ul class="external-links"><% it.links.each { %>
<li><a href="${it.url}">
<span class="glyphicon glyphicon-link" aria-hidden="true"></span>
${it.description?:it.url}</a></li>
<% } %></ul>
<% } %>
<% if (it.versionRequirement) { %>
<p class="help-block version-requirement">requires Spring Boot ${it.versionRequirement}</p>
<% } %>
Expand Down