Skip to content

Commit

Permalink
New captions (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh authored Feb 6, 2025
2 parents 5b5cfaf + bcc9dc3 commit 09fce6b
Show file tree
Hide file tree
Showing 1,850 changed files with 25,719 additions and 13,823 deletions.
27 changes: 25 additions & 2 deletions .powershell/_includes/HugoHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ function Get-HugoMarkdown {
return [HugoMarkdown]::new($frontMatter, $bodyContent)
}

function Remove-Field {
param (
[Parameter(Mandatory = $true)]
[System.Collections.Specialized.OrderedDictionary]$frontMatter,
[Parameter(Mandatory = $true)]
[string]$fieldName
)

if ($frontMatter.Contains($fieldName)) {
$frontMatter.Remove($fieldName)
Write-Host "$fieldName removed"
}
else {
Write-Host "$fieldName does not exist"
}
}

# Function to update a field in the front matter
function Update-Field {
param (
Expand Down Expand Up @@ -106,7 +123,8 @@ function Update-StringList {
[Parameter(Mandatory = $true)]
[string[]]$values,
[string]$addAfter = $null,
[string]$addBefore = $null
[string]$addBefore = $null,
[switch]$Overwrite
)

# Ensure the input values are unique and always an array
Expand Down Expand Up @@ -141,7 +159,12 @@ function Update-StringList {
$existingValues = $frontMatter[$fieldName]
$newValues = $values | Where-Object { -not ($existingValues -icontains $_) }
if ($newValues.Count -ne 0) {
$frontMatter[$fieldName] += $newValues
if ($Overwrite) {
$frontMatter[$fieldName] = $newValues
}
else {
$frontMatter[$fieldName] += $newValues
}
Write-Host "$fieldName updated with new unique values"
}
else {
Expand Down
55 changes: 54 additions & 1 deletion .powershell/_includes/ResourceHelpers.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

. ./.powershell/_includes/OpenAI.ps1

function New-ResourceId {
param (
Expand Down Expand Up @@ -32,5 +32,58 @@ function Get-ResourceType {
}
}

function Get-UpdatedCategories {
param (
[string[]]$CurrentCategories,
[hashtable]$CatalogCategories,
[string]$ResourceContent,
[string]$ResourceTitle,
[string]$ResourceYear,
[int]$MaxCategories = 5,
[int]$MinCategories = 1,
[int]$ResourceYearLimit = 2014
)

# Convert the category catalog into a formatted string
$catalogString = ($CatalogCategories.GetEnumerator() | ForEach-Object { "`"$($_.Key)`": $($_.Value)" }) -join "`n"

If ($ResourceYear -lt $ResourceYearLimit) {
$maxCategories = 2
$MinCategories = 1
}

# Construct a prompt for OpenAI
$prompt = @"
You are an expert in content classification. Given the resource title, content, and a predefined catalog of categories with descriptions, choose the most relevant categories that capture the core themes, arguments, and principles of the resource.
- **Resource Title:** "$ResourceTitle"
- **Resource Year:** "$ResourceYear"
- **Resource Content:** "$ResourceContent"
- **Catalog of Valid Categories and Descriptions:**
$catalogString
### Rules:
1. Prioritise categories related to Scrum when discussing Scrum concepts (e.g., ‘Scrum Master’, ‘Definition of Done’, ‘Scrum Team’).
2. For quality-focused discussions, prioritise categories like ‘Definition of Done’, ‘Software Increment’, ‘Continuous Delivery’, and ‘Technical Excellence’.
3. Do NOT assign broad Agile categories (e.g., ‘Agile Coaching’) if the content is specifically about Scrum principles.
4. Avoid assigning categories based on isolated words—focus on the context and main arguments.
5. Limit the selection to "$MinCategories"-"$MaxCategories" categories to ensure precision.
6. Do not assign a category if it is not meaningfully reflected in theme and intent of the content.
7. Ensure that you match the case and spelling of the categories in the catalog.
Return only the updated categories as a comma-separated list with no additional characters.
"@

# Get a response from OpenAI
$updatedCategoriesString = Get-OpenAIResponse -Prompt $prompt

# Convert the response into an array
$updatedCategories = $updatedCategoriesString -split ', ' | ForEach-Object { $_.Trim() }

return $updatedCategories
}



Write-Host "ResourceHelpers.ps1 loaded" -ForegroundColor Green
279 changes: 279 additions & 0 deletions .powershell/single-use/resources/Update-Catagories.ps1

Large diffs are not rendered by default.

131 changes: 108 additions & 23 deletions .powershell/single-use/resources/Update-ReourcesFrontMatter.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@
. ./.powershell/_includes/ResourceHelpers.ps1

# Iterate through each blog folder and update markdown files
$outputDir = "site\content\resources\blog\2025"
$outputDir = ".\site\content\resources\blog"

# Get list of directories and select the first 10
$resources = Get-ChildItem -Path $outputDir -Recurse -Filter "index.md" #| Select-Object -First 10

# Initialize a hash table to track counts of each ResourceType
$resourceTypeCounts = @{}

# Total count for progress tracking
$TotalFiles = $resources.Count
$Counter = 0

$resources | ForEach-Object {

$Counter++
$PercentComplete = ($Counter / $TotalFiles) * 100

Write-Progress -Activity "Processing Markdown Files" -Status "Processing $Counter of $TotalFiles" -PercentComplete $PercentComplete


$resourceDir = (Get-Item -Path $_).DirectoryName
$markdownFile = $_
Write-Host "--------------------------------------------------------"
Expand All @@ -19,13 +33,18 @@ $resources | ForEach-Object {
# Load markdown as HugoMarkdown object
$hugoMarkdown = Get-HugoMarkdown -Path $markdownFile

if (-not $hugoMarkdown.FrontMatter.description) {
#=================CLEAN============================
Remove-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'id'
#=================description=================
if (-not $hugoMarkdown.FrontMatter.description -or $hugoMarkdown.FrontMatter.description -match "no specific details provided") {
# Generate a new description using OpenAI
$prompt = "Generate a concise, engaging description of no more than 160 characters for the following video: '$($videoData.snippet.title)'. The video details are: '$($videoData.snippet.description)'"
$prompt = "Generate a concise, engaging description of no more than 160 characters for the following resource: '$($videoData.snippet.title)'. The Resource details are: '$($hugoMarkdown.BodyContent)'"
$description = Get-OpenAIResponse -Prompt $prompt
# Update the description in the front matter
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'description' -fieldValue $description -addAfter 'title'
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'description' -fieldValue $description -addAfter 'title' -
}

#=================ResourceId=================
$ResourceId = $null;
if ($hugoMarkdown.FrontMatter.Contains("ResourceId")) {
$ResourceId = $hugoMarkdown.FrontMatter.ResourceId
Expand All @@ -35,40 +54,70 @@ $resources | ForEach-Object {
}
else {
$ResourceId = New-ResourceId
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceId' -fieldValue $ResourceId -addAfter 'description'
}
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceId' -fieldValue $ResourceId -addAfter 'description'
#=================ResourceType=================
$ResourceType = Get-ResourceType -FilePath $resourceDir
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceType' -fieldValue $ResourceType -addAfter 'ResourceId' -Overwrite

#=================ResourceImport+=================
if (Test-Path (Join-Path $resourceDir "data.yaml" ) || Test-Path (Join-Path $resourceDir "data.json" )) {
$ResourceImport = $true
}
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImport' -fieldValue $ResourceImport -addAfter 'ResourceId' -Overwrite
if ($hugoMarkdown.FrontMatter.ResourceImport) {
switch ($ResourceType) {
"blog" {
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImportSource' -fieldValue "Wordpress" -addAfter 'ResourceImport'
If (([datetime]$hugoMarkdown.FrontMatter.date) -lt ([datetime]'2011-02-16')) {
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImportOriginalSource' -fieldValue "GeeksWithBlogs" -addAfter 'ResourceImportSource' -Overwrite
}
else {
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImportOriginalSource' -fieldValue "Wordpress" -addAfter 'ResourceImportSource' -Overwrite
}
}
"videos" {

}
}
}
else {
Remove-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImportSource'
Remove-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImportOriginalSource'
}
# =================Add aliases===================
$aliases = @()
switch ($ResourceType) {
"blog" {
}
"podcast" {
}
"videos" {
}
}
# Always add the ResourceId as an alias
if ($hugoMarkdown.FrontMatter.Contains("ResourceId")) {
$aliases += "/resources/$($hugoMarkdown.FrontMatter.ResourceId)"
}
Update-StringList -frontMatter $hugoMarkdown.FrontMatter -fieldName 'aliases' -values $aliases -addAfter 'slug'
# =================Add 404 aliases===================
$404aliases = @()
$404aliases += $hugoMarkdown.FrontMatter.aliases | Where-Object { $_ -notmatch $hugoMarkdown.FrontMatter.ResourceId }
switch ($ResourceType) {
"blog" {
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImport' -fieldValue $hugoMarkdown.FrontMatter.Contains("ResourceImportId") -addAfter 'ResourceId' -Overwrite
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImportSource' -fieldValue "Wordpress" -addAfter 'ResourceImport'
If (([datetime]$hugoMarkdown.FrontMatter.date) -lt ([datetime]'2011-02-16')) {
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImportOriginalSource' -fieldValue "GeeksWithBlogs" -addAfter 'ResourceImportSource'
}
else {
Update-Field -frontMatter $hugoMarkdown.FrontMatter -fieldName 'ResourceImportOriginalSource' -fieldValue "Wordpress" -addAfter 'ResourceImportSource'
}
if ($hugoMarkdown.FrontMatter.Contains("slug")) {
$slug = $hugoMarkdown.FrontMatter.slug
$aliases += "/$slug"
$404aliases += "/$slug"
$aliases += "/blog/$slug"
$404aliases += "/blog/$slug"
}
if ($hugoMarkdown.FrontMatter.Contains("title")) {
$slug = $hugoMarkdown.FrontMatter.slug
$urlSafeTitle = ($hugoMarkdown.FrontMatter.title -replace '[:\/\\*?"<>|#%.!,]', '-' -replace '\s+', '-').ToLower()
if ($urlSafeTitle -ne $slug) {
$aliases += "/$urlSafeTitle"
$404aliases += "/$urlSafeTitle"
$aliases += "/blog/$urlSafeTitle"
$404aliases += "/blog/$urlSafeTitle"
}
}

}
"podcast" {

Expand All @@ -80,20 +129,56 @@ $resources | ForEach-Object {

}
}
# Always add the ResourceId as an alias
if ($hugoMarkdown.FrontMatter.Contains("ResourceId")) {
$aliases += "/resources/$($hugoMarkdown.FrontMatter.ResourceId)"
}
Update-StringList -frontMatter $hugoMarkdown.FrontMatter -fieldName 'aliases' -values $aliases -addAfter 'slug'
if ($404aliases -is [array] -and $404aliases.Count -gt 0) {
Update-StringList -frontMatter $hugoMarkdown.FrontMatter -fieldName 'aliasesFor404' -values $404aliases -addAfter 'aliases'
}

#================Catsagories & TAGS==========================
. ./.powershell/single-use/resources/Update-Catagories.ps1

$year = [datetime]::Parse($hugoMarkdown.FrontMatter.date).Year
$BodyContent = $hugoMarkdown.BodyContent
If ($hugoMarkdown.FrontMatter.ResourceType -eq "videos") {
$captionsPath = Join-Path $resourceDir "index.captions.en.md"
if (Test-Path ($captionsPath )) {
$BodyContent = Get-Content $captionsPath -Raw
}
}
#-----------------Categories-------------------
$unknownCategories = @();
if ($hugoMarkdown.FrontMatter.Contains("categories")) {
$unknownCategories = $hugoMarkdown.FrontMatter.categories | Where-Object { -not $CatalogCategories.ContainsKey($_) }
}
If ($unknownCategories.Count -gt 0 -or -not $hugoMarkdown.FrontMatter.Contains("categories") -or ($hugoMarkdown.FrontMatter.categories -is [array] -and $hugoMarkdown.FrontMatter.categories.Count -eq 0)) {
$newCatagories = Get-UpdatedCategories -CurrentCategories $hugoMarkdown.FrontMatter.categories -Catalog $CatalogCategories -ResourceContent $BodyContent -ResourceTitle $hugoMarkdown.FrontMatter.title -ResourceYear $year -MaxCategories 7 -MinCategories 3
Update-StringList -frontMatter $hugoMarkdown.FrontMatter -fieldName 'categories' -values $newCatagories -Overwrite
}
#-----------------Tags-------------------
$unknownTags = @();
if ($hugoMarkdown.FrontMatter.Contains("tags")) {
$unknownTags = $hugoMarkdown.FrontMatter.tags | Where-Object { -not $CatalogTags.ContainsKey($_) }
}
If ($unknownTags.Count -gt 0 -or -not $hugoMarkdown.FrontMatter.Contains("tags") -or ($hugoMarkdown.FrontMatter.tags -is [array] -and $hugoMarkdown.FrontMatter.tags.Count -eq 0)) {
$newtags = Get-UpdatedCategories -CurrentCategories $hugoMarkdown.FrontMatter.tags -Catalog $CatalogTags -ResourceContent $BodyContent -ResourceTitle $hugoMarkdown.FrontMatter.title -ResourceYear $year -MaxCategories 15 -MinCategories 10
Update-StringList -frontMatter $hugoMarkdown.FrontMatter -fieldName 'tags' -values $newtags -Overwrite
}

# =================COMPLETE===================
Save-HugoMarkdown -hugoMarkdown $hugoMarkdown -Path $markdownFile
}
else {
Write-Host "Skipping folder: $blogDir (missing index.md)"
}
# Track count of ResourceType
if ($resourceTypeCounts.ContainsKey($ResourceType)) {
$resourceTypeCounts[$ResourceType]++
}
else {
$resourceTypeCounts[$ResourceType] = 1
}
}

Write-Host "All markdown files processed."
Write-Host "--------------------------------------------------------"
Write-Host "Summary of updated Resource Types:"
$resourceTypeCounts.GetEnumerator() | ForEach-Object { Write-Host "$($_.Key): $($_.Value)" }
6 changes: 6 additions & 0 deletions site/content/categories/agile-product-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Agile Product Management
description: Strategies for maximising value through iterative discovery, delivery, and outcome-driven development.

---

6 changes: 6 additions & 0 deletions site/content/categories/ai-and-automation-in-agility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: AI and Automation in Agility
description: Leveraging AI-driven automation to enhance agility, decision-making, and software delivery.

---

6 changes: 6 additions & 0 deletions site/content/categories/application-lifecycle-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Application Lifecycle Management
description: Managing the development, maintenance, and governance of software applications throughout their lifecycle.

---

6 changes: 6 additions & 0 deletions site/content/categories/azure-devops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Azure DevOps
description: A set of development tools and services by Microsoft for CI/CD, collaboration, and agile project management.

---

6 changes: 6 additions & 0 deletions site/content/categories/code-and-complexity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Code and Complexity
description: Discussions around software code quality, complexity management, and best practices in development.

---

6 changes: 6 additions & 0 deletions site/content/categories/complexity-thinking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Complexity Thinking
description: An approach to understanding and managing organisations, systems, and uncertainty using complexity science, emergence, and nonlinear dynamics.

---

6 changes: 6 additions & 0 deletions site/content/categories/decision-theory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Decision Theory
description: Decision-making in uncertain environments using heuristics, probability, and behavioural economics.

---

6 changes: 6 additions & 0 deletions site/content/categories/devops.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: DevOps
description: The integration of engineering, operations, and security practices to enable continuous delivery of value.

---

6 changes: 6 additions & 0 deletions site/content/categories/discovery-and-learning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Discovery and Learning
description: Exploring new ideas, innovation, and continuous learning in product and software development.

---

6 changes: 6 additions & 0 deletions site/content/categories/enterprise-agility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Enterprise Agility
description: Scaling agility beyond teams to drive organisational responsiveness and adaptability.

---

6 changes: 6 additions & 0 deletions site/content/categories/events-and-presentations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Events and Presentations
description: Talks, conferences, webinars, and presentations related to Agile, DevOps, and software engineering.

---

6 changes: 6 additions & 0 deletions site/content/categories/flow-efficiency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Flow Efficiency
description: Optimising the throughput of work across the value stream to improve speed and reduce bottlenecks.

---

Loading

0 comments on commit 09fce6b

Please sign in to comment.