root / okeanos_site / views.py @ c14ab89f
History | View | Annotate | Download (1.6 kB)
1 |
import urllib2 |
---|---|
2 |
|
3 |
from django.views.generic.simple import direct_to_template |
4 |
from django.conf import settings |
5 |
|
6 |
OKEANOS_NEWS_CONTENT_URL = getattr(settings, 'OKEANOS_NEWS_CONTENT_URL', False) |
7 |
|
8 |
OKEANOS_STATIC = getattr(settings, 'OKEANOS_STATIC_URL', '/okeanos_static/') |
9 |
OKEANOS_SITE_URL = getattr(settings, 'OKEANOS_SITE_URL', '/okeanos') |
10 |
OKEANOS_VIDEO_URL = getattr(settings, 'OKEANOS_VIDEO_URL', '') |
11 |
OKEANOS_APP_URL = getattr(settings, 'OKEANOS_APP_URL', '/') |
12 |
|
13 |
# needed for flash fallback video
|
14 |
OKEANOS_MP4_VIDEO_URL = OKEANOS_VIDEO_URL.get('mp4', {}).get('src', False) |
15 |
|
16 |
context = { |
17 |
'OKEANOS_STATIC_URL': OKEANOS_STATIC,
|
18 |
'OKEANOS_SITE_URL': OKEANOS_SITE_URL,
|
19 |
'OKEANOS_VIDEO_URL': OKEANOS_VIDEO_URL,
|
20 |
'OKEANOS_APP_URL': OKEANOS_APP_URL,
|
21 |
'OKEANOS_MP4_VIDEO_URL': OKEANOS_MP4_VIDEO_URL,
|
22 |
'OKEANOS_VIDEO_POSTER_IMAGE_URL': settings.OKEANOS_VIDEO_POSTER_IMAGE_URL,
|
23 |
'OKEANOS_VIDEO_FLOWPLAYER_URL': settings.OKEANOS_VIDEO_FLOWPLAYER_URL,
|
24 |
'VIDEO_WIDTH': 640, |
25 |
'VIDEO_HEIGHT': 360 |
26 |
} |
27 |
|
28 |
def _load_news_content(): |
29 |
"""
|
30 |
Import news html content from external location
|
31 |
"""
|
32 |
data = ""
|
33 |
if not OKEANOS_NEWS_CONTENT_URL: |
34 |
return data
|
35 |
|
36 |
try:
|
37 |
response = urllib2.urlopen(OKEANOS_NEWS_CONTENT_URL, '', 5) |
38 |
data = response.read() |
39 |
except:
|
40 |
pass
|
41 |
|
42 |
return data
|
43 |
|
44 |
def intro(request): |
45 |
return direct_to_template(request, "okeanos/intro.html", context) |
46 |
|
47 |
def index(request): |
48 |
news_context = {'news_content':_load_news_content()}
|
49 |
context.update(news_context) |
50 |
return direct_to_template(request, "okeanos/index.html", context) |
51 |
|