From: Fabian Keil <fk@fabiankeil.de>
Date: Mon, 26 May 2008 17:30:59 +0000 (+0000)
Subject: Provide an OpenSearch Description to access the
X-Git-Tag: v_3_0_9~59
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/faq/@default-cgi@/user-manual/static/diff?a=commitdiff_plain;h=e1a5911ec4ffee093da8352b1b6973d40b322f77;p=privoxy.git

Provide an OpenSearch Description to access the
show-url-info page through "search engine plugins".
---

diff --git a/cgi.c b/cgi.c
index 8a0ce49e..cc8ef2cc 100644
--- a/cgi.c
+++ b/cgi.c
@@ -1,4 +1,4 @@
-const char cgi_rcs[] = "$Id: cgi.c,v 1.106 2008/05/21 15:24:38 fabiankeil Exp $";
+const char cgi_rcs[] = "$Id: cgi.c,v 1.107 2008/05/26 16:23:19 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgi.c,v $
@@ -11,7 +11,7 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.106 2008/05/21 15:24:38 fabiankeil Exp $"
  *                Functions declared include:
  * 
  *
- * Copyright   :  Written by and Copyright (C) 2001-2004, 2006-2007
+ * Copyright   :  Written by and Copyright (C) 2001-2004, 2006-2008
  *                the SourceForge Privoxy team. http://www.privoxy.org/
  *
  *                Based on the Internet Junkbuster originally written
@@ -38,6 +38,10 @@ const char cgi_rcs[] = "$Id: cgi.c,v 1.106 2008/05/21 15:24:38 fabiankeil Exp $"
  *
  * Revisions   :
  *    $Log: cgi.c,v $
+ *    Revision 1.107  2008/05/26 16:23:19  fabiankeil
+ *    - Fix spelling in template-not-found message.
+ *    - Declare referrer_is_safe()'s alternative_prefix[] static.
+ *
  *    Revision 1.106  2008/05/21 15:24:38  fabiankeil
  *    Mark csp as immutable for a bunch of functions.
  *
