web: support for versioning from environment variables
This commit is contained in:
parent
ba9bb07b21
commit
3c26baa3cf
46
Makefile
46
Makefile
|
@ -7,6 +7,10 @@ export GOOSE_DRIVER=sqlite3
|
||||||
export GOOSE_DBSTRING=./data.db
|
export GOOSE_DBSTRING=./data.db
|
||||||
export GOOSE_MIGRATION_DIR=db/migrations
|
export GOOSE_MIGRATION_DIR=db/migrations
|
||||||
|
|
||||||
|
export REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION=$(shell echo "$${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION:-1.9.12}")
|
||||||
|
export REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION=$(shell echo "$${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION:-1.11.10}")
|
||||||
|
export REDMAGE_WEB_DEPENDENCIES_THEMECHANGE_VERSION=$(shell echo "$${REDMAGE_WEB_DEPENDENCIES_THEMECHANGE_VERSION:-2.0.2}")
|
||||||
|
|
||||||
start: dev-dependencies
|
start: dev-dependencies
|
||||||
@air
|
@air
|
||||||
|
|
||||||
|
@ -27,40 +31,40 @@ build-dependencies:
|
||||||
echo "Node modules not found, installing them"
|
echo "Node modules not found, installing them"
|
||||||
npm install
|
npm install
|
||||||
fi
|
fi
|
||||||
@if [ ! -f "public/htmx-1.9.11.min.js" ]; then
|
@if [ ! -f "public/htmx-${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION}.min.js" ]; then
|
||||||
mkdir -p public
|
mkdir -p public
|
||||||
echo "Htmx not found, installing it"
|
echo "Htmx ${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION} not found, installing it"
|
||||||
curl -o public/htmx-1.9.11.min.js https://unpkg.com/htmx.org@1.9.11/dist/htmx.min.js
|
curl -o public/htmx-${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION}.min.js https://unpkg.com/htmx.org@${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION}/dist/htmx.min.js
|
||||||
fi
|
fi
|
||||||
@if [ ! -f "public/htmx-response-targets-1.9.11.min.js" ]; then
|
@if [ ! -f "public/htmx-response-targets-${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION}.min.js" ]; then
|
||||||
mkdir -p public
|
mkdir -p public
|
||||||
echo "Htmx response targets not found, installing it"
|
echo "Htmx response targets ${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION} not found, installing it"
|
||||||
curl -o public/htmx-response-targets-1.9.11.min.js https://cdnjs.cloudflare.com/ajax/libs/htmx/1.9.11/ext/response-targets.min.js
|
curl -o public/htmx-response-targets-${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION}.min.js https://cdnjs.cloudflare.com/ajax/libs/htmx/${REDMAGE_WEB_DEPENDENCIES_HTMX_VERSION}/ext/response-targets.min.js
|
||||||
fi
|
fi
|
||||||
@if [ ! -f "public/dayjs-1.11.10.min.js" ]; then
|
@if [ ! -f "public/dayjs-${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}.min.js" ]; then
|
||||||
mkdir -p public
|
mkdir -p public
|
||||||
echo "Dayjs not found, installing it"
|
echo "Dayjs ${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION} not found, installing it"
|
||||||
curl -o public/dayjs-1.11.10.min.js https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.10/dayjs.min.js
|
curl -o public/dayjs-${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}.min.js https://cdnjs.cloudflare.com/ajax/libs/dayjs/${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}/dayjs.min.js
|
||||||
fi
|
fi
|
||||||
@if [ ! -f "public/dayjs-relativeTime-1.11.10.min.js" ]; then
|
@if [ ! -f "public/dayjs-relativeTime-${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}.min.js" ]; then
|
||||||
mkdir -p public
|
mkdir -p public
|
||||||
echo "Dayjs Relative Time not found, installing it"
|
echo "Dayjs Relative Time ${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION} not found, installing it"
|
||||||
curl -o public/dayjs-relativeTime-1.11.10.min.js https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.10/plugin/relativeTime.min.js
|
curl -o public/dayjs-relativeTime-${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}.min.js https://cdnjs.cloudflare.com/ajax/libs/dayjs/${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}/plugin/relativeTime.min.js
|
||||||
fi
|
fi
|
||||||
@if [ ! -f "public/dayjs-utc-1.11.10.min.js" ]; then
|
@if [ ! -f "public/dayjs-utc-${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}.min.js" ]; then
|
||||||
mkdir -p public
|
mkdir -p public
|
||||||
echo "Dayjs UTC plugin not found, installing it"
|
echo "Dayjs UTC ${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION} plugin not found, installing it"
|
||||||
curl -o public/dayjs-utc-1.11.10.min.js https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.10/plugin/utc.min.js
|
curl -o public/dayjs-utc-${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}.min.js https://cdnjs.cloudflare.com/ajax/libs/dayjs/${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}/plugin/utc.min.js
|
||||||
fi
|
fi
|
||||||
@if [ ! -f "public/dayjs-timezone-1.11.10.min.js" ]; then
|
@if [ ! -f "public/dayjs-timezone-${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}.min.js" ]; then
|
||||||
mkdir -p public
|
mkdir -p public
|
||||||
echo "Dayjs Timezone plugin not found, installing it"
|
echo "Dayjs Timezone ${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION} plugin not found, installing it"
|
||||||
curl -o public/dayjs-timezone-1.11.10.min.js https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.10/plugin/timezone.min.js
|
curl -o public/dayjs-timezone-${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}.min.js https://cdnjs.cloudflare.com/ajax/libs/dayjs/${REDMAGE_WEB_DEPENDENCIES_DAYJS_VERSION}/plugin/timezone.min.js
|
||||||
fi
|
fi
|
||||||
@if [ ! -f "public/theme-change-2.0.2.min.js" ]; then
|
@if [ ! -f "public/theme-change-${REDMAGE_WEB_DEPENDENCIES_THEMECHANGE_VERSION}.min.js" ]; then
|
||||||
mkdir -p public
|
mkdir -p public
|
||||||
echo "Theme change not found, installing it"
|
echo "Theme change ${REDMAGE_WEB_DEPENDENCIES_THEMECHANGE_VERSION} not found, installing it"
|
||||||
curl -o public/theme-change-2.0.2.min.js https://cdn.jsdelivr.net/npm/theme-change@2.0.2/index.js
|
curl -o public/theme-change-${REDMAGE_WEB_DEPENDENCIES_THEMECHANGE_VERSION}.min.js https://cdn.jsdelivr.net/npm/theme-change@${REDMAGE_WEB_DEPENDENCIES_THEMECHANGE_VERSION}/index.js
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build: build-dependencies prepare
|
build: build-dependencies prepare
|
||||||
|
|
|
@ -56,6 +56,10 @@ var DefaultConfig = map[string]any{
|
||||||
|
|
||||||
"telemetry.trace.ratio": 1,
|
"telemetry.trace.ratio": 1,
|
||||||
|
|
||||||
|
"web.dependencies.htmx.version": "1.9.12",
|
||||||
|
"web.dependencies.dayjs.version": "1.11.10",
|
||||||
|
"web.dependencies.themechange.version": "2.0.2",
|
||||||
|
|
||||||
"runtime.version": "0.0.1",
|
"runtime.version": "0.0.1",
|
||||||
"runtime.environment": "development",
|
"runtime.environment": "development",
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,8 @@ templ Head(vc *views.Context, extras ...templ.Component) {
|
||||||
<meta name="keywords" content="Reddit, Image, Downloader"/>
|
<meta name="keywords" content="Reddit, Image, Downloader"/>
|
||||||
<link rel="stylesheet" href="/public/style.css"/>
|
<link rel="stylesheet" href="/public/style.css"/>
|
||||||
<link rel="icon" href="/public/favicon.svg"/>
|
<link rel="icon" href="/public/favicon.svg"/>
|
||||||
<script src="/public/htmx-1.9.11.min.js"></script>
|
@HTMX(vc)
|
||||||
<script src="/public/htmx-response-targets-1.9.11.min.js"></script>
|
@ThemeChange(vc)
|
||||||
<script src="/public/theme-change-2.0.2.min.js"></script>
|
|
||||||
if vc.Config.Bool("http.hotreload") {
|
if vc.Config.Bool("http.hotreload") {
|
||||||
<script src="/public/hot_reload.js"></script>
|
<script src="/public/hot_reload.js"></script>
|
||||||
}
|
}
|
||||||
|
|
9
views/components/htmx.templ
Normal file
9
views/components/htmx.templ
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package components
|
||||||
|
|
||||||
|
import "github.com/tigorlazuardi/redmage/views"
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
templ HTMX(c *views.Context) {
|
||||||
|
<script src={ fmt.Sprintf("/public/htmx-%s.min.js", c.Config.String("web.dependencies.htmx.version")) }></script>
|
||||||
|
<script src={ fmt.Sprintf("/public/htmx-response-targets-%s.min.js", c.Config.String("web.dependencies.htmx.version")) }></script>
|
||||||
|
}
|
8
views/components/theme_change.templ
Normal file
8
views/components/theme_change.templ
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package components
|
||||||
|
|
||||||
|
import "github.com/tigorlazuardi/redmage/views"
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
templ ThemeChange(c *views.Context) {
|
||||||
|
<script src={ fmt.Sprintf("/public/theme-change-%s.min.js", c.Config.String("web.dependencies.themechange.version")) }></script>
|
||||||
|
}
|
Loading…
Reference in a new issue