Skip to content

Instantly share code, notes, and snippets.

View naepalm's full-sized avatar

Janae Cram naepalm

View GitHub Profile
@naepalm
naepalm / MediaSave.cshtml
Last active December 3, 2015 19:38
A little razor template snippet that re-saves/republishes all media in Umbraco
@using Umbraco.Core.Models;
@{
var mediaService = ApplicationContext.Current.Services.MediaService;
SaveMedias(mediaService.GetRootMedia().ToList());
}
@functions
{
namespace Client.Web.Models
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Buzz.Hybrid;
using Buzz.Hybrid.Models;
@naepalm
naepalm / TextPage.cshtml
Last active March 21, 2016 17:22
Basic text page template content with headings & general content for styling
@inherits UmbracoViewPage<TextPageViewModel>
@using Client.Web.Models.ViewModels
@{
Layout = "OneColumn.cshtml";
}
<section id="primary" class="col-s-8 offset-s-2">
@*Model.BodyText*@
<h1>Heading 1</h1>
public class CacheService : ICacheService
{
private readonly MemoryCache _memoryCache = new MemoryCache("Cache.Key");
public void Add<T>(T cacheObject, string key)
{
var cacheItemPolicy = new CacheItemPolicy
{
AbsoluteExpiration = DateTimeOffset.Now.AddHours(24)
};
@naepalm
naepalm / RazorServerDirectoryListingHelper.cshtml
Created August 17, 2016 16:45
Displays a list of directories and files on a server, for those nasty moments when you don't have access and are looking for something.
@helper RenderFolders(string dirPath, bool displaySubDirs = false)
{
try
{
List<string> dirs = new List<string>(Directory.EnumerateDirectories(dirPath));
<h4>@string.Format("Directory: {0}", dirPath.Substring(dirPath.LastIndexOf("\\") + 1))</h4>
<p>@(string.Format("{0} directories found.", dirs.Count))</p>
<ul>
@foreach (var dir in dirs)
@naepalm
naepalm / TastyCookies.js
Last active August 23, 2016 21:06
Kyle's handy-dandy cookie scripts.
/**
* @class Cookie
* @description Helper functions for adding and deleting cookies.
*/
var Cookie = {
/**
* @method delete
* @param {string} cookieName - The name of the cookie to delete.
* @description Deletes the indicated cookie.
*/
@naepalm
naepalm / TextOverImagePartial.cshtml
Created January 12, 2017 22:10
Files to easily render the Text Over Image Editor on the front.
@model TextOverImage.Models.ImageWithText
@{
// Use this code to render this partial in your template. Replace "banner" with whatever your property name is
// Make sure to include @using TextOverImage.Models at the top of your template
//@if(Model.Content.HasProperty("banner") && Model.Content.HasValue("banner"))
//{
// @Html.Partial("TextOverImagePartial", Model.Content.GetPropertyValue<ImageWithText>("banner")
//}

Skrift headquarters resides in Bellingham, WA, at whatever restaurant or coffee house of choice suits Erica, Janae, and Kyle for their weekly meetings. At it's core, the magazine was contrived to bring the global Umbraco community together and find a localized place to promote uWestFest and other festivals around the world. Having worked together for seven years, each member of the team brings their own unique skills to Skrift's management. As a freelance UX designer, Erica is in charge of design, user testing, and statistics, Janae specializes in the C#, HTML, and CSS of the site as their resident code junkie, and Kyle puts his skills to use both as their Javascript guru and Editor In Chief (he's an award winning journalist and cartoonist, you know!*). Passionate about the web and Umbraco with skills developed working together in an agency bef

@naepalm
naepalm / ZoomAreaCropperView.cshtml
Last active May 26, 2017 16:58
A simple example of how to use the Zoom Area Cropper in a view.
@inherits UmbracoTemplatePage
@using ZoomAreaCropper.Models
@{
Layout = null;
}
@if (Model.Content.HasValue("photo"))
{
var photo = Model.Content.GetPropertyValue<ZoomAreaCropper>("photo");
if (photo.HasMedia)
@naepalm
naepalm / DocTypeGridEditorReusableContentExample.cshtml
Created June 8, 2017 20:19
An example for how a DocType Grid Editor partial view should look with the DTGE: Reusable Content Extension
@inherits UmbracoTemplatePage
@{
// Set a variable to use the default content if no linked content has been selected
var content = Model.Content;
// Check to see if there's a linked page value
if(Model.Content.HasProperty("dtgeLinkedId") && Model.Content.HasValue("dtgeLinkedId"))
{
// Run the linked page value through Umbraco.TypedContent() to get the IPublishedContent page
var dtgePage = Umbraco.TypedContent(Model.Content.GetPropertyValue("dtgeLinkedId"));