Removes non-completed/tested/used code for templates which was during a WIP of the grid some time ago.

This commit is contained in:
Shannon
2014-11-25 17:36:44 +11:00
parent ea785a6585
commit e2cc342adf
5 changed files with 0 additions and 222 deletions

View File

@@ -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);

View File

@@ -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())

View File

@@ -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"
)
};
}
}
}

View File

@@ -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; }
}
}

View File

@@ -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" />