Bahn: aisupport, Analyse-O2C-C2S, awesome-bahn-mcp-servers, beam-mcp,
Confluence_Bot, db-planet-mcp-server, O2C-Harness, project-audit,
Projekt-KIQ-HP, teamlandkarte-mcp
Dhive: Jury-Voting
Privat: CV, NoteGraph (NOTE: NoteGraph needs complete redo after consolidation)
Shared: AI-Orchestrator, OrgMyLife, power_skills_and_more
Shared/references: symphony (read-only)
Bahn repos remain available as independent remotes - this monorepo
pulls them in via subtree, the originals are untouched.
106 lines
4.5 KiB
PowerShell
106 lines
4.5 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Liest spezifische Confluence-Seiten per API
|
|
#>
|
|
|
|
$ConfluenceUrl = "https://arija-confluence.jaas.service.deutschebahn.com"
|
|
$ApiBase = "$ConfluenceUrl/rest/api"
|
|
$OutputDir = "project-audit\data\confluence-ttsi"
|
|
|
|
$PageIds = @(
|
|
@{ id = "424295009"; name = "TAF-TAP-TSI-Programmakte" }
|
|
@{ id = "428930895"; name = "TAF-TAP-TSI-Programmsteuerung" }
|
|
@{ id = "490596078"; name = "TAF-TAP-TSI-Fachliche-Dokumentation" }
|
|
)
|
|
|
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
|
|
|
Write-Host "============================================================"
|
|
Write-Host " Confluence TTSI-Space Seiten lesen"
|
|
Write-Host "============================================================"
|
|
|
|
$PAT = Read-Host "Confluence PAT"
|
|
$Headers = @{ "Authorization" = "Bearer $PAT" }
|
|
|
|
New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null
|
|
|
|
Add-Type -AssemblyName System.Web -ErrorAction SilentlyContinue
|
|
|
|
function Convert-HtmlToText($html) {
|
|
if ($null -eq $html) { return "" }
|
|
$text = $html -replace '<br\s*/?>', "`n"
|
|
$text = $text -replace '<p[^>]*>', "`n"
|
|
$text = $text -replace '</p>', ""
|
|
$text = $text -replace '<li[^>]*>', "`n- "
|
|
$text = $text -replace '<h[1-6][^>]*>', "`n## "
|
|
$text = $text -replace '</h[1-6]>', "`n"
|
|
$text = $text -replace '<tr[^>]*>', "`n| "
|
|
$text = $text -replace '<td[^>]*>', " | "
|
|
$text = $text -replace '<th[^>]*>', " | "
|
|
$text = $text -replace '<[^>]+>', ''
|
|
try { $text = [System.Web.HttpUtility]::HtmlDecode($text) } catch {}
|
|
return $text.Trim()
|
|
}
|
|
|
|
foreach ($Page in $PageIds) {
|
|
$PageId = $Page.id
|
|
$PName = $Page.name
|
|
Write-Host ""
|
|
Write-Host ">> $PName (ID: $PageId)" -ForegroundColor Yellow
|
|
|
|
$Uri = "$ApiBase/content/$PageId`?expand=body.storage,version,space,children.page"
|
|
try {
|
|
$Resp = Invoke-WebRequest -Uri $Uri -Headers $Headers -UseBasicParsing -ErrorAction Stop
|
|
$Data = $Resp.Content | ConvertFrom-Json
|
|
Write-Host " Titel: $($Data.title) (v$($Data.version.number))" -ForegroundColor Green
|
|
|
|
# HTML speichern
|
|
$HtmlContent = ""
|
|
if ($Data.body -and $Data.body.storage) { $HtmlContent = $Data.body.storage.value }
|
|
$HtmlContent | Out-File "$OutputDir\$PName.html" -Encoding UTF8
|
|
|
|
# Markdown speichern
|
|
$TextContent = Convert-HtmlToText $HtmlContent
|
|
$MdContent = "# $($Data.title)`n`n> Page ID: $PageId | Version: $($Data.version.number) | Space: $($Data.space.key)`n`n---`n`n$TextContent"
|
|
$MdContent | Out-File "$OutputDir\$PName.md" -Encoding UTF8
|
|
|
|
Write-Host " Gespeichert ($($HtmlContent.Length) Zeichen)"
|
|
|
|
# Kindseiten auflisten
|
|
if ($Data.children -and $Data.children.page -and $Data.children.page.results) {
|
|
Write-Host " Kindseiten:" -ForegroundColor DarkGray
|
|
foreach ($Child in $Data.children.page.results) {
|
|
Write-Host " - $($Child.title) (ID: $($Child.id))"
|
|
}
|
|
|
|
# Kindseiten auch lesen
|
|
foreach ($Child in $Data.children.page.results) {
|
|
Write-Host " >> Kindseite: $($Child.title)..." -NoNewline
|
|
$ChildUri = "$ApiBase/content/$($Child.id)`?expand=body.storage,version"
|
|
try {
|
|
$CResp = Invoke-WebRequest -Uri $ChildUri -Headers $Headers -UseBasicParsing -ErrorAction Stop
|
|
$CData = $CResp.Content | ConvertFrom-Json
|
|
$CHtml = ""
|
|
if ($CData.body -and $CData.body.storage) { $CHtml = $CData.body.storage.value }
|
|
$CText = Convert-HtmlToText $CHtml
|
|
$SafeTitle = $Child.title -replace '[\\/:*?"<>|]', '_'
|
|
if ($SafeTitle.Length -gt 60) { $SafeTitle = $SafeTitle.Substring(0, 60) }
|
|
$CMd = "# $($Child.title)`n`n> Page ID: $($Child.id) | Parent: $PName`n`n---`n`n$CText"
|
|
$CMd | Out-File "$OutputDir\$PName`_$SafeTitle.md" -Encoding UTF8
|
|
$CHtml | Out-File "$OutputDir\$PName`_$SafeTitle.html" -Encoding UTF8
|
|
Write-Host " OK" -ForegroundColor Green
|
|
} catch {
|
|
Write-Host " FEHLER" -ForegroundColor Red
|
|
}
|
|
}
|
|
}
|
|
} catch {
|
|
Write-Host " FEHLER: $($_.Exception.Message)" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "============================================================" -ForegroundColor Green
|
|
Write-Host " FERTIG! Ergebnisse in $OutputDir" -ForegroundColor Green
|
|
Write-Host "============================================================" -ForegroundColor Green
|