Left: | ||
Right: |
OLD | NEW |
---|---|
1 # Copyright: 2012 MoinMoin:CheerXiao | 1 # Copyright: 2012 MoinMoin:CheerXiao |
2 # Copyright: 2003-2013 MoinMoin:ThomasWaldmann | 2 # Copyright: 2003-2013 MoinMoin:ThomasWaldmann |
3 # Copyright: 2011 MoinMoin:AkashSinha | 3 # Copyright: 2011 MoinMoin:AkashSinha |
4 # Copyright: 2011 MoinMoin:ReimarBauer | 4 # Copyright: 2011 MoinMoin:ReimarBauer |
5 # Copyright: 2008 MoinMoin:FlorianKrupicka | 5 # Copyright: 2008 MoinMoin:FlorianKrupicka |
6 # Copyright: 2010 MoinMoin:DiogenesAugusto | 6 # Copyright: 2010 MoinMoin:DiogenesAugusto |
7 # Copyright: 2001 Richard Jones <richard@bizarsoftware.com.au> | 7 # Copyright: 2001 Richard Jones <richard@bizarsoftware.com.au> |
8 # Copyright: 2001 Juergen Hermann <jh@web.de> | 8 # Copyright: 2001 Juergen Hermann <jh@web.de> |
9 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details. | 9 # License: GNU GPL v2 (or any later version), see LICENSE.txt for details. |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 | 45 |
46 from MoinMoin.i18n import _, L_, N_ | 46 from MoinMoin.i18n import _, L_, N_ |
47 from MoinMoin.themes import render_template, contenttype_to_class | 47 from MoinMoin.themes import render_template, contenttype_to_class |
48 from MoinMoin.apps.frontend import frontend | 48 from MoinMoin.apps.frontend import frontend |
49 from MoinMoin.forms import (OptionalText, RequiredText, URL, YourOpenID, YourEma il, | 49 from MoinMoin.forms import (OptionalText, RequiredText, URL, YourOpenID, YourEma il, |
50 RequiredPassword, Checkbox, InlineCheckbox, Select, Names, | 50 RequiredPassword, Checkbox, InlineCheckbox, Select, Names, |
51 Tags, Natural, Hidden, MultiSelect, Enum, Subscripti ons, | 51 Tags, Natural, Hidden, MultiSelect, Enum, Subscripti ons, |
52 validate_name, NameNotValidError) | 52 validate_name, NameNotValidError) |
53 from MoinMoin.items import BaseChangeForm, Item, NonExistent, NameNotUniqueError , FieldNotUniqueError, get_itemtype_specific_tags | 53 from MoinMoin.items import BaseChangeForm, Item, NonExistent, NameNotUniqueError , FieldNotUniqueError, get_itemtype_specific_tags |
54 from MoinMoin.items.content import content_registry | 54 from MoinMoin.items.content import content_registry |
55 from MoinMoin.items.ticket import TicketSearchForm | |
55 from MoinMoin import user, util | 56 from MoinMoin import user, util |
56 from MoinMoin.constants.keys import * | 57 from MoinMoin.constants.keys import * |
57 from MoinMoin.constants.namespaces import * | 58 from MoinMoin.constants.namespaces import * |
58 from MoinMoin.constants.itemtypes import ITEMTYPE_DEFAULT, ITEMTYPE_TICKET, ITEM TYPE_USERPROFILE | 59 from MoinMoin.constants.itemtypes import ITEMTYPE_DEFAULT, ITEMTYPE_TICKET, ITEM TYPE_USERPROFILE |
59 from MoinMoin.constants.chartypes import CHARS_UPPER, CHARS_LOWER | 60 from MoinMoin.constants.chartypes import CHARS_UPPER, CHARS_LOWER |
60 from MoinMoin.constants.contenttypes import * | 61 from MoinMoin.constants.contenttypes import * |
61 from MoinMoin.util import crypto | 62 from MoinMoin.util import crypto |
62 from MoinMoin.util.interwiki import url_for_item, split_fqname, CompositeName | 63 from MoinMoin.util.interwiki import url_for_item, split_fqname, CompositeName |
63 from MoinMoin.search import SearchForm | 64 from MoinMoin.search import SearchForm |
64 from MoinMoin.search.analyzers import item_name_analyzer | 65 from MoinMoin.search.analyzers import item_name_analyzer |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 if time_sorting == "new": | 319 if time_sorting == "new": |
319 facets.append(sorting.FieldFacet("mtime", reverse=True)) | 320 facets.append(sorting.FieldFacet("mtime", reverse=True)) |
320 elif time_sorting == "old": | 321 elif time_sorting == "old": |
321 facets.append(sorting.FieldFacet("mtime", reverse=False)) | 322 facets.append(sorting.FieldFacet("mtime", reverse=False)) |
322 return facets | 323 return facets |
323 | 324 |
324 | 325 |
325 @frontend.route('/+search/<itemname:item_name>', methods=['GET', 'POST']) | 326 @frontend.route('/+search/<itemname:item_name>', methods=['GET', 'POST']) |
326 @frontend.route('/+search', defaults=dict(item_name=u''), methods=['GET', 'POST' ]) | 327 @frontend.route('/+search', defaults=dict(item_name=u''), methods=['GET', 'POST' ]) |
327 def search(item_name): | 328 def search(item_name): |
328 search_form = SearchForm.from_flat(request.values) | 329 if request.args.get('itemtype') == ITEMTYPE_TICKET: |
330 search_form = TicketSearchForm.from_flat(request.values) | |
331 else: | |
332 search_form = SearchForm.from_flat(request.values) | |
329 ajax = True if request.args.get('boolajax') else False | 333 ajax = True if request.args.get('boolajax') else False |
330 valid = search_form.validate() | 334 valid = search_form.validate() |
331 time_sorting = False | 335 time_sorting = False |
332 filetypes = [] | 336 filetypes = [] |
333 if ajax: | 337 if ajax: |
334 query = request.args.get('q') | 338 query = request.args.get('q') |
335 history = request.args.get('history') == "true" | 339 history = request.args.get('history') == "true" |
336 time_sorting = request.args.get('time_sorting') | 340 time_sorting = request.args.get('time_sorting') |
337 filetypes = request.args.get('filetypes') | 341 filetypes = request.args.get('filetypes') |
338 filetypes = filetypes.split(',')[:-1] # To remove the extra u'' at the end of the list | 342 if filetypes: |
343 filetypes = filetypes.split(',')[:-1] # To remove the extra u'' at the end of the list | |
339 else: | 344 else: |
340 query = search_form['q'].value | 345 query = search_form['q'].value |
341 history = bool(request.values.get('history')) | 346 history = bool(request.values.get('history')) |
342 if valid or ajax: | 347 if valid or ajax: |
343 # most fields in the schema use a StandardAnalyzer, it omits fairly freq uently used words | 348 # most fields in the schema use a StandardAnalyzer, it omits fairly freq uently used words |
344 # this finds such words and reports to the user | 349 # this finds such words and reports to the user |
345 analyzer = StandardAnalyzer() | 350 analyzer = StandardAnalyzer() |
346 omitted_words = [token.text for token in analyzer(query, removestops=Fal se) if token.stopped] | 351 omitted_words = [token.text for token in analyzer(query, removestops=Fal se) if token.stopped] |
347 | 352 |
348 idx_name = ALL_REVS if history else LATEST_REVS | 353 idx_name = ALL_REVS if history else LATEST_REVS |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 content_suggestions = [word for word, score in results.key_terms(CON TENT, docs=20, numterms=10)] | 395 content_suggestions = [word for word, score in results.key_terms(CON TENT, docs=20, numterms=10)] |
391 flaskg.clock.stop('search suggestions') | 396 flaskg.clock.stop('search suggestions') |
392 flaskg.clock.start('search render') | 397 flaskg.clock.start('search render') |
393 | 398 |
394 lastword = query.split(' ')[-1] | 399 lastword = query.split(' ')[-1] |
395 word_suggestions = [] | 400 word_suggestions = [] |
396 if len(lastword) > 2: | 401 if len(lastword) > 2: |
397 corrector = searcher.corrector(CONTENT) | 402 corrector = searcher.corrector(CONTENT) |
398 word_suggestions = corrector.suggest(lastword, limit=3) | 403 word_suggestions = corrector.suggest(lastword, limit=3) |
399 if ajax: | 404 if ajax: |
400 html = render_template('ajaxsearch.html', | 405 if request.args.get('itemtype') == ITEMTYPE_TICKET: |
401 results=results, | 406 html = render_template('ticket_ajaxsearch.html', |
sksaurabhkathpalia
2015/05/27 12:24:24
There is no file named ticket_ajaxsearch.html in t
vipul
2015/05/27 12:35:51
sorry, it was a new file, forgot to add it. Includ
| |
402 word_suggestions=u', '.join(word_suggesti ons), | 407 results=results, |
403 name_suggestions=u', '.join(name_suggesti ons), | 408 history=history, |
404 content_suggestions=u', '.join(content_su ggestions), | 409 content_suggestions=u', '.join(conten t_suggestions), |
405 omitted_words=u', '.join(omitted_words), | 410 ) |
406 history=history, | 411 else: |
407 ) | 412 html = render_template('ajaxsearch.html', |
413 results=results, | |
414 word_suggestions=u', '.join(word_sugg estions), | |
415 name_suggestions=u', '.join(name_sugg estions), | |
416 content_suggestions=u', '.join(conten t_suggestions), | |
417 omitted_words=u', '.join(omitted_word s), | |
418 history=history, | |
419 ) | |
408 else: | 420 else: |
409 html = render_template('search.html', | 421 html = render_template('search.html', |
410 results=results, | 422 results=results, |
411 name_suggestions=u', '.join(name_suggesti ons), | 423 name_suggestions=u', '.join(name_suggesti ons), |
412 content_suggestions=u', '.join(content_su ggestions), | 424 content_suggestions=u', '.join(content_su ggestions), |
413 query=query, | 425 query=query, |
414 medium_search_form=search_form, | 426 medium_search_form=search_form, |
415 item_name=item_name, | 427 item_name=item_name, |
416 omitted_words=u', '.join(omitted_words), | 428 omitted_words=u', '.join(omitted_words), |
417 history=history, | 429 history=history, |
(...skipping 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2390 @frontend.route('/+new', methods=['GET', 'POST']) | 2402 @frontend.route('/+new', methods=['GET', 'POST']) |
2391 def new(): | 2403 def new(): |
2392 # TODO: Implement creation of blog entries and ticket items | 2404 # TODO: Implement creation of blog entries and ticket items |
2393 raise NotImplementedError | 2405 raise NotImplementedError |
2394 | 2406 |
2395 | 2407 |
2396 @frontend.errorhandler(404) | 2408 @frontend.errorhandler(404) |
2397 def page_not_found(e): | 2409 def page_not_found(e): |
2398 return render_template('404.html', | 2410 return render_template('404.html', |
2399 item_name=e.description), 404 | 2411 item_name=e.description), 404 |
OLD | NEW |