added search and logout to Linux
This commit is contained in:
parent
cbc6755791
commit
3d1768540d
7 changed files with 236 additions and 50 deletions
|
@ -21,7 +21,7 @@ class Bungloo:
|
||||||
self.preferences = Windows.Preferences(self)
|
self.preferences = Windows.Preferences(self)
|
||||||
self.preferences.show()
|
self.preferences.show()
|
||||||
|
|
||||||
#self.oauth_implementation = Windows.Oauth(self)
|
self.oauth_implementation = Windows.Oauth(self)
|
||||||
|
|
||||||
if self.controller.stringForKey("user_access_token") != "":
|
if self.controller.stringForKey("user_access_token") != "":
|
||||||
self.authentification_succeded()
|
self.authentification_succeded()
|
||||||
|
@ -43,29 +43,45 @@ class Bungloo:
|
||||||
|
|
||||||
def authentification_succeded(self):
|
def authentification_succeded(self):
|
||||||
self.preferences.hide()
|
self.preferences.hide()
|
||||||
#if hasattr(self, "oauth_implementation"):
|
if hasattr(self, "oauth_implementation"):
|
||||||
# self.oauth_implementation.hide()
|
self.oauth_implementation.hide()
|
||||||
self.preferences.active(False)
|
self.preferences.active(False)
|
||||||
self.init_web_views()
|
self.init_web_views()
|
||||||
|
|
||||||
def init_web_views(self):
|
def init_web_views(self):
|
||||||
self.timeline = Windows.Timeline(self)
|
self.timeline = Windows.Timeline(self)
|
||||||
#self.mentions = Windows.Timeline(self, "mentions", "Mentions")
|
|
||||||
self.timeline.show()
|
self.timeline.show()
|
||||||
#self.conversation = Windows.Timeline(self, "conversation", "Conversation")
|
|
||||||
#self.profile = Windows.Timeline(self, "profile", "Profile")
|
|
||||||
self.find_entity = Windows.FindEntity(self)
|
self.find_entity = Windows.FindEntity(self)
|
||||||
|
|
||||||
def timeline_show(self):
|
|
||||||
self.timeline.show()
|
|
||||||
|
|
||||||
def mentions_show(self):
|
|
||||||
self.controller.unreadMentions(0)
|
|
||||||
#self.mentions.show()
|
|
||||||
|
|
||||||
def find_entity_show(self):
|
def find_entity_show(self):
|
||||||
self.find_entity.show()
|
self.find_entity.show()
|
||||||
|
|
||||||
|
def timeline_show(self):
|
||||||
|
self.timeline.show()
|
||||||
|
self.timeline.evaluateJavaScript("bungloo.sidebar.onTimeline();")
|
||||||
|
|
||||||
|
def mentions_show(self):
|
||||||
|
self.controller.unreadMentions(0)
|
||||||
|
self.timeline.evaluateJavaScript("bungloo.sidebar.onMentions();")
|
||||||
|
|
||||||
|
def conversation_show(self):
|
||||||
|
self.timeline.evaluateJavaScript("bungloo.sidebar.onConversation();")
|
||||||
|
|
||||||
|
def profile_show(self):
|
||||||
|
self.timeline.evaluateJavaScript("bungloo.sidebar.onEntityProfile();")
|
||||||
|
|
||||||
|
def search_show(self):
|
||||||
|
self.timeline.evaluateJavaScript("bungloo.sidebar.onSearch();")
|
||||||
|
|
||||||
|
def open_about(self):
|
||||||
|
self.controller.openURL("http://jabs.nu/bungloo")
|
||||||
|
|
||||||
|
def log_out(self):
|
||||||
|
self.oauth_implementation.log_out()
|
||||||
|
self.timeline.close()
|
||||||
|
self.preferences.show()
|
||||||
|
#self.timeline.evaluateJavaScript("bungloo.sidebar.logout()")
|
||||||
|
|
||||||
|
|
||||||
class Controller(QtCore.QObject):
|
class Controller(QtCore.QObject):
|
||||||
|
|
||||||
|
@ -131,7 +147,7 @@ class Controller(QtCore.QObject):
|
||||||
self.app.timeline.set_window_title("Bungloo (^" + str(i) + ")")
|
self.app.timeline.set_window_title("Bungloo (^" + str(i) + ")")
|
||||||
else:
|
else:
|
||||||
self.app.timeline.set_window_title("Bungloo")
|
self.app.timeline.set_window_title("Bungloo")
|
||||||
#self.app.mentions.evaluateJavaScript("bungloo_instance.unread_mentions = 0;")
|
self.app.timeline.evaluateJavaScript("bungloo.mentions.unread_mentions = 0;")
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str, str, str, str)
|
@QtCore.pyqtSlot(str, str, str, str)
|
||||||
def notificateUserAboutMentionFromNameWithPostIdAndEntity(self, text, name, post_id, entity):
|
def notificateUserAboutMentionFromNameWithPostIdAndEntity(self, text, name, post_id, entity):
|
||||||
|
|
|
@ -101,19 +101,32 @@ class Timeline:
|
||||||
|
|
||||||
|
|
||||||
def initUI(self):
|
def initUI(self):
|
||||||
newPostAction = QtGui.QAction("&New Post", self.window)
|
menubar = self.window.menuBar()
|
||||||
|
|
||||||
|
newPostAction = QtGui.QAction("&New post", self.window)
|
||||||
newPostAction.setShortcut("Ctrl+N")
|
newPostAction.setShortcut("Ctrl+N")
|
||||||
newPostAction.setStatusTip("Open new post window")
|
newPostAction.setStatusTip("Open new post window")
|
||||||
newPostAction.triggered.connect(self.app.controller.openNewMessageWidow)
|
newPostAction.triggered.connect(self.app.controller.openNewMessageWidow)
|
||||||
|
|
||||||
|
findEntityAction = QtGui.QAction("&Open profile for entity ...", self.window)
|
||||||
|
findEntityAction.setShortcut("Ctrl+u")
|
||||||
|
findEntityAction.setStatusTip("Find entity and open its profile view")
|
||||||
|
findEntityAction.triggered.connect(self.app.find_entity_show)
|
||||||
|
|
||||||
|
logOutAction = QtGui.QAction("&Log out", self.window)
|
||||||
|
logOutAction.setStatusTip("Log out from this entity")
|
||||||
|
logOutAction.triggered.connect(self.app.log_out)
|
||||||
|
|
||||||
exitAction = QtGui.QAction("&Exit", self.window)
|
exitAction = QtGui.QAction("&Exit", self.window)
|
||||||
exitAction.setShortcut("Ctrl+Q")
|
exitAction.setShortcut("Ctrl+Q")
|
||||||
exitAction.setStatusTip("Exit Bungloo")
|
exitAction.setStatusTip("Exit Bungloo")
|
||||||
exitAction.triggered.connect(QtGui.qApp.quit)
|
exitAction.triggered.connect(QtGui.qApp.quit)
|
||||||
|
|
||||||
menubar = self.window.menuBar()
|
|
||||||
fileMenu = menubar.addMenu("&File")
|
fileMenu = menubar.addMenu("&File")
|
||||||
fileMenu.addAction(newPostAction)
|
fileMenu.addAction(newPostAction)
|
||||||
|
fileMenu.addAction(findEntityAction)
|
||||||
|
fileMenu.addSeparator()
|
||||||
|
fileMenu.addAction(logOutAction)
|
||||||
fileMenu.addAction(exitAction)
|
fileMenu.addAction(exitAction)
|
||||||
|
|
||||||
timelineAction = QtGui.QAction("&Timeline", self.window)
|
timelineAction = QtGui.QAction("&Timeline", self.window)
|
||||||
|
@ -126,26 +139,41 @@ class Timeline:
|
||||||
mentionsAction.setStatusTip("Show Mentions")
|
mentionsAction.setStatusTip("Show Mentions")
|
||||||
mentionsAction.triggered.connect(self.app.mentions_show)
|
mentionsAction.triggered.connect(self.app.mentions_show)
|
||||||
|
|
||||||
findEntityAction = QtGui.QAction("&Open Profile", self.window)
|
conversationAction = QtGui.QAction("&Conversation", self.window)
|
||||||
findEntityAction.setShortcut("Ctrl+u")
|
conversationAction.setShortcut("Ctrl+3")
|
||||||
findEntityAction.setStatusTip("Find entity and open its profile view")
|
conversationAction.setStatusTip("Show Conversation")
|
||||||
findEntityAction.triggered.connect(self.app.find_entity_show)
|
conversationAction.triggered.connect(self.app.conversation_show)
|
||||||
|
|
||||||
hideAction = QtGui.QAction("&Hide window", self.window)
|
profileAction = QtGui.QAction("&Profile", self.window)
|
||||||
hideAction.setShortcut("Ctrl+W")
|
profileAction.setShortcut("Ctrl+4")
|
||||||
hideAction.setStatusTip("Hide this window")
|
profileAction.setStatusTip("Show Profile")
|
||||||
hideAction.triggered.connect(self.hide)
|
profileAction.triggered.connect(self.app.profile_show)
|
||||||
|
|
||||||
windowMenu = menubar.addMenu("&Windows")
|
searchAction = QtGui.QAction("&Search", self.window)
|
||||||
|
searchAction.setShortcut("Ctrl+F")
|
||||||
|
searchAction.setStatusTip("Show Search")
|
||||||
|
searchAction.triggered.connect(self.app.search_show)
|
||||||
|
|
||||||
|
windowMenu = menubar.addMenu("&View")
|
||||||
windowMenu.addAction(timelineAction)
|
windowMenu.addAction(timelineAction)
|
||||||
windowMenu.addAction(mentionsAction)
|
windowMenu.addAction(mentionsAction)
|
||||||
windowMenu.addAction(hideAction)
|
windowMenu.addAction(conversationAction)
|
||||||
windowMenu.addAction(findEntityAction)
|
windowMenu.addAction(profileAction)
|
||||||
|
windowMenu.addAction(searchAction)
|
||||||
|
|
||||||
|
aboutAction = QtGui.QAction("&About Bungloo", self.window)
|
||||||
|
aboutAction.setStatusTip("Open about page in Webbrowser")
|
||||||
|
aboutAction.triggered.connect(self.app.open_about)
|
||||||
|
|
||||||
|
helpMenu = menubar.addMenu("&Help")
|
||||||
|
helpMenu.addAction(aboutAction)
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
self.window.show()
|
self.window.show()
|
||||||
#self.window.raise_()
|
#self.window.raise_()
|
||||||
#QtGui.qApp.setActiveWindow(self.window)
|
#QtGui.qApp.setActiveWindow(self.window)
|
||||||
|
def close(self):
|
||||||
|
self.window.close()
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
self.window.hide()
|
self.window.hide()
|
||||||
|
@ -174,7 +202,11 @@ class Oauth:
|
||||||
self.core.page().mainFrame().evaluateJavaScript(script)
|
self.core.page().mainFrame().evaluateJavaScript(script)
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
script = "bungloo_instance.authenticate();"
|
script = "bungloo.oauth.authenticate();"
|
||||||
|
self.core.page().mainFrame().evaluateJavaScript(script)
|
||||||
|
|
||||||
|
def log_out(self):
|
||||||
|
script = "bungloo.oauth.logout()";
|
||||||
self.core.page().mainFrame().evaluateJavaScript(script)
|
self.core.page().mainFrame().evaluateJavaScript(script)
|
||||||
|
|
||||||
def handle_authentication(self, url):
|
def handle_authentication(self, url):
|
||||||
|
@ -203,7 +235,7 @@ class Oauth:
|
||||||
dialog.exec_()
|
dialog.exec_()
|
||||||
|
|
||||||
def bungloo_callback(self, url):
|
def bungloo_callback(self, url):
|
||||||
script = "bungloo_instance.requestAccessToken('" + url.toString() + "');"
|
script = "bungloo.oauth.requestAccessToken('" + url.toString() + "');"
|
||||||
self.core.page().mainFrame().evaluateJavaScript(script)
|
self.core.page().mainFrame().evaluateJavaScript(script)
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
|
|
|
@ -35,6 +35,10 @@ function(HostApp, Core, Paths, URI) {
|
||||||
Core.prototype.hide.call(this, this.container);
|
Core.prototype.hide.call(this, this.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Profile.prototype.logout = function() {
|
||||||
|
this.container = "";
|
||||||
|
}
|
||||||
|
|
||||||
Profile.prototype.showList = function(list) {
|
Profile.prototype.showList = function(list) {
|
||||||
$(this.body).hide();
|
$(this.body).hide();
|
||||||
$(this.followingsBody).hide();
|
$(this.followingsBody).hide();
|
||||||
|
|
111
WebKit/scripts/controller/Search.js
Normal file
111
WebKit/scripts/controller/Search.js
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
define([
|
||||||
|
"helper/HostApp",
|
||||||
|
"helper/Core",
|
||||||
|
"helper/Paths",
|
||||||
|
"lib/URI"
|
||||||
|
],
|
||||||
|
|
||||||
|
function(HostApp, Core, Paths, URI) {
|
||||||
|
|
||||||
|
|
||||||
|
function Search() {
|
||||||
|
|
||||||
|
Core.call(this);
|
||||||
|
|
||||||
|
this.action = "search";
|
||||||
|
|
||||||
|
this.container = document.createElement("div");
|
||||||
|
document.getElementById("content").appendChild(this.container);
|
||||||
|
|
||||||
|
this.body = document.createElement("ol");
|
||||||
|
|
||||||
|
this.form = document.createElement("form");
|
||||||
|
this.form.className = this.action;
|
||||||
|
this.input = document.createElement("input");
|
||||||
|
this.input.type = "search";
|
||||||
|
this.input.placeholder = "Search ...";
|
||||||
|
this.form.appendChild(this.input);
|
||||||
|
|
||||||
|
var _this = this;
|
||||||
|
this.form.onsubmit = function() { _this.doSearch(_this.input.value); return false; };
|
||||||
|
this.form.action = "#";
|
||||||
|
|
||||||
|
this.container.appendChild(this.form);
|
||||||
|
this.container.appendChild(this.body);
|
||||||
|
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
Search.prototype = Object.create(Core.prototype);
|
||||||
|
|
||||||
|
|
||||||
|
Search.prototype.show = function() {
|
||||||
|
Core.prototype.show.call(this, this.container);
|
||||||
|
this.input.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
Search.prototype.hide = function() {
|
||||||
|
Core.prototype.hide.call(this, this.container);
|
||||||
|
}
|
||||||
|
|
||||||
|
Search.prototype.doSearch = function(query) {
|
||||||
|
|
||||||
|
this.body.innerHTML = ""; // remove old results
|
||||||
|
|
||||||
|
if (query == "") return;
|
||||||
|
this.input.value = query;
|
||||||
|
|
||||||
|
var endpoint = "https://skate.io/api/search";
|
||||||
|
var api_key = "15cbec6445887eff3408";
|
||||||
|
|
||||||
|
var url = URI(endpoint);
|
||||||
|
url.addSearch("api_key", api_key);
|
||||||
|
url.addSearch("text", query);
|
||||||
|
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
|
Paths.getURL(url.toString(), "GET", function(resp) {
|
||||||
|
|
||||||
|
var results = JSON.parse(resp.responseText).results;
|
||||||
|
var statuses = [];
|
||||||
|
for (var i = 0; i < results.length; i++) {
|
||||||
|
var result = results[i].source;
|
||||||
|
var status = {
|
||||||
|
entity: result.entity,
|
||||||
|
content: {
|
||||||
|
text: result.content
|
||||||
|
},
|
||||||
|
published_at: result.published_at,
|
||||||
|
id: result.public_id,
|
||||||
|
type: result.post_type,
|
||||||
|
version: result.post_version,
|
||||||
|
app: {
|
||||||
|
url: "http://skate.io",
|
||||||
|
name: "skate.io"
|
||||||
|
},
|
||||||
|
mentions: []
|
||||||
|
}
|
||||||
|
|
||||||
|
statuses.push(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var i = 0; i < statuses.length; i++) {
|
||||||
|
var status = statuses[i];
|
||||||
|
if (status.type == "https://tent.io/types/post/status/v0.1.0") {
|
||||||
|
|
||||||
|
var new_node = _this.getStatusDOMElement(status);
|
||||||
|
_this.body.appendChild(new_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Search.prototype.searchFor = function(query) {
|
||||||
|
this.doSearch(query);
|
||||||
|
bungloo.sidebar.onSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Search;
|
||||||
|
|
||||||
|
});
|
|
@ -120,6 +120,13 @@ function(HostApp, Paths, Cache) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sidebar.prototype.removeEntityAvatar = function() {
|
||||||
|
var img = this.menu.user.getElementsByTagName("img")[0];
|
||||||
|
img.src = "img/sidebar/user.png";
|
||||||
|
img.src_inactive = img.src;
|
||||||
|
img.src_active = img.src;
|
||||||
|
}
|
||||||
|
|
||||||
Sidebar.prototype.showContentFor = function(active_part, active_li) {
|
Sidebar.prototype.showContentFor = function(active_part, active_li) {
|
||||||
|
|
||||||
// Show active content
|
// Show active content
|
||||||
|
@ -177,6 +184,15 @@ function(HostApp, Paths, Cache) {
|
||||||
this.showContentFor(bungloo.search, this.menu.search);
|
this.showContentFor(bungloo.search, this.menu.search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sidebar.prototype.logout = function() {
|
||||||
|
this.removeEntityAvatar();
|
||||||
|
bungloo.timeline.logout();
|
||||||
|
bungloo.mentions.logout();
|
||||||
|
bungloo.conversation.logout();
|
||||||
|
bungloo.entityProfile.logout();
|
||||||
|
bungloo.search.logout();
|
||||||
|
}
|
||||||
|
|
||||||
return Sidebar;
|
return Sidebar;
|
||||||
|
|
||||||
});
|
});
|
|
@ -634,7 +634,7 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
|
|
||||||
Core.prototype.logout = function() {
|
Core.prototype.logout = function() {
|
||||||
|
|
||||||
this.body.innerHTML = "";
|
if(this.body) this.body.innerHTML = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,32 +14,39 @@ requirejs.config({
|
||||||
baseUrl: 'scripts'
|
baseUrl: 'scripts'
|
||||||
});
|
});
|
||||||
|
|
||||||
function start() {
|
function start(view) {
|
||||||
/*
|
|
||||||
require(["controller/Oauth"], function(Oauth) {
|
|
||||||
|
|
||||||
bungloo.oauth = new Oauth();
|
if (view == "oauth") {
|
||||||
|
|
||||||
});*/
|
require(["controller/Oauth"], function(Oauth) {
|
||||||
|
|
||||||
require([
|
bungloo.oauth = new Oauth();
|
||||||
"controller/Sidebar",
|
|
||||||
"controller/Timeline",
|
|
||||||
"controller/Mentions",
|
|
||||||
"controller/Profile",
|
|
||||||
"controller/Conversation",
|
|
||||||
"controller/Search"
|
|
||||||
|
|
||||||
], function(Sidebar, Timeline, Mentions, Profile, Conversation, Search) {
|
});
|
||||||
|
|
||||||
bungloo.sidebar = new Sidebar();
|
} else {
|
||||||
bungloo.timeline = new Timeline();
|
|
||||||
bungloo.mentions = new Mentions();
|
|
||||||
bungloo.entityProfile = new Profile();
|
|
||||||
bungloo.conversation = new Conversation();
|
|
||||||
bungloo.search = new Search();
|
|
||||||
|
|
||||||
});
|
|
||||||
|
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.timeline = new Timeline();
|
||||||
|
bungloo.mentions = new Mentions();
|
||||||
|
bungloo.entityProfile = new Profile();
|
||||||
|
bungloo.conversation = new Conversation();
|
||||||
|
bungloo.search = new Search();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue