Commits

Gregory Petukhov  committed e6b6d8d

Integrate search

  • Participants
  • Parent commits 61369d2

Comments (0)

Files changed (6)

 
 .env
 var/db
+var/whoosh.db
 static/static
 coverage
 
 
 Note that django-account is used for login/signup in this demo project.
 In your project you can use any login/signup application.
+
+Also haystack and whoosh are used for search. Search component is optional
+and you can disabled it with settings.PYBB_SEARCH_ENABLED. It is disabled by default,
+but enabled in this demo.

File requirements.txt

 -e hg+http://bitbucket.org/lorien/pybb#egg=pybb
 django-account
 django-urlauth
+django-haystack
+whoosh
 
 # tests
 coverage >= 3.0

File search_sites.py

+import haystack
+
+haystack.autodiscover()
     'account',
     'urlauth',
     'django_coverage',
+    'haystack',
 )
 
 # A sample logging configuration. The only tangible logging
 
 # PyBB configuration
 from pybb.settings import *
+PYBB_SEARCH_ENABLED = True
 
 # django-account configuration
 from account.settings import *
 
 # django-coverage configuration
 COVERAGE_REPORT_HTML_OUTPUT_DIR = os.path.join(ROOT, 'coverage')
+
+# haystack configuration
+HAYSTACK_SITECONF = 'search_sites'
+HAYSTACK_SEARCH_ENGINE = 'whoosh'
+HAYSTACK_WHOOSH_PATH = os.path.join(ROOT, 'var', 'whoosh.db')

File templates/base.html

                     <ul id="main-menu">
                         <li><a href="{% url pybb_index %}">Форум</a></li>
                         <li><a href="{% url pybb_user_list %}">Пользователи</a></li>
+                        <li><a href="{% url pybb_post_search %}">Поиск</a></li>
                     </ul>
                     <ul id="profile-menu">
                         {% if user.is_authenticated %}