Package omeroweb :: Package webstart :: Module views
[hide private]
[frames] | no frames]

Source Code for Module omeroweb.webstart.views

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3  #  
 4  #  
 5  #  
 6  # Copyright (c) 2008 University of Dundee.  
 7  #  
 8  # This program is free software: you can redistribute it and/or modify 
 9  # it under the terms of the GNU Affero General Public License as 
10  # published by the Free Software Foundation, either version 3 of the 
11  # License, or (at your option) any later version. 
12  #  
13  # This program is distributed in the hope that it will be useful, 
14  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  # GNU Affero General Public License for more details. 
17  #  
18  # You should have received a copy of the GNU Affero General Public License 
19  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
20  #  
21  # Author: Aleksandra Tarkowska <A(dot)Tarkowska(at)dundee(dot)ac(dot)uk>, 2008. 
22  #  
23  # Version: 1.0 
24  # 
25   
26  import os 
27  from glob import glob 
28   
29  from django.conf import settings 
30  from django.core import template_loader 
31  from django.template import RequestContext as Context 
32  from django.shortcuts import render_to_response 
33  from django.http import HttpResponse 
34  from django.core.urlresolvers import reverse 
35  from django.views.decorators.cache import never_cache 
36   
37  from omero_version import omero_version 
38 39 -def index(request):
40 template = settings.INDEX_TEMPLATE 41 if not isinstance(template, basestring): 42 template = 'webstart/index.html' 43 44 insight_url = None 45 if settings.WEBSTART: 46 insight_url = request.build_absolute_uri(reverse("webstart_insight")) 47 48 return render_to_response(template,{'insight_url':insight_url, "version": omero_version})
49
50 @never_cache 51 -def insight(request):
52 t = template_loader.get_template('webstart/insight.xml') 53 54 codebase = request.build_absolute_uri(settings.STATIC_URL+'webstart/jars/') 55 href = request.build_absolute_uri(reverse("webstart_insight")) 56 57 pattern = os.path.abspath(os.path.join(settings.OMERO_HOME, "lib", "insight", "*.jar").replace('\\','/')) 58 jarlist = glob(pattern) 59 jarlist = [os.path.basename(x) for x in jarlist] 60 61 # ticket:9478 put insight jar at the start of the list if available 62 # This can be configured via omero.web.webstart_jar to point to a 63 # custom value. 64 idx = jarlist.index(settings.WEBSTART_JAR) 65 if idx > 0: 66 jarlist.pop(idx) 67 jarlist.insert(0, settings.WEBSTART_JAR) 68 69 idy = jarlist.index(settings.NANOXML_JAR) 70 if idy > 0: 71 jarlist.pop(idy) 72 jarlist.insert(len(jarlist)-1, settings.NANOXML_JAR) 73 74 context = {'codebase': codebase, 'href': href, 'jarlist': jarlist, 75 'icon': settings.WEBSTART_ICON, 76 'heap': settings.WEBSTART_HEAP, 77 'host': settings.WEBSTART_HOST, 78 'port': settings.WEBSTART_PORT, 79 'class': settings.WEBSTART_CLASS, 80 'title': settings.WEBSTART_TITLE, 81 'vendor': settings.WEBSTART_VENDOR, 82 'homepage': settings.WEBSTART_HOMEPAGE, 83 } 84 85 c = Context(request, context) 86 return HttpResponse(t.render(c), content_type="application/x-java-jnlp-file")
87