forked from MsuLab/TextumBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove webodf submodule. Move converter to core. Prettify textedit app.
Task MsuLab#10
- Loading branch information
Showing
10 changed files
with
88 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
[submodule "textum/textedit/webodf"] | ||
path = textum/textedit/webodf | ||
url = https://github.com/KopBob/WebODF | ||
[submodule "textum/textedit/converter/unoconv"] | ||
path = textum/textedit/converter/unoconv | ||
[submodule "textum/textedit/core/converter/unoconv"] | ||
path = textum/textedit/core/converter/unoconv | ||
url = https://github.com/KopBob/unoconv |
Empty file.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# encoding: utf-8 | ||
from django.http import HttpResponse | ||
from django.utils import simplejson | ||
|
||
|
||
|
||
MIMEANY = '*/*' | ||
MIMEJSON = 'application/json' | ||
MIMETEXT = 'text/plain' | ||
|
||
|
||
def response_mimetype(request): | ||
"""response_mimetype -- Return a proper response mimetype, accordingly to | ||
what the client accepts, as available in the `HTTP_ACCEPT` header. | ||
request -- a HttpRequest instance. | ||
""" | ||
can_json = MIMEJSON in request.META['HTTP_ACCEPT'] | ||
can_json |= MIMEANY in request.META['HTTP_ACCEPT'] | ||
return MIMEJSON if can_json else MIMETEXT | ||
|
||
|
||
class JSONResponse(HttpResponse): | ||
"""JSONResponse -- Extends HTTPResponse to handle JSON format response. | ||
This response can be used in any view that should return a json stream of | ||
data. | ||
Usage: | ||
def a_iew(request): | ||
content = {'key': 'value'} | ||
return JSONResponse(content, mimetype=response_mimetype(request)) | ||
""" | ||
def __init__(self, obj='', json_opts=None, mimetype=MIMEJSON, *args, **kwargs): | ||
json_opts = json_opts if isinstance(json_opts, dict) else {} | ||
content = simplejson.dumps(obj, **json_opts) | ||
super(JSONResponse, self).__init__(content, mimetype, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# encoding: utf-8 | ||
import mimetypes | ||
import re | ||
from django.core.urlresolvers import reverse | ||
|
||
|
||
|
||
def order_name(name): | ||
"""order_name -- Limit a text to 20 chars length, if necessary strips the | ||
middle of the text and substitute it for an ellipsis. | ||
name -- text to be limited. | ||
""" | ||
name = re.sub(r'^.*/', '', name) | ||
if len(name) <= 20: | ||
return name | ||
return name[:10] + "..." + name[-7:] | ||
|
||
|
||
def serialize(instance, file_attr='file'): | ||
"""serialize -- Serialize a Picture instance into a dict. | ||
instance -- Picture instance | ||
file_attr -- attribute name that contains the FileField or ImageField | ||
""" | ||
obj = getattr(instance, file_attr) | ||
return { | ||
'url': obj.url, | ||
'name': order_name(obj.name), | ||
'type': mimetypes.guess_type(obj.path)[0] or 'application/rtf', | ||
'thumbnailUrl': obj.url, | ||
'size': obj.size, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule webodf
deleted from
017bfb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters