0.0.2 - fix httpx
This commit is contained in:
parent
133b37c490
commit
a65477fac4
5 changed files with 54 additions and 14 deletions
9
CHANGELOG.md
Normal file
9
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# HTMX-PATTERNS CHANGELOG
|
||||||
|
|
||||||
|
## 0.0.2
|
||||||
|
|
||||||
|
* fix https
|
||||||
|
|
||||||
|
## 0.0.1
|
||||||
|
|
||||||
|
* infinite scroll
|
||||||
22
Dockerfile
Normal file
22
Dockerfile
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
FROM python:3.11
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN pip install uv
|
||||||
|
|
||||||
|
COPY pyproject.toml .
|
||||||
|
COPY htmx_patterns/__about__.py ./htmx_patterns/__about__.py
|
||||||
|
COPY htmx_patterns/__init__.py ./htmx_patterns/__init__.py
|
||||||
|
COPY README.md .
|
||||||
|
|
||||||
|
RUN uv pip install --system .
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
RUN uv pip install --system --no-deps .
|
||||||
|
ENV TZ=America/Chicago
|
||||||
|
ENV ENV=production
|
||||||
|
# CMD ['htmx-patterns', 'api', 'run']
|
||||||
|
CMD htmx-patterns api run
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# SPDX-FileCopyrightText: 2024-present Waylon S. Walker <waylon@waylonwalker.com>
|
# SPDX-FileCopyrightText: 2024-present Waylon S. Walker <waylon@waylonwalker.com>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
__version__ = "0.0.1"
|
__version__ = "0.0.2"
|
||||||
|
|
|
||||||
|
|
@ -32,19 +32,17 @@ class ApiServer(BaseModel):
|
||||||
proxy_headers: bool = True
|
proxy_headers: bool = True
|
||||||
|
|
||||||
|
|
||||||
@pass_context
|
# @pass_context
|
||||||
def https_url_for(context: dict, name: str, **path_params: Any) -> str:
|
# def https_url_for(context: dict, name: str, **params: Any) -> str:
|
||||||
request = context["request"]
|
# http_url = url_for_query(context, name, **params)
|
||||||
http_url = request.url_for(name, **path_params)
|
# return str(http_url).replace("http", "https", 1)
|
||||||
return str(http_url).replace("http", "https", 1)
|
|
||||||
|
|
||||||
|
|
||||||
@pass_context
|
@pass_context
|
||||||
def url_for_query(context: dict, name: str, **params: dict) -> str:
|
def url_for_query(context: dict, name: str, **params: dict) -> str:
|
||||||
request = context["request"]
|
request = context["request"]
|
||||||
url = str(request.url_for(name))
|
url = str(request.url_for(name))
|
||||||
if params == {}:
|
|
||||||
return url
|
|
||||||
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
|
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
|
||||||
|
|
||||||
# Parse the URL
|
# Parse the URL
|
||||||
|
|
@ -71,6 +69,9 @@ def url_for_query(context: dict, name: str, **params: dict) -> str:
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if os.environ.get("ENV") in ["dev", "qa", "prod"]:
|
||||||
|
updated_url = updated_url.replace("http", "https", 1)
|
||||||
|
|
||||||
return updated_url
|
return updated_url
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -80,16 +81,15 @@ def get_templates(config: BaseSettings) -> Jinja2Templates:
|
||||||
templates.env.filters["timestamp"] = lambda u: datetime.fromtimestamp(
|
templates.env.filters["timestamp"] = lambda u: datetime.fromtimestamp(
|
||||||
u, tz=timezone.utc
|
u, tz=timezone.utc
|
||||||
).strftime("%B %d, %Y")
|
).strftime("%B %d, %Y")
|
||||||
templates.env.globals["https_url_for"] = https_url_for
|
|
||||||
templates.env.globals["url_for"] = url_for_query
|
templates.env.globals["url_for"] = url_for_query
|
||||||
templates.env.globals["config"] = config
|
templates.env.globals["config"] = config
|
||||||
console.print(f'Using environment: {os.environ.get("ENV")}')
|
console.print(f'Using environment: {os.environ.get("ENV")}')
|
||||||
|
|
||||||
if os.environ.get("ENV") in ["dev", "qa", "prod"]:
|
# if os.environ.get("ENV") in ["dev", "qa", "prod"]:
|
||||||
templates.env.globals["url_for"] = https_url_for
|
# templates.env.globals["url_for"] = https_url_for
|
||||||
console.print("Using HTTPS")
|
# console.print("Using HTTPS")
|
||||||
else:
|
# else:
|
||||||
console.print("Using HTTP")
|
# console.print("Using HTTP")
|
||||||
|
|
||||||
return templates
|
return templates
|
||||||
|
|
||||||
|
|
|
||||||
9
justfile
Normal file
9
justfile
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
default:
|
||||||
|
@just --list
|
||||||
|
|
||||||
|
build-image:
|
||||||
|
podman build -t docker.io/waylonwalker/htmx-patterns-waylonwalker-com:0.0.2 .
|
||||||
|
|
||||||
|
push-image:
|
||||||
|
podman push docker.io/waylonwalker/htmx-patterns-waylonwalker-com:0.0.2
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue