From 9ee1584ede8a948e9c2ed03ca6117759a9281733 Mon Sep 17 00:00:00 2001 From: perploug Date: Thu, 3 Oct 2013 20:58:16 +0200 Subject: [PATCH] Initial PublishedContent service for niceUrl access --- .../resources/publishedcontent.resource.js | 44 +++++++++++++++++++ .../src/less/property-editors.less | 10 +++++ .../Editors/PublishedContentController.cs | 19 ++++++++ 3 files changed, 73 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js create mode 100644 src/Umbraco.Web/Editors/PublishedContentController.cs diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js new file mode 100644 index 0000000000..82977020a4 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/common/resources/publishedcontent.resource.js @@ -0,0 +1,44 @@ +/** + * @ngdoc service + * @name umbraco.resources.publishedContentResource + * @description service to retrieve published content from the umbraco cache + * + * + **/ +function publishedContentResource($q, $http, umbRequestHelper) { + + //the factory object returned + return { + + /** + * @ngdoc method + * @name umbraco.resources.publishedContentResource#getUrl + * @methodOf umbraco.resources.publishedContentResource + * + * @description + * Returns a url, given a node ID + * + * ##usage + *
+         * publishedContentResource.getUrl()
+         *    .then(function(stylesheets) {
+         *        alert('its here!');
+         *    });
+         * 
+ * + * @param {Int} id Id of node to return the public url to + * @returns {Promise} resourcePromise object containing the url. + * + */ + getUrl: function (id) { + return umbRequestHelper.resourcePromise( + $http.get( + umbRequestHelper.getApiUrl( + "publishedContentApiBaseUrl", + "GetUrl",[{id: id}])), + 'Failed to retreive url for id:' + id); + } + }; +} + +angular.module('umbraco.resources').factory('publishedContentResource', publishedContentResource); diff --git a/src/Umbraco.Web.UI.Client/src/less/property-editors.less b/src/Umbraco.Web.UI.Client/src/less/property-editors.less index e856a3855e..a06a0d4837 100644 --- a/src/Umbraco.Web.UI.Client/src/less/property-editors.less +++ b/src/Umbraco.Web.UI.Client/src/less/property-editors.less @@ -5,6 +5,16 @@ width:66.6%; } +.umb-editor-tiny { + width: 50px; +} + +.umb-editor-small { + width: 90px; +} + + + .umb-modal .umb-editor { width: 95%; } diff --git a/src/Umbraco.Web/Editors/PublishedContentController.cs b/src/Umbraco.Web/Editors/PublishedContentController.cs new file mode 100644 index 0000000000..bd1325aa33 --- /dev/null +++ b/src/Umbraco.Web/Editors/PublishedContentController.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Umbraco.Web.Mvc; + +namespace Umbraco.Web.Editors +{ + [PluginController("UmbracoApi")] + public class PublishedContentController : UmbracoAuthorizedJsonController + { + UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current); + public string GetNiceUrl(int id) + { + return helper.NiceUrl(id); + } + } +}