Skip to content

Instantly share code, notes, and snippets.

@hermanussen
Created January 18, 2017 16:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hermanussen/821313b79fd25a20fad16109cb85fddb to your computer and use it in GitHub Desktop.
Save hermanussen/821313b79fd25a20fad16109cb85fddb to your computer and use it in GitHub Desktop.
This script crawls the release notes for Sitecore releases on dev.sitecore.net
# 1. This script crawls the release notes for Sitecore releases on dev.sitecore.net
# 2. It will then generate a file called searchfixedpatches.html
# 3. Open the generated file in your browser and you will be able to search for Sitecore support patch numbers
# Robin Hermanussen - 2017
# Use this script at your own risk
$ScriptPath = Split-Path -parent $MyInvocation.MyCommand.Definition
$webClient = New-Object System.Net.WebClient
$allReleases = $webClient.DownloadString('https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform.aspx')
$releaseLinks = $allReleases | Select-String '<h3><a href=\".*\">.*</a></h3>' -AllMatches | % { $_.Matches.Value }
$result = @"
<html>
<head>
<title>Search for fixed patches in releases</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<p>Search for which release a patch might be fixed in. E.g.: if you have a dll like Sitecore.Support.422018.dll in your solution, you will want to search for 422018 to see if that has already been fixed in some release.</p>
<p>Enter support fix number: <input type="text" id="searchbox" /><p>
<div id="container"></div>
</body>
<script type="text/javascript">
var items = [
"@
ForEach ($releaseLink in $releaseLinks)
{
$releaseLink = $releaseLink.Substring(13)
$releaseLink = $releaseLink.Substring(0, $releaseLink.IndexOf('"'))
$releaseLink = $releaseLink.Substring(0, $releaseLink.Length - 5)
$releaseLinkFull = 'https://dev.sitecore.net' + $releaseLink + '/Release Notes'
$releaseNotes = $webClient.DownloadString($releaseLinkFull)
$patchNumbers = $releaseNotes | Select-String '[0-9]{6}|[0-9]{5}' -AllMatches | % { $_.Matches.Value }
ForEach ($patchNumber in $patchNumbers)
{
$result += "['$patchNumber', '$releaseLinkFull'],"
}
}
$result += @"
];
`$(document).ready(function(){
`$("#searchbox").keyup(function(){
var matches = [];
var val = `$("#searchbox").val();
for(var i = 0; i < items.length; i++) {
if(items[i][0] === val) {
matches.push('<li><a href="' + items[i][1] + '">' + items[i][1] + '</a></li>')
}
}
container.innerHTML = 'Mentions:<br /><ul>';
for(var i = 0; i < matches.length; i++) {
container.innerHTML += matches[i];
}
container.innerHTML += '</ul>'
});
});
</script>
</html>
"@
$result | out-File $ScriptPath\searchfixedpatches.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment