Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

debug youtube + font

  • Loading branch information...
commit 3f774a5466cbbc76ed030b35cd40e1f7ef137aff 1 parent bb3e2da
Camille Boissel authored
Showing with 60 additions and 9 deletions.
  1. +55 −0 bbcode/bbtags/text_formatting.py
  2. +5 −9 bbcode/bbtags/web.py
View
55 bbcode/bbtags/text_formatting.py
@@ -558,6 +558,59 @@ class Right(TagNode):
def parse(self):
return '<p style="text-align:right;">%s</p>' % self.parse_inner()
+
+class Font(ArgumentTagNode):
+ """
+ Add special font to the text.
+
+ Usage:
+
+ [code lang=bbdocs linenos=0][font=<font>]Text[/font]
+
+ Arguments:
+
+ Allowed values for [i]font[/i]: Arial, Arial Black, Comic Sans MS, Courier New, Georgia, Impact, Sans-serif, Serif, Times New Roman, Trebuchet MS, Verdana
+ """
+ _allowed = ('Arial', 'Arial Black', 'Comic Sans MS', 'Courier New', 'Georgia', 'Impact', 'Sans-serif', 'Serif', 'Times New Roman', 'Trebuchet MS', 'Verdana')
+ verbose_name = 'Font'
+ open_pattern = re.compile(patterns.single_argument % 'font', re.IGNORECASE)
+ close_pattern = re.compile(patterns.closing % 'font', re.IGNORECASE)
+
+ def parse(self):
+ if not self.argument:
+ return self.parse_inner()
+ arg = self.argument
+ if not arg in self._allowed:
+ soft_raise("Font '%s' not allowed." % arg)
+ return self.parse_inner()
+ return '<span style="font-family:%s">%s</span>' % (arg, self.parse_inner())
+
+
+class IntSize(ArgumentTagNode):
+ """
+ Changes the size of text.
+
+ Usage:
+
+ [code lang=bbdocs linenos=0][size=<size>]Text[/size][/code]
+
+ Arguments:
+
+ Allowed values for [i]size[/i]: 1, 2, 3, 4, 5, 6, 7
+ """
+ _allowed = ('1', '2', '3', '4', '5', '6', '7')
+ open_pattern = re.compile(patterns.single_argument % 'size', re.IGNORECASE)
+ close_pattern = re.compile(patterns.closing % 'size', re.IGNORECASE)
+
+ def parse(self):
+ if not self.argument:
+ return self.parse_inner()
+ arg = self.argument.lower()
+ if not arg in self._allowed:
+ soft_raise("Size '%s' not allowed." % arg)
+ return self.parse_inner()
+ return '<font size="%s">%s</font>' % (arg, self.parse_inner())
+
register(Em)
register(Strong)
register(P)
@@ -578,3 +631,5 @@ def parse(self):
register(Left)
register(Center)
register(Right)
+register(Font)
+# register(IntSize)
View
14 bbcode/bbtags/web.py
@@ -120,9 +120,10 @@ class Youtube(TagNode):
Usage:
- [code lang=bbdocs linenos=0][youtube]http://www.youtube.com/watch?v=FjPf6B8EVJI[/youtube][/code]
+ [code lang=bbdocs linenos=0][youtube]FjPf6B8EVJI[/youtube][/code]
"""
- _video_id_pattern = re.compile('v=(\w+)')
+ verbose_name = 'Youtube'
+ _video_id_pattern = re.compile('([a-zA-Z0-9]+)')
open_pattern = re.compile(patterns.no_argument % 'youtube', re.IGNORECASE)
close_pattern = re.compile(patterns.closing % 'youtube', re.IGNORECASE)
@@ -144,12 +145,7 @@ def parse(self):
return self.raw_content
videoid = videoid[0]
return (
- '<object width="560" height="340"><param name="movie" value="http:/'
- '/www.youtube.com/v/%s&amp;hl=en&amp;fs=1&amp;"></param><param name'
- '="allowFullScreen" value="true"></param><param name="allowscriptac'
- 'cess" value="always"></param><embed src="http://www.youtube.com/v/'
- '%s&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" a'
- 'llowscriptaccess="always" allowfullscreen="true" width="560" heigh'
+ '<iframe width="560" height="315" src="http://www.youtube.com/embed/%s" frameborder="0" allowfullscreen></iframe>' % videoid
)
@@ -170,7 +166,7 @@ class Dailymotion(TagNode):
[code lang=bbdocs linenos=0][dailymotion]xtg9f[/dailymotion][/code]
"""
verbose_name = 'Dailymotion'
- _video_id_pattern = re.compile('([a-z0-9]+)')
+ _video_id_pattern = re.compile('([a-zA-Z0-9]+)')
open_pattern = re.compile(patterns.no_argument % 'dailymotion', re.IGNORECASE)
close_pattern = re.compile(patterns.closing % 'dailymotion', re.IGNORECASE)
Please sign in to comment.
Something went wrong with that request. Please try again.