=== modified file 'src/unity_zotero_daemon.py'
--- src/unity_zotero_daemon.py	2013-03-19 22:32:08 +0000
+++ src/unity_zotero_daemon.py	2013-04-29 15:56:39 +0000
@@ -63,7 +63,19 @@
 
 FILTERS = []
 
-EXTRA_METADATA = []
+META0 = {'id': 'authors',
+         'type': 's',
+         'field': Unity.SchemaFieldType.OPTIONAL}
+META1 = {'id': 'journal',
+         'type': 's',
+         'field': Unity.SchemaFieldType.OPTIONAL}
+META2 = {'id': 'abstract',
+         'type': 's',
+         'field': Unity.SchemaFieldType.OPTIONAL}
+META3 = {'id': 'fulltitle',
+         'type': 's',
+         'field': Unity.SchemaFieldType.OPTIONAL}
+EXTRA_METADATA = [META0, META1, META2, META3]
 
 
 def search(search, filters):
@@ -81,7 +93,6 @@
     extras metadata fields(variant)
     '''
     results = []
-    icon_hint = Gio.ThemedIcon.new("text-html").to_string()
 
     dbFile = ""
     for path in PATHS:
@@ -101,8 +112,6 @@
             c.close()
         for record in records:
             title = record[0]
-            if len(title) > 70:
-                shorttitle = title[:69] + u"…"
             uri = record[1]
             journal = record[2]
             author1 = record[3]
@@ -112,69 +121,45 @@
             author5 = record[7]
             authors = "%s, %s, %s, %s, %s" % (author1, author2, author3, author4, author5)
             abstract = record[8]
-            if len(authors) > 30:
-                authors = authors[:26] + " et al"
-            icon_hint = Gio.ThemedIcon.new('text-html').to_string()
             if search.lower() in title.lower():
                 if uri:
                     results.append({'uri': uri,
-                                    'icon': icon_hint,
-                                    'category': 0,
-                                    'title': shorttitle,
-                                    'comment': '%s\n%s\n%s\n%s' % (authors, journal, title, abstract)})
+                                    'title': title,
+                                    'authors': authors,
+                                    'journal': journal,
+                                    'abstract': abstract})
     return results
 
 
-def preview(scope, uri):
-    """Preview request handler"""
-    model = scope.props.results_model
-    iteration = model.get_first_iter()
-    end_iter = model.get_last_iter()
-    preview = None
-    while iteration != end_iter:
-        if model.get_value(iteration, 0) == uri:
-            title = ""
-            description = ""
-            preview_info = model.get_value(iteration, 5)
-            try:
-                description += "<big><b>" + preview_info.split("\n")[2].title() + "</b></big>\n\n"
-            except:
-                print("No Title")
-
-            try:
-                description += "<b>" + preview_info.split("\n")[1].title() + "</b>\n\n"
-            except:
-                print("No Journal")
-
-            try:
-                description += "<b>" + preview_info.split("\n")[0].title() + "</b>\n\n"
-            except:
-                print("No Authors")
-
-            try:
-                description += preview_info.split("\n")[3].title()
-            except:
-                print("No Abstract")
-
-            # Assemble the preview
-            preview = Unity.GenericPreview.new(title, description, None)
-            preview.props.image_source_uri = "file://" + model.get_value(iteration, 1)
-
-            # Add the "View" action
-            view_action = Unity.PreviewAction.new("activate_uri", "View Article", None)
-            view_action.connect("activated", activate)
-            preview.add_action(view_action)
-
-            break
-
-        iteration = model.next(iteration)
-    if preview is None:
-        print("Couldn't find model row for requested preview uri: '%s'", uri)
-    return preview
-
-
-def activate(scope, uri):
-    return Unity.ActivationResponse(handled=Unity.HandledType.NOT_HANDLED)
+class Preview(Unity.ResultPreviewer):
+    '''
+    Creates the preview for the result
+    '''
+    def do_run(self):
+        '''
+        Create a preview and return it
+        '''
+        preview = Unity.GenericPreview.new(self.result.title, '', None)
+        preview.props.image_source_uri = 'file://%s' % self.result.icon_hint
+        try:
+            preview.props.subtitle = self.result.metadata['authors'].get_string()
+        except KeyError as e:
+            print(e)
+        description = ''
+        try:
+            description += self.result.metadata['journal'].get_string() + '\n\n'
+        except KeyError as e:
+            print(e)
+        try:
+            description += self.result.metadata['abstract'].get_string()
+        except KeyError as e:
+            print(e)
+        preview.props.description_markup = description
+      
+        # Add the "View" action
+        show_action = Unity.PreviewAction.new("show", _("View Article"), None)
+        preview.add_action(show_action)
+        return preview
 
 
 # Classes below this point establish communication
@@ -210,19 +195,8 @@
                     i['comment'] = ''
                 if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '':
                     i['dnd_uri'] = i['uri']
-                i['metadata'] = {}
-                if EXTRA_METADATA:
-                    for e in i:
-                        for m in EXTRA_METADATA:
-                            if m['id'] == e:
-                                i['metadata'][e] = i[e]
-                i['metadata']['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS)
-                result = Unity.ScopeResult.create(str(i['uri']), str(i['icon']),
-                                                  i['category'], i['result_type'],
-                                                  str(i['mimetype']), str(i['title']),
-                                                  str(i['comment']), str(i['dnd_uri']),
-                                                  i['metadata'])
-                result_set.add_result(result)
+                i['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS)
+                result_set.add_result(**i)
         except Exception as error:
             print(error)
 
@@ -278,6 +252,20 @@
         se = MySearch(search_context)
         return se
 
+    def do_activate(self, result, metadata, action):
+        '''
+        What to do when a resut is clicked
+        '''
+        return Unity.ActivationResponse(handled=Unity.HandledType.NOT_HANDLED, goto_uri=None)
+
+    def do_create_previewer(self, result, metadata):
+        '''
+        Creates a preview when a resut is right-clicked
+        '''
+        result_preview = Preview()
+        result_preview.set_scope_result(result)
+        result_preview.set_search_metadata(metadata)
+        return result_preview
 
 def load_scope():
     return Scope()

=== modified file 'tests/test_zotero.py'
--- tests/test_zotero.py	2013-03-14 00:31:22 +0000
+++ tests/test_zotero.py	2013-04-29 15:56:39 +0000
@@ -38,9 +38,9 @@
         self.scope = None
         self.scope_module = None
 
-    def test_valid_searches(self):
+    def test_valid_search(self):
         self.scope_module.PATHS = ['tests/data/mock_zotero_pass/']
-        expected_results = ['[Qualitative and quantitative analysis of fluoxetine hydrochloride by…',
+        expected_results = ['[Qualitative and quantitative analysis of fluoxetine hydrochloride by 19F NMR]',
                             'http://www.ncbi.nlm.nih.gov/pubmed/22812008']
         results = []
         for s in ['fluoxetine']:
@@ -55,6 +55,13 @@
             result_set = self.perform_query(s)
             self.assertEqual(len(result_set.results), 0)
 
+    def test_activation(self):
+        result = Unity.ScopeResult()
+        result.uri = "http://www.ncbi.nlm.nih.gov/pubmed/2281200"
+        activation = self.scope.activate(result, Unity.SearchMetadata(), None)
+        self.assertEqual(activation.props.goto_uri, None)
+        self.assertEqual(activation.props.handled, Unity.HandledType.NOT_HANDLED)
+
 
 if __name__ == '__main__':
     unittest.main()

