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
60c83ee3
Commit
60c83ee3
authored
Aug 22, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:benjaoming/django-wiki
parents
a558ea65
d9518ea8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
28 deletions
+54
-28
django_notify/models.py
+1
-0
django_notify/urls.py
+7
-5
django_notify/views.py
+9
-4
wiki/plugins/notifications/static/wiki/plugins/notifications/js/ui.js
+7
-3
wiki/plugins/notifications/templates/wiki/plugins/notifications/menubaritem.html
+9
-7
wiki/templates/wiki/base.html
+8
-1
wiki/templates/wiki/search.html
+8
-5
wiki/templatetags/wiki_tags.py
+5
-3
No files found.
django_notify/models.py
View file @
60c83ee3
...
...
@@ -100,3 +100,4 @@ class Notification(models.Model):
db_table
=
settings
.
DB_TABLE_PREFIX
+
'_notification'
verbose_name
=
_
(
u'notification'
)
verbose_name_plural
=
_
(
u'notifications'
)
ordering
=
(
'-id'
,)
django_notify/urls.py
View file @
60c83ee3
...
...
@@ -2,11 +2,13 @@
from
django.conf.urls.defaults
import
patterns
,
url
urlpatterns
=
patterns
(
''
,
url
(
'^json/get/$'
,
'django_notify.views.get_notifications'
,
name
=
'json_get'
,
kwargs
=
{}),
url
(
'^json/mark-read/$'
,
'django_notify.views.mark_read'
,
name
=
'json_mark_read_base'
,
kwargs
=
{}),
url
(
'^json/mark-read/(
\
d+)/$'
,
'django_notify.views.mark_read'
,
name
=
'json_mark_read'
,
kwargs
=
{}),
url
(
'^goto/(?P<notification_id>
\
d+)/$'
,
'django_notify.views.goto'
,
name
=
'goto'
,
kwargs
=
{}),
url
(
'^goto/$'
,
'django_notify.views.goto'
,
name
=
'goto_base'
,
kwargs
=
{}),
url
(
'^json/get/$'
,
'django_notify.views.get_notifications'
,
name
=
'json_get'
),
url
(
'^json/get/(?P<latest_id>
\
d+)/$'
,
'django_notify.views.get_notifications'
,
name
=
'json_get'
),
url
(
'^json/mark-read/$'
,
'django_notify.views.mark_read'
,
name
=
'json_mark_read_base'
),
url
(
'^json/mark-read/(
\
d+)/$'
,
'django_notify.views.mark_read'
,
name
=
'json_mark_read'
),
url
(
'^json/mark-read/(?P<id_lte>
\
d+)/(?P<id_gte>
\
d+)/$'
,
'django_notify.views.mark_read'
,
name
=
'json_mark_read'
),
url
(
'^goto/(?P<notification_id>
\
d+)/$'
,
'django_notify.views.goto'
,
name
=
'goto'
),
url
(
'^goto/$'
,
'django_notify.views.goto'
,
name
=
'goto_base'
),
)
def
get_pattern
(
app_name
=
"notify"
,
namespace
=
"notify"
):
...
...
django_notify/views.py
View file @
60c83ee3
...
...
@@ -15,10 +15,11 @@ def get_notifications(request, latest_id=None, is_viewed=False, max_results=10):
notifications
=
notifications
.
filter
(
is_viewed
=
is_viewed
)
if
not
latest_id
is
None
:
notifications
=
notifications
.
filter
(
latest_
id__gt
=
latest_id
)
notifications
=
notifications
.
filter
(
id__gt
=
latest_id
)
notifications
=
notifications
.
order_by
(
'-id'
)
notifications
=
notifications
.
prefetch_related
(
'subscription'
)
notifications
=
notifications
[:
max_results
]
notifications
=
notifications
[:
max_results
]
from
django.contrib.humanize.templatetags.humanize
import
naturaltime
...
...
@@ -45,14 +46,17 @@ def goto(request, notification_id=None):
@login_required_ajax
@json_view
def
mark_read
(
request
,
up_to_id
,
notification_type_id
=
None
):
def
mark_read
(
request
,
id_lte
,
notification_type_id
=
None
,
id_gte
=
None
):
notifications
=
models
.
Notification
.
objects
.
filter
(
subscription__settings__user
=
request
.
user
,
id__lte
=
up_to_id
)
id__lte
=
id_lte
)
if
notification_type_id
:
notifications
=
notifications
.
filter
(
notification_type__id
=
notification_type_id
)
if
id_gte
:
notifications
=
notifications
.
filter
(
id__gte
=
id_gte
)
notifications
.
update
(
is_viewed
=
True
)
return
{
'success'
:
True
}
\ No newline at end of file
wiki/plugins/notifications/static/wiki/plugins/notifications/js/ui.js
View file @
60c83ee3
notify_oldest_id
=
0
;
notify_latest_id
=
0
;
notify_update_timeout
=
30000
;
notify_update_timeout_adjust
=
1.2
;
// factor to adjust between each timeout.
function
notify_update
()
{
jsonWrapper
(
URL_NOTIFY_GET_NEW
,
function
(
data
)
{
jsonWrapper
(
URL_NOTIFY_GET_NEW
+
notify_latest_id
+
'/'
,
function
(
data
)
{
if
(
data
.
success
)
{
$
(
'.notification-cnt'
).
html
(
data
.
objects
.
length
);
if
(
data
.
objects
.
length
>
0
)
{
...
...
@@ -12,9 +13,10 @@ function notify_update() {
}
else
{
$
(
'.notification-cnt'
).
removeClass
(
'badge-important'
);
}
for
(
var
i
=
0
;
i
<
data
.
objects
.
length
;
i
++
)
{
for
(
var
i
=
data
.
objects
.
length
-
1
;
i
>=
0
;
i
--
)
{
n
=
data
.
objects
[
i
];
notify_latest_id
=
n
.
pk
>
notify_latest_id
?
n
.
pk
:
notify_latest_id
;
notify_oldest_id
=
(
n
.
pk
<
notify_oldest_id
||
notify_oldest_id
==
0
)
?
n
.
pk
:
notify_oldest_id
;
$
(
'.notification-li-container'
).
prepend
(
$
(
'<li><a href="'
+
URL_NOTIFY_GOTO
+
n
.
pk
+
'/"><div>'
+
n
.
message
+
'</div><div class="since">'
+
n
.
since
+
'</div></a></li>'
))
}
}
...
...
@@ -23,7 +25,9 @@ function notify_update() {
function
notify_mark_read
()
{
$
(
'.notification-li-container'
).
empty
();
url
=
URL_NOTIFY_MARK_READ
+
notify_latest_id
+
'/'
;
url
=
URL_NOTIFY_MARK_READ
+
notify_latest_id
+
'/'
+
notify_oldest_id
+
'/'
;
notify_oldest_id
=
0
;
notify_latest_id
=
0
;
jsonWrapper
(
url
,
function
(
data
)
{
if
(
data
.
success
)
{
notify_update
();
...
...
wiki/plugins/notifications/templates/wiki/plugins/notifications/menubaritem.html
View file @
60c83ee3
{% load i18n sekizai_tags %}
<script
type=
"text/javascript"
>
URL_NOTIFY_GET_NEW
=
"{% url notify:json_get %}"
;
URL_NOTIFY_MARK_READ
=
"{% url notify:json_mark_read_base %}"
;
URL_NOTIFY_GOTO
=
"{% url notify:goto_base %}"
;
</script>
<script
type=
"text/javascript"
src=
"{{ STATIC_URL }}wiki/plugins/notifications/js/ui.js"
></script>
{% comment %}
<li
class=
"dropdown"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
...
...
@@ -20,3 +14,11 @@
</ul>
</li>
{% endcomment %}
{% load i18n sekizai_tags %}
<script
type=
"text/javascript"
>
URL_NOTIFY_GET_NEW
=
"{% url notify:json_get %}"
;
URL_NOTIFY_MARK_READ
=
"{% url notify:json_mark_read_base %}"
;
URL_NOTIFY_GOTO
=
"{% url notify:goto_base %}"
;
</script>
<script
type=
"text/javascript"
src=
"{{ STATIC_URL }}wiki/plugins/notifications/js/ui.js"
></script>
wiki/templates/wiki/base.html
View file @
60c83ee3
...
...
@@ -118,7 +118,7 @@
{% include "wiki/plugins/notifications/menubaritem.html" %}
<li
class=
"dropdown"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
<span
class=
"
icon-user"
>
</span>
<span
class=
"
badge notification-cnt"
>
0
</span>
{{ user }}
<b
class=
"caret"
></b>
</a>
...
...
@@ -129,6 +129,13 @@
{% trans "Log out" %}
</a>
</li>
<li
class=
"divider"
></li>
<div
class=
"notification-list"
>
<div
class=
"notification-li-container"
></div>
<li
class=
"notifications-empty"
><a
href=
"#"
><em>
{% trans "No notifications" %}
</em></a></li>
<li
class=
"divider"
></li>
<li><a
href=
"#"
onclick=
"notify_mark_read()"
>
{% trans "Clear notifications list" %}
</a></li>
</div>
</ul>
</li>
</ul>
...
...
wiki/templates/wiki/search.html
View file @
60c83ee3
{% 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
class=
"page-header"
>
{% trans "Search results for:" %} {{ search_query }}
</h1>
<form
class=
"form-search directory-toolbar"
>
<
div
class=
"well well-small
"
>
<
p
class=
"lead
"
>
<div
class=
"pull-right"
>
{{ search_form.query }}
<button
class=
"btn"
><span
class=
"icon-search"
></span></button>
</div>
<p>
{% blocktrans with paginator.object_list.count as cnt %}Your search returned
<strong>
{{ cnt }}
</strong>
results.{% endblocktrans %}
</p>
<div
class=
"clearfix"
></div>
</
div
>
</
p
>
</form>
<table
class=
"table table-striped"
>
<tr>
<th
style=
"width: 75%"
>
{% trans "Title" %}
</th>
...
...
wiki/templatetags/wiki_tags.py
View file @
60c83ee3
...
...
@@ -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