Changeset 3118
- Timestamp:
- 01/21/08 09:26:11 (10 months ago)
- Files:
-
- trachacksplugin/0.11/trachacks/htdocs/js/trachacks.js (modified) (3 diffs)
- trachacksplugin/0.11/trachacks/templates/hacks_new.html (modified) (1 diff)
- trachacksplugin/0.11/trachacks/templates/hacks_view.html (modified) (2 diffs)
- trachacksplugin/0.11/trachacks/web_ui.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trachacksplugin/0.11/trachacks/htdocs/js/trachacks.js
r2996 r3118 1 /* Add helpers to tag cloud. */ 2 var clean_tags = function(tags) { 3 var 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. */ 10 var highlight_tags = function() { 11 var 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 1 22 $(document).ready(function() { 2 23 // Move the label for each field into the hint block. … … 52 73 } 53 74 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); 61 77 62 78 $('#cloud a').click(function() { … … 77 93 }); 78 94 79 $('#tags').each(function() {80 var tags = clean_tags(this.value).split(/ +/);81 95 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 88 98 }); trachacksplugin/0.11/trachacks/templates/hacks_new.html
r2995 r3118 109 109 <input tabindex="4" checked="${t == type or None}" type="radio" value="${t}" 110 110 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> 114 116 </py:for> 115 117 </dd> trachacksplugin/0.11/trachacks/templates/hacks_view.html
r2983 r3118 14 14 <body> 15 15 <div id="content" class="tags"> 16 <form id="query" method=" get">16 <form id="query" method="post"> 17 17 <div> 18 18 <input type="text" id="tag-query" name="q" size="40" accesskey="t" 19 19 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> 21 27 </div> 22 28 <div py:if="query_error" id="query-error"> … … 24 30 </div> 25 31 <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> 26 39 <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> 28 45 </ul> 46 <p> 47 eg. <a href="${href('hacks', q='pdf or latex')}">pdf or latex</a> 48 </p> 29 49 </div> 30 50 </form> trachacksplugin/0.11/trachacks/web_ui.py
r2996 r3118 30 30 31 31 32 33 32 def pluralise(n, word): 34 33 """Return a (naively) pluralised phrase from a count and a singular … … 119 118 data['releases'] = releases 120 119 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) 122 125 123 126 add_stylesheet(req, 'tags/css/tractags.css') … … 203 206 204 207 def cloud_renderer(tag, count, percent): 208 self.env.log.debug(percent) 205 209 return builder.a(tag, href='#', style='font-size: %ipx' % 206 210 int(min_px + percent * (max_px - min_px))) … … 224 228 data['release'] = ['0.11'] 225 229 230 self.env.log.debug('MUPPETS AHOY') 226 231 return 'hacks_new.html', data, None 227 232 … … 256 261 return 'hacks_view.html', data, None 257 262 258 def fetch_hacks(self, req, data, types ):263 def fetch_hacks(self, req, data, types, releases): 259 264 """Return a list of hacks in the form 260 265 … … 264 269 vote_system = VoteSystem(self.env) 265 270 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) 267 275 268 276 # Limit … … 299 307 # Rank 300 308 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))) 302 313 303 314 # Navigation 304 315 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')) 306 317 limit = len(hacks) 307 318 data['limit'] = data['limit_message'] = limit … … 309 320 add_ctxtnav(req, 'More') 310 321 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')) 312 323 else: 313 324 add_ctxtnav(req, 'Default') 314 325 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')) 316 327 else: 317 328 add_ctxtnav(req, 'All') 318 329 if limit > 10: 319 330 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')) 321 332 else: 322 333 add_ctxtnav(req, 'Less') … … 328 339 329 340 class 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.""" 331 342 implements(IPasswordStore) 332 343
