from migdal import app_settings
+
class Category(models.Model):
taxonomy = models.CharField(_('taxonomy'), max_length=32,
choices=app_settings.TAXONOMIES)
--- /dev/null
+from django.conf import settings
+import datetime
+from haystack import indexes
+from migdal.models import Entry
+
+from copy import copy
+
+
+class EntryIndex(indexes.SearchIndex, indexes.Indexable):
+ date = indexes.DateTimeField(indexed=True, model_attr="date")
+ author = indexes.CharField(model_attr="author")
+
+ def get_model(self):
+ return Entry
+
+ def index_queryset(self):
+ """Used when the entire index for model is updated."""
+ return self.get_model().objects.filter(date__lte=datetime.datetime.now())
+
+
+def add_translatable(index_class, fields, languages=None):
+ """Adds some translatable fields to a search index, and a getter."""
+ if languages is None:
+ languages = settings.LANGUAGES
+ for name, field in fields.items():
+ for lang_code, lang_name in languages:
+ new_field = copy(field)
+ fname = "%s_%s" % (name, lang_code)
+ new_field.index_fieldname = fname
+ new_field.model_attr = fname
+ setattr(index_class, fname, new_field)
+ index_class.fields[fname] = new_field
+
+
+add_translatable(EntryIndex, {
+ 'title': indexes.CharField(indexed=True, document=False),
+ 'lead': indexes.CharField(indexed=True, document=False),
+ 'body': indexes.CharField(indexed=True, document=False)
+ })
+
+
+getattr(EntryIndex, "body_%s" % settings.LANGUAGE_CODE).document = True
--- /dev/null
+{% extends "base.html" %}
+{% load url from future %}
+{% load i18n %}
+{% load migdal_tags %}
+
+
+{% block "body" %}
+<h1>{% trans "Search results" %}</h1>
+
+{% for result in page.object_list %}
+{% entry_short result.object %}
+{% empty %}
+<p>{% trans "No results found." %}</p>
+{% endfor %}
+
+{% if page.has_previous or page.has_next %}
+<div>
+ {% if page.has_previous %}<a href="?q={{ query }}&page={{ page.previous_page_number }}">{% endif %}{% trans "« Previous" %}{% if page.has_previous %}</a>{% endif %}
+ |
+ {% if page.has_next %}<a href="?q={{ query }}&page={{ page.next_page_number }}">{% endif %}{% trans "Next »" %}{% if page.has_next %}</a>{% endif %}
+</div>
+{% else %}
+{# Show some example queries to run, maybe query syntax, something else? #}
+{% endif %}
+{% endblock "body" %}
'django.contrib.comments',
'django_comments_xtd',
'pipeline',
+ 'haystack',
'pagination',
'sorl.thumbnail',
--- /dev/null
+HAYSTACK_CONNECTIONS = {
+ 'default': {
+ 'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
+ 'URL': 'http://127.0.0.1:8983/solr/prawokultury'
+ },
+}
+
+from django.conf import settings
+HAYSTACK_DOCUMENT_FIELD = "body_%s" % settings.LANGUAGE_CODE
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
+ url(r'^search/', include('haystack.urls')),
) + i18n_patterns('',
url(string_concat(r'^', _('events'), r'/'), include('events.urls')),
url(r'^comments/', include('django_comments_xtd.urls')),
}),
)
-urlpatterns += staticfiles_urlpatterns()
\ No newline at end of file
+urlpatterns += staticfiles_urlpatterns()
django-gravatar
django_comments_xtd
django-pipeline>=1.2,<1.3
+
#pyScss
#git+git://github.com/Kronuz/pyScss.git@d8f4da23a3c87696a75b3830ed4ab49b75550a93#egg=pyScss
#TODO: pyScss support, for now just install sass
+
+-e git+https://github.com/toastdriven/django-haystack.git@master#egg=django-haystack
+pysolr
--- /dev/null
+#!/bin/bash
+
+ROOT=$(git rev-parse --show-toplevel)
+
+find $ROOT -name '*.py' | xargs etags -o ${ROOT}/TAGS
+if [ -n "$VIRTUAL_ENV" ]; then
+ find ${VIRTUAL_ENV}/lib -name '*.py' |xargs etags -a -o ${ROOT}/TAGS
+else
+ echo "No Virtual env enabled, will not add it to TAGS"
+fi
+
+find $ROOT/prawokultury/static/css -name '*.css' |xargs etags -a -o ${ROOT}/TAGS
+#find $ROOT/prawokultury/static/js -name '*.js' |xargs etags -a -o ${ROOT}/TAGS