Changeset 14423 for lang/python

Show
Ignore:
Timestamp:
06/22/08 21:52:08 (5 months ago)
Author:
ayu
Message:
  • added english version.
Location:
lang/python/incsearch/djangoapp
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • lang/python/incsearch/djangoapp/docsearch/templates/docsearch/index.html

    r14402 r14423  
    11<html> 
    22  <head> 
    3 <title>DocSearch</title> 
     3<title>Python Module Search</title> 
    44<script src="/d/static/jquery-1.2.3.pack.js"></script> 
    5 <script src="/d/static/jquery.shortkeys.js" type="text/javascript"></script> 
    65<script src="/d/static/docsearch.js"></script> 
    76</head> 
    87<body onload="loadfunc()"> 
    9 <table border=0> 
    10 <tr><td> 
    11 <h1>DocSearch</h1> 
    12 </td> 
    13 <td> 
     8<img src="/d/static/pythonmodulesearch.gif" border="0"/> 
    149<form name="queryform"> 
    15 <input type="text" id="querybox" name="query" size="30" onkeyup="search(this)"/> <input type="button" value="Search" onclick="search()"/> 
     10Module name, function name, etc...-&gt; <input type="text" id="querybox" name="query" size="30" onkeyup="search(this)"/> 
    1611</form> 
    17 </td> 
    18 </tr> 
    19 </table> 
    2012<table id="tbl"> 
    2113<tr> 
  • lang/python/incsearch/djangoapp/docsearch/urls.py

    r14402 r14423  
    1414    #検索 
    1515    url(r"^s/$", "docsearch.views.search"), 
     16 
     17    #英語版TOPページ 
     18    url(r"^en/$", direct_to_template, {"template": "docsearch/index_en.html"}, 
     19        name="top"), 
     20     
     21    #検索 
     22    url(r"^en/s/$", "docsearch.views.search_en"), 
     23 
    1624    ) 
    1725 
  • lang/python/incsearch/djangoapp/docsearch/views.py

    r14402 r14423  
    77 
    88from incsearch.searcher import find_dangerous 
     9 
     10from settings import DOCSEARCHINDEX, DOCSEARCHINDEX_EN 
    911 
    1012def search(request): 
     
    2022    if len(query) < 2: 
    2123        return returnnone() 
    22     res = find_dangerous("/users/ayu/work/incsearch/testdb", str(query)) 
     24    res = find_dangerous(DOCSEARCHINDEX, str(query)) 
    2325    response.write(json.write(map(lambda x:str(x).split("\t"), res))) 
    2426    return response 
    2527     
     28def search_en(request): 
     29    response = HttpResponse(mimetype="text/javascript")                 
     30 
     31    def returnnone(): 
     32        response.write(json.write(None)) 
     33        return response 
     34    print dir(request) 
     35    if request.method != "GET": 
     36        return returnnone() 
     37    query = request.GET.get("q", "u") 
     38    if len(query) < 2: 
     39        return returnnone() 
     40    res = find_dangerous(DOCSEARCHINDEX_EN, str(query)) 
     41    response.write(json.write(map(lambda x:str(x).split("\t"), res))) 
     42    return response 
     43     
  • lang/python/incsearch/djangoapp/static/docsearch.js

    r14402 r14423  
    4848    eventsetter(); 
    4949    focussetter(); 
     50} 
     51 
     52function search_en(e){ 
     53    var query = document.queryform.query.value; 
     54    if(prevquery == query) return; 
     55    prevquery = query; 
     56    $.ajax({ 
     57            url: "/d/ds/en/s/?q=" + query, 
     58                type: "GET", 
     59                data: {}, 
     60                dataType: "json", 
     61                timeout: 10000, 
     62                error: function(){$("#searchresult").html("error");}, 
     63                success: function(data){ 
     64                if(data){ 
     65                    buf = ""; 
     66                    items = []; 
     67                    $(data).each(function(i){ 
     68                            var item; 
     69                            if(this[2]=="-") 
     70                                item = "/d/static/docsearch/endata/enlib/"+this[1]; 
     71                            else 
     72                                item = "/d/static/docsearch/endata/enlib/"+this[1]+"#incsearch_"+this[2]; 
     73                            items.push(item); 
     74                            buf += "<a href='"+item+"' target='win' id='item_"+i+"'> * " +this[3]+ "</a><br/>"; 
     75                        }); 
     76                    if(items.length == 0){ 
     77                        $("#searchresult").html("Not found."); 
     78                        return; 
     79                    } 
     80                    $("#searchresult").html(buf); 
     81                    if(curdoc != items[0]){ 
     82                        frames["win"].document.location.href=items[0]; 
     83                        curdoc = items[0]; 
     84                    } 
     85                    $("#item_0").css("background-color", "#ccccff"); 
     86                    curpos = 0; 
     87                } 
     88            } 
     89        }); 
    5090} 
    5191