mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-25 10:59:03 +00:00
Display repository if required in quickstart maven snippet widget
[#52044647]
This commit is contained in:
@@ -34,13 +34,19 @@
|
||||
</select>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="project-quickstart-maven-widget-template">
|
||||
<pre>
|
||||
<dependency>
|
||||
<script type="text/html" id="project-quickstart-maven-widget-dependency-template"><dependency>
|
||||
<groupId><%= groupId %></groupId>
|
||||
<artifactId><%= artifactId %></artifactId>
|
||||
<version><%= fullName %></version>
|
||||
</dependency>
|
||||
</pre>
|
||||
|
||||
</script>
|
||||
<script type="text/html" id="project-quickstart-maven-widget-repository-template">
|
||||
<repository>
|
||||
<id><%= id %></id>
|
||||
<name><%= name %></name>
|
||||
<url><%= url %></url>
|
||||
<snapshots>
|
||||
<enabled><%= snapshotsEnabled %></enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</script>
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
---
|
||||
|
||||
{{ content }}
|
||||
Vendored
-6
File diff suppressed because one or more lines are too long
@@ -2,34 +2,43 @@ window.Spring = window.Spring || {};
|
||||
|
||||
Spring.ProjectDocumentationWidget = function() {
|
||||
var quickStartEl = $('.js-quickstart-selector');
|
||||
var mavenWidgetEl = $('.js-quickstart-maven-widget');
|
||||
var documentationEl = $('.js-documentation-widget');
|
||||
|
||||
var projectUrl = apiBaseUrl + "/project_metadata/" + projectId;
|
||||
var promise = Spring.loadProject(projectUrl);
|
||||
|
||||
promise.then(function(project) {
|
||||
new Spring.WidgetView({
|
||||
el: documentationEl,
|
||||
model: project,
|
||||
template: $("#project-documentation-widget-template").text()
|
||||
}).render();
|
||||
|
||||
var mavenWidget = new Spring.WidgetView({
|
||||
el: $('.js-quickstart-maven-widget'),
|
||||
model: project.releases[0],
|
||||
template: $("#project-quickstart-maven-widget-template").text()
|
||||
}).render();
|
||||
|
||||
new Spring.QuickStartSelectorView({
|
||||
el: quickStartEl,
|
||||
model: project,
|
||||
template: $("#project-quickstart-selector-template").text(),
|
||||
mavenWidget: mavenWidget
|
||||
}).render();
|
||||
|
||||
Spring.buildDocumentationWidget(documentationEl, project);
|
||||
Spring.buildQuickStartWidget(quickStartEl, mavenWidgetEl, project);
|
||||
});
|
||||
};
|
||||
|
||||
Spring.buildDocumentationWidget = function(documentationEl, project) {
|
||||
new Spring.DocumentationWidgetView({
|
||||
el: documentationEl,
|
||||
model: project,
|
||||
template: $("#project-documentation-widget-template").text()
|
||||
}).render();
|
||||
|
||||
}
|
||||
Spring.buildQuickStartWidget = function(quickStartEl, mavenWidgetEl, project) {
|
||||
var mavenWidget = new Spring.MavenSnippetView({
|
||||
el: mavenWidgetEl,
|
||||
model: project.releases[0],
|
||||
dependencyTemplate: $("#project-quickstart-maven-widget-dependency-template").text(),
|
||||
repositoryTemplate: $("#project-quickstart-maven-widget-repository-template").text()
|
||||
}).render();
|
||||
|
||||
new Spring.QuickStartSelectorView({
|
||||
el: quickStartEl,
|
||||
model: project,
|
||||
template: $("#project-quickstart-selector-template").text(),
|
||||
mavenWidget: mavenWidget
|
||||
}).render();
|
||||
|
||||
}
|
||||
|
||||
Spring.loadProject = function(url) {
|
||||
return $.ajax(url, {
|
||||
dataType: 'jsonp',
|
||||
@@ -65,7 +74,7 @@ Spring.Project = function(data) {
|
||||
return this;
|
||||
};
|
||||
|
||||
Spring.WidgetView = Backbone.View.extend({
|
||||
Spring.DocumentationWidgetView = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
this.template = _.template(this.options.template);
|
||||
_.bindAll(this, "render");
|
||||
@@ -77,7 +86,24 @@ Spring.WidgetView = Backbone.View.extend({
|
||||
);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
Spring.MavenSnippetView = Backbone.View.extend({
|
||||
initialize: function() {
|
||||
this.dependencyTemplate = _.template(this.options.dependencyTemplate);
|
||||
this.repositoryTemplate = _.template(this.options.repositoryTemplate);
|
||||
_.bindAll(this, "render");
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var html = $("<pre></pre>");
|
||||
html.append(this.dependencyTemplate(this.model));
|
||||
if (this.model.repository != null) {
|
||||
html.append(this.repositoryTemplate(this.model.repository));
|
||||
}
|
||||
this.$el.html(html);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
Spring.QuickStartSelectorView = Backbone.View.extend({
|
||||
|
||||
+10
-1
@@ -1,3 +1,8 @@
|
||||
---
|
||||
layout: empty
|
||||
title: Your Project Name Here
|
||||
---
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
@@ -16,10 +21,14 @@
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="../underscore.js"></script>
|
||||
<script type="text/javascript" src="../backbone.js"></script>
|
||||
<script type="text/javascript" src="../../bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="../../bootstrap/js/bootstrap-select.js"></script>
|
||||
<script type="text/javascript" src="../projectDocumentationWidget.js"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="spec/ProjectSpec.js"></script>
|
||||
<script type="text/javascript" src="spec/QuickStartWidgetSpec.js"></script>
|
||||
|
||||
{% include widget_template.html %}
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
describe("Project", function () {
|
||||
|
||||
describe("rendering", function () {
|
||||
var project;
|
||||
|
||||
beforeEach(function () {
|
||||
project = new Spring.Project({
|
||||
id: "spring-data-jpa",
|
||||
name: "Spring Data JPA",
|
||||
projectReleases: [
|
||||
{fullName: "1.4.0.RC1", refDocUrl: "http://localhost/1.4.0/ref", apiDocUrl: "http://localhost/1.4.0/api", preRelease: true, current: false, supported: false},
|
||||
{fullName: "1.3.4", refDocUrl: "http://example.com/1.3.4/ref", apiDocUrl: "http://example.com/1.3.4/api", preRelease: false, current: true, supported: false},
|
||||
{fullName: "1.2.1", refDocUrl: "http://spring.io/1.2.1/ref", apiDocUrl: "http://spring.io/1.2.1/api", preRelease: false, current: false, supported: true}
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
describe("releases", function() {
|
||||
var releases;
|
||||
beforeEach(function() {
|
||||
releases = project.releases;
|
||||
});
|
||||
|
||||
it("has a release for each project release", function() {
|
||||
expect(releases.length).toEqual(3);
|
||||
});
|
||||
|
||||
it("has a version", function() {
|
||||
expect(releases[0].fullName).toEqual("1.4.0.RC1");
|
||||
});
|
||||
|
||||
it("has a documentation", function() {
|
||||
expect(releases[0].refDocUrl).toEqual("http://localhost/1.4.0/ref");
|
||||
expect(releases[0].apiDocUrl).toEqual("http://localhost/1.4.0/api");
|
||||
});
|
||||
|
||||
it("has a statusIconClass", function() {
|
||||
expect(releases[0].statusIconClass()).toEqual("icon-pre-release");
|
||||
expect(releases[1].statusIconClass()).toEqual("icon-current-version");
|
||||
expect(releases[2].statusIconClass()).toEqual("icon-supported-version");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,87 @@
|
||||
describe("QuickStartWidget", function () {
|
||||
|
||||
describe("rendering", function () {
|
||||
|
||||
beforeEach(function () {
|
||||
var project = new Spring.Project({
|
||||
"id": "spring-data-jpa",
|
||||
"name": "Spring Data JPA",
|
||||
"repoUrl": "http://github.com/SpringSource/spring-data-jpa",
|
||||
"siteUrl": "http://projects.springframework.io/spring-data-jpa",
|
||||
"projectReleases": [
|
||||
{
|
||||
"refDocUrl": "http://docs.springframework.io/spring-data/jpa/docs/1.4.0.RC1/reference/html/",
|
||||
"apiDocUrl": "http://docs.springframework.io/spring-data/jpa/docs/1.4.0.RC1/api/",
|
||||
"groupId": "org.springframework.data",
|
||||
"artifactId": "spring-data-jpa",
|
||||
"repository": {
|
||||
"id": "spring-milestones",
|
||||
"name": "Spring Milestones",
|
||||
"url": "http://repo.springsource.org/milestone",
|
||||
"snapshotsEnabled": false
|
||||
},
|
||||
"fullName": "1.4.0.RC1",
|
||||
"supported": false,
|
||||
"shortName": "1.4.0.RC1",
|
||||
"current": false,
|
||||
"preRelease": true
|
||||
},
|
||||
{
|
||||
"refDocUrl": "http://docs.springframework.io/spring-data/jpa/docs/1.3.4.RELEASE/reference/html/",
|
||||
"apiDocUrl": "http://docs.springframework.io/spring-data/jpa/docs/1.3.4.RELEASE/api/",
|
||||
"groupId": "org.springframework.data",
|
||||
"artifactId": "spring-data-jpa",
|
||||
"repository": null,
|
||||
"fullName": "1.3.4.RELEASE",
|
||||
"supported": false,
|
||||
"shortName": "1.3.4",
|
||||
"current": true,
|
||||
"preRelease": false
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
$('#jasmine_content').append("<div id='quick_select_widget'></div> ");
|
||||
$('#jasmine_content').append("<div id='maven_widget'></div> ");
|
||||
Spring.buildQuickStartWidget("#quick_select_widget", "#maven_widget", project);
|
||||
});
|
||||
|
||||
|
||||
it("lists out each release's version", function () {
|
||||
expect($('#quick_select_widget')).toContainText("1.4.0.RC1");
|
||||
expect($('#quick_select_widget')).toContainText("1.3.4");
|
||||
});
|
||||
|
||||
it("shows the dependency based on the default release", function() {
|
||||
expect($('#maven_widget')).toContainText("org.springframework.data");
|
||||
expect($('#maven_widget')).toContainText("spring-data-jpa");
|
||||
expect($('#maven_widget')).toContainText("1.4.0.RC1");
|
||||
});
|
||||
|
||||
it("shows the right dependency when users select a different release", function() {
|
||||
$('#jasmine_content select').val(1).change();
|
||||
|
||||
expect($('#maven_widget')).toContainText("org.springframework.data");
|
||||
expect($('#maven_widget')).toContainText("spring-data-jpa");
|
||||
expect($('#maven_widget')).toContainText("1.3.4.RELEASE");
|
||||
});
|
||||
|
||||
it("shows the repository information if it's present", function() {
|
||||
expect($('#maven_widget')).toContainText("spring-milestones");
|
||||
expect($('#maven_widget')).toContainText("Spring Milestones");
|
||||
expect($('#maven_widget')).toContainText("http://repo.springsource.org/milestone");
|
||||
expect($('#maven_widget')).toContainText("false");
|
||||
});
|
||||
|
||||
it("removes the repository if the user selects a relase without a repository", function (){
|
||||
$('#jasmine_content select').val(1).change();
|
||||
|
||||
expect($('#maven_widget')).not.toContainText("repository");
|
||||
expect($('#maven_widget')).not.toContainText("spring-milestones");
|
||||
expect($('#maven_widget')).not.toContainText("Spring Milestones");
|
||||
expect($('#maven_widget')).not.toContainText("http://repo.springsource.org/milestone");
|
||||
expect($('#maven_widget')).not.toContainText("false");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user