removed add image and implemented reposts

This commit is contained in:
Jeena Paradies 2012-11-25 22:19:34 +01:00
parent 5ca4fd7985
commit 3a81618436
6 changed files with 164 additions and 131 deletions

View file

@ -99,7 +99,6 @@
<string key="NSFrame">{{257, 2}, {38, 17}}</string> <string key="NSFrame">{{257, 2}, {38, 17}}</string>
<reference key="NSSuperview" ref="568628114"/> <reference key="NSSuperview" ref="568628114"/>
<reference key="NSWindow"/> <reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="NSEnabled">YES</bool> <bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="894039108"> <object class="NSTextFieldCell" key="NSCell" id="894039108">
<int key="NSCellFlags">68157504</int> <int key="NSCellFlags">68157504</int>
@ -184,23 +183,15 @@
<string key="NSTitle">Add current location</string> <string key="NSTitle">Add current location</string>
<string key="NSKeyEquiv"/> <string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int> <int key="NSMnemonicLoc">2147483647</int>
<object class="NSCustomResource" key="NSOnImage" id="400068421"> <object class="NSCustomResource" key="NSOnImage">
<string key="NSClassName">NSImage</string> <string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuCheckmark</string> <string key="NSResourceName">NSMenuCheckmark</string>
</object> </object>
<object class="NSCustomResource" key="NSMixedImage" id="196417858"> <object class="NSCustomResource" key="NSMixedImage">
<string key="NSClassName">NSImage</string> <string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSMenuMixedState</string> <string key="NSResourceName">NSMenuMixedState</string>
</object> </object>
</object> </object>
<object class="NSMenuItem" id="502380341">
<reference key="NSMenu" ref="723763594"/>
<string key="NSTitle">Add photo</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="400068421"/>
<reference key="NSMixedImage" ref="196417858"/>
</object>
</object> </object>
</object> </object>
</object> </object>
@ -271,14 +262,6 @@
</object> </object>
<int key="connectionID">100054</int> <int key="connectionID">100054</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">addImage:</string>
<reference key="source" ref="512844837"/>
<reference key="destination" ref="502380341"/>
</object>
<int key="connectionID">100056</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection"> <object class="IBOutletConnection" key="connection">
<string key="label">delegate</string> <string key="label">delegate</string>
@ -394,7 +377,6 @@
<object class="NSMutableArray" key="children"> <object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="921309347"/> <reference ref="921309347"/>
<reference ref="502380341"/>
</object> </object>
<reference key="parent" ref="0"/> <reference key="parent" ref="0"/>
</object> </object>
@ -403,11 +385,6 @@
<reference key="object" ref="921309347"/> <reference key="object" ref="921309347"/>
<reference key="parent" ref="723763594"/> <reference key="parent" ref="723763594"/>
</object> </object>
<object class="IBObjectRecord">
<int key="objectID">100055</int>
<reference key="object" ref="502380341"/>
<reference key="parent" ref="723763594"/>
</object>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="flattenedProperties"> <object class="NSMutableDictionary" key="flattenedProperties">
@ -425,7 +402,6 @@
<string>100040.IBPluginDependency</string> <string>100040.IBPluginDependency</string>
<string>100041.IBPluginDependency</string> <string>100041.IBPluginDependency</string>
<string>100043.IBPluginDependency</string> <string>100043.IBPluginDependency</string>
<string>100055.IBPluginDependency</string>
<string>5.IBPluginDependency</string> <string>5.IBPluginDependency</string>
<string>5.IBWindowTemplateEditedContentRect</string> <string>5.IBWindowTemplateEditedContentRect</string>
<string>6.IBPluginDependency</string> <string>6.IBPluginDependency</string>
@ -444,7 +420,6 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{127, 736}, {299, 113}}</string> <string>{{127, 736}, {299, 113}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object> </object>

View file

@ -42,7 +42,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.4.0</string> <string>0.4.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>
@ -57,7 +57,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>0.4.0</string> <string>0.4.2</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
<string>public.app-category.lifestyle</string> <string>public.app-category.lifestyle</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>

View file

@ -14,6 +14,13 @@
</head> </head>
<body> <body>
<h1>Tentia 0.4.2</h1>
<p>Removed Photo post type because the Tent protocol in version 0.1.0 does not quite support it yet</p>
<p>Implemented showing and making reposts</p>
<hr />
<h1>Tentia 0.4.1</h1> <h1>Tentia 0.4.1</h1>
<p>Fixed problem where you couldn't log in again after you logged out.</p> <p>Fixed problem where you couldn't log in again after you logged out.</p>

View file

@ -22,7 +22,7 @@ ol {
li, .error { li, .error {
clear: both; clear: both;
padding: 8px 16px 8px 8px; padding: 8px;
background: #eee; background: #eee;
border-top: 1px solid #fefefe; border-top: 1px solid #fefefe;
border-bottom: 1px solid #c9c9c9; border-bottom: 1px solid #c9c9c9;
@ -71,13 +71,6 @@ h1 {
font-weight: bold; font-weight: bold;
margin: 0; margin: 0;
padding: 0; padding: 0;
margin-right: -8px;
overflow: hidden;
white-space: nowrap;
}
h1.favorited:after {
content: "*";
} }
h1 img { h1 img {
@ -87,13 +80,10 @@ h1 img {
p { p {
margin: 0; margin: 0;
padding: 0; padding: 0;
padding-left: 3px; word-wrap: break-word;
margin-left: -3px;
padding-bottom: 2px;
margin-bottom: -2px;
} }
.image, .twitpic { .image {
float: left; float: left;
margin-left: 2px; margin-left: 2px;
width: 48px; width: 48px;
@ -108,18 +98,6 @@ p {
height: 48px; height: 48px;
} }
.twitpic {
float: right;
width: 75px;
height: 75px;
}
.twitpic a {
display: block;
width: 75px;
height: 75px;
}
.images:empty { .images:empty {
display: none; display: none;
} }
@ -134,39 +112,18 @@ p {
margin-right: 5px; margin-right: 5px;
} }
.direct-message { .images img.photo {
color: #555; max-width: 100%;
} max-height: auto;
margin-right: 0;
.retweeted span { border-radius: 3px;
height: 11px; box-shadow: 0 0 1px black;
width: 15px;
background: url(../img/sprite-icons.png) no-repeat -192px -1px;
display: inline-block;
margin: 0 3px 0 4px;
} }
.data { .data {
margin-left: 62px; margin-left: 62px;
} }
.message {
overflow: hidden;
}
.reply, .direct-message {
display: none;
font-weight: normal;
}
.reply a {
font-weight: bold;
}
li:hover .reply, li:hover .direct-message {
display: inline;
}
li .name:first-child { li .name:first-child {
margin-left: -3px; margin-left: -3px;
} }
@ -225,28 +182,30 @@ li:first-child:hover .date {
border-top: 0; border-top: 0;
} }
.reply_to, .retweet, .remove { aside {
width: 15px;
float: right;
margin: 0 3px 3px 3px;
visibility: hidden;
}
.reply_to, .repost, .remove {
width: 15px; width: 15px;
height: 12px; height: 12px;
position: absolute;
top: 5px;
right: 10px;
background: url(../img/sprite-icons.png) no-repeat -16px 0; background: url(../img/sprite-icons.png) no-repeat -16px 0;
display: none; display: inline-block;
} }
li:hover .reply_to, li:hover .retweet, li:hover .remove { li:hover aside {
display: block; visibility: visible;
} }
.retweet { .repost {
top: 18px;
background-position: -192px 0; background-position: -192px 0;
} }
.remove { .remove {
background-position: -128px 0; background-position: -128px 0;
top: 20px;
} }
li.mentioned { li.mentioned {
@ -257,9 +216,11 @@ li.mentioned {
border-right: 0; border-right: 0;
} }
.photo { .reposted_by:before {
margin-top: 10px; content: " ";
max-width: 100%; display: inline-block;
border-radius: 3px; background: url(../img/sprite-icons.png) no-repeat -192px 0;
box-shadow: 0 0 1px black; height: 12px;
} width: 15px;
margin-right: 5px;
}

View file

@ -68,7 +68,7 @@ function(Core, Paths, HostApp, URI) {
} }
} else if (status.type == "https://tent.io/types/post/repost/v0.1.0") { } else if (status.type == "https://tent.io/types/post/repost/v0.1.0") {
//debug(status) this.getRepost(status, this.body.firstChild);
} }
} }
@ -125,6 +125,30 @@ function(Core, Paths, HostApp, URI) {
} }
} }
Timeline.prototype.getRepost = function(repost, before_node) {
var _this = this;
var callback = function(resp) {
var status = JSON.parse(resp.responseText);
status.__repost = repost;
var li = _this.getStatusDOMElement(status);
before_node.parentNode.insertBefore(li, before_node);
}
Paths.findProfileURL(repost.content.entity, function(profile_url) {
if (profile_url) {
Paths.getURL(profile_url, "GET", function(resp) {
var profile = JSON.parse(resp.responseText);
var server = profile["https://tent.io/types/info/core/v0.1.0"].servers[0];
Paths.getURL(URI(server + "/posts/" + repost.content.id).toString(), "GET", callback, null, false);
}, null, false); // do not send auth-headers
}
})
}
Timeline.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri) { Timeline.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri) {
var _this = this; var _this = this;
var callback = function(data) { _this.getNewData(); } var callback = function(data) { _this.getNewData(); }
@ -137,6 +161,14 @@ function(Core, Paths, HostApp, URI) {
Core.prototype.remove.call(this, id, callback); Core.prototype.remove.call(this, id, callback);
} }
Timeline.prototype.repost = function(id, entity, callback) {
var _this = this;
if (!callback) {
callback = function(data) { _this.getNewData(); }
}
Core.prototype.repost.call(this, id, entity, callback);
}
return Timeline; return Timeline;
}); });

