Task #7274 (closed)
Opened 12 years ago
Closed 12 years ago
DOC: Development examples documentation
Reported by: | atarkowska | Owned by: | cxallan |
---|---|---|---|
Priority: | critical | Milestone: | OMERO-4.4 |
Component: | Documentation | Version: | n.a. |
Keywords: | n.a. | Cc: | cxallan, wmoore, cneves |
Resources: | n.a. | Referenced By: | n.a. |
References: | n.a. | Remaining Time: | 0.0d |
Sprint: | n.a. |
Description
This ticket should include examples how to configure, use and add own static files and their handler
Change History (7)
comment:1 Changed 12 years ago by atarkowska
comment:2 Changed 12 years ago by atarkowska
- Cc cxallan wmoore added
comment:3 Changed 12 years ago by atarkowska
- Cc cneves-x added
comment:4 Changed 12 years ago by cxallan
- Owner changed from atarkowska to cxallan
comment:5 Changed 12 years ago by wmoore
If I do this:
$ omero config set omero.web.staticfile_dirs '[["alias", "/Users/will/Desktop/static"], ["blah", "/Users/will/Desktop/static"]]'
It seems to have no effect on where static files are copied on web start
Copying '/Users/will/Desktop/OMERO/dist/lib/python/omeroweb/webstart/static/webstart/img/icon-omero-web.png' 735 static files copied to '/Users/will/Desktop/OMERO/dist/lib/python/omeroweb/static'. Starting OMERO.web... Validating models... 0 errors found Django version 1.3.1, using settings 'omeroweb.settings' Development server is running at http://0.0.0.0:4080/ Quit the server with CONTROL-C.
comment:6 Changed 12 years ago by wmoore
Ah - OK, I get it. omero.web.staticfile_dirs simply specifies additional source dirs for static files. Do we provide any way to change the location that they are copied to? Or it is Always lib/python/omeroweb/static
comment:7 Changed 12 years ago by cxallan
- Remaining Time changed from 1 to 0
- Resolution set to fixed
- Status changed from new to closed
Completed.
Using STATICS in the template
django.contrib.staticfiles collects static files from each of your applications (and any other places you specify) into a single location that can easily be served in production.
By default, static files should be put within static/ subdirectories of apps in INSTALLED_APPS. Some projects will probably also have static assets that aren’t tied to a particular app. The STATICFILES_DIRS setting is a tuple of filesystem directories to check when loading static files.
for example:
http://host:port/static/3rdparty/jquery_1.4.2.js
and less fabulous way:
http://host:port/static/YOUR_APP/image/logo.jpg
WARNING: In every inherited template any code outside blocks redefinitions is not executed. So in this case {% load webclient_tags %} has to be called inside each block.
or use context processor for setting "global" variable.
Using STATICS in views methods:
Developer might be also interested in using static prefix directly in the python code such as views, forms, etc.
Serving static files:
The static files tools are mostly designed to help with getting static files successfully deployed into production. This usually means a separate, dedicated static file server, which is a lot of overhead to mess with when developing locally. Thus, the staticfiles app ships with a quick and dirty helper view that you can use to serve files locally in development. This will only work if DEBUG is True.
That's because this view is grossly inefficient and probably insecure. This is only intended for local development, and should never be used in production.
Config changes:
Deprecated:
New OMERO config command:
Deprecated:
New OMERO config command: