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
edx
django-wiki
Commits
b032b613
Commit
b032b613
authored
May 17, 2014
by
benjaoming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:benjaoming/django-wiki
parents
38dc640d
8c453359
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
6 deletions
+13
-6
wiki/forms.py
+2
-0
wiki/templates/wiki/create.html
+2
-5
wiki/views/article.py
+9
-1
No files found.
wiki/forms.py
View file @
b032b613
...
@@ -261,6 +261,8 @@ class CreateForm(forms.Form, SpamProtectionMixin):
...
@@ -261,6 +261,8 @@ class CreateForm(forms.Form, SpamProtectionMixin):
if
settings
.
URL_CASE_SENSITIVE
:
if
settings
.
URL_CASE_SENSITIVE
:
already_existing_slug
=
models
.
URLPath
.
objects
.
filter
(
slug
=
slug
,
parent
=
self
.
urlpath_parent
)
already_existing_slug
=
models
.
URLPath
.
objects
.
filter
(
slug
=
slug
,
parent
=
self
.
urlpath_parent
)
else
:
else
:
slug
=
slug
.
lower
()
slug
=
slug
.
replace
(
'-'
,
'_'
)
already_existing_slug
=
models
.
URLPath
.
objects
.
filter
(
slug__iexact
=
slug
,
parent
=
self
.
urlpath_parent
)
already_existing_slug
=
models
.
URLPath
.
objects
.
filter
(
slug__iexact
=
slug
,
parent
=
self
.
urlpath_parent
)
if
already_existing_slug
:
if
already_existing_slug
:
already_urlpath
=
already_existing_slug
[
0
]
already_urlpath
=
already_existing_slug
[
0
]
...
...
wiki/templates/wiki/create.html
View file @
b032b613
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
// if downcode doesn't hit, the char will be stripped here
// if downcode doesn't hit, the char will be stripped here
s
=
s
.
replace
(
/
[^
-
\w\s]
/g
,
''
);
// remove unneeded chars
s
=
s
.
replace
(
/
[^
-
\w\s]
/g
,
''
);
// remove unneeded chars
s
=
s
.
replace
(
/^
\s
+|
\s
+$/g
,
''
);
// trim leading/trailing spaces
s
=
s
.
replace
(
/^
\s
+|
\s
+$/g
,
''
);
// trim leading/trailing spaces
s
=
s
.
replace
(
/
[
-
\s]
+/g
,
'
-'
);
// convert spaces to hyphen
s
s
=
s
.
replace
(
/
[
-
\s]
+/g
,
'
_'
);
// convert spaces and hyphens to underscore
s
s
=
s
.
toLowerCase
();
// convert to lowercase
s
=
s
.
toLowerCase
();
// convert to lowercase
return
s
.
substring
(
0
,
num_chars
);
// trim to first num_chars chars
return
s
.
substring
(
0
,
num_chars
);
// trim to first num_chars chars
}
}
...
@@ -30,10 +30,7 @@
...
@@ -30,10 +30,7 @@
var
e
=
$
(
"#id_slug"
)[
0
];
var
e
=
$
(
"#id_slug"
)[
0
];
if
(
!
e
.
_changed
)
{
if
(
!
e
.
_changed
)
{
slug
=
URLify
(
this
.
value
,
50
);
slug
=
URLify
(
this
.
value
,
50
);
wikislug
=
slug
.
replace
(
/
\-
/g
,
" "
);
e
.
value
=
slug
;
wikislug
=
wikislug
.
replace
(
/
\w\S
*/gi
,
function
(
txt
){
return
txt
.
charAt
(
0
).
toUpperCase
()
+
txt
.
substr
(
1
);});
wikislug
=
wikislug
.
replace
(
/
\s
*/g
,
""
);
e
.
value
=
wikislug
;
}
}
});
});
});
});
...
...
wiki/views/article.py
View file @
b032b613
...
@@ -62,7 +62,15 @@ class Create(FormView, ArticleMixin):
...
@@ -62,7 +62,15 @@ class Create(FormView, ArticleMixin):
initial
[
'slug'
]
=
self
.
request
.
GET
.
get
(
'slug'
,
None
)
initial
[
'slug'
]
=
self
.
request
.
GET
.
get
(
'slug'
,
None
)
kwargs
[
'initial'
]
=
initial
kwargs
[
'initial'
]
=
initial
form
=
form_class
(
self
.
request
,
self
.
urlpath
,
**
kwargs
)
form
=
form_class
(
self
.
request
,
self
.
urlpath
,
**
kwargs
)
form
.
fields
[
'slug'
]
.
widget
=
forms
.
TextInputPrepend
(
prepend
=
'/'
+
self
.
urlpath
.
path
)
form
.
fields
[
'slug'
]
.
widget
=
forms
.
TextInputPrepend
(
prepend
=
'/'
+
self
.
urlpath
.
path
,
attrs
=
{
# Make patterns force lowercase if we are case insensitive to bless the user with a
# bit of strictness, anyways
'pattern'
:
'[a-z0-9_]+'
if
not
settings
.
URL_CASE_SENSITIVE
else
'[a-zA-Z0-9_]+'
,
'title'
:
'Lowercase letters, numbers, and underscores'
if
not
settings
.
URL_CASE_SENSITIVE
else
'Letters, numbers, and underscores'
,
}
)
return
form
return
form
def
form_valid
(
self
,
form
):
def
form_valid
(
self
,
form
):
...
...
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