fnp
/
wolnelektury.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2d0838e
)
small fixes
author
Marcin Koziej
<marcin.koziej@nowoczesnapolska.org.pl>
Mon, 3 Sep 2012 14:48:59 +0000
(16:48 +0200)
committer
Marcin Koziej
<marcin.koziej@nowoczesnapolska.org.pl>
Mon, 3 Sep 2012 14:48:59 +0000
(16:48 +0200)
apps/catalogue/management/commands/importbooks.py
patch
|
blob
|
history
apps/catalogue/templates/catalogue/book_searched.html
patch
|
blob
|
history
apps/search/custom.py
patch
|
blob
|
history
apps/search/index.py
patch
|
blob
|
history
apps/search/templates/newsearch/search.html
patch
|
blob
|
history
apps/search/templatetags/search_tags.py
patch
|
blob
|
history
diff --git
a/apps/catalogue/management/commands/importbooks.py
b/apps/catalogue/management/commands/importbooks.py
index
93c68a2
..
1f08f7c
100644
(file)
--- a/
apps/catalogue/management/commands/importbooks.py
+++ b/
apps/catalogue/management/commands/importbooks.py
@@
-48,7
+48,6
@@
class Command(BaseCommand):
build_txt=options.get('build_txt'),
build_pdf=options.get('build_pdf'),
build_mobi=options.get('build_mobi'),
build_txt=options.get('build_txt'),
build_pdf=options.get('build_pdf'),
build_mobi=options.get('build_mobi'),
- search_index=options.get('search_index'),
search_index_tags=False)
for ebook_format in Book.ebook_formats:
if os.path.isfile(file_base + '.' + ebook_format):
search_index_tags=False)
for ebook_format in Book.ebook_formats:
if os.path.isfile(file_base + '.' + ebook_format):
diff --git
a/apps/catalogue/templates/catalogue/book_searched.html
b/apps/catalogue/templates/catalogue/book_searched.html
index
a965bfc
..
4ac66fb
100644
(file)
--- a/
apps/catalogue/templates/catalogue/book_searched.html
+++ b/
apps/catalogue/templates/catalogue/book_searched.html
@@
-15,7
+15,13
@@
{% if hit.themes_hit %}
{% inline_tag_list hit.themes_hit %}
{% endif %}
{% if hit.themes_hit %}
{% inline_tag_list hit.themes_hit %}
{% endif %}
- <a href="{{hit.fragment.get_absolute_url}}">{{hit.fragment.text|truncatewords_html:15|safe}}</a>
+ <a href="{{hit.fragment.get_absolute_url}}">
+ {% if hit.snippet %}
+ {{hit.snippet|safe}}
+ {% else %}
+ {{hit.fragment.text|truncatewords_html:15|safe}}
+ {% endif %}
+ </a>
</div>
{% endif %}
{% endif %}
</div>
{% endif %}
{% endif %}
diff --git
a/apps/search/custom.py
b/apps/search/custom.py
index
6cb18fd
..
6c16f22
100644
(file)
--- a/
apps/search/custom.py
+++ b/
apps/search/custom.py
@@
-119,8
+119,8
@@
class CustomSolrInterface(sunburnt.SolrInterface):
if matches:
return self.substring(kwargs['text'], matches,
if matches:
return self.substring(kwargs['text'], matches,
-
margins=kwargs.get('margins', 30),
- mark=kwargs.get('mark', ("<b>", "</b>")))
+ margins=kwargs.get('margins', 30),
+
mark=kwargs.get('mark', ("<b>", "</b>")))
else:
return None
else:
return None
@@
-151,5
+151,6
@@
class CustomSolrInterface(sunburnt.SolrInterface):
snip = snip[:e + off] + mark[1] + snip[e + off:]
snip = snip[:s + off] + mark[0] + snip[s + off:]
# maybe break on word boundaries
snip = snip[:e + off] + mark[1] + snip[e + off:]
snip = snip[:s + off] + mark[0] + snip[s + off:]
# maybe break on word boundaries
+
return snip
return snip
diff --git
a/apps/search/index.py
b/apps/search/index.py
index
5c05ffb
..
557f404
100644
(file)
--- a/
apps/search/index.py
+++ b/
apps/search/index.py
@@
-968,6
+968,7
@@
class Search(SolrIndex):
snips = map(lambda s: s and s.replace("/\n", "\n"), snips)
searchresult.snippets = snips
snips = map(lambda s: s and s.replace("/\n", "\n"), snips)
searchresult.snippets = snips
+
return snips
def hint_tags(self, query, pdcounter=True, prefix=True):
return snips
def hint_tags(self, query, pdcounter=True, prefix=True):
diff --git
a/apps/search/templates/newsearch/search.html
b/apps/search/templates/newsearch/search.html
index
c494ca6
..
635bae8
100644
(file)
--- a/
apps/search/templates/newsearch/search.html
+++ b/
apps/search/templates/newsearch/search.html
@@
-29,11
+29,9
@@
<li>
<p><a href="{{result.book.get_absolute_url}}">{{result.book.pretty_title}}</a> (id: {{result.book_id}}, score: {{result.score}})</p>
<ul>
<li>
<p><a href="{{result.book.get_absolute_url}}">{{result.book.pretty_title}}</a> (id: {{result.book_id}}, score: {{result.score}})</p>
<ul>
- {% for
hit in result.hi
ts %}
+ {% for
snip in hit.snippe
ts %}
<li>
<li>
- {% for snip in hit.3.snippets %}
- {{snip|safe}}<br/>
- {% endfor %}
+ {{snip|safe}}<br/>
</li>
{% endfor %}
</li>
{% endfor %}
diff --git
a/apps/search/templatetags/search_tags.py
b/apps/search/templatetags/search_tags.py
index
b19593e
..
6a2ccad
100644
(file)
--- a/
apps/search/templatetags/search_tags.py
+++ b/
apps/search/templatetags/search_tags.py
@@
-42,7
+42,7
@@
def book_searched(context, result):
for (idx, hit) in hits:
# currently we generate one snipper per hit though.
for (idx, hit) in hits:
# currently we generate one snipper per hit though.
- if
'fragment' in hit
:
+ if
result.snippets[idx] is None
:
continue
snip = result.snippets[idx]
# fix some formattting
continue
snip = result.snippets[idx]
# fix some formattting