markmin embed:http://... not work trunk version

224 views
Skip to first unread message

Jose

unread,
Jul 25, 2012, 10:07:12 PM7/25/12
to web...@googlegroups.com
Hi all

From the book:

The following is not working
embed:http://www.youtube.com/embed/x1w8hKTJ2Co

show me the url and not the video

I'm using the trunk version, in version 1.99.7 works well.
José

Vladyslav Kozlovskyy

unread,
Jul 26, 2012, 1:04:21 AM7/26/12
to web...@googlegroups.com, Massimo Di Pierro
Hi, Jose!

try 'iframe' instead of 'embed':

iframe:http://www.youtube.com/embed/x1w8hKTJ2Co


In 1.99.7 embed looks like iframe, and iframe is not used at all (it's a new feature):

>>> markmin2html('embed:http://www.youtube.com/embed/x1w8hKTJ2Co')
'<p><iframe src="http://www.youtube.com/embed/x1w8hKTJ2Co" frameborder="0" allowfullscreen></iframe></p>'

>>> markmin2html('iframe:http://www.youtube.com/embed/x1w8hKTJ2Co')
'<p>iframe:<a href="http://www.youtube.com/embed/x1w8hKTJ2Co">http://www.youtube.com/embed/x1w8hKTJ2Co</a></p>


in the trunk embed is simply a link with class='embed'. We need css rule to make this link works:

>>> markmin2html('embed:http://www.youtube.com/embed/x1w8hKTJ2Co')
'<p><a href="http://www.youtube.com/embed/x1w8hKTJ2Co" class="embed">http://www.youtube.com/embed/x1w8hKTJ2Co</a></p>'

>>> markmin2html('iframe:http://www.youtube.com/embed/x1w8hKTJ2Co')
'<p><iframe src="http://www.youtube.com/embed/x1w8hKTJ2Co" frameborder="0" allowfullscreen></iframe></p>'


Vladyslav Kozlovskyy (Ukraine)


26.07.12 05:07, Jose написав(ла):
--
 
 
 

Massimo Di Pierro

unread,
Jul 26, 2012, 5:47:08 AM7/26/12
to web...@googlegroups.com, Massimo Di Pierro
This may be considered a breaking of backward compatibility and we need to think about it.

Originally the emebed:... attribute was supposed to check if the link supports the oembed protocol and determine what to do (iframe or not) automatically. There is actually code in web2py (gluon/contrib/autolinks.py) to do this automatically but it not yet used by markmin.

Jose

unread,
Jul 26, 2012, 9:40:21 AM7/26/12
to web...@googlegroups.com, Massimo Di Pierro


El jueves, 26 de julio de 2012 02:04:21 UTC-3, dbdeveloper escribió:
Hi, Jose!

try 'iframe' instead of 'embed':

iframe:http://www.youtube.com/embed/x1w8hKTJ2Co

Ok Vladyslav, but I think the same as Massimo, this breaks backwards compatibility.

Jose

Vladyslav Kozlovskyy

unread,
Jul 26, 2012, 6:03:35 PM7/26/12
to web...@googlegroups.com
well, give me an example of correct iframe and embed output and I'll change markmin. ok?

Vladyslav Kozlovskyy (Ukraine)

26.07.12 16:40, Jose написав(ла):
--
 
 
 



Massimo Di Pierro

unread,
Jul 26, 2012, 6:30:21 PM7/26/12
to web...@googlegroups.com
Before you change it, let me think about this some more...

Massimo Di Pierro

unread,
Jul 27, 2012, 6:57:35 PM7/27/12
to web...@googlegroups.com
I think embed:http://url.... should be deprecated in MARKMIN.

It think if a url is found and not marked-up whether or not prefixed with "embed:" the url should be precessed by the function 


This function uses the oembed protocol to figure out the best way to embed the content pointed by the url (whether it is an image, a video, a youtube page, etc.) The {} argument is a dictionary that will be used for caching.

The iframe prefix should be left alone but may need to discuss security. Should it be enabled by default?

This may actually simplify markmin.

Massimo

Vladyslav Kozlovskyy

unread,
Jul 28, 2012, 9:21:20 AM7/28/12
to web...@googlegroups.com, Massimo Di Pierro
autolinks is right module. but I have some questions:

1. markmin doesn't have dependencies. Now it will be dependent on autolinks. Solution: we can "disable" autolink if it isn't found on path. Right?
2. Autolink is LGPL, makmin is MIT/BSD/GPL. I do not understand differentiation between them. Is there all alright ?
3. now the regex expression for search autolinks must be:   http(s)://*  Yes?
4. second parameter for expand_one: {} - do we always need to use empty dict here or better to use variable to cache repeated urls ?
5. if embed will be depricated, how about backward compatibility?

Vladyslav Kozlovskyy


28.07.12 01:57, Massimo Di Pierro написав(ла):
--
 
 
 

Massimo Di Pierro

unread,
Jul 28, 2012, 10:36:39 AM7/28/12
to web...@googlegroups.com, Massimo Di Pierro
1.2. I wrote autolinks and it is not used by anything else. We can change the licence and - in principle - we can move the code we need in markmin2html.py.

3. yes
4. perhaps we can pass a dict to markmin?
5. I do not think embed is documented in the book. If we silently ignore embed and treat embed:http://... the same as http://.. and the url points to an oembed service, it should still embed using the oembed rules. If not it will use a link instead of an iframe. Technically is a minor change of behavior but it will not break any app. Alternatively we can use embed: as alias of iframe:... if no oembed rule. What do you think?

Vladyslav Kozlovskyy

unread,
Jul 28, 2012, 3:14:50 PM7/28/12
to web...@googlegroups.com, Massimo Di Pierro
I think, the best way is to use autolinks as a render()'s parameter (autolinks replaces auto parameter):

def default_autolinks(url):
   """ default autolinks for links, pictures and
       videos using video tag
   """
   return '<a href="%s">%s</a>' % (url, url)

render(....., autolinks=default_autolinks)

disable autolinks:

render(....., autolinks=None)

use other autolinks:

from gluon.contrib.autolinks import expand_one

render(...., autolinks=lambda url: expand_one(url, {}) )


Your decision?

Vladyslav Kozlovskyy



28.07.12 17:36, Massimo Di Pierro написав(ла):
--
 
 
 

Massimo Di Pierro

unread,
Jul 28, 2012, 6:28:01 PM7/28/12
to web...@googlegroups.com, Massimo Di Pierro
I think this is a reasonable solution. The helper MARKMIN could be smarter and use autolinks expand_one.

Vladyslav Kozlovskyy

unread,
Jul 28, 2012, 7:09:05 PM7/28/12
to web...@googlegroups.com, Massimo Di Pierro
Ok. Wait the patch

29.07.12 01:28, Massimo Di Pierro написав(ла):
--
 
 
 

Reply all
Reply to author
Forward
0 new messages