Removes non-completed/tested/used code for templates which was during a WIP of the grid some time ago.
This commit is contained in:
@@ -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
|
||||
* <pre>
|
||||
* stylesheetResource.getAll()
|
||||
* .then(function(stylesheets) {
|
||||
* alert('its here!');
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @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
|
||||
* <pre>
|
||||
* stylesheetResource.getRulesByName("ie7stylesheet")
|
||||
* .then(function(rules) {
|
||||
* alert('its here!');
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @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);
|
||||
@@ -196,11 +196,6 @@ namespace Umbraco.Web.Editors
|
||||
"stylesheetApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<StylesheetController>(
|
||||
controller => controller.GetAll())
|
||||
},
|
||||
|
||||
{
|
||||
"templateApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<TemplateController>(
|
||||
controller => controller.GetById(0))
|
||||
},
|
||||
{
|
||||
"memberTypeApiBaseUrl", Url.GetUmbracoApiServiceBaseUrl<MemberTypeController>(
|
||||
controller => controller.GetAllTypes())
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the content json for the content id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a data type wth a given ID
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[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"
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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<ActionNew>(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<string>("application"));
|
||||
.ConvertLegacyMenuItem(null, "inittemplates", queryStrings.GetValue<string>("application"));
|
||||
|
||||
//refresh action
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(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<ActionNew>(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<string>("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<ActionDelete>(ui.Text("actions", ActionDelete.Instance.Alias))
|
||||
menu.Items.Add<ActionDelete>(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<string>("application"));
|
||||
.ConvertLegacyMenuItem(entity, "templates", queryStrings.GetValue<string>("application"));
|
||||
}
|
||||
|
||||
//add refresh
|
||||
menu.Items.Add<RefreshNode, ActionRefresh>(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")
|
||||
|
||||
@@ -308,7 +308,6 @@
|
||||
<Compile Include="Editors\EntityControllerConfigurationAttribute.cs" />
|
||||
<Compile Include="Editors\ImagesController.cs" />
|
||||
<Compile Include="Editors\PackageInstallController.cs" />
|
||||
<Compile Include="Editors\TemplateController.cs" />
|
||||
<Compile Include="Editors\CanvasDesignerController.cs" />
|
||||
<Compile Include="Editors\UserController.cs" />
|
||||
<Compile Include="GridTemplateExtensions.cs" />
|
||||
@@ -329,7 +328,6 @@
|
||||
<Compile Include="Editors\TemplateQueryController.cs" />
|
||||
<Compile Include="Models\ContentEditing\ContentBaseItemSave.cs" />
|
||||
<Compile Include="Models\ContentEditing\MediaItemSave.cs" />
|
||||
<Compile Include="Models\ContentEditing\TemplateDisplay.cs" />
|
||||
<Compile Include="Models\DetachedContent.cs" />
|
||||
<Compile Include="Models\ImageCropAnchor.cs" />
|
||||
<Compile Include="Models\ImageCropCoordinates.cs" />
|
||||
|
||||
Reference in New Issue
Block a user