fixing problems with new post
This commit is contained in:
parent
3fff224924
commit
16d7016e29
10 changed files with 851 additions and 807 deletions
|
@ -171,13 +171,12 @@ class Controller(QtCore.QObject):
|
|||
pass
|
||||
|
||||
@QtCore.pyqtSlot(str)
|
||||
def openNewMessageWidow(self, is_private=False, string=""):
|
||||
string = str(string)
|
||||
self.openNewMessageWindowInReplyTostatusIdwithStringIsPrivate(None, None, string, is_private)
|
||||
def openNewMessageWidow(self):
|
||||
self.openNewMessageWindowInReplyTostatus(None)
|
||||
|
||||
@QtCore.pyqtSlot(str, str, str, bool)
|
||||
def openNewMessageWindowInReplyTostatusIdwithStringIsPrivate(self, entity, status_id, string, is_private):
|
||||
new_message_window = Windows.NewPost(self.app, string, "[]", is_private)
|
||||
def openNewMessageWindowInReplyTostatus(self, status_string):
|
||||
new_message_window = Windows.NewPost(self.app)
|
||||
new_message_window.show()
|
||||
new_message_window.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||
self.app.new_message_windows.append(new_message_window)
|
||||
|
|
|
@ -329,11 +329,12 @@ class FindEntity(QtGui.QDialog):
|
|||
|
||||
|
||||
class NewPost(Helper.RestorableWindow):
|
||||
def __init__(self, app, string, mentions, is_private):
|
||||
def __init__(self, app, string=None, mentions="[]", is_private=False, post_id=None):
|
||||
self.app = app
|
||||
self.string = string
|
||||
self.mentions = mentions
|
||||
self.is_private = is_private
|
||||
self.post_id = post_id
|
||||
|
||||
Helper.RestorableWindow.__init__(self, "newpost", self.app)
|
||||
self.activateWindow()
|
||||
|
@ -414,7 +415,11 @@ class NewPost(Helper.RestorableWindow):
|
|||
if self.is_private:
|
||||
is_private = "true"
|
||||
|
||||
callback = "function() { bungloo.newpost.setString('%s'); bungloo.newpost.setIsPrivate(%s); bungloo.newpost.setMentions(%s);}" % (self.string, is_private, self.mentions)
|
||||
post_id = ""
|
||||
if self.post_id:
|
||||
post_id = self.post_id
|
||||
|
||||
callback = "function() { bungloo.newpost.setString('%s'); bungloo.newpost.setIsPrivate(%s); bungloo.newpost.setMentions(%s); bungloo.newPostAction.setPostId(%s); }" % (self.string, is_private, self.mentions, post_id)
|
||||
|
||||
script = "function HostAppGo() { start('newpost', " + callback + "); }"
|
||||
self.webView.page().mainFrame().evaluateJavaScript(script)
|
||||
|
@ -425,6 +430,11 @@ class NewPost(Helper.RestorableWindow):
|
|||
self.webView.page().mainFrame().evaluateJavaScript(script)
|
||||
|
||||
def sendMessage(self):
|
||||
script = "bungloo.newpost.send()"
|
||||
self.webView.page().mainFrame().evaluateJavaScript(script)
|
||||
self.close()
|
||||
|
||||
"""
|
||||
count = len(self.textInput.toPlainText())
|
||||
if count > 0 and count <= 256:
|
||||
message = Helper.PostModel()
|
||||
|
@ -438,6 +448,7 @@ class NewPost(Helper.RestorableWindow):
|
|||
self.close()
|
||||
else:
|
||||
QtGui.qApp.beep()
|
||||
"""
|
||||
|
||||
def openFileDialog(self):
|
||||
fileNamePath = QtGui.QFileDialog.getOpenFileName(self, "Choose a image", "", "Images (*.png *.gif *.jpg *.jpeg)")
|
||||
|
|
|
@ -29,7 +29,7 @@ function() {
|
|||
this.counter = $("<span>256</span>");
|
||||
var buttons = $(
|
||||
"<p>" +
|
||||
"<button id='images'><img src='images/images.png'></button>" +
|
||||
//"<button id='images'><img src='images/images.png'></button>" +
|
||||
"<button id='private'><img src='images/public.png'></button>" +
|
||||
"<button id='send'><img src='images/send.png'></button>" +
|
||||
"</p>");
|
||||
|
@ -50,6 +50,12 @@ function() {
|
|||
this.textarea.focus()
|
||||
}
|
||||
|
||||
NewPost.prototype.setStatus = function(status_string) {
|
||||
this.status = JSON.parse(status_string);
|
||||
debug(this.status)
|
||||
// FIXME set string, private, mentions, etc.
|
||||
};
|
||||
|
||||
NewPost.prototype.setString = function(string) {
|
||||
this.textarea.val(string);
|
||||
}
|
||||
|
@ -190,8 +196,133 @@ function() {
|
|||
NewPost.prototype.send = function() {
|
||||
debug("Send not implemented yet");
|
||||
$("textarea").focus();
|
||||
var count = 256 - this.textarea.val().length + (this.mentions.length * 6);
|
||||
if(count >= 0) {
|
||||
this.sentNewMessage();
|
||||
} else {
|
||||
debug("BEEP");
|
||||
}
|
||||
}
|
||||
|
||||
NewPost.prototype.sendNewMessage = function() {
|
||||
|
||||
var content = this.textarea.val();
|
||||
|
||||
var url = URI(HostApp.serverUrl("new_post"));
|
||||
|
||||
var type = in_reply_to_status_id.length == 0 ? "https://tent.io/types/status/v0#" : "https://tent.io/types/status/v0#reply";
|
||||
|
||||
var data = {
|
||||
"type": type,
|
||||
"published_at": parseInt(new Date().getTime(), 10),
|
||||
"permissions": {
|
||||
"public": !is_private
|
||||
},
|
||||
"content": {
|
||||
"text": content,
|
||||
},
|
||||
};
|
||||
|
||||
if (location) {
|
||||
//data["content"]["location"] = { "type": "Point", "coordinates": location }
|
||||
}
|
||||
|
||||
var mentions = this.parseMentions(content, in_reply_to_status_id, in_reply_to_entity);
|
||||
|
||||
if (mentions.length > 0) {
|
||||
data["mentions"] = mentions;
|
||||
if (is_private) {
|
||||
var entities = {};
|
||||
for (var i = 0; i < mentions.length; i++) {
|
||||
var entity = mentions[i]["entity"]
|
||||
entities[entity] = true;
|
||||
};
|
||||
|
||||
data["permissions"]["entities"] = entities;
|
||||
}
|
||||
}
|
||||
|
||||
// APICalls.http_call(url.toString(), http_method, callback, JSON.stringify(data));
|
||||
APICalls.post(url.toString(), JSON.stringify(data), {
|
||||
content_type: data.type,
|
||||
callback: callback
|
||||
});
|
||||
}
|
||||
/*
|
||||
NewPost.prototype.sendNewMessageWithImage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri, is_private, callback) {
|
||||
|
||||
var url = URI(APICalls.mkApiRootPath("/posts"));
|
||||
|
||||
var data = {
|
||||
"type": "https://tent.io/types/post/photo/v0.1.0",
|
||||
"published_at": parseInt(new Date().getTime() / 1000, 10),
|
||||
"permissions": {
|
||||
"public": !is_private
|
||||
},
|
||||
"content": {
|
||||
"caption": content,
|
||||
},
|
||||
};
|
||||
|
||||
if (location) {
|
||||
data["content"]["location"] = { "type": "Point", "coordinates": location }
|
||||
}
|
||||
|
||||
var mentions = this.parseMentions(content, in_reply_to_status_id, in_reply_to_entity);
|
||||
if (mentions.length > 0) {
|
||||
data["mentions"] = mentions;
|
||||
if (is_private) {
|
||||
var entities = {};
|
||||
for (var i = 0; i < mentions.length; i++) {
|
||||
var entity = mentions[i]["entity"]
|
||||
entities[entity] = true;
|
||||
};
|
||||
|
||||
data["permissions"]["entities"] = entities;
|
||||
}
|
||||
}
|
||||
|
||||
var data_string = JSON.stringify(data);
|
||||
|
||||
var boundary = "TentAttachment----------TentAttachment";
|
||||
var post = "--" + boundary + "\r\n";
|
||||
|
||||
post += 'Content-Disposition: form-data; name="post"; filename="post.json"\r\n';
|
||||
post += 'Content-Length: ' + data_string.length + '\r\n';
|
||||
post += 'Content-Type: application/vnd.tent.v0+json\r\n';
|
||||
post += 'Content-Transfer-Encoding: binary\r\n\r\n';
|
||||
post += data_string;
|
||||
|
||||
post += "\r\n--" + boundary + "\r\n";
|
||||
|
||||
var blob_string = image_data_uri.split(',')[1];
|
||||
var mime_type = image_data_uri.split(',')[0].split(':')[1].split(';')[0];
|
||||
var ext = "png";
|
||||
if (mime_type == "image/jpeg") {
|
||||
ext = "jpeg";
|
||||
} else if (mime_type == "image/gif") {
|
||||
ext = "gif";
|
||||
}
|
||||
|
||||
|
||||
post += 'Content-Disposition: form-data; name="photos[0]"; filename="photo.' + ext + '"\r\n';
|
||||
post += 'Content-Length: ' + blob_string.length + "\r\n";
|
||||
post += 'Content-Type: ' + mime_type + "\r\n";
|
||||
post += 'Content-Transfer-Encoding: base64\r\n\r\n';
|
||||
post += blob_string;
|
||||
post += "\r\n--" + boundary + "--\r\n";
|
||||
|
||||
var newCallback = function(resp) {
|
||||
if (resp.status == 403) {
|
||||
var err = JSON.parse(resp.responseText);
|
||||
HostApp.alertTitleWithMessage(resp.statusText, err.error);
|
||||
}
|
||||
callback(resp);
|
||||
}
|
||||
|
||||
APICalls.postMultipart(url.toString(), newCallback, post, boundary);
|
||||
}
|
||||
*/
|
||||
|
||||
return NewPost;
|
||||
})
|
|
@ -96,7 +96,6 @@ function(HostApp, APICalls, Hmac) {
|
|||
those.entity = those.profile.content.entity;
|
||||
HostApp.setStringForKey(those.entity, "entity")
|
||||
HostApp.setServerUrls(those.profile.content.servers[0].urls);
|
||||
|
||||
APICalls.post(HostApp.serverUrl("new_post"), JSON.stringify(those.app_info), {
|
||||
content_type: "https://tent.io/types/app/v0#",
|
||||
no_auth: true,
|
||||
|
@ -112,7 +111,7 @@ function(HostApp, APICalls, Hmac) {
|
|||
callback: function(resp) {
|
||||
var data = JSON.parse(resp.responseText);
|
||||
those.authRequest(data.post, app_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}});
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -46,9 +46,13 @@ function(Core, APICalls, HostApp, URI) {
|
|||
}
|
||||
|
||||
|
||||
Timeline.prototype.newStatus = function(statuses, append) {
|
||||
Timeline.prototype.newStatus = function(_statuses, append) {
|
||||
|
||||
statuses = statuses.data;
|
||||
for (var entity in _statuses.profiles) {
|
||||
bungloo.cache.profiles[entity] = _statuses.profiles[entity];
|
||||
}
|
||||
|
||||
statuses = _statuses.posts;
|
||||
if(statuses != null && statuses.length > 0) {
|
||||
|
||||
this.before.loading = false;
|
||||
|
@ -63,7 +67,7 @@ function(Core, APICalls, HostApp, URI) {
|
|||
this.since_id_entity = status.entity;
|
||||
}
|
||||
|
||||
if (status.type == "https://tent.io/types/status/v0#" || status.type == "https://tent.io/types/post/photo/v0.1.0") {
|
||||
if (status.type == "https://tent.io/types/status/v0#") {
|
||||
|
||||
var new_node = this.getStatusDOMElement(status);
|
||||
|
||||
|
@ -110,9 +114,11 @@ function(Core, APICalls, HostApp, URI) {
|
|||
"https://tent.io/types/delete/v0#",
|
||||
//"https://tent.io/types/post/photo/v0.1.0"
|
||||
];
|
||||
//url.addSearch("types", post_types.join(","));
|
||||
url.addSearch("types", post_types.join(","));
|
||||
//url.addSearch("sort_by", "published_at");
|
||||
url.addSearch("limit", this.posts_limit);
|
||||
url.addSearch("max_refs", 20);
|
||||
url.addSearch("profiles", "entity");
|
||||
|
||||
if(this.since_id && !append) {
|
||||
url.addSearch("since_id", this.since_id);
|
||||
|
@ -144,7 +150,7 @@ function(Core, APICalls, HostApp, URI) {
|
|||
|
||||
if (!this.reload_blocked) {
|
||||
this.reload_blocked = true;
|
||||
// APICalls.http_call(url.toString(), http_method, callback, data); // FIXME: error callback
|
||||
|
||||
APICalls.get(url.toString(), { callback: callback });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,10 +36,10 @@ function(jQuery, HostApp, Hmac, Cache) {
|
|||
console.error("No content type for " + options.url);
|
||||
return;
|
||||
} else {
|
||||
if(options.content_type != "application/json") {
|
||||
content_type = "application/vnd.tent.post.v0+json; type=\"" + options.content_type + "\"";
|
||||
if(options.content_type == "application/json") {
|
||||
content_type = "application/json";
|
||||
} else {
|
||||
content_type = options.content_type;
|
||||
content_type = "application/vnd.tent.post.v0+json; type=\"" + options.content_type + "\"";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ function(jQuery, HostApp, Hmac, Cache) {
|
|||
} else if(!options.no_auth) {
|
||||
console.error("No user_access_token yet - " + options.url);
|
||||
}
|
||||
xhr.setRequestHeader("Cache-Control", "no-cache");
|
||||
},
|
||||
url: options.url,
|
||||
contentType: content_type,
|
||||
|
@ -72,13 +73,26 @@ function(jQuery, HostApp, Hmac, Cache) {
|
|||
data: options.data,
|
||||
processData: false,
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
console.error("HTTP CALL (" + xhr.status + ")" + xhr.statusText + " " + options.http_method + " (" + options.url + "): '" + xhr.responseText + "'");
|
||||
console.error("HTTP CALL (" + xhr.status + ") " + xhr.statusText + " " + options.http_method + " URL(" + options.url + "): '" + xhr.responseText + "'");
|
||||
}
|
||||
};
|
||||
|
||||
jQuery.ajax(settings);
|
||||
}
|
||||
|
||||
APICalls.head = function(url, options) {
|
||||
var settings = {
|
||||
url: url,
|
||||
http_method: "HEAD",
|
||||
};
|
||||
|
||||
for (var key in options) {
|
||||
settings[key] = options[key];
|
||||
}
|
||||
|
||||
APICalls.http_call(settings);
|
||||
}
|
||||
|
||||
APICalls.get = function(url, options) {
|
||||
var settings = {
|
||||
url: url,
|
||||
|
@ -225,6 +239,23 @@ function(jQuery, HostApp, Hmac, Cache) {
|
|||
return APICalls.parseHeaderForLink(header_string, regexp);
|
||||
}
|
||||
|
||||
APICalls.parseHeader = function(header_string) {
|
||||
var header_strings = header_string.split(/\n/);
|
||||
var headers = {};
|
||||
for (var i = 0; i < header_strings.length; i++) {
|
||||
var hs = header_strings[i].split(/:(.+)?/);
|
||||
headers[hs[0]] = hs[1];
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
APICalls.getCount = function(resp) {
|
||||
var count = 0;
|
||||
var headers = APICalls.parseHeader(resp.getAllResponseHeaders());
|
||||
if(headers["Count"]) count = parseInt(headers["Count"], 10);
|
||||
return count;
|
||||
}
|
||||
|
||||
APICalls.parseHeaderForLink = function(header_string, match) {
|
||||
var headers = header_string.split(/\n/);
|
||||
var links = [];
|
||||
|
|
|
@ -69,6 +69,7 @@ function(jQuery, APICalls, URI, HostApp, Cache) {
|
|||
image.className = "image";
|
||||
image.src = "img/default-avatar.png";
|
||||
image.onmousedown = function(e) { e.preventDefault(); };
|
||||
image.onerror = function() { this.src = 'img/default-avatar.png' };
|
||||
item.appendChild(image);
|
||||
|
||||
var image_username = a.cloneNode();
|
||||
|
@ -224,7 +225,7 @@ function(jQuery, APICalls, URI, HostApp, Cache) {
|
|||
mentions.push(mention);
|
||||
}
|
||||
|
||||
_this.replyTo(status.entity, status.id, mentions, (status && status.permissions && !status.permissions.public));
|
||||
_this.replyTo(status);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -234,7 +235,7 @@ function(jQuery, APICalls, URI, HostApp, Cache) {
|
|||
return false;
|
||||
}
|
||||
|
||||
template.username.innerText = status.entity;
|
||||
if(bungloo.cache.profiles[status.entity].name) template.username.innerText = bungloo.cache.profiles[status.entity].name;
|
||||
template.username.href = status.entity;
|
||||
template.username.title = status.entity;
|
||||
template.username.onclick = function() {
|
||||
|
@ -242,47 +243,12 @@ function(jQuery, APICalls, URI, HostApp, Cache) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if(bungloo.cache.profiles[status.entity].avatar_digest) {
|
||||
template.image.src = HostApp.serverUrl("attachment").replace(/\{entity\}/, encodeURIComponent(status.entity)).replace(/\{digest\}/, bungloo.cache.profiles[status.entity].avatar_digest);
|
||||
}
|
||||
|
||||
template.image.onclick = template.username.onclick;
|
||||
|
||||
var profile_callback = function(p) {
|
||||
|
||||
var basic = p["https://tent.io/types/info/basic/v0.1.0"];
|
||||
|
||||
if (p && basic) {
|
||||
if(basic.name) {
|
||||
template.username.title = template.username.innerText;
|
||||
template.username.innerText = basic.name;
|
||||
}
|
||||
if(basic.avatar_url) {
|
||||
template.image.onerror = function() { template.image.src = 'img/default-avatar.png' };
|
||||
template.image.src = basic.avatar_url;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var p = this.cache.profiles.getItem(status.entity);
|
||||
|
||||
if (p && p != "null") {
|
||||
|
||||
profile_callback(p);
|
||||
|
||||
} else {
|
||||
|
||||
APICalls.findProfileURL(status.entity, function(profile_url) {
|
||||
|
||||
if (profile_url) {
|
||||
APICalls.http_call(profile_url, "GET", function(resp) {
|
||||
var p = JSON.parse(resp.responseText);
|
||||
if (p && p != "null") {
|
||||
_this.cache.profiles.setItem(status.entity, p);
|
||||
profile_callback(p);
|
||||
}
|
||||
|
||||
}, null, false); // do not send auth-headers
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (status && status.permissions && !status.permissions.public) {
|
||||
template.is_private.style.display = '';
|
||||
|
@ -389,9 +355,11 @@ function(jQuery, APICalls, URI, HostApp, Cache) {
|
|||
template.source.innerHTML = status.__repost.app.name;
|
||||
template.source.title = status.__repost.app.url;
|
||||
} else {
|
||||
template.source.href = status.app.url;
|
||||
template.source.innerHTML = status.app.name;
|
||||
template.source.title = status.app.url;
|
||||
if(status.app) {
|
||||
template.source.href = status.app.url;
|
||||
template.source.innerHTML = status.app.name;
|
||||
template.source.title = status.app.url;
|
||||
}
|
||||
}
|
||||
|
||||
return template.item;
|
||||
|
@ -498,60 +466,6 @@ function(jQuery, APICalls, URI, HostApp, Cache) {
|
|||
}
|
||||
}
|
||||
|
||||
Core.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri, is_private, callback) {
|
||||
|
||||
if (image_data_uri) {
|
||||
|
||||
this.sendNewMessageWithImage(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri, is_private, callback);
|
||||
|
||||
} else {
|
||||
|
||||
var url = URI(HostApp.serverUrl("new_post"));
|
||||
|
||||
var type = in_reply_to_status_id.length == 0 ? "https://tent.io/types/status/v0#" : "https://tent.io/types/status/v0#reply";
|
||||
debug(typeof in_reply_to_status_id)
|
||||
debug(in_reply_to_status_id.length)
|
||||
debug(type)
|
||||
|
||||
var data = {
|
||||
"type": type,
|
||||
"published_at": parseInt(new Date().getTime(), 10),
|
||||
"permissions": {
|
||||
"public": !is_private
|
||||
},
|
||||
"content": {
|
||||
"text": content,
|
||||
},
|
||||
};
|
||||
|
||||
if (location) {
|
||||
//data["content"]["location"] = { "type": "Point", "coordinates": location }
|
||||
}
|
||||
|
||||
var mentions = this.parseMentions(content, in_reply_to_status_id, in_reply_to_entity);
|
||||
|
||||
if (mentions.length > 0) {
|
||||
data["mentions"] = mentions;
|
||||
if (is_private) {
|
||||
var entities = {};
|
||||
for (var i = 0; i < mentions.length; i++) {
|
||||
var entity = mentions[i]["entity"]
|
||||
entities[entity] = true;
|
||||
};
|
||||
|
||||
data["permissions"]["entities"] = entities;
|
||||
}
|
||||
}
|
||||
|
||||
// APICalls.http_call(url.toString(), http_method, callback, JSON.stringify(data));
|
||||
APICalls.post(url.toString(), JSON.stringify(data), {
|
||||
content_type: data.type,
|
||||
callback: callback
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Core.prototype.repost = function(id, entity, callback) {
|
||||
var url = URI(APICalls.mkApiRootPath("/posts"));
|
||||
|
||||
|
@ -582,80 +496,6 @@ function(jQuery, APICalls, URI, HostApp, Cache) {
|
|||
APICalls.http_call(url.toString(), "POST", new_callback, JSON.stringify(data));
|
||||
}
|
||||
|
||||
Core.prototype.sendNewMessageWithImage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri, is_private, callback) {
|
||||
|
||||
var url = URI(APICalls.mkApiRootPath("/posts"));
|
||||
|
||||
var data = {
|
||||
"type": "https://tent.io/types/post/photo/v0.1.0",
|
||||
"published_at": parseInt(new Date().getTime() / 1000, 10),
|
||||
"permissions": {
|
||||
"public": !is_private
|
||||
},
|
||||
"content": {
|
||||
"caption": content,
|
||||
},
|
||||
};
|
||||
|
||||
if (location) {
|
||||
data["content"]["location"] = { "type": "Point", "coordinates": location }
|
||||
}
|
||||
|
||||
var mentions = this.parseMentions(content, in_reply_to_status_id, in_reply_to_entity);
|
||||
if (mentions.length > 0) {
|
||||
data["mentions"] = mentions;
|
||||
if (is_private) {
|
||||
var entities = {};
|
||||
for (var i = 0; i < mentions.length; i++) {
|
||||
var entity = mentions[i]["entity"]
|
||||
entities[entity] = true;
|
||||
};
|
||||
|
||||
data["permissions"]["entities"] = entities;
|
||||
}
|
||||
}
|
||||
|
||||
var data_string = JSON.stringify(data);
|
||||
|
||||
var boundary = "TentAttachment----------TentAttachment";
|
||||
var post = "--" + boundary + "\r\n";
|
||||
|
||||
post += 'Content-Disposition: form-data; name="post"; filename="post.json"\r\n';
|
||||
post += 'Content-Length: ' + data_string.length + '\r\n';
|
||||
post += 'Content-Type: application/vnd.tent.v0+json\r\n';
|
||||
post += 'Content-Transfer-Encoding: binary\r\n\r\n';
|
||||
post += data_string;
|
||||
|
||||
post += "\r\n--" + boundary + "\r\n";
|
||||
|
||||
var blob_string = image_data_uri.split(',')[1];
|
||||
var mime_type = image_data_uri.split(',')[0].split(':')[1].split(';')[0];
|
||||
var ext = "png";
|
||||
if (mime_type == "image/jpeg") {
|
||||
ext = "jpeg";
|
||||
} else if (mime_type == "image/gif") {
|
||||
ext = "gif";
|
||||
}
|
||||
|
||||
|
||||
post += 'Content-Disposition: form-data; name="photos[0]"; filename="photo.' + ext + '"\r\n';
|
||||
post += 'Content-Length: ' + blob_string.length + "\r\n";
|
||||
post += 'Content-Type: ' + mime_type + "\r\n";
|
||||
post += 'Content-Transfer-Encoding: base64\r\n\r\n';
|
||||
post += blob_string;
|
||||
post += "\r\n--" + boundary + "--\r\n";
|
||||
|
||||
var newCallback = function(resp) {
|
||||
if (resp.status == 403) {
|
||||
var err = JSON.parse(resp.responseText);
|
||||
HostApp.alertTitleWithMessage(resp.statusText, err.error);
|
||||
}
|
||||
callback(resp);
|
||||
}
|
||||
|
||||
APICalls.postMultipart(url.toString(), newCallback, post, boundary);
|
||||
}
|
||||
|
||||
Core.prototype.remove = function(id, callback, type) {
|
||||
type = type || "post";
|
||||
if (confirm("Really delete this " + type + "?")) {
|
||||
|
@ -920,19 +760,8 @@ function(jQuery, APICalls, URI, HostApp, Cache) {
|
|||
}
|
||||
}
|
||||
|
||||
Core.prototype.replyTo = function(entity, status_id, mentions, is_private) {
|
||||
|
||||
var string = "^" + entity.replace("https://", "") + " ";
|
||||
|
||||
var ms = "";
|
||||
for (var i = 0; i < mentions.length; i++) {
|
||||
var e = mentions[i].entity.replace("https://", "");
|
||||
if(string.indexOf(e) == -1) ms += " ^" + e;
|
||||
}
|
||||
|
||||
if(ms.length > 0) string += "\n\n/cc" + ms;
|
||||
|
||||
HostApp.openNewMessageWidow(entity, status_id, string, is_private);
|
||||
Core.prototype.replyTo = function(status) {
|
||||
HostApp.openNewMessageWidow(status);
|
||||
}
|
||||
|
||||
Core.prototype.postDeleted = function(post_id, entity) {
|
||||
|
|
|
@ -85,13 +85,12 @@ define(function() {
|
|||
}
|
||||
}
|
||||
|
||||
HostApp.openNewMessageWidow = function(entity, status_id, string, is_private) {
|
||||
HostApp.openNewMessageWidow = function(status) {
|
||||
|
||||
if (OS_TYPE == "mac") {
|
||||
controller.openNewMessageWindowInReplyTo_statusId_withString_isPrivate_(entity, status_id, string, is_private);
|
||||
controller.openNewMessageWindowInReplyToStatus(JSON.stringify(status));
|
||||
} else {
|
||||
is_private = is_private == true
|
||||
controller.openNewMessageWindowInReplyTostatusIdwithStringIsPrivate(entity, status_id, string, is_private);
|
||||
controller.openNewMessageWindowInReplyTostatus(JSON.stringify(status));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ var bungloo = {
|
|||
entityProfile: null,
|
||||
conversation: null,
|
||||
search: null,
|
||||
cache: {},
|
||||
cache: { profiles: {}},
|
||||
newpost: null
|
||||
};
|
||||
|
||||
|
|
Reference in a new issue