Skip to content

Instantly share code, notes, and snippets.

View vtml's full-sized avatar

Vincent Lui vtml

View GitHub Profile
@vtml
vtml / environment-parameter.json
Last active October 30, 2023 05:56
Sample Sitecore Code Deployment ARM Template
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"sitecoreAdminPassword": {
"reference": {
"keyVault": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.KeyVault/vaults/keyvault-kv"
},
"secretName": "sitecoreAdminPassword"
@vtml
vtml / RestrictTemplateFieldWriteAccess.ps1
Created October 25, 2023 04:28
Subject Matter Experts Content Approvers Restrictions
# Create a list of field names on the Standard Template. This will help us filter out extraneous fields.
$standardTemplate = Get-Item -Path "master:" -ID "{1930BBEB-7805-471A-A3BE-4858AC7CF696}"
$standardTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$standardTemplate
$standardFields = $standardTemplateTemplateItem.OwnFields + $standardTemplateTemplateItem.Fields | Select-Object -ExpandProperty ID -Unique
$itemTemplate = Get-Item -Path "."
$itemTemplateTemplateItem = [Sitecore.Data.Items.TemplateItem]$itemTemplate
$itemTemplateFields = $itemTemplateTemplateItem.OwnFields + $itemTemplateTemplateItem.Fields | Select-Object -ExpandProperty ID -Unique
$filterFields = $itemTemplateFields | Where-Object { $standardFields -notcontains $_ } | Get-Item | Sort-Object
@vtml
vtml / PreAuthenticationCustomHeader.cs
Created April 11, 2023 05:43
Adding a hard coded authentication header to the Coveo HTML Index Crawler
using Sitecore.Configuration;
using Coveo.SearchProvider.Processors.FetchPageContent.PreAuthenticators;
namespace CPA.Foundation.Coveo.Processors.preAuthentication
{
/// <summary>
/// Adds a custom authentication header so that Coveo indexer can bypass login page for authenticated content
/// https://docs.coveo.com/en/2326/coveo-for-sitecore-v5/index-page-content-with-the-fetchpagecontentprocessor#the-preauthentication-section
/// </summary>
public class PreAuthenticationCustomHeader : IFetchPageContentPreAuthenticatorProcessor
@vtml
vtml / Foundation.Coveo.config
Last active April 11, 2023 05:04
Coveo Configuration for Sitecore SXA Multi Site with Docker Containers
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:env="http://www.sitecore.net/xmlconfig/env/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:coveo="http://www.sitecore.net/xmlconfig/coveo/">
<sitecore role:require="Standalone or ContentManagement or ContentDelivery" coveo:require="!disabled">
<settings>
<!--
From https://github.com/Sitecore/Sitecore.Demo.Platform/blob/main/src/Foundation/CoveoIndexing/code/App_Config/Include/Foundation/Foundation.CoveoIndexing.config.demo
Coveo for Sitecore back-end code tries to issue HTTPS requests to the CM at the end of a rebuild to validate items are searchable and deleted from the index.
This does not work inside the Docker container network which only has HTTP endpoints.
We disable committed and deleted documents polling to solve this issue.
-->
<setting name="Coveo.Indexing.CommittedDocumentsPollingEnabled" value="false" />
@vtml
vtml / FixPageLinkUrisPostItemProcessing.cs
Created April 11, 2023 04:58
Fix Sitecore Multi Site Context URL before Coveo Indexing
using System;
using System.Linq;
using System.Text.RegularExpressions;
using Coveo.Framework.Processor;
using Coveo.SearchProvider.Pipelines;
using Sitecore.Data;
using Sitecore.Sites;
using System.Collections.Generic;
using Sitecore.Data.Items;
using Sitecore.Data.Managers;
@vtml
vtml / docker-compose.override.yml
Last active March 31, 2023 07:35
Docker Compose additional Network Aliases
labels:
- "traefik.http.middlewares.force-STS-Header.headers.forceSTSHeader=true"
- "traefik.http.middlewares.force-STS-Header.headers.stsSeconds=31536000"
- "traefik.http.routers.cd-secure.entrypoints=websecure"
- "traefik.http.routers.cd-secure.rule=Host(`${CD_HOST}`,`${SITE1_CD_HOST}`,`${SITE2_CD_HOST}`)"
- "traefik.http.routers.cd-secure.tls=true"
- "traefik.http.routers.cd-secure.middlewares=force-STS-Header"
networks:
default:
aliases:
@vtml
vtml / daemon.json
Created June 15, 2022 08:08
Docker Desktop configuration
{
"dns": [
"1.1.1.1",
"1.0.0.1",
"<Insert multiple DNS Entries>"
],
"experimental": false
}
@vtml
vtml / SearchQuery.cs
Created November 22, 2021 01:49 — forked from bic742/SearchQuery.cs
Extended Sitecore SearchQuery to support sorting and more complex search criteria
using GraphQL.Types;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Linq;
using Sitecore.ContentSearch.Linq.Utilities;
using Sitecore.ContentSearch.Utilities;
using Sitecore.Data;
using Sitecore.Data.Managers;
using Sitecore.Globalization;
using Sitecore.Services.GraphQL.Content.GraphTypes.ContentSearch;
using Sitecore.Services.GraphQL.GraphTypes.Connections;
@vtml
vtml / git-setup.sh
Created November 17, 2021 11:03 — forked from patik/git-setup.sh
Git and Node with Zscaler proxy
#!/bin/sh
# Git proxy settings
echo "Configuring Git..."
git config --global http.proxy http://gateway.zscaler.net:80/
git config --system http.proxy http://gateway.zscaler.net:80/
git config --global http.sslVerify false
git config --system http.sslVerify false
git config --global --unset http.sslcainfo
git config --system --unset http.sslcainfo
@vtml
vtml / Publish.ps1
Created October 20, 2021 11:05
Ultimate Sitecore Publishing Powershell Script
param (
[Parameter(HelpMessage = "If ItemIds are specified, only that item will publish. The Item ID should be in the format of {110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}")]
[string[]]
$ItemIds = @(),
[Parameter(HelpMessage = "Target Database name. e.g. Web")]
[string[]]
$TargetDatabases,
[Parameter(HelpMessage = "All languages will publish unless explicitly specified")]