From 6d55737cdc6e757207fd5dbbcc7711b29b1d6c82 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Wed, 11 Nov 2015 17:34:57 +0530 Subject: [PATCH] Show DB index in search results. Signed-off-by: Arun Prakash Jana --- markit | 8 ++++---- markit.1 | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/markit b/markit index e50d4e3..76ee60d 100755 --- a/markit +++ b/markit @@ -237,7 +237,7 @@ def searchdb(cur, keywords): arguments = [] arguments.append(searchtag) placeholder = "'%' || ? || '%'" - query = "SELECT url, metadata, tags FROM bookmarks WHERE tags LIKE (%s)" % placeholder + query = "SELECT id, url, metadata, tags FROM bookmarks WHERE tags LIKE (%s)" % placeholder if searchAll == True: # Match all keywords in URL or Title query += " OR (" for token in keywords: @@ -264,9 +264,9 @@ def searchdb(cur, keywords): count = 0 results = [] for row in cur.execute(query, arguments): - results.append(row[0]) + results.append(row[1]) count += 1 - print("\x1B[1m\x1B[93m%d. \x1B[0m\x1B[92m%s\x1B[0m\n\t%s\n\t\x1B[91m[TAGS]\x1B[0m %s" % (count, row[0], row[1], row[2][1:-1])) + print("\x1B[1m\x1B[93m%d. \x1B[0m\x1B[92m%s\x1B[0m (%d)\n\t%s\n\t\x1B[91m[TAGS]\x1B[0m %s" % (count, row[1], row[0], row[2], row[3][1:-1])) if count == 0: return @@ -274,7 +274,7 @@ def searchdb(cur, keywords): print("") while True: - nav = input("Index number to open: ") + nav = input("Result number to open: ") if is_int(nav): index = int(nav) - 1 if index < 0: diff --git a/markit.1 b/markit.1 index 1404a11..1d380dc 100644 --- a/markit.1 +++ b/markit.1 @@ -58,7 +58,10 @@ in DB. Show all bookmark records from the DB along with actual index. Shows URL, title data and tags. .TP .BI \-s " keywords" -Search bookmarks for a (partial) tag or keywords and show the results. Prompts to enter result number to open in browser. Note that the sequential index number may not match the real index in database. Shows URL, title data and tags. +Search bookmarks for a (partial) tag or any keyword and show the results. Prompts to enter result number to open in browser. Note that the sequential index number may not match the real index in database. DB index is shown in the end within `()`. +.TP +.BI \-S " keywords" +Search bookmarks for a (partial) tag or occurrence of all keywords in URL or title data and show the results. Rest same as `-s`. .TP .BI \-u " N" Update bookmark at index