Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #7190 (closed)

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

Extended static files handler investigation

Reported by: atarkowska Owned by: atarkowska
Priority: minor Milestone: OMERO-4.4
Component: Web Version: n.a.
Keywords: n.a. Cc: web-team@…
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.0d
Sprint: 2011-11-29 (3)

Description

Investigation of how we want to use & reuse Django django.contrib.staticfiles app and how it make it easily extendible.

Change History (7)

comment:1 Changed 12 years ago by atarkowska

  • Remaining Time set to 1

comment:2 Changed 12 years ago by atarkowska

  • Cc web-team@… added

comment:3 Changed 12 years ago by atarkowska

  • Status changed from new to accepted

comment:4 Changed 12 years ago by atarkowska

  • Remaining Time changed from 1 to 0
  • Resolution set to fixed
  • Status changed from accepted to closed

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.

  • GENERAL: In order to refer to these files in templates use the included context processor which allows template code like:
{% load static %}
<link rel="stylesheet" href="{% get_static_prefix %}YOUR_APP/css/layout.css" type="text/css" />

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.

{% load static %}
<img src="{{ STATIC_URL }}YOUR_APP/image/logo.jpg" />

http://host:port/static/YOUR_APP/image/logo.jpg

  • CUSTOMISATION: In order to refer to the existing static files which are served from OMERO.web app you need to add static tag {% static "YOUR_APP/path_to_media" %}
<script type="text/javascript" src="{% static "common/javascript/jquery_1.4.2.js" %}"/>

http://host:port/static/common/javascript/jquery_1.4.2.js

Last edited 12 years ago by atarkowska (previous) (diff)

comment:5 Changed 12 years ago by atarkowska

Referring to comments from the meeting 2011-11-14 above comment was updated.

comment:6 Changed 12 years ago by atarkowska

In order to take the adventage of static prefixes given template has to be rendered with a given context dictionary

from django.template import RequestContext    
return render_to_response(template_name, context_instance=RequestContext(request))

comment:7 Changed 12 years ago by atarkowska

Referring to the changes made in #7369 there is no longer need to create custom context processors for static aliases.

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.80145 sec.)

We're Hiring!