Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
012e5181
Commit
012e5181
authored
Feb 09, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed wikipath extension
parent
ea392495
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
simplewiki/mdx_wikipath.py
+7
-11
simplewiki/models.py
+1
-1
No files found.
simplewiki/mdx_wikipath.py
View file @
012e5181
...
...
@@ -16,7 +16,6 @@ class WikiPathExtension(markdown.Extension):
# set extension defaults
self
.
config
=
{
'base_url'
:
[
'/'
,
'String to append to beginning or URL.'
],
'end_url'
:
[
'/'
,
'String to append to end of URL.'
],
'html_class'
:
[
'wikipath'
,
'CSS hook. Leave blank for none.'
]
}
...
...
@@ -31,7 +30,7 @@ class WikiPathExtension(markdown.Extension):
# append to end of inline patterns
WIKI_RE
=
r'\[(?P<linkTitle>.+?)\]\(wiki:(?P<wikiTitle>[a-zA-Z\d/_-]*)\)'
wikiPathPattern
=
WikiPath
(
WIKI_RE
,
self
.
getConfigs
()
)
wikiPathPattern
=
WikiPath
(
WIKI_RE
,
self
.
config
)
wikiPathPattern
.
md
=
md
md
.
inlinePatterns
.
add
(
'wikipath'
,
wikiPathPattern
,
"<reference"
)
...
...
@@ -45,30 +44,27 @@ class WikiPath(markdown.inlinepatterns.Pattern):
if
article_title
.
startswith
(
"/"
):
article_title
=
article_title
[
1
:]
url
=
self
.
config
[
'base_url'
]
+
article_title
url
=
self
.
config
[
'base_url'
]
[
0
]
+
article_title
label
=
m
.
group
(
'linkTitle'
)
a
=
etree
.
Element
(
'a'
)
a
.
set
(
'href'
,
url
)
a
.
text
=
label
if
self
.
config
[
'html_class'
]:
a
.
set
(
'class'
,
self
.
config
[
'html_class'
])
if
self
.
config
[
'html_class'
]
[
0
]
:
a
.
set
(
'class'
,
self
.
config
[
'html_class'
]
[
0
]
)
return
a
def
_getMeta
(
self
):
""" Return meta data or config data. """
base_url
=
self
.
config
[
'base_url'
]
end_url
=
self
.
config
[
'end_url'
]
html_class
=
self
.
config
[
'html_class'
]
base_url
=
self
.
config
[
'base_url'
][
0
]
html_class
=
self
.
config
[
'html_class'
][
0
]
if
hasattr
(
self
.
md
,
'Meta'
):
if
self
.
md
.
Meta
.
has_key
(
'wiki_base_url'
):
base_url
=
self
.
md
.
Meta
[
'wiki_base_url'
][
0
]
if
self
.
md
.
Meta
.
has_key
(
'wiki_end_url'
):
end_url
=
self
.
md
.
Meta
[
'wiki_end_url'
][
0
]
if
self
.
md
.
Meta
.
has_key
(
'wiki_html_class'
):
html_class
=
self
.
md
.
Meta
[
'wiki_html_class'
][
0
]
return
base_url
,
end_url
,
html_class
return
base_url
,
html_class
def
makeExtension
(
configs
=
None
)
:
return
WikiPathExtension
(
configs
=
configs
)
...
...
simplewiki/models.py
View file @
012e5181
...
...
@@ -267,7 +267,7 @@ class Revision(models.Model):
# Create pre-parsed contents - no need to parse on-the-fly
ext
=
WIKI_MARKDOWN_EXTENSIONS
#
ext += ["wikipath(base_url=%s)" % reverse('wiki_view', args=('/',))]
ext
+=
[
"wikipath(base_url=
%
s)"
%
reverse
(
'wiki_view'
,
args
=
(
'/'
,))]
print
ext
self
.
contents_parsed
=
markdown
(
self
.
contents
,
extensions
=
ext
,
...
...
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