From 8130b833289ee95e9886d1b42070b4ba1d6fdac9 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 24 Jun 2025 18:35:13 +0200 Subject: [PATCH] GoMFT: tmpl bugfix to work with current version until a new release pushed (#5435) --- ct/gomft.sh | 40 +++++++++++++++++++ .../json/{gomft.json.bak => gomft.json} | 0 install/gomft-install.sh | 38 ++++++++++++++++-- 3 files changed, 75 insertions(+), 3 deletions(-) rename frontend/public/json/{gomft.json.bak => gomft.json} (100%) diff --git a/ct/gomft.sh b/ct/gomft.sh index b16388217..365dbf7d3 100644 --- a/ct/gomft.sh +++ b/ct/gomft.sh @@ -45,6 +45,9 @@ function update_script() { msg_ok "Stopped $APP" msg_info "Updating $APP to ${RELEASE}" + if ! command -v git >/dev/null 2>&1; then + $STD apt-get install -y git + fi rm -f /opt/gomft/gomft temp_file=$(mktemp) curl -fsSL "https://github.com/StarFleetCPTN/GoMFT/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" @@ -53,6 +56,43 @@ function update_script() { cd /opt/gomft $STD npm install $STD npm run build + TEMPL_VERSION="$(awk '/github.com\/a-h\/templ/{print $2}' go.mod)" + $STD go install github.com/a-h/templ/cmd/templ@${TEMPL_VERSION} + # dirty hack to fix templ + cat <<'EOF' >/opt/gomft/components/file_metadata/search/file_metadata_search_content.templ +package search + +import ( + "context" + "github.com/starfleetcptn/gomft/components/file_metadata" + "github.com/starfleetcptn/gomft/components/file_metadata/list" +) + +templ FileMetadataSearchContent(ctx context.Context, data file_metadata.FileMetadataSearchData) { + +
+ if len(data.Files) > 0 { + @list.FileMetadataListPartial(ctx, file_metadata.FileMetadataListData{ + Files: data.Files, + Page: data.Page, + Limit: data.Limit, + TotalCount: data.TotalCount, + TotalPages: data.TotalPages, + Filter: data.Filter, + SortBy: data.SortBy, + SortDir: data.SortDir, + }, "/files/search/partial", "#search-results-container") + } else { +
+ + + +

No files found matching your search criteria.

+
+ } +
+} +EOF $STD "$HOME"/go/bin/templ generate export CGO_ENABLED=1 export GOOS=linux diff --git a/frontend/public/json/gomft.json.bak b/frontend/public/json/gomft.json similarity index 100% rename from frontend/public/json/gomft.json.bak rename to frontend/public/json/gomft.json diff --git a/install/gomft-install.sh b/install/gomft-install.sh index ae9c9a8a5..1e6d2389a 100644 --- a/install/gomft-install.sh +++ b/install/gomft-install.sh @@ -36,9 +36,41 @@ cd /opt/gomft TEMPL_VERSION="$(awk '/github.com\/a-h\/templ/{print $2}' go.mod)" $STD go install github.com/a-h/templ/cmd/templ@${TEMPL_VERSION} cp /opt/gomft/components/file_metadata/search/file_metadata_search_content.templ{,.bak} -sed -i -e '/
/a \ @{' \ - -e '/^ }$/a \ }' \ - /opt/gomft/components/file_metadata/search/file_metadata_search_content.templ +# dirty hack to fix templ +cat <<'EOF' >/opt/gomft/components/file_metadata/search/file_metadata_search_content.templ +package search + +import ( + "context" + "github.com/starfleetcptn/gomft/components/file_metadata" + "github.com/starfleetcptn/gomft/components/file_metadata/list" +) + +templ FileMetadataSearchContent(ctx context.Context, data file_metadata.FileMetadataSearchData) { + +
+ if len(data.Files) > 0 { + @list.FileMetadataListPartial(ctx, file_metadata.FileMetadataListData{ + Files: data.Files, + Page: data.Page, + Limit: data.Limit, + TotalCount: data.TotalCount, + TotalPages: data.TotalPages, + Filter: data.Filter, + SortBy: data.SortBy, + SortDir: data.SortDir, + }, "/files/search/partial", "#search-results-container") + } else { +
+ + + +

No files found matching your search criteria.

+
+ } +
+} +EOF $STD "$HOME"/go/bin/templ generate $STD go build -o gomft main.go chmod +x /opt/gomft/gomft