Skip to content

Commit cb647d7

Browse files
committed
Minor config changes & style tweaks.
1 parent af11603 commit cb647d7

File tree

10 files changed

+47
-25
lines changed

10 files changed

+47
-25
lines changed

Makefile

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
PROJECT_NAME := $(shell basename $CURDIR)
22
VIRTUAL_ENV := $(CURDIR)/.venv
33
LOCAL_PYTHON := $(VIRTUAL_ENV)/bin/python3
4+
LOCAL_NODE_JS := $(shell which node)
5+
LOCAL_LESS_JS := $(shell which lessc)
46

57
define HELP
68
Manage $(PROJECT_NAME). Usage:
@@ -23,12 +25,19 @@ all help:
2325
@echo "$$HELP"
2426

2527
env: $(VIRTUAL_ENV)
28+
node-env: $(LOCAL_NODE_JS)
2629

2730
$(VIRTUAL_ENV):
2831
if [ ! -d $(VIRTUAL_ENV) ]; then \
2932
echo "Creating Python virtual env in \`${VIRTUAL_ENV}\`"; \
3033
python3 -m venv $(VIRTUAL_ENV); \
31-
fi
34+
fi;
35+
36+
$(LOCAL_NODE_JS):
37+
if [ ! -f $(LOCAL_LESS_JS) ]; then \
38+
echo "Installing lessc"; \
39+
npm install -g lessc; \
40+
fi;
3241

3342
.PHONY: run
3443
run: env

flask_assets_tutorial/assets.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
from flask_assets import Bundle, Environment
44

55

