Added StaticDataMiddleware for serving files from mulitple sites, desktop background and positioning
This commit is contained in:
parent
3081224bbc
commit
201385ec70
8 changed files with 52 additions and 13 deletions
|
|
@ -6,9 +6,9 @@ import json
|
|||
|
||||
from werkzeug.wrappers import Request, Response
|
||||
from werkzeug.local import LocalManager
|
||||
from werkzeug.wsgi import SharedDataMiddleware
|
||||
from werkzeug.exceptions import HTTPException, NotFound
|
||||
from werkzeug.contrib.profiler import ProfilerMiddleware
|
||||
from werkzeug.wsgi import SharedDataMiddleware
|
||||
|
||||
import mimetypes
|
||||
import frappe
|
||||
|
|
@ -18,6 +18,7 @@ import frappe.api
|
|||
import frappe.utils.response
|
||||
import frappe.website.render
|
||||
from frappe.utils import get_site_name
|
||||
from frappe.middlewares import StaticDataMiddleware
|
||||
|
||||
local_manager = LocalManager([frappe.local])
|
||||
|
||||
|
|
@ -98,9 +99,8 @@ def serve(port=8000, profile=False, site=None, sites_path='.'):
|
|||
'/assets': os.path.join(sites_path, 'assets'),
|
||||
})
|
||||
|
||||
if site:
|
||||
application = SharedDataMiddleware(application, {
|
||||
'/files': os.path.join(sites_path, site, 'public', 'files')
|
||||
application = StaticDataMiddleware(application, {
|
||||
'/files': os.path.abspath(sites_path)
|
||||
})
|
||||
|
||||
run_simple('0.0.0.0', int(port), application, use_reloader=True,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
color: white;
|
||||
padding-top: 5px;
|
||||
text-align: center;
|
||||
text-shadow: 0px 0px 10px rgba(0, 0, 0, 0.6);
|
||||
text-shadow: 1px 1px 3px rgba(0, 0, 0, 1), 1px 1px 5px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
|
|
@ -66,4 +66,14 @@
|
|||
color: white;
|
||||
display: inline-block;
|
||||
min-width: 15px;
|
||||
}
|
||||
|
||||
#page-desktop {
|
||||
position: absolute;
|
||||
min-width: 100%;
|
||||
min-height: 100%;
|
||||
overflow: auto;
|
||||
padding-top: 14px;
|
||||
padding-bottom: 50px;
|
||||
margin-bottom: -50px;
|
||||
}
|
||||
26
frappe/middlewares.py
Normal file
26
frappe/middlewares.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import os
|
||||
|
||||
from werkzeug.wsgi import SharedDataMiddleware
|
||||
from frappe.utils import get_site_name, get_site_path, get_site_base_path, get_path, cstr
|
||||
|
||||
class StaticDataMiddleware(SharedDataMiddleware):
|
||||
def __call__(self, environ, start_response):
|
||||
self.environ = environ
|
||||
return super(StaticDataMiddleware, self).__call__(environ, start_response)
|
||||
|
||||
def get_directory_loader(self, directory):
|
||||
def loader(path):
|
||||
site = get_site_name(self.environ.get('HTTP_HOST'))
|
||||
path = os.path.join(directory, site, 'public', 'files', cstr(path))
|
||||
if os.path.isfile(path):
|
||||
return os.path.basename(path), self._opener(path)
|
||||
else:
|
||||
return None, None
|
||||
|
||||
return loader
|
||||
|
|
@ -1,4 +1,10 @@
|
|||
body {
|
||||
html {
|
||||
min-height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
padding-top: 36px;
|
||||
padding-bottom: 50px;
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB |
BIN
frappe/public/images/ui/random-polygons.jpg
Executable file
BIN
frappe/public/images/ui/random-polygons.jpg
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 258 KiB |
|
|
@ -31,11 +31,8 @@ frappe.avatar = function(user, large, title) {
|
|||
}
|
||||
|
||||
frappe.ui.set_user_background = function(src) {
|
||||
if(!src) src = "assets/frappe/images/ui/background-4-1.jpg";
|
||||
if(!src) src = "assets/frappe/images/ui/random-polygons.jpg";
|
||||
frappe.dom.set_style(repl('#page-desktop { \
|
||||
position: fixed;\
|
||||
left: 0px; min-width: 100%; height: 100%; overflow: auto;\
|
||||
padding-top: 14px; \
|
||||
background: url("%(src)s") center center fixed; \
|
||||
}', {src:src}))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
|
||||
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
|
||||
{% for include in include_css -%}
|
||||
<link type="text/css" rel="stylesheet" href="{{ include }}">
|
||||
{%- endfor -%}
|
||||
</head>
|
||||
<body>
|
||||
<div class="splash">{% include "public/images/frappe.svg" %}</div>
|
||||
|
|
@ -13,9 +16,6 @@
|
|||
<div id="body_div">
|
||||
</div>
|
||||
<footer></footer>
|
||||
{% for include in include_css -%}
|
||||
<link type="text/css" rel="stylesheet" href="{{ include }}">
|
||||
{%- endfor -%}
|
||||
<script type="text/javascript" src="/assets/frappe/js/lib/jquery/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
window._version_number = "{{ build_version }}";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue