diff --git a/Slingshot.Api/Abstract/Repository.cs b/Slingshot.Api/Abstract/Repository.cs index 89da187..20a54ca 100644 --- a/Slingshot.Api/Abstract/Repository.cs +++ b/Slingshot.Api/Abstract/Repository.cs @@ -14,6 +14,7 @@ public abstract class Repository { protected Uri _inputUri; protected string _repoUrl; + protected string _repoDisplayUrl; protected string _branch; protected string _repositoryName; protected string _userName; @@ -25,6 +26,8 @@ public Repository(Uri uri) _inputUri = uri; } + public abstract string RepositoryDisplayUrl { get; } + public abstract string RepositoryUrl { get; } public abstract string RepositoryName { get; } diff --git a/Slingshot.Api/Concrete/GitHubRepository.cs b/Slingshot.Api/Concrete/GitHubRepository.cs index 96ce0e9..44b7c43 100644 --- a/Slingshot.Api/Concrete/GitHubRepository.cs +++ b/Slingshot.Api/Concrete/GitHubRepository.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Web; using System.IO; +using System.Text; namespace Slingshot.Concrete { @@ -33,15 +34,28 @@ public override async Task GetTemplateUrlAsync() { JObject template = null; string templateUrl = null; + StringBuilder builder = null; if (_inputUri.Segments.Length > 2) { string branch = await GetBranch(); - templateUrl = string.Format(Constants.Repository.GitCustomTemplateFormat, + builder = new StringBuilder(string.Format(Constants.Repository.GitCustomTemplateFolderUrlFormat, UserName, RepositoryName, - branch); + branch)); + for (var i = 5; i < _inputUri.Segments.Length; i++) + { + string segment = _inputUri.Segments[i]; + if(segment.EndsWith(".md", StringComparison.OrdinalIgnoreCase)) + { + break; + } + + builder.Append(segment); + } + + templateUrl = builder.ToString().TrimEnd(Constants.Path.SlashChars) + "/azuredeploy.json"; template = await DownloadTemplate(templateUrl); } @@ -69,16 +83,38 @@ public override string RepositoryUrl _repoUrl = string.Format("https://{0}/{1}/{2}", _inputUri.Host, UserName, RepositoryName); } } - return _repoUrl; } } + public override string RepositoryDisplayUrl + { + get + { + if (string.IsNullOrEmpty(_repoDisplayUrl)) + { + string lastSegment = _inputUri.Segments[_inputUri.Segments.Length - 1]; + string url = _inputUri.ToString(); + if (lastSegment.EndsWith(".md", StringComparison.OrdinalIgnoreCase)) + { + int lastSlashIndex = url.LastIndexOf('/'); + _repoDisplayUrl = _inputUri.ToString().Substring(0, lastSlashIndex); + } + else + { + _repoDisplayUrl = url; + } + } + + return _repoDisplayUrl; + } + } + public override async Task GetBranch() { if (string.IsNullOrEmpty(_branch)) { - if (_inputUri.Segments.Length >= 4) + if (_inputUri.Segments.Length > 4) { _branch = _inputUri.Segments[4].Trim(Constants.Path.SlashChars); } diff --git a/Slingshot.Api/Content/Styles/app.css b/Slingshot.Api/Content/Styles/app.css index 41866a2..a0f5f5b 100644 --- a/Slingshot.Api/Content/Styles/app.css +++ b/Slingshot.Api/Content/Styles/app.css @@ -43,6 +43,12 @@ pre { margin-bottom:20px; } min-height: 200px; } +.header-label{ + white-space:nowrap; + width:670px; + overflow: hidden; +} + /* ANIMATION STYLINGS ============================================================================= */ #signup-form { position:relative; min-height:300px; overflow:hidden; padding:30px; } diff --git a/Slingshot.Api/Controllers/ARMController.cs b/Slingshot.Api/Controllers/ARMController.cs index 74f43d5..8506586 100644 --- a/Slingshot.Api/Controllers/ARMController.cs +++ b/Slingshot.Api/Controllers/ARMController.cs @@ -313,7 +313,6 @@ public async Task GetTemplate(string repositoryUrl) JObject returnObj = new JObject(); Repository repo = Repository.CreateRepositoryObj(repositoryUrl); - repositoryUrl = repo.RepositoryUrl; string templateUrl = await repo.GetTemplateUrlAsync(); JObject template = await repo.DownloadTemplateAsync(); @@ -344,7 +343,8 @@ public async Task GetTemplate(string repositoryUrl) returnObj["resourceGroup"] = resourceGroupName; returnObj["template"] = template; returnObj["templateUrl"] = templateUrl; - returnObj["repositoryUrl"] = repositoryUrl; + returnObj["repositoryUrl"] = repo.RepositoryUrl; + returnObj["repositoryDisplayUrl"] = repo.RepositoryDisplayUrl; returnObj["branch"] = branch; // Check if the template takes in a Website parameter diff --git a/Slingshot.Api/Helpers/Constants.cs b/Slingshot.Api/Helpers/Constants.cs index 0e453a2..3bb0a97 100644 --- a/Slingshot.Api/Helpers/Constants.cs +++ b/Slingshot.Api/Helpers/Constants.cs @@ -16,7 +16,7 @@ public class Path public class Repository { public const string EmptySiteTemplateUrl = "http://deploytoazure.azurewebsites.net/sitewithrepository.json"; - public const string GitCustomTemplateFormat = "https://raw.githubusercontent.com/{0}/{1}/{2}/azuredeploy.json"; + public const string GitCustomTemplateFolderUrlFormat = "https://raw.githubusercontent.com/{0}/{1}/{2}/"; public const string GitHubApiRepoInfoFormat = "https://api.github.com/repos/{0}/{1}"; } diff --git a/Slingshot.Api/ng/Scripts/app.js b/Slingshot.Api/ng/Scripts/app.js index dea273e..7424a0c 100644 --- a/Slingshot.Api/ng/Scripts/app.js +++ b/Slingshot.Api/ng/Scripts/app.js @@ -176,6 +176,7 @@ angular.module('formApp', ['ngAnimate', 'ui.router']) $scope.formData.branch = result.data.branch; $scope.formData.tenants = result.data.tenants; $scope.formData.repositoryUrl = result.data.repositoryUrl; + $scope.formData.repositoryDisplayUrl = result.data.repositoryDisplayUrl; $scope.formData.siteName = result.data.siteName; $scope.formData.siteNameQuery = result.data.siteName; diff --git a/Slingshot.Api/ng/Views/form-setup.html b/Slingshot.Api/ng/Views/form-setup.html index 7ff6c04..b6e986d 100644 --- a/Slingshot.Api/ng/Views/form-setup.html +++ b/Slingshot.Api/ng/Views/form-setup.html @@ -1,11 +1,11 @@ 
-
- Git Repository Url - {{formData.repositoryUrl}} +
+ Git Repository Url - {{formData.repositoryDisplayUrl}}
-
- Branch - {{formData.branch}} +
+ Branch - {{formData.branch}}