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
e5cbdf45
Commit
e5cbdf45
authored
Sep 27, 2013
by
benjaoming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:benjaoming/django-wiki
parents
aca44f09
51019fcc
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
63 additions
and
44 deletions
+63
-44
wiki/plugins/images/templates/wiki/plugins/images/index.html
+1
-1
wiki/plugins/images/templates/wiki/plugins/images/purge.html
+1
-1
wiki/plugins/images/templates/wiki/plugins/images/render.html
+1
-1
wiki/plugins/images/templates/wiki/plugins/images/revision_add.html
+1
-1
wiki/plugins/images/templates/wiki/plugins/images/sidebar.html
+1
-1
wiki/plugins/images/templatetags/wiki_thumbnails.py
+1
-0
wiki/templates/wiki/create_root.html
+1
-1
wiki/urls.py
+6
-6
wiki/views/article.py
+50
-32
No files found.
wiki/plugins/images/templates/wiki/plugins/images/index.html
View file @
e5cbdf45
{% extends "wiki/article.html" %}
{% extends "wiki/article.html" %}
{% load wiki_tags i18n humanize
thumbnail
%}
{% load wiki_tags i18n humanize
wiki_thumbnails
%}
{% load url from future %}
{% load url from future %}
{% block wiki_pagetitle %}{% trans "Images" %}: {{ article.current_revision.title }}{% endblock %}
{% block wiki_pagetitle %}{% trans "Images" %}: {{ article.current_revision.title }}{% endblock %}
...
...
wiki/plugins/images/templates/wiki/plugins/images/purge.html
View file @
e5cbdf45
{% extends "wiki/article.html" %}
{% extends "wiki/article.html" %}
{% load wiki_tags i18n humanize
thumbnail
%}
{% load wiki_tags i18n humanize
wiki_thumbnails
%}
{% load url from future %}
{% load url from future %}
{% block wiki_pagetitle %}{% trans "Purge deletion" %}: {{ image }}{% endblock %}
{% block wiki_pagetitle %}{% trans "Purge deletion" %}: {{ image }}{% endblock %}
...
...
wiki/plugins/images/templates/wiki/plugins/images/render.html
View file @
e5cbdf45
{% load
thumbnail
i18n %}{% comment %}
{% load
wiki_thumbnails
i18n %}{% comment %}
This template is used for the markdown extension that renders images and captions.
This template is used for the markdown extension that renders images and captions.
NB! Watch out for line breaks, markdown might add
<br
/>
s and
<p>
s.
NB! Watch out for line breaks, markdown might add
<br
/>
s and
<p>
s.
...
...
wiki/plugins/images/templates/wiki/plugins/images/revision_add.html
View file @
e5cbdf45
{% extends "wiki/article.html" %}
{% extends "wiki/article.html" %}
{% load wiki_tags i18n humanize
thumbnail
%}
{% load wiki_tags i18n humanize
wiki_thumbnails
%}
{% load url from future %}
{% load url from future %}
{% block wiki_pagetitle %}{% trans "Replace image" %}: {{ image }}{% endblock %}
{% block wiki_pagetitle %}{% trans "Replace image" %}: {{ image }}{% endblock %}
...
...
wiki/plugins/images/templates/wiki/plugins/images/sidebar.html
View file @
e5cbdf45
{% load i18n wiki_tags wiki_images_tags humanize
thumbnail
sekizai_tags %}
{% load i18n wiki_tags wiki_images_tags humanize
wiki_thumbnails
sekizai_tags %}
{% load url from future %}
{% load url from future %}
{% addtoblock "js" %}
{% addtoblock "js" %}
...
...
wiki/plugins/images/templatetags/wiki_thumbnails.py
0 → 100644
View file @
e5cbdf45
from
sorl.thumbnail.templatetags.thumbnail
import
register
wiki/templates/wiki/create_root.html
View file @
e5cbdf45
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
<h2
class=
"page-header"
>
{% trans "Root article" %}
</h2>
<h2
class=
"page-header"
>
{% trans "Root article" %}
</h2>
<form
method=
"POST"
class=
"form-horizontal"
>
<form
method=
"POST"
class=
"form-horizontal"
>
{% wiki_form
create_
form %}
{% wiki_form form %}
<div
class=
"form-group form-actions"
>
<div
class=
"form-group form-actions"
>
<div
class=
"col-lg-2"
></div>
<div
class=
"col-lg-2"
></div>
<div
class=
"col-lg-10"
>
<div
class=
"col-lg-10"
>
...
...
wiki/urls.py
View file @
e5cbdf45
...
@@ -6,6 +6,7 @@ from wiki.core.plugins import registry
...
@@ -6,6 +6,7 @@ from wiki.core.plugins import registry
from
wiki.views
import
article
,
accounts
from
wiki.views
import
article
,
accounts
from
wiki.core.utils
import
get_class_from_str
from
wiki.core.utils
import
get_class_from_str
class
WikiURLPatterns
(
object
):
class
WikiURLPatterns
(
object
):
'''
'''
configurator for wiki urls.
configurator for wiki urls.
...
@@ -27,10 +28,9 @@ class WikiURLPatterns(object):
...
@@ -27,10 +28,9 @@ class WikiURLPatterns(object):
article_settings_view_class
=
article
.
Settings
article_settings_view_class
=
article
.
Settings
article_source_view_class
=
article
.
Source
article_source_view_class
=
article
.
Source
article_plugin_view_class
=
article
.
Plugin
article_plugin_view_class
=
article
.
Plugin
revision_change_view
=
'wiki.views.article.change_revision'
revision_change_view
=
article
.
ChangeRevisionView
revision_merge_view
=
'wiki.views.article.merge'
revision_merge_view
=
'wiki.views.article.merge'
create_root
=
'wiki.views.article.root_create'
search_view_class
=
settings
.
SEARCH_VIEW
search_view_class
=
settings
.
SEARCH_VIEW
article_diff_view
=
'wiki.views.article.diff'
article_diff_view
=
'wiki.views.article.diff'
...
@@ -54,7 +54,7 @@ class WikiURLPatterns(object):
...
@@ -54,7 +54,7 @@ class WikiURLPatterns(object):
def
get_root_urls
(
self
):
def
get_root_urls
(
self
):
urlpatterns
=
patterns
(
''
,
urlpatterns
=
patterns
(
''
,
url
(
'^$'
,
self
.
article_view_class
.
as_view
(),
name
=
'root'
,
kwargs
=
{
'path'
:
''
}),
url
(
'^$'
,
self
.
article_view_class
.
as_view
(),
name
=
'root'
,
kwargs
=
{
'path'
:
''
}),
url
(
'^create-root/$'
,
self
.
create_root
,
name
=
'root_create'
),
url
(
'^create-root/$'
,
article
.
CreateRootView
.
as_view
()
,
name
=
'root_create'
),
url
(
'^_search/$'
,
get_class_from_str
(
self
.
search_view_class
)
.
as_view
(),
name
=
'search'
),
url
(
'^_search/$'
,
get_class_from_str
(
self
.
search_view_class
)
.
as_view
(),
name
=
'search'
),
url
(
'^_revision/diff/(?P<revision_id>
\
d+)/$'
,
self
.
article_diff_view
,
name
=
'diff'
),
url
(
'^_revision/diff/(?P<revision_id>
\
d+)/$'
,
self
.
article_diff_view
,
name
=
'diff'
),
)
)
...
@@ -71,7 +71,7 @@ class WikiURLPatterns(object):
...
@@ -71,7 +71,7 @@ class WikiURLPatterns(object):
def
get_revision_urls
(
self
):
def
get_revision_urls
(
self
):
urlpatterns
=
patterns
(
''
,
urlpatterns
=
patterns
(
''
,
# This one doesn't work because it don't know where to redirect after...
# This one doesn't work because it don't know where to redirect after...
url
(
'^_revision/change/(?P<article_id>
\
d+)/(?P<revision_id>
\
d+)/$'
,
self
.
revision_change_view
,
name
=
'change_revision'
),
url
(
'^_revision/change/(?P<article_id>
\
d+)/(?P<revision_id>
\
d+)/$'
,
self
.
revision_change_view
.
as_view
()
,
name
=
'change_revision'
),
url
(
'^_revision/preview/(?P<article_id>
\
d+)/$'
,
self
.
article_preview_view_class
.
as_view
(),
name
=
'preview_revision'
),
url
(
'^_revision/preview/(?P<article_id>
\
d+)/$'
,
self
.
article_preview_view_class
.
as_view
(),
name
=
'preview_revision'
),
url
(
'^_revision/merge/(?P<article_id>
\
d+)/(?P<revision_id>
\
d+)/preview/$'
,
self
.
revision_merge_view
,
name
=
'merge_revision_preview'
,
kwargs
=
{
'preview'
:
True
}),
url
(
'^_revision/merge/(?P<article_id>
\
d+)/(?P<revision_id>
\
d+)/preview/$'
,
self
.
revision_merge_view
,
name
=
'merge_revision_preview'
,
kwargs
=
{
'preview'
:
True
}),
)
)
...
@@ -88,7 +88,7 @@ class WikiURLPatterns(object):
...
@@ -88,7 +88,7 @@ class WikiURLPatterns(object):
url
(
'^(?P<article_id>
\
d+)/history/$'
,
self
.
article_history_view_class
.
as_view
(),
name
=
'history'
),
url
(
'^(?P<article_id>
\
d+)/history/$'
,
self
.
article_history_view_class
.
as_view
(),
name
=
'history'
),
url
(
'^(?P<article_id>
\
d+)/settings/$'
,
self
.
article_settings_view_class
.
as_view
(),
name
=
'settings'
),
url
(
'^(?P<article_id>
\
d+)/settings/$'
,
self
.
article_settings_view_class
.
as_view
(),
name
=
'settings'
),
url
(
'^(?P<article_id>
\
d+)/source/$'
,
self
.
article_source_view_class
.
as_view
(),
name
=
'source'
),
url
(
'^(?P<article_id>
\
d+)/source/$'
,
self
.
article_source_view_class
.
as_view
(),
name
=
'source'
),
url
(
'^(?P<article_id>
\
d+)/revision/change/(?P<revision_id>
\
d+)/$'
,
self
.
revision_change_view
,
name
=
'change_revision'
),
url
(
'^(?P<article_id>
\
d+)/revision/change/(?P<revision_id>
\
d+)/$'
,
self
.
revision_change_view
.
as_view
()
,
name
=
'change_revision'
),
url
(
'^(?P<article_id>
\
d+)/revision/merge/(?P<revision_id>
\
d+)/$'
,
self
.
revision_merge_view
,
name
=
'merge_revision'
),
url
(
'^(?P<article_id>
\
d+)/revision/merge/(?P<revision_id>
\
d+)/$'
,
self
.
revision_merge_view
,
name
=
'merge_revision'
),
url
(
'^(?P<article_id>
\
d+)/plugin/(?P<slug>
\
w+)/$'
,
self
.
article_plugin_view_class
.
as_view
(),
name
=
'plugin'
),
url
(
'^(?P<article_id>
\
d+)/plugin/(?P<slug>
\
w+)/$'
,
self
.
article_plugin_view_class
.
as_view
(),
name
=
'plugin'
),
)
)
...
@@ -106,7 +106,7 @@ class WikiURLPatterns(object):
...
@@ -106,7 +106,7 @@ class WikiURLPatterns(object):
url
(
'^(?P<path>.+/|)_dir/$'
,
self
.
article_dir_view_class
.
as_view
(),
name
=
'dir'
),
url
(
'^(?P<path>.+/|)_dir/$'
,
self
.
article_dir_view_class
.
as_view
(),
name
=
'dir'
),
url
(
'^(?P<path>.+/|)_settings/$'
,
self
.
article_settings_view_class
.
as_view
(),
name
=
'settings'
),
url
(
'^(?P<path>.+/|)_settings/$'
,
self
.
article_settings_view_class
.
as_view
(),
name
=
'settings'
),
url
(
'^(?P<path>.+/|)_source/$'
,
self
.
article_source_view_class
.
as_view
(),
name
=
'source'
),
url
(
'^(?P<path>.+/|)_source/$'
,
self
.
article_source_view_class
.
as_view
(),
name
=
'source'
),
url
(
'^(?P<path>.+/|)_revision/change/(?P<revision_id>
\
d+)/$'
,
self
.
revision_change_view
,
name
=
'change_revision'
),
url
(
'^(?P<path>.+/|)_revision/change/(?P<revision_id>
\
d+)/$'
,
self
.
revision_change_view
.
as_view
()
,
name
=
'change_revision'
),
url
(
'^(?P<path>.+/|)_revision/merge/(?P<revision_id>
\
d+)/$'
,
self
.
revision_merge_view
,
name
=
'merge_revision'
),
url
(
'^(?P<path>.+/|)_revision/merge/(?P<revision_id>
\
d+)/$'
,
self
.
revision_merge_view
,
name
=
'merge_revision'
),
url
(
'^(?P<path>.+/|)_plugin/(?P<slug>
\
w+)/$'
,
self
.
article_plugin_view_class
.
as_view
(),
name
=
'plugin'
),
url
(
'^(?P<path>.+/|)_plugin/(?P<slug>
\
w+)/$'
,
self
.
article_plugin_view_class
.
as_view
(),
name
=
'plugin'
),
# This should always go last!
# This should always go last!
...
...
wiki/views/article.py
View file @
e5cbdf45
...
@@ -8,7 +8,7 @@ from django.shortcuts import render_to_response, redirect, get_object_or_404
...
@@ -8,7 +8,7 @@ from django.shortcuts import render_to_response, redirect, get_object_or_404
from
django.template.context
import
RequestContext
from
django.template.context
import
RequestContext
from
django.utils.decorators
import
method_decorator
from
django.utils.decorators
import
method_decorator
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.views.generic.base
import
TemplateView
,
View
from
django.views.generic.base
import
TemplateView
,
View
,
RedirectView
from
django.views.generic.edit
import
FormView
from
django.views.generic.edit
import
FormView
from
django.views.generic.list
import
ListView
from
django.views.generic.list
import
ListView
...
@@ -576,18 +576,30 @@ class Settings(ArticleMixin, TemplateView):
...
@@ -576,18 +576,30 @@ class Settings(ArticleMixin, TemplateView):
return
super
(
Settings
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
Settings
,
self
)
.
get_context_data
(
**
kwargs
)
# TODO: Throw in a class-based view
class
ChangeRevisionView
(
RedirectView
):
@get_article
(
can_write
=
True
,
not_locked
=
True
)
def
change_revision
(
request
,
article
,
revision_id
=
None
,
urlpath
=
None
):
revision
=
get_object_or_404
(
models
.
ArticleRevision
,
article
=
article
,
id
=
revision_id
)
article
.
current_revision
=
revision
article
.
save
()
messages
.
success
(
request
,
_
(
u"The article
%(title)
s is now set to display revision #
%(revision_number)
d"
)
%
{
'title'
:
revision
.
title
,
'revision_number'
:
revision
.
revision_number
,})
if
urlpath
:
@method_decorator
(
get_article
(
can_write
=
True
,
not_locked
=
True
))
return
redirect
(
"wiki:history"
,
path
=
urlpath
.
path
)
def
dispatch
(
self
,
request
,
article
,
*
args
,
**
kwargs
):
self
.
article
=
article
self
.
urlpath
=
kwargs
.
pop
(
'kwargs'
,
False
)
self
.
change_revision
()
return
super
(
ChangeRevisionView
,
self
)
.
dispatch
(
request
,
*
args
,
**
kwargs
)
def
get_redirect_url
(
self
,
**
kwargs
):
if
self
.
urlpath
:
return
reverse
(
"wiki:history"
,
kwargs
=
{
'path'
:
self
.
urlpath
.
path
})
else
:
else
:
return
redirect
(
'wiki:history'
,
article_id
=
article
.
id
)
return
reverse
(
'wiki:history'
,
kwargs
=
{
'article_id'
:
self
.
article
.
id
})
def
change_revision
(
self
):
revision
=
get_object_or_404
(
models
.
ArticleRevision
,
article
=
self
.
article
,
id
=
self
.
kwargs
[
'revision_id'
])
self
.
article
.
current_revision
=
revision
self
.
article
.
save
()
messages
.
success
(
self
.
request
,
_
(
u"The article
%(title)
s is now set to display revision #
%(revision_number)
d"
)
%
{
'title'
:
revision
.
title
,
'revision_number'
:
revision
.
revision_number
,
})
class
Preview
(
ArticleMixin
,
TemplateView
):
class
Preview
(
ArticleMixin
,
TemplateView
):
...
@@ -702,31 +714,37 @@ def merge(request, article, revision_id, urlpath=None, template_file="wiki/previ
...
@@ -702,31 +714,37 @@ def merge(request, article, revision_id, urlpath=None, template_file="wiki/previ
'content'
:
content
})
'content'
:
content
})
return
render_to_response
(
template_file
,
context_instance
=
c
)
return
render_to_response
(
template_file
,
context_instance
=
c
)
# TODO: Should be a class-based view
def
root_create
(
request
):
class
CreateRootView
(
FormView
):
form_class
=
forms
.
CreateRootForm
template_name
=
'wiki/create_root.html'
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
request
.
user
.
is_superuser
:
return
redirect
(
settings
.
LOGIN_URL
+
"?next="
+
reverse
(
"wiki:root_create"
))
try
:
try
:
root
=
models
.
URLPath
.
root
()
root
=
models
.
URLPath
.
root
()
if
not
root
.
article
:
# TODO: This is too dangerous... let's say there is no root.article and we end up here,
# then it might cascade to delete a lot of things on an existing installation.... / benjaoming
root
.
delete
()
raise
NoRootURL
return
redirect
(
'wiki:get'
,
path
=
root
.
path
)
except
NoRootURL
:
except
NoRootURL
:
pass
pass
if
not
request
.
user
.
is_superuser
:
return
redirect
(
settings
.
LOGIN_URL
+
"?next="
+
reverse
(
"wiki:root_create"
))
if
request
.
method
==
'POST'
:
create_form
=
forms
.
CreateRootForm
(
request
.
POST
)
if
create_form
.
is_valid
():
models
.
URLPath
.
create_root
(
title
=
create_form
.
cleaned_data
[
"title"
],
content
=
create_form
.
cleaned_data
[
"content"
],
request
=
request
)
return
redirect
(
"wiki:root"
)
else
:
else
:
create_form
=
forms
.
CreateRootForm
()
if
root
.
article
:
return
redirect
(
'wiki:get'
,
path
=
root
.
path
)
c
=
RequestContext
(
request
,
{
'create_form'
:
create_form
,
# TODO: This is too dangerous... let's say there is no root.article and we end up here,
'editor'
:
editors
.
getEditor
(),})
# then it might cascade to delete a lot of things on an existing installation.... / benjaoming
return
render_to_response
(
"wiki/create_root.html"
,
context_instance
=
c
)
root
.
delete
()
return
super
(
CreateRootView
,
self
)
.
dispatch
(
request
,
*
args
,
**
kwargs
)
def
form_valid
(
self
,
form
):
models
.
URLPath
.
create_root
(
title
=
form
.
cleaned_data
[
"title"
],
content
=
form
.
cleaned_data
[
"content"
],
request
=
self
.
request
)
return
redirect
(
"wiki:root"
)
def
get_context_data
(
self
,
**
kwargs
):
data
=
super
(
CreateRootView
,
self
)
.
get_context_data
(
**
kwargs
)
data
[
'editor'
]
=
editors
.
getEditor
()
return
data
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