6-
def compile_stylesheet_bundles(assets: Environment):
6+
def compile_stylesheet_bundles(assets: Environment) -> Environment:
77
"""
88
Create minified CSS bundles from LESS styles.
99
1010
:param Environment assets: Flask `environment` for static assets.
11+
12+
:returns: Environment
1113
"""
1214
# Main Stylesheets Bundle
1315
main_style_bundle = Bundle(
@@ -33,11 +35,13 @@ def compile_stylesheet_bundles(assets: Environment):
3335
return assets
3436

3537

36-
def compile_static_assets(assets: Environment):
38+
def compile_static_assets(assets: Environment) -> Environment:
3739
"""
3840
Create minified JS bundles from raw Javascript files.
3941
4042
:param Environment assets: Flask `environment` for static assets.
43+
44+
:returns: Environment
4145
"""
4246
main_js_bundle = Bundle("src/js/main.js", filters="jsmin", output="dist/js/main.min.js") # Main JavaScript Bundle
4347
assets.register("main_js", main_js_bundle)

flask_assets_tutorial/static/dist/css/account.css

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nav .nav-wrapper .left-nav {
1818
justify-content: space-between;
1919
align-items: center;
2020
}
21-
nav .nav-wrapper .left-nav img {
21+
nav .nav-wrapper .left-nav .logo {
2222
width: 30px;
2323
margin-right: 40px;
2424
}
@@ -81,7 +81,7 @@ h1 {
8181

8282
nav {
8383
background: #fff;
84-
padding: 30px;
84+
padding: 15px 30px;
8585
width: auto;
8686
margin-bottom: 40px;
8787
box-shadow: 0 0 5px #bec6cf;
@@ -99,9 +99,9 @@ nav .nav-wrapper .left-nav {
9999
justify-content: space-between;
100100
align-items: center;
101101
}
102-
nav .nav-wrapper .left-nav img {
103-
width: 30px;
104-
margin-right: 40px;
102+
nav .nav-wrapper .left-nav .logo {
103+
width: 40px;
104+
margin-right: 20px;
105105
}
106106
nav .nav-wrapper .left-nav a {
107107
margin-right: 20px;

flask_assets_tutorial/static/dist/css/landing.css

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ nav .nav-wrapper .left-nav {
1818
justify-content: space-between;
1919
align-items: center;
2020
}
21-
nav .nav-wrapper .left-nav img {
21+
nav .nav-wrapper .left-nav .logo {
2222
width: 30px;
2323
margin-right: 40px;
2424
}
@@ -81,7 +81,7 @@ h1 {
8181

8282
nav {
8383
background: #fff;
84-
padding: 30px;
84+
padding: 15px 30px;
8585
width: auto;
8686
margin-bottom: 40px;
8787
box-shadow: 0 0 5px #bec6cf;
@@ -99,9 +99,9 @@ nav .nav-wrapper .left-nav {
9999
justify-content: space-between;
100100
align-items: center;
101101
}
102-
nav .nav-wrapper .left-nav img {
103-
width: 30px;
104-
margin-right: 40px;
102+
nav .nav-wrapper .left-nav .logo {
103+
width: 40px;
104+
margin-right: 20px;
105105
}
106106
nav .nav-wrapper .left-nav a {
107107
margin-right: 20px;

flask_assets_tutorial/static/src/less/nav.less

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
nav {
44
background: #fff;
5-
padding: 30px;
5+
padding: 15px 30px;
66
width: auto;
77
margin-bottom: 40px;
8-
box-shadow: 0 0 5px #bec6cf;
8+
box-shadow: 0 0 5px @box-shadow-nav;
99

1010
.nav-wrapper {
1111
max-width: 900px;
@@ -20,10 +20,11 @@ nav {
2020
justify-content: space-between;
2121
align-items: center;
2222

23-
img {
24-
width: 30px;
25-
margin-right: 40px;
23+
.logo {
24+
width: 40px;
25+
margin-right: 20px;
2626
}
27+
2728
a {
2829
margin-right: 20px;
2930
font-weight: 400;
@@ -32,7 +33,7 @@ nav {
3233
}
3334

3435
a {
35-
color: #4d545d;
36+
color: @nav-link-color;
3637
transition: @transition;
3738
text-decoration: none;
3839

flask_assets_tutorial/static/src/less/variables.less

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Colors
22
@theme-color: #5eb9d7;
33
@background-color: #e1eaf5;
4+
45
@box-shadow: 0 0 5px rgba(65, 67, 144, 0.15);
6+
@box-shadow-nav: #bec6cf;
7+
@nav-link-color: #4d545d;
58
@header-color: #5f6988;
69

710
// Fonts
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<nav class="navigation-default">
22
<div class="nav-wrapper">
33
<div class="left-nav">
4-
<img src="{{ url_for('static', filename='dist/img/[email protected]') }}" alt="logo" />
5-
<a href="{{ url_for('main_blueprint.home') }}">Home</a>
6-
<a href="{{ url_for('main_blueprint.about') }}">About</a>
7-
<a href="{{ url_for('main_blueprint.etc') }}">Etc</a>
4+
<img class="logo" src="{{ url_for('static', filename='dist/img/[email protected]') }}" alt="logo" />
5+
<a class="nav-link" href="{{ url_for('main_blueprint.home') }}">Home</a>
6+
<a class="nav-link" href="{{ url_for('main_blueprint.about') }}">About</a>
7+
<a class="nav-link" href="{{ url_for('main_blueprint.etc') }}">Etc</a>
88
</div>
99
<div class="right-nav">
10-
<a href="{{ url_for('admin_blueprint.dashboard') }}">My Account</a>
10+
<a class="nav-link" href="{{ url_for('admin_blueprint.dashboard') }}">My Account</a>
1111
</div>
1212
</div>
1313
</nav>

gunicorn.conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
reload = True
1919
workers = 1
2020
threads = 1
21+
bind = ["127.0.0.1:8000"]
2122

2223
if ENVIRONMENT == "production":
2324
daemon = True

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pytest = "*"
2323
black = "*"
2424
isort = "*"
2525
gunicorn = "*"
26-
flask-sock = "^0.7.0"
26+
flask-sock = "*"
2727

2828
[tool.poetry.scripts]
2929
run = "wsgi:app"

requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and (sys_p
55
cssmin==0.2.0 ; python_version >= "3.10" and python_version < "4.0"
66
exceptiongroup==1.2.0 ; python_version >= "3.10" and python_version < "3.11"
77
flask-assets==2.1.0 ; python_version >= "3.10" and python_version < "4.0"
8+
flask-sock==0.7.0 ; python_version >= "3.10" and python_version < "4.0"
89
flask==3.0.0 ; python_version >= "3.10" and python_version < "4.0"
910
gunicorn==21.2.0 ; python_version >= "3.10" and python_version < "4.0"
11+
h11==0.14.0 ; python_version >= "3.10" and python_version < "4.0"
1012
iniconfig==2.0.0 ; python_version >= "3.10" and python_version < "4.0"
1113
isort==5.13.2 ; python_version >= "3.10" and python_version < "4.0"
1214
itsdangerous==2.1.2 ; python_version >= "3.10" and python_version < "4.0"
@@ -22,7 +24,9 @@ pluggy==1.3.0 ; python_version >= "3.10" and python_version < "4.0"
2224
ply==3.11 ; python_version >= "3.10" and python_version < "4.0"
2325
pytest==7.4.3 ; python_version >= "3.10" and python_version < "4.0"
2426
python-dotenv==1.0.0 ; python_version >= "3.10" and python_version < "4.0"
27+
simple-websocket==1.0.0 ; python_version >= "3.10" and python_version < "4.0"
2528
tomli==2.0.1 ; python_version >= "3.10" and python_version < "3.11"
2629
typing-extensions==4.9.0 ; python_version >= "3.10" and python_version < "3.11"
2730
webassets==2.0 ; python_version >= "3.10" and python_version < "4.0"
2831
werkzeug==3.0.1 ; python_version >= "3.10" and python_version < "4.0"
32+
wsproto==1.2.0 ; python_version >= "3.10" and python_version < "4.0"

0 commit comments

Comments
 (0)