Work on #16 This was a relatively large amount of work. It introduces assets which are stored in the assets sub directory and stored in the database with the asset type in the database.
47 lines
922 B
Bash
47 lines
922 B
Bash
#!/usr/bin/env bash
|
|
|
|
getYamlBlock(){
|
|
vecho "getYamlBlock $*"
|
|
cd "$dataDir" || return
|
|
local filename
|
|
filename="$(findFile "$1")"
|
|
|
|
# If there is a yaml file, use it
|
|
# if not, try and get the yaml header
|
|
getYamlFile "$filename" || getYamlHeader "$filename"
|
|
}
|
|
|
|
getYamlFile(){
|
|
vecho "getYamlFile $*"
|
|
cd "$dataDir" || return
|
|
local filename
|
|
filename="$(findFile "$1")"
|
|
if [ -f "$filename.yaml" ]; then
|
|
cat "$filename.yaml"
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
getYamlHeader(){
|
|
vecho "getYamlHeader $*"
|
|
cd "$dataDir" || return
|
|
local filename
|
|
filename="$(findFile "$1")"
|
|
sed -n '1 { /^---/ { :a N; /\n---/! ba; p} }' "$filename" |
|
|
sed '1d;$d;s/\t/ /g'
|
|
}
|
|
|
|
getYamlTitle(){
|
|
vecho "getYamlTitle $*"
|
|
cd "$dataDir" || return
|
|
getYamlBlock "$1" | yq -r '.Title'
|
|
}
|
|
|
|
getYamlTags(){
|
|
vecho "getYamlTags $*"
|
|
cd "$dataDir" || return
|
|
getYamlBlock "$1" | yq -r '.Tags | if . == null then [] else . end | join("\n")'
|
|
}
|
|
|