/kai/templates/search.mako

https://bitbucket.org/bbangert/kai/ · Mako · 148 lines · 121 code · 27 blank · 0 comment · 3 complexity · abfb4af7e56e20b6da9194315b5325a9 MD5 · raw file

  1. <div class="yui-b content">
  2. <div id="searchcontrol"/>
  3. </div>
  4. </div>
  5. <%def name="styles()">
  6. ${parent.styles()}
  7. <link href="http://www.google.com/uds/css/gsearch.css" type="text/css" rel="stylesheet"/>
  8. <script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0&amp;key=ABQIAAAAgvmgA94hbkqC7kh6JzKluxQQvUAzTIjSyGWv2egO9TxsQcw_PhRfptE4k-DD1r2KrOOojaXEJjVp-Q" type="text/javascript"></script>
  9. <script type="text/javascript">
  10. var fixurl = {update: function (searchControl, searcher, query) {
  11. window.location.hash = encodeURIComponent(query).replace(/%20/g, "+");
  12. }};
  13. function cse() {
  14. // Grab the form element we use
  15. var sFormDiv = document.getElementById("searchcontrol");
  16. // Create a search control
  17. var searchControl = new GSearchControl();
  18. var options;
  19. var searcher;
  20. var cseId = "017012331895443894274:qqjvs4jj_ag";
  21. searcher = new GwebSearch();
  22. options = new GsearcherOptions();
  23. options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
  24. searcher.setSiteRestriction(cseId, null);
  25. searcher.setUserDefinedLabel("Web");
  26. searchControl.addSearcher(searcher, options);
  27. searcher = new GwebSearch();
  28. options = new GsearcherOptions();
  29. options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
  30. searcher.setSiteRestriction(cseId, "IRCLogs");
  31. searcher.setUserDefinedLabel("IRC Logs");
  32. searchControl.addSearcher(searcher, options);
  33. searcher = new GblogSearch();
  34. options = new GsearcherOptions();
  35. searcher.setQueryAddition("pylons python");
  36. searcher.setUserDefinedLabel("Blogs");
  37. searchControl.addSearcher(searcher, options);
  38. // Setup search control settings
  39. searchControl.setSearchStartingCallback(fixurl, fixurl.update)
  40. searchControl.setResultSetSize(GSearch.LARGE_RESULTSET);
  41. var drawOptions = new GdrawOptions();
  42. drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
  43. // Tell the searcher to draw itself and tell it where to attach
  44. searchControl.draw(sFormDiv, drawOptions);
  45. // Execute an inital search, use the existing anchor param if present
  46. var query = decodeURIComponent(location.hash.substring(1).replace(/\+/g, "%20"));
  47. if (query) {
  48. searchControl.execute(query);
  49. } else {
  50. searchControl.execute("wsgi response");
  51. }
  52. }
  53. function OnLoad() {
  54. new cse();
  55. }
  56. GSearch.setOnLoadCallback(OnLoad);
  57. </script>
  58. <style type="text/css">
  59. body #searchcontrol, #searchcontrol p, .gs-snippet {
  60. background-color: white;
  61. font-family: Arial, sans-serif;
  62. font-size: 13px;
  63. }
  64. h1 .tagline,
  65. h1 a,
  66. h1 a .tagline {
  67. font-size : 13px;
  68. font-weight : normal;
  69. color : rgb(9, 122, 182);
  70. cursor : pointer;
  71. text-decoration : none;
  72. }
  73. a span.tagline:hover {
  74. text-decoration : underline;
  75. color : rgb(237, 92, 11);
  76. }
  77. a, a:link, a:visited, a:active {
  78. border-bottom: none;
  79. }
  80. .gsc-control {
  81. width:100%;
  82. max-width: 600px;
  83. }
  84. form .gsc-search-box {
  85. width: 350px;
  86. }
  87. table.gsc-branding {
  88. width: 350px;
  89. }
  90. table.gsc-resultsHeader, div.gsc-blogConfig {
  91. width: 400px;
  92. }
  93. /* disable twiddle and size selectors for left column */
  94. #searchcontrol .gsc-twiddle {
  95. background-image : none;
  96. }
  97. #searchcontrol .gsc-resultsHeader .gsc-title {
  98. padding-left : 0px;
  99. font-weight : bold;
  100. font-size : 14px;
  101. }
  102. #searchcontrol .gsc-resultsHeader {
  103. width: 200px;
  104. }
  105. #searchcontrol .gsc-resultsHeader div.gsc-results-selector {
  106. display : none;
  107. }
  108. #searchcontrol .gsc-resultsRoot {
  109. padding-top : 6px;
  110. }
  111. /* long form visible urls should be on */
  112. .gsc-webResult div.gs-visibleUrl-short {
  113. display: none;
  114. }
  115. .gsc-webResult div.gs-visibleUrl-long {
  116. display: block;
  117. }
  118. </style>
  119. </%def>
  120. <%def name="title()">${parent.title()} - ${_('Search')}</%def>
  121. <%inherit file="/layout.mako" />