如何为GAE文档创建Firefox搜索插件?

时间:2011-10-23 09:38:59

标签: search firefox-addon

这里的主要问题是搜索网址:

  

http://code.google.com/intl/it/query/#p=appengine&q=query

它不包含?符号,也包含#符号。 这样的URL没有通过XML验证,所以我尝试了不同的其他方法(甚至包含附加参数),但还没有找到可行的解决方案。

这是我目前所拥有的(图像部分被截断以简化):

<?xml version="1.0" encoding="UTF-8"?>  
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"  
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">  
  <ShortName>Google AppEngine</ShortName>  
  <Description>Search the GAE documents at Google Code website.</Description>  
  <InputEncoding>UTF-8</InputEncoding>  
  <Image width="16" height="16" type="image/x-icon">data:image/x-icon;base64,...</Image>  
  <Url type="text/html" method="GET" template="http://code.google.com/intl/it/query/#p=appengine">  
    <Param name="a" value="{moz:locale}"/>
    <Param name="q" value="{searchTerms}"/>  
  </Url>  
  <moz:SearchForm>http://code.google.com/intl/it/appengine/docs/</moz:SearchForm>  
</OpenSearchDescription>

1 个答案:

答案 0 :(得分:1)

使用实体&amp;&进行编码,XML有效:

<?xml version="1.0" encoding="UTF-8"?>  
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"  
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">  
  <ShortName>Google AppEngine</ShortName>  
  <Description>Search the GAE documents at Google Code website.</Description>  
  <InputEncoding>UTF-8</InputEncoding>  
  <Image width="16" height="16" type="image/x-icon">data:image/x-icon;base64,25</Image>  
  <Url type="text/html" method="GET" template="http://code.google.com/intl/it/query/#p=appengine&amp;q={searchTerms}"></Url>  
  <moz:SearchForm>http://code.google.com/intl/it/appengine/docs/</moz:SearchForm>  
</OpenSearchDescription>

将此XML复制到http://validator.w3.org/check以确认有效。