Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-wiki
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-wiki
Commits
f8a6e1c3
Commit
f8a6e1c3
authored
Aug 22, 2012
by
benjaoming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Search "optimization".... layout-wise :)
parent
0012481a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
wiki/templates/wiki/search.html
+5
-3
wiki/templatetags/wiki_tags.py
+5
-3
No files found.
wiki/templates/wiki/search.html
View file @
f8a6e1c3
{% extends "wiki/
articl
e.html" %}
{% extends "wiki/
bas
e.html" %}
{% load wiki_tags i18n humanize %}
{% load url from future %}
{% block pagetitle %}{% trans "Search results for:" %} {{ search_query }}{% endblock %}
{% block wiki_contents_tab %}
{% block wiki_contents %}
<h1>
{% trans "Search results for:" %} {{ search_query }}
</h1>
<form
class=
"form-search directory-toolbar"
>
<div
class=
"well well-small"
>
<div
class=
"pull-right"
>
{{ search_form.query }}
</div>
<p>
{% blocktrans with paginator.object_list.count as cnt %}Your search return
<strong>
{{ cnt }}
</strong>
results.{% endblocktrans %}
</p>
<div
class=
"clearfix"
></div>
</div>
</form>
<table
class=
"table table-striped"
>
<tr>
<th
style=
"width: 75%"
>
{% trans "Title" %}
</th>
...
...
wiki/templatetags/wiki_tags.py
View file @
f8a6e1c3
...
...
@@ -72,10 +72,12 @@ def get_content_snippet(content, keyword, max_words=30):
words
=
filter
(
lambda
x
:
x
!=
""
,
striptags
(
m
.
group
(
"after"
))
.
replace
(
"
\n
"
,
" "
)
.
split
(
" "
))
after
=
" "
.
join
(
words
[:
max_words
-
len
(
before_words
)])
before
=
" "
.
join
(
before_words
)
html
=
"
%
s
<strong>
%
s</strong>
%
s"
%
(
before
,
striptags
(
keyword
),
after
)
html
=
"
%
s
%
s
%
s"
%
(
before
,
striptags
(
keyword
),
after
)
kw_p
=
re
.
compile
(
r'(
%
s)'
%
keyword
,
re
.
IGNORECASE
)
html
=
kw_p
.
sub
(
r"<strong>\1</strong>"
,
html
)
html
=
mark_safe
(
html
)
else
:
html
=
" "
.
join
(
filter
(
lambda
x
:
x
!=
""
,
striptags
(
content
)
.
replace
(
"
\n
"
,
" "
)
.
split
(
" "
))[:
max_words
])
return
html
@register.filter
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment