Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
012e5181
Commit
012e5181
authored
13 years ago
by
Bridger Maxwell
Browse files
Options
Downloads
Patches
Plain Diff
Fixed wikipath extension
parent
ea392495
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
simplewiki/mdx_wikipath.py
+7
-11
7 additions, 11 deletions
simplewiki/mdx_wikipath.py
simplewiki/models.py
+1
-1
1 addition, 1 deletion
simplewiki/models.py
with
8 additions
and
12 deletions
simplewiki/mdx_wikipath.py
+
7
−
11
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
.
getC
onfig
s
()
)
wikiPathPattern
=
WikiPath
(
WIKI_RE
,
self
.
c
onfig
)
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
)
...
...
This diff is collapsed.
Click to expand it.
simplewiki/models.py
+
1
−
1
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
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment