-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ChristosT/add-fonts-as-assets
fix(assets): Download fonts as offline assets
- Loading branch information
Showing
3 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# search "./.download/fonts_with_urls.css" for remote assets and download them | ||
# produce a new file with "./generator/fonts.css" local paths instead of remote | ||
# this script should run on the top-level directory of the project | ||
|
||
import re | ||
from pathlib import Path | ||
from urllib.request import urlretrieve | ||
from urllib.parse import urlparse | ||
|
||
ROOT = Path(__file__).parent.parent.absolute() | ||
|
||
pattern = re.compile("http[^)]*") # capture from http until a parenthesis ')' | ||
with open(ROOT / ".download/fonts_with_urls.css", "r") as fonts: | ||
lines = fonts.read() | ||
new_lines = lines | ||
for url in pattern.finditer(lines): | ||
parsed_url = urlparse(url[0]).path | ||
destination = Path(parsed_url).name | ||
urlretrieve(url[0], str(ROOT / ".generator" / destination)) | ||
new_lines = re.sub(url[0], f'"{destination}"', new_lines) | ||
|
||
with open(ROOT / ".generator/fonts.css", "w") as out: | ||
out.write(new_lines) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
QUASAR_URL=https://registry.npmjs.org/quasar/-/quasar-2.12.4.tgz | ||
FONTS_URL="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" | ||
mkdir -p .download && cd .download && curl -L $QUASAR_URL | tar --strip-components=1 -xzv | ||
cd .. | ||
python ./.generator/generate.py | ||
python -m trame.tools.widgets --config ./.generator/config.yaml --output ./ | ||
curl -o ./.download/fonts_with_urls.css "$FONTS_URL" | ||
python ./.generator/get_fonts.py | ||
|
||
python -m trame.tools.widgets --config ./.generator/config.yaml --output ./ | ||
mv ./.generator/*.ttf ./trame_quasar/module/quasar/vue3/ |