Skip to content

Instantly share code, notes, and snippets.

View jeremy-farrance's full-sized avatar

Jeremy Farrance jeremy-farrance

View GitHub Profile
@jeremy-farrance
jeremy-farrance / web-rewrite-snip.config
Last active July 4, 2021 21:07
DNN - Use in IIS to serve sitemap.aspx AS sitemap.xml
<!-- manually add this in to your DNN instance's web.config -->
<!-- Desc: for tools or services that expect sitemap.xml instead of .aspx,
this will deliver the results of DNN's sitemap.aspx AS the expected XML file in the root
-->
<system.webServer>
<rewrite>
<rules>
<rule name="XML sitemap from sitemap.aspx" stopProcessing="true">
<match url=".+" />
<conditions>
@jeremy-farrance
jeremy-farrance / web.config
Created March 29, 2019 19:46
Example of a NewtonSoft.Json BindingRedirect in web.config for ASP.NET IIS
<!-- other stuff -->
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- other stuff -->
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-32767.32767.32767.32767" newVersion="10.0.0.0" />
</dependentAssembly>
@jeremy-farrance
jeremy-farrance / sftp.json
Last active September 13, 2020 00:19
VS Code sftp.json for liximomo's vscode-sftp extension for DNN (DotNetNuke) front-end editing
{
"host": "___HOST_NAME___",
"username": "___USER_NAME___",
"password": "___PASSWORD___",
"name": "AccuTheme",
"context": "./app",
"protocol": "ftp",
"port": 21,
"secure": true,
"secureOptions": {
@jeremy-farrance
jeremy-farrance / _functions-ToSlug.cshtml
Last active February 25, 2023 18:03
ToSlug, Generate URL slug from a name, title, etc.
@functions {
// Turn any text or title in to a URL Slug
// original = https://stackoverflow.com/questions/2920744/url-slugify-algorithm-in-c
// .ToSlug("My Title=Heading - &*(-) end-") >> "my-titleheading-end"
public string ToSlug(string phrase)
{
byte[] bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(phrase);
string str = System.Text.Encoding.ASCII.GetString(bytes);
@jeremy-farrance
jeremy-farrance / _SidebarMenu-excerpt.cshtml
Last active November 11, 2019 20:49
DNN RazorHost or DDRMenu RazorScript to access 2sxc data (Content-Types) using AsDynamic()
// from PDEG project 2019
@using ToSic.SexyContent.Environment.Dnn7
var sxci = Factory.SxcInstanceForModule(3354, 606); // ModID of Flyout Menu editor, TabID of SITE/Manage Flyouts Links
var dyn = Factory.CodingHelpers(sxci);
var appContent = Factory.App(2); // Content App is usually 2, but not always
var myPageDetails = dyn.AsDynamic(appContent.Data["Content"]);
/* DNN 8.x 9.x
Note: stored in SQL dbo.[]HostSettings as AUM_KeepInQueryStringRegex
Settings, SEO, URL Management, Expressions
Keep in Querystring Regular Expression
Default
/nomo/\d+|/runningDefault/[^/]+|/popup/(?:true|false)|/(?:page|category|sort|tags)/[^/]+|tou/[^/]+|(/utm[^/]+/[^/]+)+
@jeremy-farrance
jeremy-farrance / _Helpers--Basic.cshtml
Last active September 20, 2021 23:12
2sxc - Accuraty reusable library of functions (started fall 2019)
@* common ASL functions that help or simplyfy things in 2sxc
usage from another Razor script:
// get library of helpful functions/commands
var lib = CreateInstance("_Helpers--Basic.cshtml");
// then call them with @lib.ConvertLineBreaks(myString)
*@
@using System.Text.RegularExpressions -- used by ToSlug()
@jeremy-farrance
jeremy-farrance / RazorKit.cshtml
Last active July 22, 2020 00:09
RazorKit with Poly (Polymorph), IsSuper, IsAccuratyIP, GetIpAddress, GetIpFromHostname for DNN (OHS) Projects
@* >>> put me in your /App_Code folder
Changes and updates:
- combined all previous versions in to this one 20200721 JRF
- added ThemePath() and ThemeCssPath() 20200720 JRF
- added Razor.Blade (dependency) and misc cleanups, self-docs 202004 JRF
- added initial Polymorph and business rules 20200102 JRF
- added to project and renamed to razor-kit.cshtml 20190313 JRF
- added GetIpFromHostname(); resolve a DNS entry (FQDN)
- added GetIpAddress() of the website visitor
- New 20181015 JRF
@jeremy-farrance
jeremy-farrance / __debug-vb.ascx
Last active June 19, 2020 15:49
A DNN Theme include file that outputs useful Debug info for OHS, development, etc.
<%-- THIS IS THE VB.NET VERSION
>> unfortunately it does not stay in sync with the C# version, so its probably better to
>> use this as a reference for the VB code and use the actual output from the C# version
For older templates, works best if included before closing DIV in main footer section of _footer.ascx like this
<!-- #include virtual="__debug-vb.ascx" -->
--%>
<% If GetIpAddress() = "192.241.63.162" Then %>
@jeremy-farrance
jeremy-farrance / __debug.ascx
Last active August 8, 2021 18:04
A DNN Theme footer include file that outputs useful Debug info for OHS, development, etc. C#, CSharp, .NET
<%-- THIS IS THE C# CSharp .NET VERSION
NOTES:
- the way we get the Skin name is "janky" ;)
- uses Bootstrap (next version won't?)
How to use:
1. Save this file in your theme folder, usually includes/__debug.ascx
2. Update the IPs; add the WAN IP(s) for your location(s)
3. Update the Bootstrap version manually
4. Either in includes/_footer.ascx (or Home.ascx), before closing DIV in main <footer> section add this