[p2pu-dev] jsFiddle and Syntax Highlighting
Piotr Zalewa
piotr at zalewa.info
Fri Sep 16 22:29:12 UTC 2011
I didn't knew about embed.ly
Here is the regexp part from urls.py responsible for embedded
# embedded
r'^(?P<slug>[a-zA-Z0-9]{5})/embedded/$'
r'^(?P<slug>[a-zA-Z0-9]{5})/embedded/(?P<tabs>.*)/(?P<skin>\w+)/$'
r'^(?P<slug>[a-zA-Z0-9]{5})/embedded/(?P<tabs>.*)/$'
r'^(?P<slug>[a-zA-Z0-9]{5})/(?P<version>\d+)/embedded/$'
r'^(?P<slug>[a-zA-Z0-9]{5})/(?P<version>\d+)/embedded/(?P<tabs>.*)/(?P<skin>\w+)/$'
r'^(?P<slug>[a-zA-Z0-9]{5})/(?P<version>\d+)/embedded/(?P<tabs>.*)/$'
name='embedded_with_version_and_tabs'),
r'^(?P<author>\w+)/(?P<slug>[a-zA-Z0-9]{5})/embedded/$'
r'^(?P<author>\w+)/(?P<slug>[a-zA-Z0-9]{5})/embedded/(?P<tabs>.*)/(?P<skin>\w+)/$'
r'^(?P<author>\w+)/(?P<slug>[a-zA-Z0-9]{5})/embedded/(?P<tabs>.*)/$'
r'^(?P<author>\w+)/(?P<slug>[a-zA-Z0-9]{5})/(?P<version>\d+)/embedded/$'
r'^(?P<author>\w+)/(?P<slug>[a-zA-Z0-9]{5})/(?P<version>\d+)/embedded/(?P<tabs>.*)/(?P<skin>\w+)/$'
r'^(?P<author>\w+)/(?P<slug>[a-zA-Z0-9]{5})/(?P<version>\d+)/embedded/(?P<tabs>.*)/$'
Names are explained in http://doc.jsfiddle.net/use/embedding.html
If someone would like to talk to me I'm sitting next to Exhibit Hall 1
entrence. (gchat zaloon at gmail.com)
zalun
On 09/16/11 17:55, Dan Diebolt wrote:
> I am fairly certain that the problem with the jsFiddle embed is in the
> regular expression matching embedly uses to parse the ebmeded url.
> jsFiddle URLs can have a wide range of forms as they communicate the
> configuration of the fiddle using extra url paths. As a preliminary
> investigation I sent an inquiry to the jsFiddle mailing list and perhaps
> Zalun et al will come up with an answer. Then I will contact embed.ly
> <http://embed.ly> and hopefully they will get jsFiddle on the provider list.
>
> ==========================================
>
> A platform I work with (p2pu.org <http://p2pu.org/>) has attempted to
> use embed.ly <http://embed.ly/> to come up with a shortcode to embed
> jsFiddles into their platofrm via their configuration of CKEditor. Here
> is an example of the embed shortcode that works:
>
> [embed:http://jsfiddle.net/dandiebolt/agaCq/]
>
> Although jsFiddle is not on Embedly's provider list
>
> http://api.embed.ly/v1/api/services
>
> various forms of the jsFiddle URL do embed. I am not sure why that
> happens but I suspect that the reason it does not embed in other cases
> is because they are using a overly simplified regular expression to
> match jsFiddle URLs. These details may not be to interesting to you but
> I would like to pose the independent question as to what regular
> expression does match a jsFiddle URL taking into account all the
> features a jsFiddle may have:
>
> * anonymous fiddles (no user)
> * characters encoding the jsFiddle ID
> * jsFiddle versions
> * stylesheets
> * show
> * default embed with no tabs specified
> * embed with tabs specified.
> * dependancies
>
> Here is my crude attempt to write a regexp for a jsFiddle URL with
> various capturing parentheses tossed in:
>
> /
> (jsfiddle\.net\/)
> ([a-zA-Z0-9]\/)?
> ([a-zA-Z0-9]\/)
> (show\/|embedded\/((html|css|js|resources|result){0,5}\/([a-zA-Z0-9])?\/)?
> /
>
> I have no idea what characters are allowed for the jsFiddle ID or user
> names so I just specified alphanumerics. Also I overlooked version
> numbers, & dependancies when I typed this regexp. Moreover I never
> tested it.
>
> So if someone wants a challenge I would like to find the regexp that
> matches all jsFiddle URLs without getting too anal. The key area is
> focus on is the embedded path which can contain tabs (and you apparently
> can list a tab twice) because the whole goal of embedly is to embed the
> jsFiddle URL in an iframe on blog or cms.
>
> My overall goal is to get embed.ly <http://embed.ly> to support jsFiddle
> embeds and I will bird dog that issue but it would be a nice piece of
> information to have a regexp for matching any jsFiddle.
>
>
>
>
> _______________________________________________
> p2pu-dev mailing list
> p2pu-dev at lists.p2pu.org
> http://lists.p2pu.org/mailman/listinfo/p2pu-dev
More information about the p2pu-dev
mailing list