فهرست منبع

[search] Rebase on 2.2

Romain Rigaux 13 سال پیش
والد
کامیت
5d91f99

+ 10 - 109
apps/search/src/search/templates/index.mako

@@ -23,113 +23,12 @@ import math
 
 <%namespace name="macros" file="macros.mako" />
 
-${ commonheader(_('Search'), "search", user) }
+${ commonheader(_('Search'), "search", user) | n,unicode }
 
-<style>
-  .content {
-    margin-left: 58px;
-  }
-
-  .action {
-    margin-right: 5px;
-  }
-
-  .action a, .time a, .account-group, .retweeted {
-    color: #999999;
-  }
-
-  .account-group a {
-    text-decoration: none;
-    font-weight: normal;
-  }
-
-  .username {
-    font-size: 12px;
-  }
-
-  .time {
-    color: #BBBBBB;
-    float: right;
-    margin-top: 1px;
-    position: relative;
-  }
-
-  .avatar {
-    position: absolute;
-    margin-left: -56px!important;
-    margin-top: 4px!important;
-    -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-    -moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-    box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-    -webkit-border-radius: 5px;
-    -moz-border-radius: 5px;
-    border-radius: 5px;
-  }
-
-  .text {
-    margin-bottom: 4px;
-    cursor: pointer;
-  }
-
-  .tweet-actions li {
-    display: inline;
-  }
-
-  .stream-item-footer {
-    font-size: 12px;
-    color: #999999;
-  }
-
-  ul.tweet-actions {
-    list-style: none outside none;
-  }
-
-  ul.tweet-actions {
-    margin: 0;
-    padding: 0;
-  }
-
-  .fullname {
-    color: #333333;
-    font-weight: bold;
-  }
-
-  .stream-item-footer, .retweeted {
-    font-size: 12px;
-    padding-top: 1px;
-  }
-
-  .icon {
-    background-position: 0 0;
-    background-repeat: no-repeat;
-    display: inline-block;
-    vertical-align: text-top;
-    height: 13px;
-    width: 14px;
-    margin-top: 0;
-    margin-left: -2px;
-  }
-  .icon-reply {
-    background-image: url("/search/static/art/reply.png");
-  }
-  .icon-retweet {
-    background-image: url("/search/static/art/retweet.png");
-  }
-  .twitter-logo {
-    background-image: url("/search/static/art/bird_gray_32.png");
-    width: 32px;
-    height: 32px;
-    background-repeat: no-repeat;
-    display: inline-block;
-    vertical-align: top;
-    margin-top: 2px;
-  }
-
-</style>
 
 <div class="container-fluid">
     <div class="row-fluid">
-        %if solr_query['facets'] == 1:
+        % if solr_query['facets'] == 1:
         <div class="span3">
             <div class="well" style="padding: 8px 0;">
             <ul class="nav nav-list">
@@ -193,12 +92,12 @@ ${ commonheader(_('Search'), "search", user) }
             </div>
         </div>
         <div class="span9">
-        %else:
+        % else:
         <div class="span12">
-        %endif
+        % endif
             <form class="form-search well">
                 <i class="twitter-logo"></i>
-                ${ search_form }
+                ${ search_form | n,unicode }
                 <button class="btn" type="submit">${_('Search')}</button>
                 <div class="btn-group pull-right">
                   <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
@@ -229,10 +128,10 @@ ${ commonheader(_('Search'), "search", user) }
                         previous = int(solr_query["start"]) - int(solr_query["rows"])
                         next = int(solr_query["start"]) + int(solr_query["rows"])
                       %>
-                      %if int(solr_query["start"]) > 0:
+                      % if int(solr_query["start"]) > 0:
                         <li><a title="${_('Beginning of List')}" href="?query=${solr_query["q"]}&fq=${solr_query["fq"]}&sort=${solr_query["sort"]}&rows=${solr_query["rows"]}&start=${beginning}">&larr; ${_('Beginning of List')}</a></li>
                         <li><a title="Previous Page" href="?query=${solr_query["q"]}&fq=${solr_query["fq"]}&sort=${solr_query["sort"]}&rows=${solr_query["rows"]}&start=${previous}">${_('Previous Page')}</a></li>
-                      %endif
+                      % endif
                       <li><a title="Next page" href="?query=${solr_query["q"]}&fq=${solr_query["fq"]}&sort=${solr_query["sort"]}&rows=${solr_query["rows"]}&start=${next}">${_('Next Page')}</a></li>
                     </ul>
                     <p>${_('Show')}
@@ -249,6 +148,8 @@ ${ commonheader(_('Search'), "search", user) }
   ${rr}
 </div>
 
+<link rel="stylesheet" href="/search/static/css/search.css">
+
 <script src="/static/ext/js/moment.min.js" type="text/javascript" charset="utf-8"></script>
 <script>
   $(document).ready(function(){
@@ -274,4 +175,4 @@ ${ commonheader(_('Search'), "search", user) }
   });
 </script>
 
-${ commonfooter(messages) }
+${ commonfooter(messages) | n,unicode }

