Merge lp:~submarine/unity-scope-zotero/bug1174987 into lp:unity-scope-zotero

Proposed by Mark Tully
Status: Merged
Approved by: David Callé
Approved revision: 24
Merged at revision: 24
Proposed branch: lp:~submarine/unity-scope-zotero/bug1174987
Merge into: lp:unity-scope-zotero
Diff against target: 144 lines (+31/-18)
3 files modified
.bzrignore (+5/-0)
po/unity-scope-zotero.pot (+15/-6)
src/unity_zotero_daemon.py (+11/-12)
To merge this branch: bzr merge lp:~submarine/unity-scope-zotero/bug1174987
Reviewer Review Type Date Requested Status
David Callé Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+169669@code.launchpad.net

Commit message

Updates SQL query to take into account zotero attachments

Description of the change

Updating SQL query to take into account that in Zotero 4, urls may not be included in the main entry of an article, but rather in an attachment. The query now uses the url in the article entry if it exists, or else uses the first url in the attachments.

Also escaping forbidden characters in the preview description which was preventing it from being displayed if the forbidden characters were in the description.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
David Callé (davidc3) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '.bzrignore'
2--- .bzrignore 1970-01-01 00:00:00 +0000
3+++ .bzrignore 2013-06-16 00:37:28 +0000
4@@ -0,0 +1,5 @@
5+*.log
6+*.substvars
7+./build
8+./debian/files
9+./debian/unity-scope-zotero
10
11=== modified file 'po/unity-scope-zotero.pot'
12--- po/unity-scope-zotero.pot 2013-03-06 00:58:55 +0000
13+++ po/unity-scope-zotero.pot 2013-06-16 00:37:28 +0000
14@@ -8,7 +8,7 @@
15 msgstr ""
16 "Project-Id-Version: PACKAGE VERSION\n"
17 "Report-Msgid-Bugs-To: \n"
18-"POT-Creation-Date: 2013-03-06 00:56+0000\n"
19+"POT-Creation-Date: 2013-06-16 01:19+0100\n"
20 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
21 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
22 "Language-Team: LANGUAGE <LL@li.org>\n"
23@@ -17,22 +17,27 @@
24 "Content-Type: text/plain; charset=CHARSET\n"
25 "Content-Transfer-Encoding: 8bit\n"
26
27-#: ../src/unity_zotero_daemon.py:33 ../data/zotero.scope.in.h:4
28+#: ../src/unity_zotero_daemon.py:34 ../data/zotero.scope.in.h:4
29 msgid "Search Zotero"
30 msgstr ""
31
32-#: ../src/unity_zotero_daemon.py:34
33+#: ../src/unity_zotero_daemon.py:35
34 msgid "Sorry, there are no Zotero results that match your search."
35 msgstr ""
36
37-#: ../src/unity_zotero_daemon.py:35
38+#: ../src/unity_zotero_daemon.py:36
39 msgid "Powered by Zotero"
40 msgstr ""
41
42-#: ../src/unity_zotero_daemon.py:59
43+#: ../src/unity_zotero_daemon.py:62
44 msgid "Articles"
45 msgstr ""
46
47+#. Add the "View" action
48+#: ../src/unity_zotero_daemon.py:158
49+msgid "View Article"
50+msgstr ""
51+
52 #: ../data/zotero.scope.in.h:1
53 msgid "zotero;"
54 msgstr ""
55@@ -42,5 +47,9 @@
56 msgstr ""
57
58 #: ../data/zotero.scope.in.h:3
59-msgid "Find Zotero items"
60+msgid ""
61+"This is an Ubuntu search plugin that enables information from Zotero to be "
62+"searched and displayed in the Dash underneath the Reference header. If you "
63+"do not wish to search this content source, you can disable this search "
64+"plugin."
65 msgstr ""
66
67=== modified file 'src/unity_zotero_daemon.py'
68--- src/unity_zotero_daemon.py 2013-04-29 15:49:22 +0000
69+++ src/unity_zotero_daemon.py 2013-06-16 00:37:28 +0000
70@@ -20,6 +20,7 @@
71 import os.path
72 import shutil
73 import sqlite3
74+import html
75
76 APP_NAME = 'unity-scope-zotero'
77 LOCAL_PATH = '/usr/share/locale/'
78@@ -40,11 +41,12 @@
79 DEFAULT_RESULT_TYPE = Unity.ResultType.DEFAULT
80
81 PATHS = [os.getenv("HOME") + "/.mozilla/firefox/", os.getenv("HOME") + "/.zotero/zotero/"]
82-QUERY = ''' SELECT title.value, url.value, pub.value, c1.lastName, c2.lastName, c3.lastName, c4.lastName, c5.lastName, abstract.value
83+QUERY = '''SELECT title.value, COALESCE(url.value, url2.value), pub.value, GROUP_CONCAT(COALESCE(c1.lastName, "") || ' ' || COALESCE(c2.lastName, "") || ' ' || COALESCE(c3.lastName, "") || ' ' || COALESCE(c4.lastName, "") || ' ' || COALESCE(c5.lastName, "")) as creator, abstract.value
84 FROM items i
85 INNER JOIN itemDataValues title ON title.valueID =(SELECT itemData.valueID FROM itemData WHERE itemData.fieldID =(SELECT fieldID FROM fields WHERE fields.fieldName = 'title' LIMIT 1) AND itemData.itemID=i.itemID LIMIT 1)
86 LEFT JOIN itemTypes t ON t.itemTypeID = i.itemTypeID
87-LEFT JOIN itemDataValues url ON url.valueID =(SELECT itemData.valueID FROM itemData WHERE itemData.fieldID =(SELECT fieldID FROM fields WHERE fields.fieldName = 'url' LIMIT 1) AND itemData.itemID=i.itemID LIMIT 1)
88+LEFT JOIN itemDataValues url ON url.valueID = (SELECT itemData.valueID FROM itemData WHERE itemData.fieldID =(SELECT fieldID FROM fields WHERE fields.fieldName = 'url' LIMIT 1) AND itemData.itemID=i.itemID LIMIT 1)
89+LEFT JOIN itemDataValues url2 on url2.valueID = (SELECT itemData.valueID FROM itemData WHERE itemData.fieldID =(SELECT fieldID FROM fields WHERE fields.fieldName = 'url' LIMIT 1) AND itemData.itemID = (SELECT itemAttachments.itemID FROM itemAttachments WHERE itemAttachments.sourceItemID = i.itemID) LIMIT 1)
90 LEFT JOIN creatorData c1 ON c1.creatorDataID =(SELECT creatorDataID FROM creators WHERE creatorID =(SELECT creatorID FROM itemCreators WHERE itemID = i.itemID ORDER BY orderIndex LIMIT 0,1) LIMIT 1)
91 LEFT JOIN creatorData c2 ON c2.creatorDataID =(SELECT creatorDataID FROM creators WHERE creatorID =(SELECT creatorID FROM itemCreators WHERE itemID = i.itemID ORDER BY orderIndex LIMIT 1,1) LIMIT 1)
92 LEFT JOIN creatorData c3 ON c3.creatorDataID =(SELECT creatorDataID FROM creators WHERE creatorID =(SELECT creatorID FROM itemCreators WHERE itemID = i.itemID ORDER BY orderIndex LIMIT 2,1) LIMIT 1)
93@@ -53,7 +55,8 @@
94 LEFT JOIN itemDataValues pub ON pub.valueID =(SELECT itemData.valueID FROM itemData WHERE itemData.fieldID =(SELECT fieldID FROM fields WHERE fields.fieldName = 'publicationTitle' LIMIT 1) AND itemData.itemID=i.itemID LIMIT 1)
95 LEFT JOIN itemDataValues abstract ON abstract.valueID =(SELECT itemData.valueID FROM itemData WHERE itemData.fieldID =(SELECT fieldID FROM fields WHERE fields.fieldName = 'abstractNote' LIMIT 1) AND itemData.itemID=i.itemID LIMIT 1)
96 LEFT JOIN deletedItems ON i.itemID = deletedItems.itemID
97-WHERE deletedItems.itemID IS NULL AND t.typeName = "journalArticle"'''
98+WHERE deletedItems.itemID IS NULL AND t.typeName = "journalArticle"
99+GROUP BY title.value'''
100
101 c1 = {'id': 'scholar',
102 'name': _('Articles'),
103@@ -114,13 +117,8 @@
104 title = record[0]
105 uri = record[1]
106 journal = record[2]
107- author1 = record[3]
108- author2 = record[4]
109- author3 = record[5]
110- author4 = record[6]
111- author5 = record[7]
112- authors = "%s, %s, %s, %s, %s" % (author1, author2, author3, author4, author5)
113- abstract = record[8]
114+ authors = record[3]
115+ abstract = record[4]
116 if search.lower() in title.lower():
117 if uri:
118 results.append({'uri': uri,
119@@ -151,11 +149,11 @@
120 except KeyError as e:
121 print(e)
122 try:
123- description += self.result.metadata['abstract'].get_string()
124+ description += html.escape(self.result.metadata['abstract'].get_string())
125 except KeyError as e:
126 print(e)
127 preview.props.description_markup = description
128-
129+
130 # Add the "View" action
131 show_action = Unity.PreviewAction.new("show", _("View Article"), None)
132 preview.add_action(show_action)
133@@ -267,5 +265,6 @@
134 result_preview.set_search_metadata(metadata)
135 return result_preview
136
137+
138 def load_scope():
139 return Scope()
140
141=== modified file 'tests/data/mock_zotero_pass/zotero.default/zotero/zotero-lensbackup.sqlite'
142Binary files tests/data/mock_zotero_pass/zotero.default/zotero/zotero-lensbackup.sqlite 2013-03-14 00:31:22 +0000 and tests/data/mock_zotero_pass/zotero.default/zotero/zotero-lensbackup.sqlite 2013-06-16 00:37:28 +0000 differ
143=== modified file 'tests/data/mock_zotero_pass/zotero.default/zotero/zotero.sqlite'
144Binary files tests/data/mock_zotero_pass/zotero.default/zotero/zotero.sqlite 2013-03-14 00:31:22 +0000 and tests/data/mock_zotero_pass/zotero.default/zotero/zotero.sqlite 2013-06-16 00:37:28 +0000 differ

Subscribers

People subscribed via source and target branches

to all changes: