Static Page Generator #5

Merged
kumi merged 21 commits from dev into main 2024-07-06 14:07:00 +00:00
Owner

Summary

This pull request replaces the existing Flask application with a static site generator. It also adds a workflow to automatically build and deploy the static site to the pages branch using Forgejo Actions.

This should make the site faster and more secure, as it no longer requires a dedicated server application. In the future, the site could also be hosted directly using Forgejo Pages. The new approach could also reduce the risk of downtime due to server/code issues.

The changes are already deployed on the dev instance and can be viewed at https://dev.private.coffee.

Changes

  1. Replaced Flask Application with Static Site Generator:

    • main.py now generates static HTML files from Jinja2 templates instead of serving them using Flask.
    • The script:
      • Iterates over all templates in the templates directory.
      • Includes the icon filter for rendering SVG icons.
      • Generates a metrics file and ensures it is included in the static site.
      • Copies static assets to the output directory.
  2. Added Workflow for Automatic Deployment:

    • Created new workflow files .forgejo/workflows/build.yml and .forgejo/workflows/build-dev.yml to automate the build and deployment process.
    • Configured the workflows to:
      • Check out the repository.
      • Set up Python and install dependencies.
      • Run the static site generator script.
      • Deploy the generated static site files to the pages/pages-dev branch.

Deployment Notes

  • This pull request obsoletes the uwsgi apps, and requires a change to the Caddy configuration to serve the static files instead of reverse proxying to uwsgi.
  • Due to the force push to the pages branch, git on the server will need to be configured to rebase instead of merge when pulling changes from the pages branch.
## Summary This pull request replaces the existing Flask application with a static site generator. It also adds a workflow to automatically build and deploy the static site to the `pages` branch using Forgejo Actions. This should make the site faster and more secure, as it no longer requires a dedicated server application. In the future, the site could also be hosted directly using Forgejo Pages. The new approach could also reduce the risk of downtime due to server/code issues. The changes are already deployed on the dev instance and can be viewed at [https://dev.private.coffee](https://dev.private.coffee). ## Changes 1. **Replaced Flask Application with Static Site Generator**: - `main.py` now generates static HTML files from Jinja2 templates instead of serving them using Flask. - The script: - Iterates over all templates in the `templates` directory. - Includes the `icon` filter for rendering SVG icons. - Generates a metrics file and ensures it is included in the static site. - Copies static assets to the output directory. 2. **Added Workflow for Automatic Deployment**: - Created new workflow files `.forgejo/workflows/build.yml` and `.forgejo/workflows/build-dev.yml` to automate the build and deployment process. - Configured the workflows to: - Check out the repository. - Set up Python and install dependencies. - Run the static site generator script. - Deploy the generated static site files to the `pages`/`pages-dev` branch. ## Deployment Notes - This pull request obsoletes the uwsgi apps, and requires a change to the Caddy configuration to serve the static files instead of reverse proxying to uwsgi. - Due to the force push to the `pages` branch, git on the server will need to be configured to rebase instead of merge when pulling changes from the `pages` branch.
kumi added 13 commits 2024-07-01 09:04:47 +00:00
Refactored the Flask application to generate a static site instead of running as a dynamic web app. Added a CI workflow to build and deploy the static site on pushes to the 'static' branch.

- Replaced Flask route handling with a function that generates HTML files using Jinja2 templates.
- Modified the argparse logic to trigger the static site generation.
- Updated the .gitignore file to exclude the build directory.
- Created a Forgejo Actions workflow to automate the build and deploy process.

This change improves performance and reduces server overhead by serving pre-rendered static content.
Merge branch 'dev' into static
Some checks failed
Build and Deploy Static Site / build (push) Failing after 57s
438461f333
Merge branch 'dev' into static
Some checks failed
Build and Deploy Static Site / build (push) Failing after 55s
b8851c8049
Merge branch 'dev' into static
All checks were successful
Build and Deploy Static Site / build (push) Successful in 1m1s
03c1885af1
feat(ci): automate build and deploy for dev and main branches
Some checks failed
Build and Deploy Static Site / build (push) Failing after 59s
d337e8a207
- Added a new GitHub Actions workflow for the development branch to build and deploy the static site.
- Modified the existing workflow to trigger on the main branch instead of the static branch.
- Refactored the main.py script for consistency in string quotation.

