27 lines
917 B
PowerShell
27 lines
917 B
PowerShell
# Brain記事エクスポートスクリプト
|
|
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[int]$ArticleId
|
|
)
|
|
|
|
$outputFile = "article-$ArticleId-clean.md"
|
|
|
|
Write-Host "記事ID $ArticleId をエクスポート中..." -ForegroundColor Cyan
|
|
|
|
# SSHでPostgreSQLから取得
|
|
$content = ssh mai@100.76.7.3 "/usr/local/bin/docker exec gitea_db psql -U gitea -d posimai_brain -t -A -c 'SELECT full_text FROM articles WHERE id=$ArticleId'"
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "エラー: 記事の取得に失敗しました" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
# \nを実際の改行に変換
|
|
$content = $content -replace '\\n', "`r`n"
|
|
|
|
# UTF-8で保存
|
|
[System.IO.File]::WriteAllText("$PSScriptRoot\$outputFile", $content, [System.Text.Encoding]::UTF8)
|
|
|
|
Write-Host "✓ 保存完了: $outputFile" -ForegroundColor Green
|
|
Write-Host " ファイルサイズ: $([Math]::Round((Get-Item $outputFile).Length / 1KB, 2)) KB"
|