diff --git a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs index 6041e23ca5..2ab1fd97ad 100644 --- a/src/Umbraco.Web/Install/Controllers/InstallApiController.cs +++ b/src/Umbraco.Web/Install/Controllers/InstallApiController.cs @@ -84,15 +84,9 @@ namespace Umbraco.Web.Install.Controllers public IEnumerable GetPackages() { - var r = new org.umbraco.our.Repository(); - var modules = r.Modules(); - - return modules.Select(package => new Package() - { - Id = package.RepoGuid, - Name = package.Text, - Thumbnail = package.Thumbnail - }); + var installHelper = new InstallHelper(UmbracoContext); + var starterKits = installHelper.GetStarterKits(); + return starterKits; } /// diff --git a/src/Umbraco.Web/Install/InstallHelper.cs b/src/Umbraco.Web/Install/InstallHelper.cs index b0744b7809..c882a83cd8 100644 --- a/src/Umbraco.Web/Install/InstallHelper.cs +++ b/src/Umbraco.Web/Install/InstallHelper.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Configuration; using System.IO; using System.Linq; +using System.Net.Http; using System.Web; using System.Web.Script.Serialization; using System.Web.UI; @@ -11,6 +12,7 @@ using umbraco.BusinessLogic; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.IO; +using Umbraco.Core.Logging; using Umbraco.Core.Persistence; using Umbraco.Web.Install.InstallSteps; using Umbraco.Web.Install.Models; @@ -39,7 +41,7 @@ namespace Umbraco.Web.Install public IEnumerable GetAllSteps() { return new List - { + { new NewInstallStep(_umbContext.Application), new UpgradeStep(), new FilePermissionsStep(), @@ -85,12 +87,12 @@ namespace Umbraco.Web.Install { Directory.Move(IOHelper.MapPath(SystemDirectories.Install), IOHelper.MapPath("~/app_data/temp/install_backup")); } - } + } if (Directory.Exists(IOHelper.MapPath("~/Areas/UmbracoInstall"))) - { + { Directory.Delete(IOHelper.MapPath("~/Areas/UmbracoInstall"), true); - } + } } internal void InstallStatus(bool isCompleted, string errorMsg) @@ -184,5 +186,29 @@ namespace Umbraco.Web.Install return false; } } + + internal IEnumerable GetStarterKits() + { + var packages = new List(); + + try + { + var requestUri = string.Format("http://our.umbraco.org/webapi/StarterKit/Get/?umbracoVersion={0}", + UmbracoVersion.Current); + + using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri)) + using (var httpClient = new HttpClient()) + using (var response = httpClient.SendAsync(request).Result) + { + packages = response.Content.ReadAsAsync>().Result.ToList(); + } + } + catch (AggregateException ex) + { + LogHelper.Error("Could not download list of available starter kits", ex); + } + + return packages; + } } } \ No newline at end of file diff --git a/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs b/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs index f5bc96fdea..e8397136a9 100644 --- a/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs +++ b/src/Umbraco.Web/Install/InstallSteps/StarterKitDownloadStep.cs @@ -21,16 +21,17 @@ namespace Umbraco.Web.Install.InstallSteps private const string RepoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66"; - //adding a package guid hardcoded, so we can change the sent package remotely, currently this just points to txt kit - //but a future starterkit will be inserted under the same guid on our. - private const string PackageGuid = "69E44BEB-15FF-4CEE-8B64-0A7DAE498657"; - public override InstallSetupResult Execute(Guid? starterKitId) { //if there is no value assigned then use the default starter kit if (starterKitId.HasValue == false) { - starterKitId = Guid.Parse(PackageGuid); + var installHelper = new InstallHelper(UmbracoContext.Current); + var starterKits = installHelper.GetStarterKits().FirstOrDefault(); + if (starterKits != null) + starterKitId = starterKits.Id; + else + return null; } else if (starterKitId.Value == Guid.Empty) { @@ -57,7 +58,7 @@ namespace Umbraco.Web.Install.InstallSteps } if (repo.HasConnection() == false) { - throw new InstallException("Cannot connect to repository"); + throw new InstallException("Cannot connect to repository"); } var installer = new Installer(); @@ -76,7 +77,7 @@ namespace Umbraco.Web.Install.InstallSteps var installer = new Installer(); installer.LoadConfig(packageFile); installer.InstallFiles(manifestId, packageFile); - + } public override string View