fixed many things and added search

This commit is contained in:
jeena 2013-03-25 19:13:09 +01:00
parent c6220b1dc1
commit cbc6755791
10 changed files with 128 additions and 75 deletions

View file

@ -233,23 +233,23 @@ class Console(QtCore.QObject):
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def log(self, string): def log(self, string):
print "<js>: " + string print "<js>: " + unicode(string)
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def error(self, string): def error(self, string):
print "<js ERROR>: " + string print "<js ERROR>: " + unicode(string)
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def warn(self, string): def warn(self, string):
print "<js WARN>: " + string print "<js WARN>: " + unicode(string)
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def notice(self, string): def notice(self, string):
print "<js NOTICE>: " + string print "<js NOTICE>: " + unicode(string)
@QtCore.pyqtSlot(str) @QtCore.pyqtSlot(str)
def debug(self, string): def debug(self, string):
print "<js DEBUG>: " + string print "<js DEBUG>: " + unicode(string)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -44,6 +44,10 @@ class WebViewCreator(QtWebKit.QWebView):
self.actions = [] self.actions = []
QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled, True) QtWebKit.QWebSettings.globalSettings().setAttribute(QtWebKit.QWebSettings.DeveloperExtrasEnabled, True)
def copy_link():
self.page().triggerAction(QtWebKit.QWebPage.CopyLinkToClipboard)
self.action_copy_link = QtGui.QAction('Copy Lin&k', self, triggered=copy_link)
def context_menu_requested(self, point): def context_menu_requested(self, point):
context_menu = QtGui.QMenu() context_menu = QtGui.QMenu()

View file

