diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/template.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/template.resource.js
deleted file mode 100644
index d6fec8640f..0000000000
--- a/src/Umbraco.Web.UI.Client/src/common/resources/template.resource.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * @ngdoc service
- * @name umbraco.resources.stylesheetResource
- * @description service to retrieve available stylesheets
- *
- *
- **/
-function templateResource($q, $http, umbRequestHelper) {
-
- //the factory object returned
- return {
-
- /**
- * @ngdoc method
- * @name umbraco.resources.stylesheetResource#getAll
- * @methodOf umbraco.resources.stylesheetResource
- *
- * @description
- * Gets all registered stylesheets
- *
- * ##usage
- *
- * stylesheetResource.getAll()
- * .then(function(stylesheets) {
- * alert('its here!');
- * });
- *
- *
- * @returns {Promise} resourcePromise object containing the stylesheets.
- *
- */
- getAll: function () {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "templateApiBaseUrl",
- "GetAll")),
- 'Failed to retrieve stylesheets ');
- },
-
- /**
- * @ngdoc method
- * @name umbraco.resources.stylesheetResource#getRulesByName
- * @methodOf umbraco.resources.stylesheetResource
- *
- * @description
- * Returns all defined child rules for a stylesheet with a given name
- *
- * ##usage
- *
- * stylesheetResource.getRulesByName("ie7stylesheet")
- * .then(function(rules) {
- * alert('its here!');
- * });
- *
- *
- * @returns {Promise} resourcePromise object containing the rules.
- *
- */
- getById: function (id) {
- return umbRequestHelper.resourcePromise(
- $http.get(
- umbRequestHelper.getApiUrl(
- "templateApiBaseUrl",
- "GetById",
- [{ id: id }])),
- 'Failed to retreive template ');
- },
-
- saveAndRender: function(html, templateId, pageId){
- return umbRequestHelper.resourcePromise(
- $http.post(
- umbRequestHelper.getApiUrl(
- "templateApiBaseUrl",
- "PostSaveAndRender"),
- {templateId: templateId, pageId: pageId, html: html }),
- 'Failed to retreive template ');
- }
- };
-}
-
-angular.module('umbraco.resources').factory('templateResource', templateResource);
diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs
index 0e7d48d3d9..91c26c603a 100644
--- a/src/Umbraco.Web/Editors/BackOfficeController.cs
+++ b/src/Umbraco.Web/Editors/BackOfficeController.cs
@@ -196,11 +196,6 @@ namespace Umbraco.Web.Editors
"stylesheetApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl(
controller => controller.GetAll())
},
-
- {
- "templateApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl(
- controller => controller.GetById(0))
- },
{
"memberTypeApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl(
controller => controller.GetAllTypes())
diff --git a/src/Umbraco.Web/Editors/TemplateController.cs b/src/Umbraco.Web/Editors/TemplateController.cs
deleted file mode 100644
index 3799be7e23..0000000000
--- a/src/Umbraco.Web/Editors/TemplateController.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-using AutoMapper;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-using System.Web.Http;
-using Umbraco.Core.Models;
-using Umbraco.Web.Models.ContentEditing;
-using Umbraco.Web.Mvc;
-using Umbraco.Web.WebApi;
-using Umbraco.Web.WebApi.Filters;
-
-namespace Umbraco.Web.Editors
-{
- [PluginController("UmbracoApi")]
- [UmbracoTreeAuthorize(Core.Constants.Trees.Templates)]
- public class TemplateController : UmbracoAuthorizedJsonController
- {
- ///
- /// Gets the content json for the content id
- ///
- ///
- ///
- public TemplateDisplay GetById(int id)
- {
- var template = Services.FileService.GetTemplate(id);
- if (template == null)
- {
- throw new HttpResponseException(HttpStatusCode.NotFound);
- }
-
- TemplateDisplay t = new TemplateDisplay();
- t.Alias = template.Alias;
- t.Content = template.Content;
- t.Id = template.Id;
- t.Name = template.Name;
-
- return t;
- }
-
- ///
- /// Deletes a data type wth a given ID
- ///
- ///
- ///
- [HttpDelete]
- [HttpPost]
- public HttpResponseMessage DeleteById(int id)
- {
- var foundTemplate = Services.FileService.GetTemplate(id);
- if (foundTemplate == null)
- {
- throw new HttpResponseException(HttpStatusCode.NotFound);
- }
- Services.FileService.DeleteTemplate(foundTemplate.Alias);
- return Request.CreateResponse(HttpStatusCode.OK);
- }
-
- [HttpPost]
- public HttpResponseMessage PostSaveAndRender(dynamic model)
- {
- var foundTemplate = Services.FileService.GetTemplate((int)model.templateId);
- if (foundTemplate == null)
- {
- throw new HttpResponseException(HttpStatusCode.NotFound);
- }
- foundTemplate.Content = model.html;
- Services.FileService.SaveTemplate(foundTemplate);
-
- string result = string.Empty;
- try
- {
- var url = "http://" + Request.RequestUri.Host + "/" + model.pageId + ".aspx?altTemplate=" + foundTemplate.Alias;
- result = url;
-
- WebClient wc = new WebClient();
- result = wc.DownloadString(new Uri(url));
- }
- catch (WebException exception)
- {
- if (exception.Response != null)
- {
- var responseStream = exception.Response.GetResponseStream();
-
- if (responseStream != null)
- {
- using (var reader = new StreamReader(responseStream))
- {
- result = reader.ReadToEnd();
- }
- }
- }
- }
- catch (Exception ex)
- {
- result += ex.ToString();
- }
-
-
- return new HttpResponseMessage()
- {
- Content = new StringContent(
- result,
- Encoding.UTF8,
- "text/html"
- )
- };
- }
-
-
-
- }
-}
diff --git a/src/Umbraco.Web/Models/ContentEditing/TemplateDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/TemplateDisplay.cs
deleted file mode 100644
index 5291b9cca3..0000000000
--- a/src/Umbraco.Web/Models/ContentEditing/TemplateDisplay.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.Serialization;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Umbraco.Web.Models.ContentEditing
-{
- [DataContract(Name = "template", Namespace = "")]
- public class TemplateDisplay : EntityBasic
- {
- [DataMember(Name = "content")]
- public string Content { get; set; }
- }
-}
diff --git a/src/Umbraco.Web/Trees/TemplatesTreeController.cs b/src/Umbraco.Web/Trees/TemplatesTreeController.cs
index f8cd861f6e..5e88691591 100644
--- a/src/Umbraco.Web/Trees/TemplatesTreeController.cs
+++ b/src/Umbraco.Web/Trees/TemplatesTreeController.cs
@@ -55,6 +55,8 @@ namespace Umbraco.Web.Trees
template.IsMasterTemplate,
GetEditorPath(template, queryStrings))));
+ nodes.ForEach(x => x.NodeType = "tempaltes");
+
return nodes;
}
@@ -72,9 +74,9 @@ namespace Umbraco.Web.Trees
{
//Create the normal create action
menu.Items.Add(ui.Text("actions", ActionNew.Instance.Alias))
- //Since we haven't implemented anything for languages in angular, this needs to be converted to
+ //Since we haven't implemented anything for templates in angular, this needs to be converted to
//use the legacy format
- .ConvertLegacyMenuItem(null, "initlanguages", queryStrings.GetValue("application"));
+ .ConvertLegacyMenuItem(null, "inittemplates", queryStrings.GetValue("application"));
//refresh action
menu.Items.Add(ui.Text("actions", ActionRefresh.Instance.Alias), true);
@@ -84,25 +86,49 @@ namespace Umbraco.Web.Trees
var template = Services.FileService.GetTemplate(int.Parse(id));
if (template == null) return new MenuItemCollection();
+ var entity = FromTemplate(template);
+ //Create the create action for creating sub layouts
+ menu.Items.Add(ui.Text("actions", ActionNew.Instance.Alias))
+ //Since we haven't implemented anything for templates in angular, this needs to be converted to
+ //use the legacy format
+ .ConvertLegacyMenuItem(entity, "templates", queryStrings.GetValue("application"));
+
+ //don't allow delete if it has child layouts
if (template.IsMasterTemplate == false)
{
//add delete option if it doesn't have children
- menu.Items.Add(ui.Text("actions", ActionDelete.Instance.Alias))
+ menu.Items.Add(ui.Text("actions", ActionDelete.Instance.Alias), true)
//Since we haven't implemented anything for languages in angular, this needs to be converted to
//use the legacy format
- .ConvertLegacyMenuItem(null, "templates", queryStrings.GetValue("application"));
+ .ConvertLegacyMenuItem(entity, "templates", queryStrings.GetValue("application"));
}
+ //add refresh
+ menu.Items.Add(ui.Text("actions", ActionRefresh.Instance.Alias), true);
return menu;
}
+ private UmbracoEntity FromTemplate(ITemplate template)
+ {
+ return new UmbracoEntity
+ {
+ CreateDate = template.CreateDate,
+ Id = template.Id,
+ Key = template.Key,
+ Name = template.Name,
+ NodeObjectTypeId = new Guid(Constants.ObjectTypes.Template),
+ //TODO: Fix parent/paths on templates
+ ParentId = -1,
+ Path = template.Path,
+ UpdateDate = template.UpdateDate
+ };
+ }
+
private string GetEditorPath(ITemplate template, FormDataCollection queryStrings)
{
- //UmbracoConfig.For.UmbracoSettings().Templates.DefaultRenderingEngine == RenderingEngine.Mvc && ViewHelper.ViewExists(template)
-
//TODO: Rebuild the language editor in angular, then we dont need to have this at all (which is just a path to the legacy editor)
return Path.GetExtension(template.Path).InvariantEquals(".master")
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj
index 0c2a2034b8..b0620994ec 100644
--- a/src/Umbraco.Web/Umbraco.Web.csproj
+++ b/src/Umbraco.Web/Umbraco.Web.csproj
@@ -308,7 +308,6 @@
-
@@ -329,7 +328,6 @@
-