Update teedy.ps1

This commit is contained in:
paradizelost 2020-12-17 04:02:47 -06:00 committed by GitHub
parent 39d4c22217
commit 480ce4920e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,50 +148,26 @@ function New-Document(){
param( param(
$title, $title,
$language='eng', $language='eng',
#$tags='', $tags,
$tag='',
$file
)
if($file){
$fileids= Add-File -Files $file
}
$tagid=$taghash[$tag].id
if(-not $tagid){
$tagid=new-tag -TagName $tag
}
$doctocreate=@{
title=$title;
language="eng";
tags= $tagid;
}
$doctocreate
$newdocid = (Invoke-RestMethod -uri "$siteurl/api/document" -Headers $headers -Method PUT -body $doctocreate -ContentType 'application/x-www-form-urlencoded').id
attach-file -documentid $newdocid -fileid $fileids
}
function New-multitagDocument(){
param(
$title,
$language='eng',
#$tags='',
$tag,
$file $file
) )
if($file){ if($file){
$fileids= Add-File -Files $file $fileids= Add-File -Files $file
} }
update-taghash update-taghash
$tagid=$taghash[$tag].id $mytags=@()
if(-not $tagid){ foreach($mytag in $tags){
$tagid=new-tag -TagName $tag $mytags += $taghash[$mytag].id
} }
$doctocreate=@{ $title=[System.Web.HttpUtility]::UrlEncode($title)
title=$title; $basequery = "title=$title&language=$language"
language=$language; if ($tags) { $tagsquery = '&tags={0}' -f ($mytags -join '&tags=') }
tags= @{'0f142bff-7922-4c70-8ad2-f492cfd2e5ec';'07002700-01d8-4547-80b9-c59a7c80f2d6'};
$newdocid = (Invoke-RestMethod -uri "$siteurl/api/document" -Headers $headers -Method PUT -body "$($basequery)$($tagsquery)" -ContentType 'application/x-www-form-urlencoded').id
if($file){
attach-file -documentid $newdocid -fileid $fileids
} }
$doctocreate $newdocid
$newdocid = (Invoke-RestMethod -uri "$siteurl/api/document" -Headers $headers -Method PUT -body $doctocreate -ContentType 'application/x-www-form-urlencoded').id
attach-file -documentid $newdocid -fileid $fileids
} }
Function Add-File(){ Function Add-File(){
param( param(