1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
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
62
63
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