Merge pull request #571 from umbraco/starterkit
Implements new starterkit rest call
This commit is contained in:
@@ -84,15 +84,9 @@ namespace Umbraco.Web.Install.Controllers
|
||||
|
||||
public IEnumerable<Package> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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<InstallSetupStep> GetAllSteps()
|
||||
{
|
||||
return new List<InstallSetupStep>
|
||||
{
|
||||
{
|
||||
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<Package> GetStarterKits()
|
||||
{
|
||||
var packages = new List<Package>();
|
||||
|
||||
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<IEnumerable<Package>>().Result.ToList();
|
||||
}
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
LogHelper.Error<InstallHelper>("Could not download list of available starter kits", ex);
|
||||
}
|
||||
|
||||
return packages;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user