Skip to content

Instantly share code, notes, and snippets.

@sbosell
sbosell / directives.js
Created February 18, 2014 01:24
Umbraco Angular Directives
app.directive('cycle', function($parse) {
return {
restrict: 'A',
priority: 400,
link: function (scope, element, attr) {
scope.$watch('isLoaded', function (newVal) {
if (!newVal) return;
var opts = $parse(attr.cycle);
$(element).cycle(opts());
@sbosell
sbosell / home.cshtml
Created February 18, 2014 01:20
Umbraco Angular Home Template
@inherits Umbraco.Web.Mvc.UmbracoViewPage<App.Models.AngRenderModel>
@{
Layout = Model.isApp ? "Blank.cshtml" : "Static.cshtml";
}
@section Content {
@if (Model.isApp)
{
<article umb-children="content.Id" cycle="{slides: '>div'}" style="clear: both">
<div ng-repeat="slider in children">
@sbosell
sbosell / web.config
Created February 18, 2014 01:10
Umbraco Angular Rewrite Rules
<rewriter>
<!-- ignore all umbraco routes -->
<rewrite url="^(/umbraco/.*)" to="$1" processing="stop" />
<!-- ignore all images, css, html fragments -->
<rewrite url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js|\.html|\.less|\.htm)(\?.+)?)$" to="$1" processing="stop" />
<!-- if the header contains app we know it is a call to get a template. We need to let it pass -->
<if header="app" match="true">
<rewrite url="(.*)" to="$1" processing="stop"/>
</if>
<!-- if google is indexing let's let it proceed and get all non angular views which is just the normal umbraco views with razor -->
@sbosell
sbosell / global.asax
Created February 17, 2014 23:59
Umbraco Angular Global
namespace MvcApplication1
{
public class Global : UmbracoApplication
{
protected override void OnApplicationStarting(object sender, EventArgs e)
{
DefaultRenderMvcControllerResolver.Current.SetDefaultControllerType(typeof(DefaultController));
@sbosell
sbosell / DefaultController.js
Created February 17, 2014 23:59
Umbraco Angular Default Controller
namespace MvcApplication1.Controllers
{
public class DefaultController : Umbraco.Web.Mvc.RenderMvcController
{
//
// GET: /Default/
public ActionResult Index(AngRenderModel model)
{
@sbosell
sbosell / angrendermodel.cs
Created February 17, 2014 23:52
Umbraco Angular AngRenderModel
namespace App.Models
{
public class AngRenderModel : Umbraco.Web.Models.RenderModel
{
public bool isApp { get; set; }
public AngRenderModel(): base(UmbracoContext.Current.PublishedContentRequest.PublishedContent)
{
}
}
@sbosell
sbosell / PageViewModel.cs
Created February 17, 2014 23:31
Umbraco Angular PageViewModel
namespace MvcApplication1.Models
{
public class PropertyViewModel
{
public object DataValue { get; set; }
public bool HasValue { get; set; }
public string PropertyTypeAlias { get; set; }
public object Value { get; set; }
public object XPathValue { get; set; }
@sbosell
sbosell / PageApiGenController.cs
Created February 17, 2014 23:28
Umbraco Angular MVC Controllers
namespace MvcApplication1.Controllers
{
// mvc needs a class to serialize a post, this is for a url
public class UrlModel
{
public string url { get; set; }
}
// id class for post
public class IdModel
@sbosell
sbosell / umbnode.js
Created February 17, 2014 22:34
Umbraco node values
{
"Id": 1053,
"Name": "Site",
"Url": "/",
"Path": "-1,1053",
"ContentTypeAlias": "SiteMaster",
"Properties": {
"umbracoRedirect": {
"DataValue": "",
"HasValue": false,
@sbosell
sbosell / services.js
Created February 17, 2014 22:16
Umbraco Angular Services
angular.module('dw.services', [])
.value('serviceBase', "/umbraco/api/pagegenapi/")
.factory('serviceApi', ['serviceBase', function (serviceBase) {
var service = {
base: serviceBase,
getMedia: serviceBase + 'GetMedia',
getContent: serviceBase + 'getContent',
getPath: serviceBase + 'getPage',
getChildren: serviceBase + 'getChildren'