Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Benjamin Graillot
scripts
Commits
b8163ce2
Commit
b8163ce2
authored
Mar 16, 2018
by
Benjamin Graillot
Browse files
Ajour de la macro EtherPad
parent
313d2cab
Changes
1
Hide whitespace changes
Inline
Side-by-side
wiki/macro/EtherPad.py
0 → 100644
View file @
b8163ce2
# -*- coding: iso-8859-1 -*-
"""
MoinMoin - EtherPad Macro
Benjamin « esum » « coq » Graillot
pour le Cr@ns
Syntaxe :
<<EtherPad(name)>>
<<EtherPad(name, show_controls=true, ...)>>
Arguments:
* name: nom du pad.
Arguments optionnels:
* show_controls: afficher les contrôles du pad.
* show_chat: afficher le clavardage.
* show_line_numbers: afficher les numéros de ligne.
* use_monospace_font: utiliser la police à chasse fixe.
* height: hauteur du pad en pixer.
* frameborder: afficher le cadre autour du pad.
"""
def
execute
(
macro
,
text
):
text
=
text
.
split
(
','
)
name
=
text
[
0
].
strip
()
args
=
[
name
]
kwargs
=
{}
for
arg
in
text
[
1
:]:
kw
=
None
if
'='
in
arg
:
arg
=
arg
.
split
(
'='
)
kw
=
arg
[
0
].
strip
()
arg
=
arg
[
1
]
arg
=
arg
.
strip
()
if
arg
.
lower
()
in
{
'true'
,
'false'
}:
arg
=
bool
(
arg
)
elif
arg
.
isnumeric
():
arg
=
int
(
arg
)
if
kw
is
None
:
args
.
append
(
arg
)
else
:
kwargs
[
kw
]
=
arg
return
macro
.
formatter
.
rawHTML
(
html
(
*
args
,
**
kwargs
))
def
html
(
name
,
show_controls
=
None
,
show_chat
=
None
,
show_line_numbers
=
None
,
use_monospace_font
=
True
,
height
=
400
,
frameborder
=
True
):
readonly
=
name
.
startswith
(
'r.'
)
if
not
isinstance
(
show_controls
,
bool
):
show_controls
=
not
readonly
if
not
isinstance
(
show_chat
,
bool
):
show_chat
=
not
readonly
if
not
isinstance
(
show_line_numbers
,
bool
):
show_line_numbers
=
not
readonly
html
=
u
'''<iframe name="{}" src="https://pad.crans.org/p/{}?showControls={}&showChat={}&showLineNumbers={}&useMonospaceFont={}" width="100%" height="{}" frameborder="{}"></iframe>'''
.
format
(
'embed_readonly'
if
readonly
else
'embed_readwrite'
,
name
,
repr
(
show_controls
).
lower
(),
repr
(
show_chat
).
lower
(),
repr
(
show_line_numbers
).
lower
(),
repr
(
use_monospace_font
).
lower
(),
height
,
int
(
frameborder
))
return
html
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment