Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
77f9db3b
Commit
77f9db3b
authored
Mar 27, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
serve css as independent files
parent
9e82896d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
33 deletions
+41
-33
modules/ui.py
modules/ui.py
+41
-33
No files found.
modules/ui.py
View file @
77f9db3b
...
...
@@ -70,17 +70,6 @@ def gr_show(visible=True):
sample_img2img
=
"assets/stable-samples/img2img/sketch-mountains-input.jpg"
sample_img2img
=
sample_img2img
if
os
.
path
.
exists
(
sample_img2img
)
else
None
css_hide_progressbar
=
"""
.wrap .m-12 svg { display:none!important; }
.wrap .m-12::before { content:"Loading..." }
.wrap .z-20 svg { display:none!important; }
.wrap .z-20::before { content:"Loading..." }
.wrap.cover-bg .z-20::before { content:"" }
.progress-bar { display:none!important; }
.meta-text { display:none!important; }
.meta-text-center { display:none!important; }
"""
# Using constants for these since the variation selector isn't visible.
# Important that they exactly match script.js for tooltip to work.
random_symbol
=
'
\U0001f3b2\ufe0f
'
# 🎲️
...
...
@@ -1566,22 +1555,6 @@ def create_ui():
(
train_interface
,
"Train"
,
"ti"
),
]
css
=
""
for
cssfile
in
modules
.
scripts
.
list_files_with_name
(
"style.css"
):
if
not
os
.
path
.
isfile
(
cssfile
):
continue
with
open
(
cssfile
,
"r"
,
encoding
=
"utf8"
)
as
file
:
css
+=
file
.
read
()
+
"
\n
"
if
os
.
path
.
exists
(
os
.
path
.
join
(
data_path
,
"user.css"
)):
with
open
(
os
.
path
.
join
(
data_path
,
"user.css"
),
"r"
,
encoding
=
"utf8"
)
as
file
:
css
+=
file
.
read
()
+
"
\n
"
if
not
cmd_opts
.
no_progressbar_hiding
:
css
+=
css_hide_progressbar
interfaces
+=
script_callbacks
.
ui_tabs_callback
()
interfaces
+=
[(
settings_interface
,
"Settings"
,
"settings"
)]
...
...
@@ -1592,7 +1565,7 @@ def create_ui():
for
_interface
,
label
,
_ifid
in
interfaces
:
shared
.
tab_names
.
append
(
label
)
with
gr
.
Blocks
(
css
=
css
,
analytics_enabled
=
False
,
title
=
"Stable Diffusion"
)
as
demo
:
with
gr
.
Blocks
(
analytics_enabled
=
False
,
title
=
"Stable Diffusion"
)
as
demo
:
with
gr
.
Row
(
elem_id
=
"quicksettings"
,
variant
=
"compact"
):
for
i
,
k
,
item
in
sorted
(
quicksettings_list
,
key
=
lambda
x
:
quicksettings_names
.
get
(
x
[
1
],
x
[
0
])):
component
=
create_setting_component
(
k
,
is_quicksettings
=
True
)
...
...
@@ -1777,25 +1750,60 @@ def create_ui():
return
demo
def
reload_javascript
():
def
webpath
(
fn
):
if
fn
.
startswith
(
script_path
):
web_path
=
os
.
path
.
relpath
(
fn
,
script_path
)
.
replace
(
'
\\
'
,
'/'
)
else
:
web_path
=
os
.
path
.
abspath
(
fn
)
return
f
'file={web_path}?{os.path.getmtime(fn)}'
def
javascript_html
():
script_js
=
os
.
path
.
join
(
script_path
,
"script.js"
)
head
=
f
'<script type="text/javascript" src="
file={os.path.abspath(script_js)}?{os.path.getmtime
(script_js)}"></script>
\n
'
head
=
f
'<script type="text/javascript" src="
{webpath
(script_js)}"></script>
\n
'
inline
=
f
"{localization.localization_js(shared.opts.localization)};"
if
cmd_opts
.
theme
is
not
None
:
inline
+=
f
"set_theme('{cmd_opts.theme}');"
for
script
in
modules
.
scripts
.
list_scripts
(
"javascript"
,
".js"
):
head
+=
f
'<script type="text/javascript" src="
file={script.path}?{os.path.getmtime
(script.path)}"></script>
\n
'
head
+=
f
'<script type="text/javascript" src="
{webpath
(script.path)}"></script>
\n
'
for
script
in
modules
.
scripts
.
list_scripts
(
"javascript"
,
".mjs"
):
head
+=
f
'<script type="module" src="
file={script.path}?{os.path.getmtime
(script.path)}"></script>
\n
'
head
+=
f
'<script type="module" src="
{webpath
(script.path)}"></script>
\n
'
head
+=
f
'<script type="text/javascript">{inline}</script>
\n
'
return
head
def
css_html
():
head
=
""
def
stylesheet
(
fn
):
return
f
'<link rel="stylesheet" property="stylesheet" href="{webpath(fn)}">'
for
cssfile
in
modules
.
scripts
.
list_files_with_name
(
"style.css"
):
if
not
os
.
path
.
isfile
(
cssfile
):
continue
head
+=
stylesheet
(
cssfile
)
if
os
.
path
.
exists
(
os
.
path
.
join
(
data_path
,
"user.css"
)):
head
+=
stylesheet
(
os
.
path
.
join
(
data_path
,
"user.css"
))
return
head
def
reload_javascript
():
js
=
javascript_html
()
css
=
css_html
()
def
template_response
(
*
args
,
**
kwargs
):
res
=
shared
.
GradioTemplateResponseOriginal
(
*
args
,
**
kwargs
)
res
.
body
=
res
.
body
.
replace
(
b
'</head>'
,
f
'{head}</head>'
.
encode
(
"utf8"
))
res
.
body
=
res
.
body
.
replace
(
b
'</head>'
,
f
'{js}</head>'
.
encode
(
"utf8"
))
res
.
body
=
res
.
body
.
replace
(
b
'</body>'
,
f
'{css}</body>'
.
encode
(
"utf8"
))
res
.
init_headers
()
return
res
...
...
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