Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Tamás Tárnok trnktms

:octocat:
View GitHub Profile
View Sitecore.IdentityServer.Host.xml
<?xml version="1.0" encoding="utf-8"?>
<Settings>
<Sitecore>
<IdentityServer>
...
<AccountOptions>
<PasswordRecoveryUrl>https://public.cm.com/sitecore/login?rc=1</PasswordRecoveryUrl>
</AccountOptions>
<Clients>
<DefaultClient>
View sitecore.identity.server.config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" >
<sitecore role:require="Standalone or ContentDelivery or ContentManagement">
<sc.variable name="identityServerAuthority" value="https://identity.server" />
<settings>
<!-- Fill the FederatedAuthentication.IdentityServer.CallbackAuthority setting if you need another host to receive callbacks from IdentityServer. It is useful for reverse proxy configuration. -->
<setting name="FederatedAuthentication.IdentityServer.CallbackAuthority" value="https://public.cm.com" />
</settings>
</sitecore>
</configuration>
View web.config for reverse proxy
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="https://cm.green/{R:1}" />
</rule>
</rules>
View Startup.cs
public class Startup
{
...
public void ConfigureServices(IServiceCollection services)
{
...
services.AddSessionWithStartSession();
...
}
View SessionExtensions.cs
public static class SessionExtensions
{
public static void AddSessionWithStartSession(this IServiceCollection services)
{
services.AddSingleton<ISessionStore, DistributedSessionStoreWithStart>();
services.AddDistributedMemoryCache();
services.AddSession(options =>
{
options.Cookie.IsEssential = true;
});
View StartSession.cs
public interface IStartSession
{
void InvokeStartSesssionActions(ISession session);
void AddToStartSession(Action<ISession> action);
}
public class StartSession : IStartSession
{
private static readonly IList<Action<ISession>> StartSessionActions = new List<Action<ISession>>();
View DistributedSessionStoreWithStart.cs
public class DistributedSessionStoreWithStart : DistributedSessionStore, ISessionStore
{
readonly IStartSession _startSession;
public DistributedSessionStoreWithStart(
IDistributedCache cache,
ILoggerFactory loggerFactory,
IStartSession startSession)
: base(cache, loggerFactory)
{
View fix-urls-in-rte.ps1
$oldUrlField = "Old URL"
$oldUrlItems = "/sitecore/content/Home"
$rteField = "Text"
$rteQuery = "/sitecore/content/rich-text-components//*[(contains(@$rteField, '{0}'))]"
$languages = "en","hu-HU"
foreach ($language in $languages) {
Write-Host "Start fixing references for language: $language"
Write-Log "Start fixing references for language: $language"
View find-item-duplicates.ps1
$sourceItems = Get-ChildItem -Recurse -Path "/sitecore/content/"
$query = "/sitecore/content//*[@@id!='{0}' and @OldUrl='{1}']"
$queryWithContains = "/sitecore/content//*[@@id!='{0}' and (@OldUrl='{1}' or contains(@OldUrl, '{2}'))]"
$foundDuplicatesCollection = New-Object System.Collections.ArrayList
Write-Host "SourceItemParentPath, SourceItemPath, SourceItemId, FoundDuplicateParentPath, FoundDuplicatePath, FoundDuplicateId, OriginalUrl, FoundDuplicateUrl" -ForegroundColor Green
foreach ($sourceItem in $sourceItems) {
$originalUrl = $sourceItem["OldUrl"]
View solr-diagnostic.cshtml
@using System.Reflection
@using Sitecore.ContentSearch
@using Sitecore.ContentSearch.SolrProvider
@using Sitecore.ContentSearch.SolrProvider.Agents
<html>
<body>
Solr Status: @SolrStatus.OkSolrStatus()
<br />
Solr Last Status: @typeof(IndexingStateSwitcher).GetField("lastSolrConnectionStatus", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(null)
<br />
You can’t perform that action at this time.