Skip to content

Commit

Permalink
Merge pull request #34 from aleksandra-tarkowska/feature/static_file_…
Browse files Browse the repository at this point in the history
…handling

Feature/static file handling
  • Loading branch information
chris-allan committed Jan 2, 2012
2 parents 60e8fd0 + 15742cc commit a794385
Show file tree
Hide file tree
Showing 723 changed files with 18,413 additions and 6,197 deletions.
39 changes: 13 additions & 26 deletions components/tools/OmeroPy/src/omero/plugins/web.py
Expand Up @@ -85,7 +85,7 @@ def _configure(self, parser):
config.add_argument("type", choices=("nginx","apache"))
config.add_argument("--http", type=int, help="HTTP port for web server (not fastcgi)")

parser.add(sub, self.syncmedia, "Advanced use: Creates needed symlinks for static media files")
parser.add(sub, self.syncmedia, "[DEPRECATED] Advanced use: Creates needed symlinks for static media files")

#
# Developer
Expand Down Expand Up @@ -174,47 +174,28 @@ def config(self, args):
Allow from all
</Directory>
<Directory "%(MEDIA)s">
<Directory "%(STATIC)s">
Options -Indexes FollowSymLinks
Order allow,deny
Allow from all
</Directory>
Alias /appmedia %(MEDIA)s
Alias /static %(STATIC)s
Alias / "%(ROOT)s/var/omero.fcgi/"
"""
d = {
"ROOT":self.ctx.dir,
"MEDIA":self.ctx.dir / "lib" / "python" / "omeroweb" / "media",
"STATIC":self.ctx.dir / "lib" / "python" / "omeroweb" / "static",
"OMEROWEBROOT":self.ctx.dir / "lib" / "python" / "omeroweb",
"FASTCGI_EXTERNAL":fastcgi_external,
"NOW":str(datetime.now()),
}
self.ctx.out(stanza % d)

def syncmedia(self, args):
import shutil
from glob import glob
location = self.ctx.dir / "lib" / "python" / "omeroweb"
# Targets
apps = map(lambda x: x.startswith('omeroweb.') and x[9:] or x, settings.INSTALLED_APPS)
apps = filter(lambda x: os.path.exists(location / x), apps)
# Destination dir
if not os.path.exists(location / 'media'):
os.mkdir(location / 'media')

# Create app media links
for app in apps:
media_dir = location / app / 'media'
if os.path.exists(media_dir):
if os.path.exists(location / 'media' / app):
os.remove(os.path.abspath(location / 'media' / app))
try:
# Windows does not support symlink
sys.getwindowsversion()
shutil.copytree(os.path.abspath(media_dir), location / 'media' / app)
except:
os.symlink(os.path.abspath(media_dir), location / 'media' / app)
self.ctx.out(
"** NO-OP ** syncmedia now part of 'web start' and is " \
"no longer required.")

def enableapp(self, args):
location = self.ctx.dir / "lib" / "python" / "omeroweb"
Expand Down Expand Up @@ -320,6 +301,12 @@ def call (self, args):


def start(self, args):
# Ensure that static media is copied to the correct location
location = self.ctx.dir / "lib" / "python" / "omeroweb"
args = [sys.executable, "manage.py", "collectstatic", "--noinput"]
rv = self.ctx.call(args, cwd = location)
if rv != 0:
self.ctx.die(607, "Failed to collect static content.\n")
import omeroweb.settings as settings
link = ("%s:%s" % (settings.APPLICATION_SERVER_HOST,
settings.APPLICATION_SERVER_PORT))
Expand Down
11 changes: 10 additions & 1 deletion components/tools/OmeroWeb/build.xml
Expand Up @@ -43,7 +43,16 @@
<target name="tools-init">
<if><not><available file="${basedir}/../target/lib/python/django"/></not>
<then>
<untar compression="gzip" src="${lib.dir}/repository/django-lib-1.1.1.tar.gz" dest="${basedir}/../target/lib/python"/>
<untar compression="gzip" src="${lib.dir}/repository/Django-1.3.1.tar.gz" dest="${basedir}/../target/lib/python">
<patternset>
<include name="Django-1.3.1/django/**"/>
</patternset>
<mapper>
<filtermapper>
<replacestring from="Django-1.3.1/" to=""/>
</filtermapper>
</mapper>
</untar>
</then>
</if>
<if><not><available file="${basedir}/../target/lib/python/flup"/></not>
Expand Down
3 changes: 3 additions & 0 deletions components/tools/OmeroWeb/omeroweb/common/__init__.py
@@ -0,0 +1,3 @@
from django.template.base import add_to_builtins

add_to_builtins('omeroweb.common.templatetags.defaulttags')
3 changes: 3 additions & 0 deletions components/tools/OmeroWeb/omeroweb/common/models.py
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
120 changes: 120 additions & 0 deletions components/tools/OmeroWeb/omeroweb/common/static/common/css/body.css
@@ -0,0 +1,120 @@
html {
height: 100%;
}

body {
background-color: #F3F3F3;
color: #555555;
font-family: Arial,Verdana,Lucida,Helvetica,sans-serif;
font-size: 13px;
height: 100%;
padding: 0px;
margin: 0px;
position: relative;
}

#content {
position:absolute;
top:102px;
right:0px;
left:0px;
bottom:0px;
background: white;
overflow:auto;
}

a:hover, a:link, a:visited {
border: medium none;
color: #1B7BC7;
text-decoration: none;
}

h1 {
font-size: 15px;
text-align: left;
margin: 0;
padding: 10px 0;
}
h2 {
font-size: 13px;
text-align: left;
}

p {
margin: 0px;
padding: 5px;
}

img {
border: 0px;
}

table {
border: 0px;
table-layout: auto;
}
th {
font-weight: bold;
vertical-align:middle;
text-align: left;
}
td {
vertical-align:top;
text-align: left;
}

form table {
border: 0px;
table-layout: auto;
}

form td {
padding: 2px;
}

form th {
border: 0px;
}

input {
margin: 0;
border: 1px solid #bbb;
background-color: #fff;
}
select {
margin: 0;
background-color: #fff;
border: 1px solid #bbb;
}
textarea {
margin: 0;
background-color: #fff;
border: 1px solid #bbb;
}

ul.errorlist {
list-style: none;
color: #e3646f;
margin: 0;
padding: 10px 0 0;
text-align: center;
}
ul.errorlist li {
border-style:none;
border-width:0;
}


label {
font-weight: bold;
}

.clear {
clear: both;
width: 0px;
margin: 0px;
padding: 0px;
}

/* used by the dialog in popup.js */
.ui-dialog-titlebar { background: gray; color: white }
@@ -0,0 +1,86 @@
img {
border: 0px;
padding: 0px;
margin: 0px;
vertical-align: middle;
}

table.contentWrapper {
width: 100%;
background: #f3f3f3;
table-layout:fixed;
height:100%;
}

#left_panel {
background-color: #ffffff;
position:absolute;
left:0px; top:0px; bottom:0px;
width:350px;
overflow: auto;
}
#center_panel {
background-color: #ffffff;
position:absolute;
left:20px; right:20px; top:0px; bottom:0px;
overflow: auto;
}
#right_panel {
background-color: #f3f3f3;
position:absolute;
width:370px;
right:0px; top:0px; bottom:0px;
overflow: auto;
}

.collapsibletrayhandle-right {
background:#F3F3F3 url(../image/tray_right_shadow.png) repeat-y scroll left top;
}
.collapsibletrayhandle-left {
background:#fff url(../image/tray_left_shadow.png) repeat-y scroll left top;
}

#trayhandle_left {
position:absolute; top:0px; left:0px; bottom:0px;
width:20px;
}
#trayhandle_right {
position:absolute;
top:0px; right:0px; bottom:0px;
width:20px;
}
#center_container {
position:absolute;
left:350px; right:370px; top:0px; bottom:0px;
}

#lhid_trayhandle_icon_right {
cursor:pointer;
position:relative;
}

#lhid_trayhandle_icon_left {
cursor:pointer;
position:relative;
}

.expanded-left {
background:transparent url(../image/tray_left_button.png) no-repeat scroll;
height:24px;
width:16px;
}
.expanded-right {
background:transparent url(../image/tray_right_button.png) no-repeat scroll;
height:24px;
width:16px;
}
.collapsed-left {
background:transparent url(../image/tray_left_expand_button.png) no-repeat scroll;
height:24px;
width:16px;
}
.collapsed-right {
background:transparent url(../image/tray_right_expand_button.png) no-repeat scroll;
height:24px;
width:16px;
}
@@ -0,0 +1,19 @@
#footer {
background-color: #F3F3F3;
clear: both;
font-size: 11px;
height: 36px;
padding: 10px;
text-align: center;
border-top: 1px solid #BBBBBB;
min-width: 1010px;
position: absolute;
width: 100%;
bottom: 0px;
margin:0px;
padding: 5px 0px;
}

#content {
bottom: 46px;
}
@@ -0,0 +1,56 @@
#top_header {
background: #fff;
position: relative;
height:75px;
}

#logo {
background: url(../image/logo.png) no-repeat scroll left bottom transparent;
height: 73px;
left: 25px;
margin: 0;
position: absolute;
top: 0;
width: 160px;
}

#menu {
position: absolute;
bottom: 0px;
right: 0px;
}
#navigation li {
float:right;
display: block;
margin: 10px;
font-size: 110%;
}

a:hover {
border: medium none;
color: #1B7BC7;
text-decoration: underline;
}

#thin_header {
margin: 0;
padding: 4px 0px;
height: 17px;
position: relative;
background: url(../image/header_bg.png) repeat-x scroll left bottom #FFFFFF;
border-bottom: 1px solid #bbb;
}

#header_right {
margin: 6px 10px;
position: absolute;
right: 0;
top: 0;
}

#header_left {
margin: 6px 10px;
position: absolute;
left: 0;
top: 0;
}

0 comments on commit a794385

Please sign in to comment.