def on_view_note(self, app, args): if len(args) < 1: self.error("Must specify note url") return app.focus_windows() nodeurl = args[1] if keepnote.notebook.is_node_url(nodeurl): host, nodeid = keepnote.notebook.parse_node_url(nodeurl) self.view_nodeid(app, nodeid) else: # do text search window = self.app.get_current_window() if window is None: return notebook = window.get_notebook() if notebook is None: return results = list(notebook.search_node_titles(nodeurl)) if len(results) == 1: self.view_nodeid(app, results[0][0]) else: viewer = window.get_viewer() viewer.start_search_result() for nodeid, title in results: node = notebook.get_node_by_id(nodeid) if node: viewer.add_search_result(node)
def on_search_titles(self, app, args): if len(args) < 1: self.error("Must specify text to search") return # get window and notebook window = self.app.get_current_window() if window is None: return notebook = window.get_notebook() if notebook is None: return # do search text = args[1] nodes = list(notebook.search_node_titles(text)) for nodeid, title in nodes: print "%s\t%s" % (title, keepnote.notebook.get_node_url(nodeid))
def get_nodeid(self, text): if keepnote.notebook.is_node_url(text): host, nodeid = keepnote.notebook.parse_node_url(text) return nodeid else: # do text search window = self.app.get_current_window() if window is None: return None notebook = window.get_notebook() if notebook is None: return None results = list(notebook.search_node_titles(text)) if len(results) == 1: return results[0][0] else: for nodeid, title in results: if title == text: return nodeid return None