Serve CSS dependencies from local webserver

Privacy improvement.
This commit is contained in:
Fabian Müller 2022-11-21 19:40:26 +01:00
parent eab91b7272
commit 5d58ba89c4
7 changed files with 48 additions and 13 deletions

2
.gitignore vendored
View File

@ -4,3 +4,5 @@ __pycache__/
*.*swp*
docker-compose.yml
dist/
node_modules/
yarn*.log

View File

@ -2,17 +2,19 @@ FROM python:3.8-alpine
RUN adduser -S fabcal
RUN apk add --no-cache build-base libuv-dev libffi-dev && \
pip3 install poetry
RUN apk add --no-cache build-base libuv-dev libffi-dev yarn && \
pip3 install -U poetry
RUN install -d -o fabcal /app
USER fabcal
COPY poetry.lock pyproject.toml /app/
COPY poetry.lock pyproject.toml package.json yarn.lock /app/
WORKDIR /app/
RUN pip install -U poetry && \
poetry install --only main
RUN poetry install --only main && \
yarn install
COPY fabcal /app/fabcal/
COPY static/ /app/static/

View File

@ -13,6 +13,9 @@ app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
for framework in ["normalize.css", "milligram", "@fortawesome/fontawesome-free"]:
app.mount(f"/assets/{framework}", StaticFiles(directory=f"node_modules/{framework}"), name=framework)
app.include_router(api_v1.router, prefix="/api/v1")
app.include_router(frontend.router, prefix="")

10
package.json Normal file
View File

@ -0,0 +1,10 @@
{
"name": "fabcal",
"version": "0.0.1",
"author": "Fabian Müller <fabian@fablab-altmuehlfranken.de>",
"license": "MIT",
"dependencies": {
"@fortawesome/fontawesome-free": "^6.2.1",
"milligram": "^1.4.1"
}
}

View File

@ -2,10 +2,9 @@
<html lang="de">
<head>
{% block header %}
{#- TODO: replace with locally served files #}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<link rel="stylesheet" href="{{ url_for('normalize.css', path='normalize.css') }}">
<link rel="stylesheet" href="{{ url_for('milligram', path='dist/milligram.min.css') }}">
<link rel="stylesheet" href="{{ url_for('@fortawesome/fontawesome-free', path='css/all.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', path='style.css') }}" type="text/css"/>
<link rel="stylesheet" href="{{ url_for('static', path='roboto.css') }}" type="text/css"/>

View File

@ -1,10 +1,9 @@
<!DOCTYPE html>
<html lang="de">
<head>
{#- TODO: replace with locally served files #}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<link rel="stylesheet" href="{{ url_for('normalize.css', path='normalize.css') }}">
<link rel="stylesheet" href="{{ url_for('milligram', path='dist/milligram.min.css') }}">
<link rel="stylesheet" href="{{ url_for('@fortawesome/fontawesome-free', path='css/all.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', path='style.css') }}" type="text/css"/>
<link rel="stylesheet" href="{{ url_for('static', path='roboto.css') }}" type="text/css"/>

20
yarn.lock Normal file
View File

@ -0,0 +1,20 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@fortawesome/fontawesome-free@^6.2.1":
version "6.2.1"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-6.2.1.tgz#344baf6ff9eaad7a73cff067d8c56bfc11ae5304"
integrity sha512-viouXhegu/TjkvYQoiRZK3aax69dGXxgEjpvZW81wIJdxm5Fnvp3VVIP4VHKqX4SvFw6qpmkILkD4RJWAdrt7A==
milligram@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/milligram/-/milligram-1.4.1.tgz#6c8c781541b0d994ccca784c60f0aca1f7104b42"
integrity sha512-RCgh/boHhcXWOUfKJWm3RJRoUeaEguoipDg0mJ31G0tFfvcpWMUlO1Zlqqr12K4kAXfDlllaidu0x7PaL2PTFg==
dependencies:
normalize.css "~8.0.1"
normalize.css@~8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/normalize.css/-/normalize.css-8.0.1.tgz#9b98a208738b9cc2634caacbc42d131c97487bf3"
integrity sha512-qizSNPO93t1YUuUhP22btGOo3chcvDFqFaj2TRybP0DMxkHOCTYwp3n34fel4a31ORXy4m1Xq0Gyqpb5m33qIg==