Skip to content

Instantly share code, notes, and snippets.

View TimGeyssens's full-sized avatar

Tim Geyssens TimGeyssens

View GitHub Profile
using Umbraco.Core;
namespace MyUmbracoWebsite
{
public class Startup : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
StaticFileHasher.HashFiles(umbracoApplication.Server.MapPath("~/css"), umbracoApplication.Server.MapPath("~/js"));
@TimGeyssens
TimGeyssens / StaticFileHasher.cs
Created August 13, 2020 09:04
StaticFileHasher for c#
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace MyUmbracWebsite
{
public static class StaticFileHasher
{
@TimGeyssens
TimGeyssens / UI-O-Matic Model
Last active November 3, 2016 21:23
Sample integration of UI-O-Matic with Github, showing the power of custom repositories (making use of https://github.com/octokit/octokit.net for the heavy lifting)
using System.ComponentModel.DataAnnotations;
using UIOMatic.Attributes;
using UIOMatic.Example.GitHubIssues.Repo;
using Umbraco.Core.Persistence.DatabaseAnnotations;
namespace UIOMatic.Example.GitHubIssues.Models
{
[UIOMatic("issues", "Issues", "Issue",
RepositoryType = typeof(GitHubIssuesRepo),
ShowOnSummaryDashboard = true)]
<setting key="DatePickerYearRange" value="10" />
<section alias="Umbraco.Forms.Migration">
<areas>
<area>developer</area>
</areas>
<tab caption="Contour to Umbraco Forms">
<control>/app_plugins/Umbraco.Forms.Migration/ContourToForms.ascx</control>
</tab>
</section>
@TimGeyssens
TimGeyssens / Import form code
Created June 17, 2015 11:44
Contour import form
public static Form ImportFormFromXml(XmlDocument xd, bool insert, string name= "")
{
Form f = null;
XmlSerializer deserializer = new XmlSerializer(typeof(Form), "UmbracoContour");
f = (Form)deserializer.Deserialize(new XmlNodeReader(xd.DocumentElement));
var formOrig = (Form)deserializer.Deserialize(new XmlNodeReader(xd.DocumentElement)); ;
@TimGeyssens
TimGeyssens / Umbraco Forms validation example
Created June 8, 2015 08:32
Umbraco Forms validation example
public class FormsValidation : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
Umbraco.Forms.Web.Controllers.UmbracoFormsController.FormValidate += UmbracoFormsController_FormValidate;
}
void UmbracoFormsController_FormValidate(object sender, Umbraco.Forms.Mvc.FormValidationEventArgs e)
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Umbraco.Forms.Core.Enums;
using System.Text.RegularExpressions;
using Umbraco.Forms.Data.Storage;
using System.Xml;
using System.Xml.XPath;
using System.Web;
@model Umbraco.Forms.Mvc.Models.FieldViewModel
<input type="text" name="@Model.Name" id="@Model.Id" class="text" value="@Model.Value" maxlength="500"
@{if(Model.Mandatory || Model.Validate){<text>data-val="true"</text>}}
@{if (Model.Mandatory) {<text> data-val-required="@Model.RequiredErrorMessage"</text>}}
@{if (Model.Validate) {<text> data-val-regex="@Model.InvalidErrorMessage" data-regex="@Html.Raw(Model.Regex)"</text>}}
/>
public class Textfield : FieldType
{
[Attributes.Setting("DefaultValue",
description = "Enter a default value")]
public string DefaultValue { get; set; }
public Textfield() {
//Provider
this.Id = new Guid("3F92E01B-29E2-4a30-BF33-9DF5580ED52C");
this.Name = "Textfield";