Exemplo n.º 1
0
 def __init__(self, result=None, **args):
     deskbar.interfaces.Match.__init__(self, category="web", icon="google.png", **args)
     self._name = htmldecode(result['titleNoFormatting'])
     self.url = result['url']
     self.set_snippet(htmldecode(result['content']))
     
     self.add_action( OpenGoogleAction(self.get_name(), self.url) )
     self.add_action( CopyToClipboardAction( _("URL"), self.url) )
Exemplo n.º 2
0
    def __init__(self, result=None, **args):
        deskbar.interfaces.Match.__init__(self,
                                          category="web",
                                          icon="google.png",
                                          **args)
        self._name = htmldecode(result['titleNoFormatting'])
        self.url = result['url']
        self.set_snippet(htmldecode(result['content']))

        self.add_action(OpenGoogleAction(self.get_name(), self.url))
        self.add_action(CopyToClipboardAction(_("URL"), self.url))
Exemplo n.º 3
0
    def _format_content(self, content, qstring):
        """
        Remove HTML tags and display only the first line
        that contains the search term
        """
        content_lines = strip_html(htmldecode(content)).split("\n")
        pattern = re.escape(qstring)
        new_content = ""
        for content in content_lines:
            if qstring in content:
                new_content += re.sub(
                    pattern, "<span weight='bold'>" + qstring + "</span>",
                    content.strip(), re.IGNORECASE | re.MULTILINE)
                new_content += "\n"

        if len(new_content) > 0:
            return new_content.strip().replace("&", "&amp;")
        else:
            return None
 def _format_content(self, content, qstring):
     """
     Remove HTML tags and display only the first line
     that contains the search term
     """
     content_lines = strip_html(htmldecode(content)).split("\n")
     pattern = re.escape(qstring)
     new_content = ""
     for content in content_lines:
         if qstring in content:
             new_content += re.sub(pattern,
                           "<span weight='bold'>"+qstring+"</span>",
                           content.strip(),
                           re.IGNORECASE | re.MULTILINE)
             new_content += "\n"
     
     if len(new_content) > 0:
         return new_content.strip().replace("&", "&amp;")
     else:
         return None