The new workflow simplifies deployment processes during development, ensuring seamless and automated integration and testing.
Merge branch 'main' into dev
Some checks failed
Build and Deploy Static Site / build (push) Has been cancelled
9030c527ef
Some checks failed
Build and Deploy Static Site / build (push) Failing after 58s
22529bfa65
Merge branch 'main' into dev
All checks were successful
Build and Deploy Static Site / build (push) Successful in 58s
1434a3b552
fix(build): ensure .gitignore is included in temp site
All checks were successful
Build and Deploy Static Site / build (push) Successful in 58s
0b0f8bb3b2
Added copying of .gitignore to the temporary static site location in both development and production build scripts. This prevents unnecessary files from being included in the new orphan branches, ensuring a cleaner and more efficient build process.
feat(build): add dev flag to static site generation
All checks were successful
Build and Deploy Static Site / build (push) Successful in 58s
b27ace9cb0
Updated the build-dev CI workflow to run the static site generation with a development flag. This ensures the build script runs in the appropriate context for development environments. No issues referenced.
feat: update README and asset paths for static site generation
All checks were successful
Build and Deploy Static Site / build (push) Successful in 1m0s
69ef1f7a1a
Switched the project description from a Flask application to a Jinja2 static website generator. Adjusted asset links in the base template to be relative, enhancing portability and simplifying deployments. These changes aim to better reflect the project's current architecture and usage.
Merge branch 'main' into dev
All checks were successful
Build and Deploy Static Site / build (push) Successful in 1m0s
3219a5019f
chore: remove Flask from requirements
All checks were successful
Build and Deploy Static Site / build (push) Successful in 57s
8e81ba73b2
Removed Flask from the requirements.txt file as it is no longer needed for the project dependencies. This helps to streamline the dependency management and reduces potential security vulnerabilities that come with maintaining unnecessary packages.
kumi added 1 commit 2024-07-01 09:11:30 +00:00
Merge branch 'main' into dev
All checks were successful
Build and Deploy Static Site / build (push) Successful in 57s
feb273a8b0
kumi added 1 commit 2024-07-01 10:06:35 +00:00
feat: add filter to convert month number to name
All checks were successful
Build and Deploy Static Site / build (push) Successful in 57s
5cdb9ad43b
Added a custom filter `month_name` to convert month numbers to their full names in templates. Updated the Transparency Report title to use this filter, enhancing readability and user experience. This change ensures that month names are displayed instead of numeric values, making the report titles clearer and more user-friendly.
kumi added 2 commits 2024-07-01 10:12:44 +00:00
feat: extend asset copying to include data directory
All checks were successful
Build and Deploy Static Site / build (push) Successful in 58s
ee2d53a36d
Expanded the asset copying functionality to also handle the 'data' directory in addition to the 'assets' folder. This ensures that both static assets and data files are included in the output directory, streamlining the build process and ensuring all necessary resources are available in the generated static site.
kumi added 2 commits 2024-07-01 13:07:56 +00:00
fix(styles): refine button margin and dropdown shadow spacing
All checks were successful
Build and Deploy Static Site / build (push) Successful in 56s
2e2327848f
Adjusted the CSS selector to more accurately apply margins to specific button elements within card bodies, enhancing layout consistency. Corrected minor formatting issue in the dropdown menu's box-shadow property for improved code readability.
kumi added 1 commit 2024-07-02 07:48:15 +00:00
Merge branch 'main' into dev
All checks were successful
Build and Deploy Static Site / build (push) Successful in 56s
fa12209b03
kumi added 1 commit 2024-07-03 11:50:08 +00:00
Merge branch 'main' into dev
All checks were successful
Build and Deploy Static Site / build (push) Successful in 58s
18d434ab5b
Author
Owner

Merging since nobody complained.

Merging since nobody complained.
kumi merged commit f050096e52 into main 2024-07-06 14:07:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: PrivateCoffee/privatecoffee-website#5
No description provided.