Skip to content

Instantly share code, notes, and snippets.

public class HousesIndex : AbstractIndexCreationTask<House>
{
public HousesIndex()
{
Map = houses => from house in houses
select new
{
house.HouseType,
house.Name,
house.Description,
x.For<IDocumentStore>().Singleton().Use(context =>
{
var documentStore = new DocumentStore
{
ConnectionStringName = "RavenDB",
Conventions = { IdentityPartsSeparator = "-" }
}.Initialize();
IndexCreation.CreateIndexes(typeof(HousesMinMaxIndex).Assembly, documentStore);
public class HousesMinMaxIndex : AbstractIndexCreationTask<House, HousesMinMaxIndex.Result>
{
public HousesMinMaxIndex()
{
Map = houses => from house in houses
select new
{
HouseType = house.HouseType,
MinPrice = house.Price,
MaxPrice = house.Price,
public class SecurityModule : IHttpModule
{
private const string Key = "PageAccessAllowed";
public void Dispose()
{
}
public void Init(HttpApplication context)
{
var fman = DI.Resolve<ShardManager>().Facets;
var years = fman.GetGroupFacets("Dates").Where(x => x.Key.FieldName == "Year").ToList();
var newsTypes = PickerUtil.DecodeValue(node.GetPropertyString("newsTypes"));
var currentYear = Request["year"] ?? "year:";
var currentNewsType = Request["newsType"] ?? "tags:";
var facets = new List<Eksponent.Lucene.Facets.Facet>()
{
public static void TestMapper<TSource>(TSource model, Expression<Func<TSource, object>> expression)
{
var body = (NewExpression) expression.Body;
foreach (var argument in body.Arguments)
{
var lambda = Expression.Lambda<Func<TSource, object>>(argument, expression.Parameters[0]);
var modelMetadata = ModelMetadata.FromLambdaExpression(lambda, new ViewDataDictionary<TSource>(model));
}
}
public static HelperResult EditField<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression)
{
var path = "/Templates/Partials/EditField/" + (template ?? "Default") + ".cshtml";
var page = WebPageBase.CreateInstanceFromVirtualPath(path);
var context = new WebPageContext(new HttpContextWrapper(HttpContext.Current), page, null);
var modelMetaData = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
var fieldname = ExpressionHelper.GetExpressionText(expression);
context.PageData["Validation"] = html.GetUnobtrusiveValidationAttributes(fieldname, modelMetaData);
@sniffdk
sniffdk / NodeServiceController.cs
Created July 11, 2012 19:03
Umbraco - GetTinyMceMediaStringFromId
public static class StaticRegexes
{
...
public static readonly Regex LocalMediaRegex = new Regex(@"/{localMedia:(\d+?)}", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
}
public class NodeServiceController : Controller
{
[HttpGet]
public JsonResult GetTinyMceMediaStringFromId(string id)
@sniffdk
sniffdk / localmedia.js
Created July 11, 2012 19:15
Umbraco - javascript functions for localmedia
function dialogHandler(id) {
var iesucks = new Date().getTime();
$.ajax('/-/NodeService/GetTinyMceMediaStringFromId', {
type: "GET",
dataType: "json",
async: false,
data: {
id: id,
iesucks: iesucks
},
@sniffdk
sniffdk / TinyMceHelpers.cs
Created July 11, 2012 19:50
Umbraco - TinyMce helpers for parsing localmedia to real links
public static HtmlString ParseTemplates(string html)
{
if (string.IsNullOrWhiteSpace(html)) return new HtmlString(html);
var doc = new HtmlDocument();
doc.LoadHtml(html);
var root = doc.DocumentNode;
if (root != null)
{