regex hack to get 2 & 3 letter words to work
authorabki <amirouche.boubekki@gmail.com>
Sun, 19 Jul 2009 15:58:11 +0000 (19 17:58 +0200)
committerabki <amirouche.boubekki@gmail.com>
Sun, 19 Jul 2009 15:58:11 +0000 (19 17:58 +0200)
modified:   models.py
modified:   planet.py
modified:   static/css/layout.css
modified:   templates/ebuildfind/base.html
modified:   templates/ebuildfind/search.html
modified:   views.py

models.py
planet.py
static/css/layout.css
templates/ebuildfind/base.html
templates/ebuildfind/search.html
views.py

index 5f1ee15..0f83e62 100644 (file)
--- a/models.py
+++ b/models.py
@@ -5,7 +5,6 @@ from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic
 
 PUNCTUATION_REGEX = re.compile('[' + re.escape(string.punctuation) + ']')
-FULL_TEXT_MIN_LENGTH = 3
 
 FULL_TEXT_STOP_WORDS = frozenset([
  'a', 'about', 'according', 'accordingly', 'affected', 'affecting', 'after',
@@ -94,6 +93,11 @@ class Searchable(object):
         ctype = ContentType.objects.get_for_model(cls)
         return Index.objects.filter(content__search=query).filter(content_type=ctype)
 
+    @staticmethod
+    def regex(cls, query):
+        ctype = ContentType.objects.get_for_model(cls)
+        return Index.objects.filter(content__regex=query).filter(content_type=ctype)
+
     def index(self):
         return Index.index(self)
 
index 6c9abd5..d6ca3c6 100644 (file)
--- a/planet.py
+++ b/planet.py
@@ -2,8 +2,6 @@ import shelve
 
 from feedcache.cache import Cache
 
-import pdb
-
 from django.template.defaultfilters import truncatewords_html
 from django.utils.encoding import smart_unicode
 
@@ -39,7 +37,7 @@ class Parser:
     """
     
     def __init__(self, url, summary=False):
-       storage = shelve.open(".feedcache")
+       storage = shelve.open("/home/timemachine/.feedcache")
        try :
            fc = Cache(storage)
            self.feed = fc.fetch(url)
index f1c901d..4d9900f 100755 (executable)
@@ -7,7 +7,6 @@ body {
        background: #FFF;\r
        color: #333;\r
        font-size: 11px;\r
-       padding: 50px 0 40px;\r
 }\r
 \r
 h7 { font-size: 11px; font-weight: normal;}\r
@@ -23,6 +22,13 @@ h7 { font-size: 11px; font-weight: normal;}
 /* headings\r
 ----------------------------------------------- */\r
 \r
+#header {\r
+       font-size: 13px;\r
+       background: #5218EC;\r
+       padding: 5px;\r
+       margin-bottom: 50px;\r
+}\r
+\r
 /* search-box\r
 ----------------------------------------------- */\r
 \r
@@ -85,4 +91,5 @@ ul, li {
 \r
 .ebuild .path {\r
     float: left;\r
+    font-weight: bold;\r
 }
\ No newline at end of file
index b20327b..73d45bf 100644 (file)
     <!--[if IE 6]><link rel="stylesheet" type="text/css" href="css/ie6.css" media="screen" /><![endif]-->
     <!--[if IE 7]><link rel="stylesheet" type="text/css"
     href="css/ie.css" media="screen" /><![endif]-->
-    <link rel="stylesheet" href="/static/css/handheld.css" type="text/css" media="handheld" />
+    <link rel="search" type="application/opensearchdescription+xml" title="Search ebuildfind" href="http://www.searchplugins.net/createos.aspx?number=37819"/>
     <meta name="verify-v1" content="Eoz2Hmql/IvlB4zKL5iMhKkJw5oPotgC7Qik72ZkLmI=" >
   </head>
   <body>
     <div class="container_16">
+    <div id="header">
+    
+    </div>
       <div class="clear"></div>
       
       <!-- search box BEGIN -->
            <input type="text" name="q" value="{% block search-value%}{% endblock %}"/> 
            <input type="submit" value="search"/>
          </form>
-         {% block help %}
-         <p>This is a search engine for ebuilds, it looks for the query in the 
-         category, description, application name. Give it a
-         try <a href="http://www.ebuildfind.net/search/?q=%2Bgnome+-extra">now</a>
-         and <a href="http://www.ebuildfind.net/search/?q=ssh">here</a></p>
-         <p><b>3 July 09':</b> The search engine is now supported by
-         Mysql FTS in boolean mode, try this <a href="http://www.ebuildfind.net/search/?q=%2Bgnome+%2Bbluetooth+-media+-nautilus">out</a>.</p>
-         <p><b>28 June 09':</b> Some ebuilds and overlays are missing please 
-         notify me bugs
-         at <a href="mailto:amirouche.boubekki@gmail.com">my email adress</a></p>
-         {% endblock %}
+         <div>
+         </div>
        </div>
       </div>
       <div class="clear"></div>
       <!-- search box END -->
       
       <!-- result box BEGIN -->
-      <div class="grid_16" id="results">
+      <div class="grid_12" id="results">
        {% block results %}{% endblock %}
       </div>
+      <div class="grid_4">
+       {% block adv %}{% endblock %}
+      </div>
       <div class="clear"></div>
       <!-- result box END -->
       
       </div>
       <div class="grid_4">
        <div>
-         <h2><a href="{GGoogle.GetLink}}">Google News</a></h2>
+         <h2><a href="{{identica.GetLink}}">Identi.ca community</a></h2>
          <div>
-
-           {% for post in GGoogle %}
+         <p>Check out <a href="http://identi.ca/ebuildfind/all">ebuildfind@identi.ca</a></p>
+           {% for post in identica %}
            <div class="post">
              <h6><a href="{{post.link}}">{{ post.title }}</a></h6>
              <div>{{ post.content|safe }}</div>
       </div>
       <div class="clear"></div>
       <div class="grid_16" id="bottom" >
+      <div>
+      {% block advbottom %}
+      {% endblock %}
+      </div>
        <p>"Gentoo" and "G" logo are the property of Gentoo
        Foundation, Inc.</p>
        <p>This website is made
          with <a href="http://www.djangoproject.com">
-           django</a> and <a href="http://www.whoosh.ca">whoosh</a>
-         hosted by <a href="http://www.alwaysdata.com">alwaysdata.com</a></p>
+           django</a> and mysql FTS hosted by 
+           <a href="http://www.alwaysdata.com">alwaysdata.com</a></p>
       </div>
       <div class="clear"></div>
 <script type="text/javascript">
index 45c3dd4..fad7d27 100644 (file)
   <li>
     <div class="ebuild">
       <ul>
-       <li class="path">{{result.content_object.path}}</li>
+       <li class="path">{{result.content_object.path}}</li>
        <li class="homepage"><a href="{{result.content_object.homepage}}">homepage</a></li>
        <div class="clear"></div>
        <li class="homepage"><a href="{{result.content_object.overlay.link}}">overlay
        homepage</a></li>
        <div class="clear"></div>
        {% if result.content_object.keywords %}
-       <li class="keywords">{{result.content_object.keywords}}</li>
+       <li class="keywords">keywords: {{result.content_object.keywords}}</li>
        {% endif %}
        {% if result.content_object.iuse %}
-       <li class="iuse">{{result.content_object.iuse}}</li>
+       <li class="iuse">iuse: {{result.content_object.iuse}}</li>
        {% endif %}
-       <li class="license">{{result.content_object.license}}</li>
+       <li class="license">license: {{result.content_object.license}}</li>
        <li class="description">{{result.content_object.description}}</li>
       </ul>
     </div>
+<div>
+</div>
   </li>
   {% endfor %}
 </ul>
 {% endblock %}
 
 {% block info %}{% endblock %}
+
+{% block adv %}
+<script type="text/javascript"><!--
+google_ad_client = "pub-0927432803901546";
+/* 160x600, created 7/3/09 */
+google_ad_slot = "9086314390";
+google_ad_width = 160;
+google_ad_height = 600;
+//-->
+</script>
+<script type="text/javascript"
+src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+{% endblock %}
+
+{% block advbottom %}
+<script type="text/javascript"><!--
+google_ad_client = "pub-0927432803901546";
+/* 728x15, created 7/3/09 */
+google_ad_slot = "9597050601";
+google_ad_width = 728;
+google_ad_height = 15;
+//-->
+</script>
+<script type="text/javascript"
+src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+{% endblock %}
\ No newline at end of file
index d10edcf..0317b71 100644 (file)
--- a/views.py
+++ b/views.py
@@ -12,15 +12,15 @@ def index(request):
     GPlanet = Parser("http://planet.gentoo.org/atom.xml")
     GOverlays = Parser("http://overlays.gentoo.org/rss20.xml")
     GNews = Parser("http://www.gentoo.org/rdf/en/gentoo-news.rdf")
-    GGoogle = Parser("http://news.google.fr/news?pz=1&ned=us&hl=en&q=gentoo+AND+(linux+OR+OS+OR+Operating+System+OR+GNU)&output=rss")  
+    identica = Parser("https://identi.ca/api/laconica/groups/timeline/gentoo.atom")
 
     response = dict()
     
-    response['GGoogle'] = GGoogle
+    response['identica'] = identica
     response['GNews'] = GNews
     response['GOverlays'] = GOverlays
     response['GPlanet'] = GPlanet
-    
+
     return render_to_response("ebuildfind/index.html", response)
 
 
@@ -39,12 +39,19 @@ def search(request):
             query = PUNCTUATION_REGEX.sub(' ', query)
         except:
             pass
-    
-    if(len(query)>2):
+
+    if(len(query)>3):
         response["error"] = False
         response["query"] = query
         results = Ebuild.search(Ebuild, query)
         response["results"] = results
         response["nb"] = len(results)
-            
+        
+    elif len(query) in (2, 3):
+        response["error"] = False
+        response["query"] = query
+        results = Ebuild.regex(Ebuild, query)
+        response["results"] = results
+        response["nb"] = len(results)
+
     return render_to_response("ebuildfind/search.html", response)