View file

@ -24,25 +24,27 @@ function(jQuery, Paths, URI, HostApp, Followings) {
var a = document.createElement("a"); var a = document.createElement("a");
var item = document.createElement("li"); var item = document.createElement("li");
var aside = document.createElement("aside");
item.appendChild(aside);
var reply_to = a.cloneNode(); var reply_to = a.cloneNode();
reply_to.className = "reply_to" reply_to.className = "reply_to"
reply_to.innerText = " "; reply_to.innerText = " ";
reply_to.href = "#"; reply_to.href = "#";
item.appendChild(reply_to); aside.appendChild(reply_to);
var retweet = a.cloneNode(); var repost = a.cloneNode();
retweet.className = "retweet"; repost.className = "repost";
retweet.innerText = " "; repost.innerText = " ";
retweet.href = "#"; repost.href = "#";
// item.appendChild(retweet); // FIXME aside.appendChild(repost);
var remove = a.cloneNode(); var remove = a.cloneNode();
remove.className = "remove"; remove.className = "remove";
remove.innerText = " "; remove.innerText = " ";
remove.href = "#"; remove.href = "#";
item.appendChild(remove); aside.appendChild(remove);
var image = document.createElement("img"); var image = document.createElement("img");
image.className = "image"; image.className = "image";
@ -63,10 +65,6 @@ function(jQuery, Paths, URI, HostApp, Followings) {
var username = a.cloneNode(); var username = a.cloneNode();
head.appendChild(username); head.appendChild(username);
var in_reply = document.createElement("span");
in_reply.className = "reply";
head.appendChild(in_reply);
var space = document.createTextNode(" "); var space = document.createTextNode(" ");
head.appendChild(space); head.appendChild(space);
@ -89,12 +87,14 @@ function(jQuery, Paths, URI, HostApp, Followings) {
pin.src = "img/pin.png"; pin.src = "img/pin.png";
pin.alt = "Map link"; pin.alt = "Map link";
geo.appendChild(pin); geo.appendChild(pin);
var in_reply_text = document.createTextNode(" in reply to "); head.appendChild(space.cloneNode());
in_reply.appendChild(in_reply_text)
var reposted_by = a.cloneNode();
var in_reply_a = a.cloneNode(); reposted_by.className = "reposted_by";
in_reply.appendChild(in_reply_a); reposted_by.style.display = "none";
head.appendChild(reposted_by)
var message = document.createElement("p"); var message = document.createElement("p");
message.className = "message"; message.className = "message";
@ -122,10 +122,10 @@ function(jQuery, Paths, URI, HostApp, Followings) {
item: item, item: item,
reply_to: reply_to, reply_to: reply_to,
is_private: is_private, is_private: is_private,
retweet: retweet,
image: image, image: image,
username: username, username: username,
in_reply: in_reply_a, repost: repost,
reposted_by: reposted_by,
message: message, message: message,
ago: ago, ago: ago,
source: source, source: source,
@ -143,13 +143,18 @@ function(jQuery, Paths, URI, HostApp, Followings) {
var template = this.getTemplate(); var template = this.getTemplate();
template.item.id = "post-" + status.id; template.item.id = "post-" + (typeof status.__repost != "undefined" ? status.__repost.id : status.id);
if (HostApp.stringForKey("entity") == status.entity) { if (HostApp.stringForKey("entity") == status.entity) {
template.remove.onclick = function() { template.remove.onclick = function() {
_this.remove(status.id); _this.remove(status.id);
return false; return false;
} }
} else if (status.__repost && HostApp.stringForKey("entity") == status.__repost.entity) {
template.remove.onclick = function() {
_this.remove(status.__repost.id);
return false;
}
} else { } else {
template.remove.style.display = "none"; template.remove.style.display = "none";
} }
@ -168,7 +173,12 @@ function(jQuery, Paths, URI, HostApp, Followings) {
} }
//template.retweet.onclick = function() { template.retweet.className = "hidden"; _this.retweet(status.id_str, template.item); return false; } //template.retweet.onclick = function() { template.retweet.className = "hidden"; _this.retweet(status.id_str, template.item); return false; }
template.repost.onclick = function() {
template.repost.className = "hidden";
_this.repost(status.id, status.entity);
return false;
}
template.username.innerText = status.entity; template.username.innerText = status.entity;
template.username.href = status.entity; // FIXME open profile template.username.href = status.entity; // FIXME open profile
@ -205,12 +215,39 @@ function(jQuery, Paths, URI, HostApp, Followings) {
}); });
} }
if (typeof status.__repost != "undefined") {
template.reposted_by.href = status.__repost.entity;
template.reposted_by.innerText = status.__repost.entity;
template.reposted_by.title = status.__repost.entity;
template.reposted_by.style.display = '';
if (this.followings.followings[status.__repost.entity]) {
var basic = this.followings.followings[status.__repost.entity].profile["https://tent.io/types/info/basic/v0.1.0"];
template.reposted_by.innerText = basic.name;
} else {
Paths.findProfileURL(status.__repost.entity, function(profile_url) {
if (profile_url) {
Paths.getURL(profile_url, "GET", function(resp) {
var p = JSON.parse(resp.responseText);
var profile = p["https://tent.io/types/info/basic/v0.1.0"];
if (profile && profile.name) {
template.reposted_by.innerText = profile.name;
}
}, null, false); // do not send auth-headers
}
});
}
}
if (status && status.permissions && !status.permissions.public) { if (status && status.permissions && !status.permissions.public) {
template.is_private.style.display = ''; template.is_private.style.display = '';
} }
template.in_reply.parentNode.className = "hidden";
var text = ""; var text = "";
if (status.type == "https://tent.io/types/post/photo/v0.1.0") { if (status.type == "https://tent.io/types/post/photo/v0.1.0") {
@ -233,17 +270,19 @@ function(jQuery, Paths, URI, HostApp, Followings) {
if (status.type == "https://tent.io/types/post/photo/v0.1.0") { if (status.type == "https://tent.io/types/post/photo/v0.1.0") {
for (var i = 0; i < status.attachments.length; i++) { for (var i = 0; i < status.attachments.length; i++) {
// closure needed for the callback
(function() {
var attachment = status.attachments[i];
var img = new Image();
img.className = "photo";
template.images.append(img);
var attachment = status.attachments[i]; var url = Paths.mkApiRootPath("/posts/" + status.id + "/attachments/" + attachment.name);
var img = new Image();
img.className = "photo";
template.message.parentNode.insertBefore(img, template.message.nextSibling);
var url = Paths.mkApiRootPath("/posts/" + status.id + "/attachments/" + attachment.name); var callback = function(resp) {
img.src = "data:image/png;base64," + resp.responseText;
var callback = function(resp) { }
img.src = "data:image/png;base64," + resp.responseText; })();
}
Paths.getURL(url.toString(), "GET", callback, null, null, attachment.type); Paths.getURL(url.toString(), "GET", callback, null, null, attachment.type);
}; };
@ -321,6 +360,25 @@ function(jQuery, Paths, URI, HostApp, Followings) {
} }
} }
Core.prototype.repost = function(id, entity, callback) {
var url = URI(Paths.mkApiRootPath("/posts"));
var data = {
"type": "https://tent.io/types/post/repost/v0.1.0",
"published_at": parseInt(new Date().getTime() / 1000, 10),
"permissions": {
"public": true
},
"content": {
"entity": entity,
"id": id
}
};
Paths.getURL(url.toString(), "POST", callback, JSON.stringify(data));
}
Core.prototype.sendNewMessageWithImage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri, callback) { Core.prototype.sendNewMessageWithImage = function(content, in_reply_to_status_id, in_reply_to_entity, location, image_data_uri, callback) {
var url = URI(Paths.mkApiRootPath("/posts")); var url = URI(Paths.mkApiRootPath("/posts"));