View TableOfContents.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
<table-of-contents title="Contents" source=".article" selector="h2,h3"></table-of-contents> | |
* "title" will be placed in a HEADER tag as the first child | |
* "source" default to the BODY tag | |
* "selector" defaults to "h2" | |
OR |
View RelativeDate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
<relative-date datetime="1971-09-03" prefix="Posted" suffix="ago"/> | |
Outputs: | |
<relative-date>Posted 52 years ago</relative-date> | |
*? |
View Nemmet.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Moved to a permanent repo here: https://github.com/deanebarker/Nemmet |
View .Using the MultiSourceTemplateProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file is just for naming |
View HideVisualViewUIDescriptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[UIDescriptorRegistration] | |
public class HideVisualViewUIDescriptor : UIDescriptor<[Page Type or interface> | |
{ | |
public HideVisualViewUIDescriptor() : base() | |
{ | |
DefaultView = CmsViewNames.AllPropertiesView; | |
EnableStickyView = false; | |
DisabledViews = new[] { CmsViewNames.PreviewView, CmsViewNames.OnPageEditView }; | |
} | |
} |
View BookRankings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
// This code depends on the FlatFiles Nuget package: https://github.com/jehugaleahsa/FlatFiles | |
// Download the dataset from here: https://view.data.post45.org/nytfull | |
var pathToFile = @"[path to file]"; | |
var mapper = DelimitedTypeMapper.Define<BookRanking>(); | |
mapper.Property(c => c.Year).ColumnName("year"); | |
mapper.Property(c => c.Week).ColumnName("week").InputFormat("yyyy-MM-dd"); |
View ExtractTextFromWord.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is some rough/stub code for extracting raw text from a Word document | |
// A modern Word document (.docx) is just a zip file. Extract it. | |
// Find a file called word/document.xml. That contains the text of the document. | |
// Paragraphs are in "w:p" tags, and text is in "w:t". | |
// Iterate the "p" tags, then concatenate all the "t" tags inside them | |
void Main() | |
{ | |
var doc = XDocument.Parse(File.ReadAllText(" [path to word/document.xml] ")); | |
XNamespace nsW = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"; |
View Startup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configuration(IAppBuilder app) | |
{ | |
// This is the URL template to call | |
// The placeholders are optional -- they will be replaced with data specific to the content that is published | |
var webhookUrl = "https://example.com?id={id}&type={type}&version={version}"; | |
// Here is an example URL that would be called for this example: | |
// https://example.com?id=17&type=ArticlePage&version=691 | |
var events = ServiceLocator.Current.GetInstance<IContentEvents>(); |
View ExtractFragmentMiddleware.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using AngleSharp.Html.Parser; | |
using Microsoft.AspNetCore.Http; | |
using System.IO; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace DeaneBarker.Optimizely.Middleware | |
{ | |
public class ExtractFragmentMiddleware | |
{ |
View Editor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This is specifically designed to do as little as possible and have no dependencies. | |
1. It's styled sort of like a code editor (?) | |
2. Spellchecking is turned off (no red squiggly lines -- I hate those!) | |
3. The TAB key will insert 2 spaces, instead of moving focus | |
4. When you press enter, it will add leading spaces to match the leading spaces on the prior line | |
...and that's all it does. |
NewerOlder