From ceabddc972d97587ef94090538fe2d4291ddd04b Mon Sep 17 00:00:00 2001 From: video-prize-ranch Date: Sat, 4 Jun 2022 20:56:04 -0400 Subject: [PATCH] Add documentation for FORCE_WEBP --- README.md | 1 + pages/frontpage.go | 3 +++ views/frontpage.hbs | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 2c3762f..01e99fa 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ It's read-only and works without JavaScript. Images and albums can be viewed wit - Albums - User page - Tag page +- Bandwidth efficient - automatically use WebP with the `FORCE_WEBP` environment variable Some things left to implement (contributions welcome!): diff --git a/pages/frontpage.go b/pages/frontpage.go index e5e77d0..cf992ad 100644 --- a/pages/frontpage.go +++ b/pages/frontpage.go @@ -1,6 +1,8 @@ package pages import ( + "os" + "codeberg.org/video-prize-ranch/rimgo/utils" "github.com/gofiber/fiber/v2" ) @@ -13,5 +15,6 @@ func HandleFrontpage(c *fiber.Ctx) error { return c.Render("frontpage", fiber.Map{ "proto": c.Protocol(), "domain": c.Hostname(), + "force_webp": os.Getenv("FORCE_WEBP"), }) } \ No newline at end of file diff --git a/views/frontpage.hbs b/views/frontpage.hbs index fb17db5..befdcf8 100644 --- a/views/frontpage.hbs +++ b/views/frontpage.hbs @@ -43,6 +43,10 @@

Just replace imgur.com or i.imgur.com with {{domain}}! You can setup automatic redirects using LibRedirect (recommended) or Redirector.

+
+ {{#if force_webp}} +

To download images as their original filetype, add ?no_webp=1 to the end of the image URL.

+ {{/if}}