|
a/Allura/allura/controllers/oembed.py |
|
b/Allura/allura/controllers/oembed.py |
|
... |
|
... |
18 |
log = logging.getLogger(__name__)
|
18 |
log = logging.getLogger(__name__)
|
19 |
|
19 |
|
20 |
class OEmbedController(WsgiDispatchController):
|
20 |
class OEmbedController(WsgiDispatchController):
|
21 |
'''Controller that serves up oembedded resources'''
|
21 |
'''Controller that serves up oembedded resources'''
|
22 |
|
22 |
|
23 |
@expose('jinja:oembed/generic.html')
|
23 |
@expose('jinja:allura:templates/oembed/generic.html')
|
24 |
def index(self, href, **kw):
|
24 |
def index(self, href, **kw):
|
25 |
try:
|
25 |
try:
|
26 |
response = g.oembed_consumer.embed(href)
|
26 |
response = g.oembed_consumer.embed(href)
|
27 |
except (oembed.OEmbedNoEndpoint, HTTPError), ex:
|
27 |
except (oembed.OEmbedNoEndpoint, HTTPError), ex:
|
28 |
return dict(href=href)
|
28 |
return dict(href=href)
|
29 |
data = response.getData()
|
29 |
data = response.getData()
|
30 |
log.info('Got response:\n%s', pformat(data))
|
30 |
log.info('Got response:\n%s', pformat(data))
|
31 |
if isinstance(response, oembed.OEmbedPhotoResponse):
|
31 |
if isinstance(response, oembed.OEmbedPhotoResponse):
|
32 |
override_template(self.index, 'jinja:oembed/photo.html')
|
32 |
override_template(self.index, 'jinja:allura:templates/oembed/photo.html')
|
33 |
elif isinstance(response, oembed.OEmbedVideoResponse):
|
33 |
elif isinstance(response, oembed.OEmbedVideoResponse):
|
34 |
override_template(self.index, 'jinja:oembed/html_tpl.html')
|
34 |
override_template(self.index, 'jinja:allura:templates/oembed/html_tpl.html')
|
35 |
elif isinstance(response, oembed.OEmbedRichResponse):
|
35 |
elif isinstance(response, oembed.OEmbedRichResponse):
|
36 |
override_template(self.index, 'jinja:oembed/html_tpl.html')
|
36 |
override_template(self.index, 'jinja:allura:templates/oembed/html_tpl.html')
|
37 |
elif isinstance(response, oembed.OEmbedLinkResponse):
|
37 |
elif isinstance(response, oembed.OEmbedLinkResponse):
|
38 |
if data['provider_name'] == 'Twitter Status':
|
38 |
if data['provider_name'] == 'Twitter Status':
|
39 |
override_template(self.index, 'jinja:oembed/link_twitter.html')
|
39 |
override_template(self.index, 'jinja:allura:templates/oembed/link_twitter.html')
|
40 |
elif data['provider_name'] == 'My Opera Community':
|
40 |
elif data['provider_name'] == 'My Opera Community':
|
41 |
override_template(self.index, 'jinja:oembed/link_opera.html')
|
41 |
override_template(self.index, 'jinja:allura:templates/oembed/link_opera.html')
|
42 |
else: # pragma no cover
|
42 |
else: # pragma no cover
|
43 |
override_template(self.index, 'jinja:oembed/link.html')
|
43 |
override_template(self.index, 'jinja:allura:templates/oembed/link.html')
|
44 |
else:
|
44 |
else:
|
45 |
pass
|
45 |
pass
|
46 |
return dict(href=href, data=data)
|
46 |
return dict(href=href, data=data)
|
47 |
|
47 |
|