aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJessica Tallon <xray7224@googlemail.com>2013-08-14 19:58:01 +0100
committerJessica Tallon <jessica@megworld.co.uk>2014-07-22 23:13:14 +0100
commit5b014a08661f718bd92971e71d173a0ea4b62c40 (patch)
tree9ec2b3793f8103b4f8bbc169aa802f77a19dfde7
parentc8bd2542d7b8face6033884fccfb898be1d12989 (diff)
downloadmediagoblin-5b014a08661f718bd92971e71d173a0ea4b62c40.tar.lz
mediagoblin-5b014a08661f718bd92971e71d173a0ea4b62c40.tar.xz
mediagoblin-5b014a08661f718bd92971e71d173a0ea4b62c40.zip
Add image URL's (thumb & full)
-rw-r--r--mediagoblin/db/mixin.py11
-rw-r--r--mediagoblin/db/models.py6
-rw-r--r--mediagoblin/federation/views.py4
3 files changed, 19 insertions, 2 deletions
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py
index 3d96ba34..87f4383a 100644
--- a/mediagoblin/db/mixin.py
+++ b/mediagoblin/db/mixin.py
@@ -202,6 +202,17 @@ class MediaEntryMixin(GenerateSlugMixin):
thumb_url = mg_globals.app.staticdirector(manager[u'default_thumb'])
return thumb_url
+ @property
+ def original_url(self):
+ """ Returns the URL for the original image
+ will return self.thumb_url if original url doesn't exist"""
+ if u"original" not in self.media_files:
+ return self.thumb_url
+
+ return mg_globals.app.public_store.file_url(
+ self.media_files[u"original"]
+ )
+
@cached_property
def media_manager(self):
"""Returns the MEDIA_MANAGER of the media's media_type
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index 281c09d9..925f0d24 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -455,6 +455,12 @@ class MediaEntry(Base, MediaEntryMixin):
"displayName": self.title,
"objectType": self.objectType,
"url": url,
+ "image": {
+ "url": request.host_url + self.thumb_url[1:],
+ },
+ "fullImage":{
+ "url": request.host_url + self.original_url[1:],
+ }
}
if show_comments:
diff --git a/mediagoblin/federation/views.py b/mediagoblin/federation/views.py
index b3f63db5..3fe5b3b5 100644
--- a/mediagoblin/federation/views.py
+++ b/mediagoblin/federation/views.py
@@ -2,7 +2,7 @@ from mediagoblin.decorators import oauth_required
from mediagoblin.db.models import User, MediaEntry
from mediagoblin.tools.response import json_response
-#@oauth_required
+@oauth_required
def user(request):
""" Handles user response at /api/user/<username>/ """
user = request.matchdict["username"]
@@ -39,7 +39,7 @@ def inbox(request):
""" Handles the user's inbox - /api/user/<username>/inbox """
raise NotImplemented("Yet to implement looking up user's inbox")
-#@oauth_required
+@oauth_required
def object(request):
""" Lookup for a object type """
objectType = request.matchdict["objectType"]