@@ -768,6 +772,9 @@ static const struct cgi_dispatcher cgi_dispatchers[] = {
    { "t",
          cgi_transparent_image, 
          NULL, TRUE /* Send a transparent image (short name) */ },
+   { "url-info-osd.xml",
+         cgi_send_url_info_osd, 
+         NULL, TRUE /* Send templates/url-info-osd.xml */ },
    { "user-manual",
           cgi_send_user_manual,
           NULL, TRUE /* Send user-manual */ },
diff --git a/cgisimple.c b/cgisimple.c
index a27598b5..9448bf3b 100644
--- a/cgisimple.c
+++ b/cgisimple.c
@@ -1,4 +1,4 @@
-const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.83 2008/05/12 14:51:30 fabiankeil Exp $";
+const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.84 2008/05/26 16:16:55 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.c,v $
@@ -36,6 +36,9 @@ const char cgisimple_rcs[] = "$Id: cgisimple.c,v 1.83 2008/05/12 14:51:30 fabian
  *
  * Revisions   :
  *    $Log: cgisimple.c,v $
+ *    Revision 1.84  2008/05/26 16:16:55  fabiankeil
+ *    Spell error correctly.
+ *
  *    Revision 1.83  2008/05/12 14:51:30  fabiankeil
  *    Don't complain about an invalid URL if show-url-info is requested
  *    without parameters. Regression introduced in 1.81 by yours truly.
@@ -978,6 +981,49 @@ jb_err cgi_send_stylesheet(struct client_state *csp,
    return JB_ERR_OK;
 
 }
+
+
+/*********************************************************************
+ *
+ * Function    :  cgi_send_url_info_osd
+ *
+ * Description :  CGI function that sends the OpenSearch Description
+ *                template for the show-url-info page. It allows to
+ *                access the page through "search engine plugins".
+ *
+ * Parameters  :
+ *          1  :  csp = Current client state (buffers, headers, etc...)
+ *          2  :  rsp = http_response data structure for output
+ *          3  :  parameters = map of cgi parameters
+ *
+ * CGI Parameters : None
+ *
+ * Returns     :  JB_ERR_OK on success
+ *                JB_ERR_MEMORY on out-of-memory error.  
+ *
+ *********************************************************************/
+jb_err cgi_send_url_info_osd(struct client_state *csp,
+                               struct http_response *rsp,
+                               const struct map *parameters)
+{
+   jb_err err = JB_ERR_MEMORY;
+   struct map *exports = default_exports(csp, NULL);
+
+   if (NULL != exports)
+   {
+      err = template_fill_for_cgi(csp, "url-info-osd.xml", exports, rsp);
+      if (JB_ERR_OK == err)
+      {
+         err = enlist(rsp->headers,
+            "Content-Type: application/opensearchdescription+xml");
+      }
+   }
+
+   return err;
+
+}
+
+
 /*********************************************************************
  *
  * Function    :  cgi_send_user_manual
diff --git a/cgisimple.h b/cgisimple.h
index 87788944..9ca0565c 100644
--- a/cgisimple.h
+++ b/cgisimple.h
@@ -1,6 +1,6 @@
 #ifndef CGISIMPLE_H_INCLUDED
 #define CGISIMPLE_H_INCLUDED
-#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.14 2006/09/06 18:45:03 fabiankeil Exp $"
+#define CGISIMPLE_H_VERSION "$Id: cgisimple.h,v 1.15 2007/01/23 15:51:17 fabiankeil Exp $"
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/cgisimple.h,v $
@@ -38,6 +38,9 @@
  *
  * Revisions   :
  *    $Log: cgisimple.h,v $
+ *    Revision 1.15  2007/01/23 15:51:17  fabiankeil
+ *    Add favicon delivery functions.
+ *
  *    Revision 1.14  2006/09/06 18:45:03  fabiankeil
  *    Incorporate modified version of Roland Rosenfeld's patch to
  *    optionally access the user-manual via Privoxy. Closes patch 679075.
@@ -147,6 +150,9 @@ extern jb_err cgi_send_default_favicon (struct client_state *csp,
 extern jb_err cgi_send_stylesheet(struct client_state *csp,
                                   struct http_response *rsp,
                                   const struct map *parameters);
+extern jb_err cgi_send_url_info_osd(struct client_state *csp,
+                                    struct http_response *rsp,
+                                    const struct map *parameters);
 extern jb_err cgi_send_user_manual(struct client_state *csp,
                                    struct http_response *rsp,
                                    const struct map *parameters);
diff --git a/templates/show-url-info b/templates/show-url-info
index f57b066d..4c2b9e1e 100644
--- a/templates/show-url-info
+++ b/templates/show-url-info
@@ -27,6 +27,11 @@
 #
 # Revisions   :
 #    $Log: show-url-info,v $
+#    Revision 1.26  2008/05/05 10:03:06  fabiankeil
+#    If the provided URL isn't valid, don't show the
+#    cgi-editor-is-disabled and filters-might-be-ineffective
+#    sections.
+#
 #    Revision 1.25  2008/04/26 10:34:18  fabiankeil
 #    If zlib support is unavailable and there are content filters active
 #    but the prevent-compression action is disabled, include a warning
@@ -159,6 +164,7 @@
   <meta name="robots" content="noindex,nofollow">
   <link rel="stylesheet" type="text/css" href="@default-cgi@send-stylesheet">
   <link rel="shortcut icon" href="@default-cgi@favicon.ico" type="image/x-icon">
+  <link rel="search" type="application/opensearchdescription+xml" title="Privoxy URL Info" href="/url-info-osd.xml">
 </head>
 
 <body>
diff --git a/templates/url-info-osd.xml b/templates/url-info-osd.xml
new file mode 100644
index 00000000..3fbaaf12
--- /dev/null
+++ b/templates/url-info-osd.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+  <ShortName>Privoxy URL Info</ShortName>
+  <Description>
+    Enter a URL to see which Privoxy actions apply.
+    Only works while the browser is configured to use Privoxy.
+  </Description>
+  <InputEncoding>ISO-8859-1</InputEncoding>
+  <OutputEncoding>ISO-8859-1</OutputEncoding>
+  <Developer>Privoxy Team</Developer>
+  <Contact>ijbswa-developers@lists.sourceforge.net</Contact>
+  <Image width="16" height="16" type="image/x-icon">@default-cgi@favicon.ico</Image>
+  <Url type="text/html" method="GET" template="@default-cgi@show-url-info?url={searchTerms}"/>
+</OpenSearchDescription>