Skip to content

Instantly share code, notes, and snippets.

View rasmuseeg's full-sized avatar
💭
Coding ofc.

Rasmus Eeg Møller rasmuseeg

💭
Coding ofc.
View GitHub Profile
@rasmuseeg
rasmuseeg / Rte.cshtml
Created August 25, 2015 12:43
Parsing Macro's inside GridEditors
@using Umbraco.Web.Templates;
@using System.Text.RegularExpressions;
@using HtmlAgilityPack;
@model dynamic
<div class="cmscontent">
@Html.Raw(TemplateUtilities.ParseInternalLinks(ParseMacros(Model.value.ToString())))
</div>
@functions{
@rasmuseeg
rasmuseeg / RichSiteSummary.cshtml
Last active September 2, 2015 10:43
Rendering RSS feed Razor as an Umbraco Macro
@using System.Xml.Linq;
@using umbraco.cms.businesslogic.web;
@using System.Web.Configuration;
@using System.Text;
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@{
List<string> contentTypes = new List<string>() { "Article" };
// Current site root
@rasmuseeg
rasmuseeg / Pagination.cshtml
Last active January 11, 2016 09:20
Pagination using bootstrap styles
@model Pagination
@RenderPagination(model)
@helper RenderPagination(Pagination model)
{
<nav>
<ul class="pagination">
<li class="@(model.Page <= 1 ? "disabled" : string.Empty)">
<a href="@(model.Page > 1 ? "?p=" + (model.Page-1) : "#" )" aria-label="Previous">
@rasmuseeg
rasmuseeg / News.cshtml
Last active October 1, 2015 07:51
Basic media list with pagination in Umbraco
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "Master.cshtml";
}
@{
int currentPage = 1;
int.TryParse(Request.QueryString["p"] + "", out currentPage);
var model = new Pagination()
{
@rasmuseeg
rasmuseeg / ContactFormModel.cs
Last active September 12, 2017 11:37
Umbraco MVC Data Annotations Attributes - Required, DisplayName, StringLength, MinLength, MaxLength etc.
public class ContactFormModel
{
[DictionaryDisplayName(nameof(CategoryId))]
[DictionaryRequired]
public int CategoryId { get; set; }
[DictionaryDisplayName(nameof(Subject))]
[DictionaryRequired]
[DictionaryMinLength(8)]
public string Subject { get; set; }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
namespace Umbraco.Web
{
public static class UmbracoExtensions
@rasmuseeg
rasmuseeg / Gruntfile.js
Created October 2, 2015 07:50
Basic Gruntfile for web projects
/// <binding ProjectOpened='watch' />
module.exports = function (grunt) {
'use strict';
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
dist: {
options: {
@rasmuseeg
rasmuseeg / Cryptography.cs
Last active August 30, 2016 14:28
Generic Cryptograpy in C#
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace YourProject.Security
{
public static class Cryptography<E>
where E : Encoding, new()
{
@rasmuseeg
rasmuseeg / NameConversion.cs
Last active October 23, 2015 08:10
Coverting string between CamelCase PascalCase PropperCase
namespace Project.Web {
public class StringExtensions {
/// <summary>
/// Convert the string to Pascal case.
/// </summary>
/// <param name="strValue"></param>
/// <returns></returns>
public static string ToPascalCase(this string strValue)
{
// If there are 0 or 1 characters, just return the string.
@rasmuseeg
rasmuseeg / HtmlHelperExtensions.cs
Last active March 11, 2016 07:57
HtmlHelper extensions
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace System.Web.Mvc
{
public static class HtmlHelperExtensions
{
#region HtmlHelper Extensions
public static string Email(this HtmlHelper helper, string email, string message = "JavaScript is disabled, please enable to read this email address")