+ 4 - 2
apps/search/src/search/templates/macros.mako

@@ -184,13 +184,15 @@ def escape(text)  :
           </small>
           <a target="_blank" href="https://twitter.com/${ result.get('user_screen_name', '') }" class="account-group">
             <img src="http://twitter.com/api/users/profile_image/${ result.get('user_screen_name', '') }" class="avatar"
-                 data-placement="left" rel="popover"  data-content="Location: ${ result.get('user_location', '') }<br/>User tweets #: ${ result.get('user_statuses_count', '') }<br/>User followers #: ${ result.get('user_followers_count', '') }" title="@${ result.get('user_screen_name', '') }" data-trigger="hover">
+                 data-placement="left" rel="popover"  data-content="Location: ${ result.get('user_location', '') }
+             <br/>User tweets #: ${ result.get('user_statuses_count', '') }
+             <br/>User followers #: ${ result.get('user_followers_count', '') }" title="@${ result.get('user_screen_name', '') }" data-trigger="hover">
             <strong class="fullname">${ result.get('user_name', '') }</strong>
             <span>&rlm;</span><span class="username">@${ result.get('user_screen_name', '') }</span>
           </a>
         </div>
         <div class="text" data-link="https://twitter.com/${ result.get('user_screen_name', '') }/status/${ result.get('id', '') }">
-          ${ parseLinks(result.get('text', '')) }
+          ${ parseLinks(result.get('text', ''))  | n,unicode }
           %if result.get('retweet_count', ''):
               <div class="retweeted">
                 ${_('Retweeted %s times') % result.get('retweet_count', '') }

+ 3 - 7
apps/search/src/search/views.py

@@ -22,12 +22,11 @@ except ImportError:
 import logging
 
 from desktop.lib.django_util import render
-
-from search.forms import QueryForm
 from desktop.lib.exceptions_renderable import PopupException
 from desktop.lib.rest.http_client import HttpClient, RestException
 from desktop.lib.rest.resource import Resource
 
+from search.forms import QueryForm
 
 
 # http://lucene.apache.org/solr/api-4_0_0-BETA/doc-files/tutorial.html#Getting+Started
@@ -85,7 +84,8 @@ class SolrApi(object):
                 ('facet.date', 'created_at'),
                 ('facet.date.start', 'NOW/DAY-305DAYS'),
                 ('facet.date.end', 'NOW/DAY+1DAY'),
-                ('facet.date.gap', '+1DAY'),)
+                ('facet.date.gap', '+1DAY'),
+             )
 
       fqs = solr_query['fq'].split('|')
       for fq in fqs:
@@ -95,7 +95,3 @@ class SolrApi(object):
       return self._root.get('collection1/browse', params)
     except RestException, e:
       raise PopupException('Error while accessing Solr: %s' % e)
-
-
-
-

+ 98 - 0
apps/search/static/css/search.css

@@ -0,0 +1,98 @@
+  .content {
+    margin-left: 58px;
+  }
+
+  .action {
+    margin-right: 5px;
+  }
+
+  .action a, .time a, .account-group, .retweeted {
+    color: #999999;
+  }
+
+  .account-group a {
+    text-decoration: none;
+    font-weight: normal;
+  }
+
+  .username {
+    font-size: 12px;
+  }
+
+  .time {
+    color: #BBBBBB;
+    float: right;
+    margin-top: 1px;
+    position: relative;
+  }
+
+  .avatar {
+    position: absolute;
+    margin-left: -56px!important;
+    margin-top: 4px!important;
+    -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
+    -moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
+    box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
+    -webkit-border-radius: 5px;
+    -moz-border-radius: 5px;
+    border-radius: 5px;
+  }
+
+  .text {
+    margin-bottom: 4px;
+    cursor: pointer;
+  }
+
+  .tweet-actions li {
+    display: inline;
+  }
+
+  .stream-item-footer {
+    font-size: 12px;
+    color: #999999;
+  }
+
+  ul.tweet-actions {
+    list-style: none outside none;
+  }
+
+  ul.tweet-actions {
+    margin: 0;
+    padding: 0;
+  }
+
+  .fullname {
+    color: #333333;
+    font-weight: bold;
+  }
+
+  .stream-item-footer, .retweeted {
+    font-size: 12px;
+    padding-top: 1px;
+  }
+
+  .icon {
+    background-position: 0 0;
+    background-repeat: no-repeat;
+    display: inline-block;
+    vertical-align: text-top;
+    height: 13px;
+    width: 14px;
+    margin-top: 0;
+    margin-left: -2px;
+  }
+  .icon-reply {
+    background-image: url("/search/static/art/reply.png");
+  }
+  .icon-retweet {
+    background-image: url("/search/static/art/retweet.png");
+  }
+  .twitter-logo {
+    background-image: url("/search/static/art/bird_gray_32.png");
+    width: 32px;
+    height: 32px;
+    background-repeat: no-repeat;
+    display: inline-block;
+    vertical-align: top;
+    margin-top: 2px;
+  }