Changeset 3118

Show
Ignore:
Timestamp:
01/21/08 09:26:11 (10 months ago)
Author:
athomas
Message:

More fixes. More features.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trachacksplugin/0.11/trachacks/htdocs/js/trachacks.js

    r2996 r3118  
     1/* Add helpers to tag cloud. */ 
     2var clean_tags = function(tags) { 
     3var split = tags.replace(/^ +| +$/g, '').split(/ +/); 
     4 
     5  split.sort(); 
     6  return split.join(' '); 
     7}; 
     8 
     9/* Highlight tags from the mini-cloud that are in the tags field. */ 
     10var highlight_tags = function() { 
     11var tags = clean_tags($('#tags').attr('value')).split(/ +/); 
     12 
     13  $('#cloud a').each(function() { 
     14    if (tags.indexOf($(this).text()) != -1) { 
     15      $(this).css('background-color', 'yellow'); 
     16    } else { 
     17      $(this).css('background-color', 'transparent'); 
     18    } 
     19  }); 
     20}; 
     21 
    122$(document).ready(function() { 
    223  // Move the label for each field into the hint block. 
     
    5273  } 
    5374 
    54   /* Add helpers to tag cloud. */ 
    55   var clean_tags = function(tags) { 
    56   var split = tags.replace(/^ +| +$/g, '').split(/ +/); 
    57  
    58     split.sort(); 
    59     return split.join(' '); 
    60   }; 
     75  $('#tags').keyup(highlight_tags); 
     76  $('#tags').change(highlight_tags); 
    6177 
    6278  $('#cloud a').click(function() { 
     
    7793  }); 
    7894 
    79   $('#tags').each(function() { 
    80   var tags = clean_tags(this.value).split(/ +/); 
    8195 
    82     $('#cloud a').each(function() { 
    83       if (tags.indexOf($(this).text()) != -1) { 
    84         $(this).css('background-color', 'yellow'); 
    85       } 
    86     }); 
    87   }); 
     96  highlight_tags(); 
     97 
    8898}); 
  • trachacksplugin/0.11/trachacks/templates/hacks_new.html

    r2995 r3118  
    109109                <input tabindex="4" checked="${t == type or None}" type="radio" value="${t}" 
    110110                  id="${t}" name="type"/> 
    111                 <label for="${t}"> 
    112                   <a href="${href.wiki(t)}">${t}</a> 
    113                 </label> 
     111                <nobr> 
     112                  <label for="${t}"> 
     113                    <a href="${href.wiki(t)}">${t}</a> 
     114                  </label> 
     115                </nobr> 
    114116              </py:for> 
    115117            </dd> 
  • trachacksplugin/0.11/trachacks/templates/hacks_view.html

    r2983 r3118  
    1414  <body> 
    1515    <div id="content" class="tags"> 
    16       <form id="query" method="get"> 
     16      <form id="query" method="post"> 
    1717        <div> 
    1818          <input type="text" id="tag-query" name="q" size="40" accesskey="t" 
    1919            value="${query}"/> 
    20           <input type="submit" value="Filter Hacks"/> 
     20          <input type="submit" value="Search Hacks"/> 
     21        </div> 
     22        <div> 
     23          <py:for each="release in releases"> 
     24            <input type="checkbox" name="release" value="${release}" 
     25              checked="${release in selected_releases or None}"/> ${release} 
     26          </py:for> 
    2127        </div> 
    2228        <div py:if="query_error" id="query-error"> 
     
    2430        </div> 
    2531        <div> 
     32          <p> 
     33            <em>This is a full-text search of the content of all hack pages.</em> 
     34          </p> 
     35          <p> 
     36            Showing <strong>${limit_message}</strong> results. 
     37          </p> 
     38          <p><strong>Search help:</strong></p> 
    2639          <ul> 
    27             <li>Showing <strong>${limit_message}</strong> results.</li> 
     40            <li>Use <strong>term1 term2</strong> to match <em>all</em> terms.</li> 
     41            <li><strong>term1 or term2</strong> will match <em>any</em> term.</li> 
     42            <li>Negate a term with <strong>-term1</strong>.</li> 
     43            <li>Group sub-queries with <strong>(term1 or term2)</strong>.</li> 
     44            <li>Quote strings to include special characters.</li> 
    2845          </ul> 
     46          <p> 
     47            eg. <a href="${href('hacks', q='pdf or latex')}">pdf or latex</a> 
     48          </p> 
    2949        </div> 
    3050      </form> 
  • trachacksplugin/0.11/trachacks/web_ui.py

    r2996 r3118  
    3030 
    3131 
    32  
    3332def pluralise(n, word): 
    3433    """Return a (naively) pluralised phrase from a count and a singular 
     
    119118        data['releases'] = releases 
    120119 
    121         hacks = self.fetch_hacks(req, data, types) 
     120        selected_releases = req.args.get('release', set(['0.10', '0.11', 'anyrelease'])) 
     121 
     122        data['selected_releases'] = selected_releases 
     123 
     124        hacks = self.fetch_hacks(req, data, types, selected_releases) 
    122125 
    123126        add_stylesheet(req, 'tags/css/tractags.css') 
     
    203206 
    204207        def cloud_renderer(tag, count, percent): 
     208            self.env.log.debug(percent) 
    205209            return builder.a(tag, href='#', style='font-size: %ipx' % 
    206210                             int(min_px + percent * (max_px - min_px))) 
     
    224228            data['release'] = ['0.11'] 
    225229 
     230        self.env.log.debug('MUPPETS AHOY') 
    226231        return 'hacks_new.html', data, None 
    227232 
     
    256261        return 'hacks_view.html', data, None 
    257262 
    258     def fetch_hacks(self, req, data, types): 
     263    def fetch_hacks(self, req, data, types, releases): 
    259264        """Return a list of hacks in the form 
    260265 
     
    264269        vote_system = VoteSystem(self.env) 
    265270 
    266         tagged = tag_system.query(req, 'realm:wiki (' + ' or '.join(types) + ')') 
     271        query = 'realm:wiki (%s) (%s)' % \ 
     272                (' or '.join(releases), ' or '.join(types)) 
     273        self.env.log.debug(query) 
     274        tagged = tag_system.query(req, query) 
    267275 
    268276        # Limit 
     
    299307        # Rank 
    300308        total_hack_count = len(hacks) 
    301         hacks = sorted(hacks, key=lambda i: -i[0])[:limit] 
     309        hacks = sorted(hacks, key=lambda i: -i[0]) 
     310        remainder = hacks[limit:] 
     311        hacks = hacks[:limit] + random.sample(remainder, 
     312                                              min(limit, len(remainder))) 
    302313 
    303314        # Navigation 
    304315        if len(hacks) >= limit: 
    305             add_ctxtnav(req, builder.a('More', href='?limit=%i&q=%s' % (limit + 10, q))) 
     316            add_ctxtnav(req, builder.a('More', href='?action=more')) 
    306317            limit = len(hacks) 
    307318            data['limit'] = data['limit_message'] = limit 
     
    309320            add_ctxtnav(req, 'More') 
    310321        if q or limit != self.limit: 
    311             add_ctxtnav(req, builder.a('Default', href='?limit=%i' % self.limit)) 
     322            add_ctxtnav(req, builder.a('Default', href='?action=default')) 
    312323        else: 
    313324            add_ctxtnav(req, 'Default') 
    314325        if total_hack_count > limit: 
    315             add_ctxtnav(req, builder.a('All', href='?limit=all&q=' + q)) 
     326            add_ctxtnav(req, builder.a('All', href='?action=all')) 
    316327        else: 
    317328            add_ctxtnav(req, 'All') 
    318329        if limit > 10: 
    319330            limit = min(limit, len(hacks)) 
    320             add_ctxtnav(req, builder.a('Less', href='?limit=%i&q=%s' % (limit - 10 > 0 and limit - 10 or 0, q))) 
     331            add_ctxtnav(req, builder.a('Less', href='?action=less')) 
    321332        else: 
    322333            add_ctxtnav(req, 'Less') 
     
    328339 
    329340class TracHacksAccountManager(HtPasswdStore): 
    330     """ Do some basic validation on new users, and create a new user page. """ 
     341    """Do some basic validation on new users and create a new user page.""" 
    331342    implements(IPasswordStore) 
    332343