Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Nuovo sito
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Nuovo sito
Commits
ebd841e0
Commit
ebd841e0
authored
May 10, 2018
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minify the output HTML
parent
f5f65ae3
Pipeline
#83
passed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
setup.py
setup.py
+1
-0
uitwww/utils.py
uitwww/utils.py
+17
-0
No files found.
setup.py
View file @
ebd841e0
...
...
@@ -39,6 +39,7 @@ setuptools.setup(
"pyyaml"
,
"requests"
,
"toml"
,
"django-htmlmin"
,
],
packages
=
[
...
...
uitwww/utils.py
View file @
ebd841e0
...
...
@@ -18,6 +18,7 @@ import datetime
import
random
import
string
from
htmlmin.minify
import
html_minify
import
gunicorn.app.base
as
baseapp
...
...
@@ -106,6 +107,22 @@ class ReverseProxied:
def
prepare_app
(
app
):
"""Add some utilities to the app"""
@
app
.
after_request
def
after_request
(
response
):
if
"text/html"
in
response
.
content_type
:
content
=
response
.
get_data
(
as_text
=
True
)
# Minify the HTML
content
=
html_minify
(
content
)
# Generate a random string and append it as the render ID
randstr
=
""
.
join
(
random
.
choice
(
string
.
ascii_letters
)
for
_
in
range
(
10
))
content
=
"<!--render:%s-->%s"
%
(
randstr
,
content
)
response
.
set_data
(
content
)
return
response
@
app
.
template_filter
(
"format_timestamp"
)
def
format_timestamp
(
timestamp
):
return
datetime
.
datetime
.
fromtimestamp
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment