From 0357c4f4b201ff97966783a838d084a6012f99fb Mon Sep 17 00:00:00 2001 From: Elias Kohout Date: Wed, 26 Mar 2025 16:32:57 +0100 Subject: [PATCH] move webserver files to ./web/ --- Dockerfile | 6 +++--- src/cmd/frontend/main.go | 4 ++-- src/{assets => }/migrations/20250102152758_article.sql | 0 src/{assets => }/migrations/20250102232127_article_fts.sql | 0 .../migrations/20250103140557_response_cache.sql | 0 .../migrations/20250103203320_response_new_column.sql | 0 .../migrations/20250107091120_remove_responses.sql | 0 .../migrations/20250107104609_drop_column_author.sql | 0 .../migrations/20250107113527_add_aisummary_column.sql | 0 .../migrations/20250112141434_document_table.sql | 0 .../migrations/20250112162651_rm_tsvector_column.sql | 0 .../migrations/20250120084318_mv_ai_summary.sql | 0 src/{internal => web}/app/app.go | 0 src/{internal => web}/app/article.go | 2 +- src/{internal => web}/app/index.go | 4 ++-- src/{internal => web}/app/rss.go | 0 src/{internal => web}/app/upsearch.go | 4 ++-- src/{internal => web}/html/article.go | 0 src/{internal => web}/html/articleLayout.go | 0 src/{internal => web}/html/articlePage.go | 0 src/{internal => web}/html/indexLayout.go | 0 src/{internal => web}/html/layout.go | 0 src/{internal => web}/html/navbar.go | 0 src/{internal => web}/html/pagination.go | 0 src/{internal => web}/middleware/logging.go | 0 src/{internal => web}/middleware/middleware.go | 0 src/{assets => web}/static/daisyui.min.css | 0 src/{assets => web}/static/tailwindcss.min.js | 0 src/{assets => web}/static/unpoly.min.css | 0 src/{assets => web}/static/unpoly.min.js | 0 30 files changed, 10 insertions(+), 10 deletions(-) rename src/{assets => }/migrations/20250102152758_article.sql (100%) rename src/{assets => }/migrations/20250102232127_article_fts.sql (100%) rename src/{assets => }/migrations/20250103140557_response_cache.sql (100%) rename src/{assets => }/migrations/20250103203320_response_new_column.sql (100%) rename src/{assets => }/migrations/20250107091120_remove_responses.sql (100%) rename src/{assets => }/migrations/20250107104609_drop_column_author.sql (100%) rename src/{assets => }/migrations/20250107113527_add_aisummary_column.sql (100%) rename src/{assets => }/migrations/20250112141434_document_table.sql (100%) rename src/{assets => }/migrations/20250112162651_rm_tsvector_column.sql (100%) rename src/{assets => }/migrations/20250120084318_mv_ai_summary.sql (100%) rename src/{internal => web}/app/app.go (100%) rename src/{internal => web}/app/article.go (96%) rename src/{internal => web}/app/index.go (95%) rename src/{internal => web}/app/rss.go (100%) rename src/{internal => web}/app/upsearch.go (94%) rename src/{internal => web}/html/article.go (100%) rename src/{internal => web}/html/articleLayout.go (100%) rename src/{internal => web}/html/articlePage.go (100%) rename src/{internal => web}/html/indexLayout.go (100%) rename src/{internal => web}/html/layout.go (100%) rename src/{internal => web}/html/navbar.go (100%) rename src/{internal => web}/html/pagination.go (100%) rename src/{internal => web}/middleware/logging.go (100%) rename src/{internal => web}/middleware/middleware.go (100%) rename src/{assets => web}/static/daisyui.min.css (100%) rename src/{assets => web}/static/tailwindcss.min.js (100%) rename src/{assets => web}/static/unpoly.min.css (100%) rename src/{assets => web}/static/unpoly.min.js (100%) diff --git a/Dockerfile b/Dockerfile index 76d3d13..fcc42ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,8 +21,8 @@ RUN go mod download # Copy the source code COPY ./src/cmd ./cmd -COPY ./src/assets ./assets COPY ./src/internal ./internal +COPY ./src/web ./web # Build the application RUN go build -o main cmd/frontend/* @@ -36,9 +36,9 @@ WORKDIR /app # Copy the built binary from the builder stage COPY --from=builder /app/main . COPY --from=builder /goose.git/goose . -COPY ./src/assets ./assets +COPY ./src/migrations ./migrations EXPOSE 8080 # Command to run the application -CMD ["sh", "-c", "/app/goose -dir=/app/assets/migrations/ postgres postgresql://$DB_USER:$DB_PASS@$DB_HOST:$DB_PORT/$DB_NAME up && /app/main"] +CMD ["sh", "-c", "/app/goose -dir=/app/migrations/ postgres postgresql://$DB_USER:$DB_PASS@$DB_HOST:$DB_PORT/$DB_NAME up && /app/main"] diff --git a/src/cmd/frontend/main.go b/src/cmd/frontend/main.go index cd7a50f..c7d3f37 100644 --- a/src/cmd/frontend/main.go +++ b/src/cmd/frontend/main.go @@ -1,12 +1,12 @@ package main import ( - "crowsnest/internal/app" "crowsnest/internal/crawler" - "crowsnest/internal/middleware" "crowsnest/internal/model" "crowsnest/internal/model/database" "crowsnest/internal/util" + "crowsnest/web/app" + "crowsnest/web/middleware" "log" "net/http" "os" diff --git a/src/assets/migrations/20250102152758_article.sql b/src/migrations/20250102152758_article.sql similarity index 100% rename from src/assets/migrations/20250102152758_article.sql rename to src/migrations/20250102152758_article.sql diff --git a/src/assets/migrations/20250102232127_article_fts.sql b/src/migrations/20250102232127_article_fts.sql similarity index 100% rename from src/assets/migrations/20250102232127_article_fts.sql rename to src/migrations/20250102232127_article_fts.sql diff --git a/src/assets/migrations/20250103140557_response_cache.sql b/src/migrations/20250103140557_response_cache.sql similarity index 100% rename from src/assets/migrations/20250103140557_response_cache.sql rename to src/migrations/20250103140557_response_cache.sql diff --git a/src/assets/migrations/20250103203320_response_new_column.sql b/src/migrations/20250103203320_response_new_column.sql similarity index 100% rename from src/assets/migrations/20250103203320_response_new_column.sql rename to src/migrations/20250103203320_response_new_column.sql diff --git a/src/assets/migrations/20250107091120_remove_responses.sql b/src/migrations/20250107091120_remove_responses.sql similarity index 100% rename from src/assets/migrations/20250107091120_remove_responses.sql rename to src/migrations/20250107091120_remove_responses.sql diff --git a/src/assets/migrations/20250107104609_drop_column_author.sql b/src/migrations/20250107104609_drop_column_author.sql similarity index 100% rename from src/assets/migrations/20250107104609_drop_column_author.sql rename to src/migrations/20250107104609_drop_column_author.sql diff --git a/src/assets/migrations/20250107113527_add_aisummary_column.sql b/src/migrations/20250107113527_add_aisummary_column.sql similarity index 100% rename from src/assets/migrations/20250107113527_add_aisummary_column.sql rename to src/migrations/20250107113527_add_aisummary_column.sql diff --git a/src/assets/migrations/20250112141434_document_table.sql b/src/migrations/20250112141434_document_table.sql similarity index 100% rename from src/assets/migrations/20250112141434_document_table.sql rename to src/migrations/20250112141434_document_table.sql diff --git a/src/assets/migrations/20250112162651_rm_tsvector_column.sql b/src/migrations/20250112162651_rm_tsvector_column.sql similarity index 100% rename from src/assets/migrations/20250112162651_rm_tsvector_column.sql rename to src/migrations/20250112162651_rm_tsvector_column.sql diff --git a/src/assets/migrations/20250120084318_mv_ai_summary.sql b/src/migrations/20250120084318_mv_ai_summary.sql similarity index 100% rename from src/assets/migrations/20250120084318_mv_ai_summary.sql rename to src/migrations/20250120084318_mv_ai_summary.sql diff --git a/src/internal/app/app.go b/src/web/app/app.go similarity index 100% rename from src/internal/app/app.go rename to src/web/app/app.go diff --git a/src/internal/app/article.go b/src/web/app/article.go similarity index 96% rename from src/internal/app/article.go rename to src/web/app/article.go index ed51c27..88fedb3 100644 --- a/src/internal/app/article.go +++ b/src/web/app/article.go @@ -1,7 +1,7 @@ package app import ( - "crowsnest/internal/html" + "crowsnest/web/html" "net/http" "strconv" ) diff --git a/src/internal/app/index.go b/src/web/app/index.go similarity index 95% rename from src/internal/app/index.go rename to src/web/app/index.go index 6b47357..b3590be 100644 --- a/src/internal/app/index.go +++ b/src/web/app/index.go @@ -1,7 +1,7 @@ package app import ( - "crowsnest/internal/html" + "crowsnest/web/html" "net/http" "strconv" ) @@ -37,6 +37,6 @@ func (app *App) Index(w http.ResponseWriter, req *http.Request) { err = html.IndexLayout(articleVMs, uint(pageId+1), totalCount+1).Render(w) if err != nil { http.Error(w, "Failed to render template", http.StatusInternalServerError) - return + return } } diff --git a/src/internal/app/rss.go b/src/web/app/rss.go similarity index 100% rename from src/internal/app/rss.go rename to src/web/app/rss.go diff --git a/src/internal/app/upsearch.go b/src/web/app/upsearch.go similarity index 94% rename from src/internal/app/upsearch.go rename to src/web/app/upsearch.go index 7d46359..a795375 100644 --- a/src/internal/app/upsearch.go +++ b/src/web/app/upsearch.go @@ -1,7 +1,7 @@ package app import ( - "crowsnest/internal/html" + "crowsnest/web/html" "net/http" ) @@ -27,6 +27,6 @@ func (app *App) UpSearch(w http.ResponseWriter, req *http.Request) { err = html.IndexLayout(articleVMs, 0, 0).Render(w) if err != nil { http.Error(w, "Failed to render template", http.StatusInternalServerError) - return + return } } diff --git a/src/internal/html/article.go b/src/web/html/article.go similarity index 100% rename from src/internal/html/article.go rename to src/web/html/article.go diff --git a/src/internal/html/articleLayout.go b/src/web/html/articleLayout.go similarity index 100% rename from src/internal/html/articleLayout.go rename to src/web/html/articleLayout.go diff --git a/src/internal/html/articlePage.go b/src/web/html/articlePage.go similarity index 100% rename from src/internal/html/articlePage.go rename to src/web/html/articlePage.go diff --git a/src/internal/html/indexLayout.go b/src/web/html/indexLayout.go similarity index 100% rename from src/internal/html/indexLayout.go rename to src/web/html/indexLayout.go diff --git a/src/internal/html/layout.go b/src/web/html/layout.go similarity index 100% rename from src/internal/html/layout.go rename to src/web/html/layout.go diff --git a/src/internal/html/navbar.go b/src/web/html/navbar.go similarity index 100% rename from src/internal/html/navbar.go rename to src/web/html/navbar.go diff --git a/src/internal/html/pagination.go b/src/web/html/pagination.go similarity index 100% rename from src/internal/html/pagination.go rename to src/web/html/pagination.go diff --git a/src/internal/middleware/logging.go b/src/web/middleware/logging.go similarity index 100% rename from src/internal/middleware/logging.go rename to src/web/middleware/logging.go diff --git a/src/internal/middleware/middleware.go b/src/web/middleware/middleware.go similarity index 100% rename from src/internal/middleware/middleware.go rename to src/web/middleware/middleware.go diff --git a/src/assets/static/daisyui.min.css b/src/web/static/daisyui.min.css similarity index 100% rename from src/assets/static/daisyui.min.css rename to src/web/static/daisyui.min.css diff --git a/src/assets/static/tailwindcss.min.js b/src/web/static/tailwindcss.min.js similarity index 100% rename from src/assets/static/tailwindcss.min.js rename to src/web/static/tailwindcss.min.js diff --git a/src/assets/static/unpoly.min.css b/src/web/static/unpoly.min.css similarity index 100% rename from src/assets/static/unpoly.min.css rename to src/web/static/unpoly.min.css diff --git a/src/assets/static/unpoly.min.js b/src/web/static/unpoly.min.js similarity index 100% rename from src/assets/static/unpoly.min.js rename to src/web/static/unpoly.min.js