Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
beat
beat.web
Commits
8ca79a8a
There was a problem fetching the pipeline summary.
Commit
8ca79a8a
authored
9 years ago
by
André Anjos
Browse files
Options
Downloads
Plain Diff
Merge branch 'issue_416' into 'master'
Issue 416 See merge request
!168
parents
fca71943
d3b22561
No related branches found
No related tags found
1 merge request
!168
Issue 416
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beat/web/common/serializers.py
+0
-4
0 additions, 4 deletions
beat/web/common/serializers.py
beat/web/ui/templatetags/markup.py
+59
-0
59 additions, 0 deletions
beat/web/ui/templatetags/markup.py
with
59 additions
and
4 deletions
beat/web/common/serializers.py
+
0
−
4
View file @
8ca79a8a
...
@@ -290,10 +290,6 @@ class ContributionCreationSerializer(serializers.ModelSerializer):
...
@@ -290,10 +290,6 @@ class ContributionCreationSerializer(serializers.ModelSerializer):
def
validate_description
(
self
,
description
):
def
validate_description
(
self
,
description
):
if
description
.
find
(
'
\\
'
)
>=
0
:
#was escaped, unescape
if
description
.
find
(
'
\\
'
)
>=
0
:
#was escaped, unescape
description
=
description
.
decode
(
'
string_escape
'
)
description
=
description
.
decode
(
'
string_escape
'
)
try
:
validate_restructuredtext
(
description
)
except
ValidationError
as
e
:
raise
serializers
.
ValidationError
(
e
)
return
description
return
description
def
validate
(
self
,
data
):
def
validate
(
self
,
data
):
...
...
This diff is collapsed.
Click to expand it.
beat/web/ui/templatetags/markup.py
+
59
−
0
View file @
8ca79a8a
...
@@ -95,6 +95,64 @@ def markdown(value, arg=''):
...
@@ -95,6 +95,64 @@ def markdown(value, arg=''):
))
))
def
get_rst_errors
(
s
,
config
):
"""
Catch errors and syntax warnings and returns them
"""
import
docutils.utils
import
docutils.parsers
import
docutils.frontend
class
SilentReporter
(
docutils
.
utils
.
Reporter
):
"""
Silent reporter
All warnings and errors will be stored and can be used subsequently
through the reporter instance
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
messages
=
[]
docutils
.
utils
.
Reporter
.
__init__
(
self
,
*
args
,
**
kwargs
)
def
system_message
(
self
,
level
,
message
,
*
children
,
**
kwargs
):
self
.
messages
.
append
((
level
,
message
,
children
,
kwargs
))
parser
=
docutils
.
parsers
.
rst
.
Parser
()
defaults
=
docutils
.
frontend
.
OptionParser
().
get_default_values
()
for
key
,
val
in
config
.
items
():
setattr
(
defaults
,
key
,
val
)
defaults
.
tab_width
=
4
defaults
.
pep_references
=
None
defaults
.
rfc_references
=
None
defaults
.
report_level
=
1
#info
defaults
.
halt_level
=
4
#severe
defaults
.
debug
=
0
#don't debug
reporter
=
SilentReporter
(
None
,
defaults
.
report_level
,
#info
defaults
.
halt_level
,
#severe
stream
=
defaults
.
warning_stream
,
debug
=
defaults
.
debug
,
#no debug
encoding
=
defaults
.
error_encoding
,
error_handler
=
defaults
.
error_encoding_error_handler
,
)
document
=
docutils
.
utils
.
new_document
(
None
,
defaults
)
document
.
reporter
=
reporter
try
:
parser
.
parse
(
s
,
document
)
except
AttributeError
:
pass
except
TypeError
:
# Catch ``TypeError`` to avoid problems with local roles
# NOTE: Is this still necessary ?
pass
return
reporter
.
messages
@register.filter
(
is_safe
=
True
)
@register.filter
(
is_safe
=
True
)
@stringfilter
@stringfilter
def
restructuredtext
(
value
,
full
=
False
):
def
restructuredtext
(
value
,
full
=
False
):
...
@@ -107,6 +165,7 @@ def restructuredtext(value, full=False):
...
@@ -107,6 +165,7 @@ def restructuredtext(value, full=False):
else
:
else
:
docutils_settings
=
getattr
(
settings
,
"
RESTRUCTUREDTEXT_FILTER_SETTINGS
"
,
{})
docutils_settings
=
getattr
(
settings
,
"
RESTRUCTUREDTEXT_FILTER_SETTINGS
"
,
{})
parts
=
publish_parts
(
source
=
force_bytes
(
value
),
writer_name
=
"
html4css1
"
,
settings_overrides
=
docutils_settings
)
parts
=
publish_parts
(
source
=
force_bytes
(
value
),
writer_name
=
"
html4css1
"
,
settings_overrides
=
docutils_settings
)
#errors = get_rst_errors(value, docutils_settings)
if
full
:
if
full
:
return
mark_safe
(
force_text
(
parts
[
"
html_body
"
]))
#with h1 title
return
mark_safe
(
force_text
(
parts
[
"
html_body
"
]))
#with h1 title
else
:
else
:
...
...
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