@ -397,3 +397,14 @@ a.youtube:before {
iframe { iframe {
max-width: 500px; max-width: 500px;
} }
form.search {
text-align: center;
padding: 5px 10%;
}
form.search input {
width: 100%;
padding: 10px;
font-size: 1.2em;
}

View file

@ -23,6 +23,14 @@ function(HostApp, Core, Paths, URI) {
Conversation.prototype = Object.create(Core.prototype); Conversation.prototype = Object.create(Core.prototype);
Conversation.prototype.show = function() {
Core.prototype.show.call(this, this.body);
}
Conversation.prototype.hide = function() {
Core.prototype.hide.call(this, this.body);
}
Conversation.addStatus = function(status) { Conversation.addStatus = function(status) {

View file

@ -2,10 +2,11 @@ define([
"helper/HostApp", "helper/HostApp",
"controller/Timeline", "controller/Timeline",
"lib/URI", "lib/URI",
"helper/Paths" "helper/Paths",
"helper/Core"
], ],
function(HostApp, Timeline, URI, Paths) { function(HostApp, Timeline, URI, Paths, Core) {
function Mentions() { function Mentions() {
@ -23,6 +24,14 @@ function(HostApp, Timeline, URI, Paths) {
Mentions.prototype = Object.create(Timeline.prototype); Mentions.prototype = Object.create(Timeline.prototype);
Mentions.prototype.show = function() {
Core.prototype.show.call(this, this.body);
}
Mentions.prototype.hide = function() {
Core.prototype.hide.call(this, this.body);
}
Mentions.prototype.newStatus = function(statuses) { Mentions.prototype.newStatus = function(statuses) {

View file

@ -20,19 +20,20 @@ function(HostApp, Core, Paths, URI) {
this.initProfileTemplate(); this.initProfileTemplate();
this.hide(); this.hide();
this.showProfileForEntity(); // Load users profile on start var _this = this;
setTimeout(function() { _this.showProfileForEntity() }, 5000); // Load users profile on start
} }
Profile.prototype = Object.create(Core.prototype); Profile.prototype = Object.create(Core.prototype);
Profile.prototype.show = function() { Profile.prototype.show = function() {
$(this.container).show(); Core.prototype.show.call(this, this.container);
} }
Profile.prototype.hide = function() { Profile.prototype.hide = function() {
$(this.container).hide(); Core.prototype.hide.call(this, this.container);
}; }
Profile.prototype.showList = function(list) { Profile.prototype.showList = function(list) {
$(this.body).hide(); $(this.body).hide();
@ -247,18 +248,23 @@ function(HostApp, Core, Paths, URI) {
} }
Profile.prototype.getFollowing = function() { Profile.prototype.getFollowing = function() {
var url = Paths.mkApiRootPath("/followings") + "/" + encodeURIComponent(this.entity); if(this.entity != HostApp.stringForKey("entity")) {
var _this = this; var url = Paths.mkApiRootPath("/followings") + "/" + encodeURIComponent(this.entity);
Paths.getURL(url, "GET", function(resp) { var _this = this;
if (resp.status >= 200 && resp.status < 400) { Paths.getURL(url, "GET", function(resp) {
var following = JSON.parse(resp.responseText); if (resp.status >= 200 && resp.status < 400) {
_this.following_id = following.id var following = JSON.parse(resp.responseText);
_this.setFollowingButton(true); _this.following_id = following.id
} else { _this.setFollowingButton(true);
_this.setFollowingButton(false); } else {
_this.following_id = null; _this.setFollowingButton(false);
} _this.following_id = null;
}) }
})
} else {
this.setFollowingButton(false);
this.following_id = null;
}
} }
Profile.prototype.showProfile = function(profile) { Profile.prototype.showProfile = function(profile) {
@ -320,21 +326,25 @@ function(HostApp, Core, Paths, URI) {
_this.populate(_this.profile_template.followed, resp.responseText); _this.populate(_this.profile_template.followed, resp.responseText);
}, null, false); }, null, false);
Paths.getURL(URI(root_url + "/followers/" + encodeURIComponent(HostApp.stringForKey("entity"))).toString(), "GET", function(resp) { if (this.entity != HostApp.stringForKey("entity")) {
if (resp.status == 200) { Paths.getURL(URI(root_url + "/followers/" + encodeURIComponent(HostApp.stringForKey("entity"))).toString(), "GET", function(resp) {
_this.relationships.following_you = true; if (resp.status == 200) {
} _this.relationships.following_you = true;
_this.setRelationships(); }
_this.setRelationships();
}, null, false); }, null, false);
Paths.getURL(URI(Paths.mkApiRootPath("/followings/" + encodeURIComponent(this.entity))), "GET", function(resp) { Paths.getURL(URI(Paths.mkApiRootPath("/followings/" + encodeURIComponent(this.entity))), "GET", function(resp) {
if (resp.status == 200) { if (resp.status == 200) {
_this.relationships.followed_by_you = true; _this.relationships.followed_by_you = true;
} }
_this.setRelationships(); _this.setRelationships();
});
}); } else {
this.setRelationships();
}
var url = URI(root_url + "/posts/count"); var url = URI(root_url + "/posts/count");
var post_types = [ var post_types = [

View file

@ -18,13 +18,13 @@ function(HostApp, Paths, Cache) {
this.menu = {}; this.menu = {};
this.menu.user = this.createItem("User", function() { _this.onEntity() }, "img/sidebar/user.png", "img/sidebar/user.png"); this.menu.user = this.createItem("User", function() { _this.onEntity(); return false; }, "img/sidebar/user.png", "img/sidebar/user.png");
this.menu.timeline = this.createItem("Timeline", function() { _this.onTimeline() }, "img/sidebar/timeline.png", "img/sidebar/timeline_active.png", true); this.menu.timeline = this.createItem("Timeline", function() { _this.onTimeline(); return false; }, "img/sidebar/timeline.png", "img/sidebar/timeline_active.png", true);
this.menu.mentions = this.createItem("Mentions", function() { _this.onMentions() }, "img/sidebar/mentions.png", "img/sidebar/mentions_active.png"); this.menu.mentions = this.createItem("Mentions", function() { _this.onMentions(); return false; }, "img/sidebar/mentions.png", "img/sidebar/mentions_active.png");
this.menu.conversation = this.createItem("Conversation", function() { _this.onConversation() }, "img/sidebar/conversation.png", "img/sidebar/conversation_active.png"); this.menu.conversation = this.createItem("Conversation", function() { _this.onConversation(); return false; }, "img/sidebar/conversation.png", "img/sidebar/conversation_active.png");
this.menu.entityProfile = this.createItem("Profile", function() { _this.onEntityProfile() }, "img/sidebar/profile.png", "img/sidebar/profile_active.png"); this.menu.entityProfile = this.createItem("Profile", function() { _this.onEntityProfile(); return false; }, "img/sidebar/profile.png", "img/sidebar/profile_active.png");
this.menu.search = this.createItem("Search", function() { _this.onSearch() }, "img/sidebar/search.png", "img/sidebar/search_active.png") this.menu.search = this.createItem("Search", function() { _this.onSearch(); return false; }, "img/sidebar/search.png", "img/sidebar/search_active.png")
this.body.appendChild(this.menu.user); this.body.appendChild(this.menu.user);
this.body.appendChild(this.menu.timeline); this.body.appendChild(this.menu.timeline);
@ -174,7 +174,7 @@ function(HostApp, Paths, Cache) {
} }
Sidebar.prototype.onSearch = function() { Sidebar.prototype.onSearch = function() {
debug("Search not implemented yet") this.showContentFor(bungloo.search, this.menu.search);
} }
return Sidebar; return Sidebar;

View file

@ -14,7 +14,7 @@ function(Core, Paths, HostApp, URI) {
this.action = "timeline"; this.action = "timeline";
this.reload_blocked = false; this.reload_blocked = false;
this.max_length = 20; this.max_length = 200;
this.timeout = 10 * 1000; // every 10 seconds this.timeout = 10 * 1000; // every 10 seconds
this.since_id = null; this.since_id = null;
this.since_id_entity = null; this.since_id_entity = null;
@ -32,6 +32,14 @@ function(Core, Paths, HostApp, URI) {
Timeline.prototype = Object.create(Core.prototype); Timeline.prototype = Object.create(Core.prototype);
Timeline.prototype.show = function() {
Core.prototype.show.call(this, this.body);
}
Timeline.prototype.hide = function() {
Core.prototype.hide.call(this, this.body);
}
Timeline.prototype.newStatus = function(statuses) { Timeline.prototype.newStatus = function(statuses) {

View file

@ -11,15 +11,22 @@ function(jQuery, Paths, URI, HostApp, Cache) {
function Core() { function Core() {
this.cache = new Cache(); this.cache = new Cache();
this.saveScrollTop = 0;
} }
Core.prototype.show = function() { Core.prototype.show = function(container) {
if (this.body) $(this.body).show(); if (container) {
$(container).show();
document.body.scrollTop = this.saveScrollTop;
}
} }
Core.prototype.hide = function() { Core.prototype.hide = function(container) {
if (this.body) $(this.body).hide(); if (container && $(container).is(":visible")) {
this.saveScrollTop = document.body.scrollTop;
$(container).hide();
}
} }
Core.prototype.getTemplate = function() { Core.prototype.getTemplate = function() {
@ -270,12 +277,20 @@ function(jQuery, Paths, URI, HostApp, Cache) {
text = text.escapeHTML().replace(/\n/g, "<br>"); text = text.escapeHTML().replace(/\n/g, "<br>");
var entities = [status.entity]; var entities = [status.entity];
status.mentions.map(function (mention) { if (status.mentions) {
entities.push(mention.entity) status.mentions.map(function (mention) {
}); entities.push(mention.entity)
});
}
template.message.innerHTML = this.replaceURLWithHTMLLinks(text, entities, template.message); template.message.innerHTML = this.replaceURLWithHTMLLinks(text, entities, template.message);
// adding show search on click hash
$(template.message).find("a.hash").click(function(e) {
bungloo.search.searchFor("#" + e.target.innerHTML);
return false;
});
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++) {
@ -802,7 +817,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
var hash = /(^|\s)(#)(\w+)/ig; var hash = /(^|\s)(#)(\w+)/ig;
return URI.withinString(text, callback).replace(hash, "$1$2<a href='https://skate.io/search?q=%23$3'>$3</a>"); return URI.withinString(text, callback).replace(hash, "$1$2<a class='hash' href='https://skate.io/search?q=%23$3'>$3</a>");
} }
Core.prototype.parseForMedia = function(text, images) { Core.prototype.parseForMedia = function(text, images) {

View file

@ -6,6 +6,7 @@ var bungloo = {
mentions: null, mentions: null,
entityProfile: null, entityProfile: null,
conversation: null, conversation: null,
search: null,
cache: {} cache: {}
}; };
@ -21,37 +22,24 @@ function start() {
});*/ });*/
require(["controller/Sidebar"], function(Sidebar) { require([
"controller/Sidebar",
"controller/Timeline",
"controller/Mentions",
"controller/Profile",
"controller/Conversation",
"controller/Search"
], function(Sidebar, Timeline, Mentions, Profile, Conversation, Search) {
bungloo.sidebar = new Sidebar(); bungloo.sidebar = new Sidebar();
});
require(["controller/Timeline"], function(Timeline) {
bungloo.timeline = new Timeline(); bungloo.timeline = new Timeline();
});
require(["controller/Mentions"], function(Mentions) {
bungloo.mentions = new Mentions(); bungloo.mentions = new Mentions();
});
require(["controller/Profile"], function(Profile) {
bungloo.entityProfile = new Profile(); bungloo.entityProfile = new Profile();
});
require(["controller/Conversation"], function(Conversation) {
bungloo.conversation = new Conversation(); bungloo.conversation = new Conversation();
bungloo.search = new Search();
}); });
} }