GithubHelp home page GithubHelp logo

Comments (7)

iparamonau avatar iparamonau commented on July 23, 2024
  • You have href commented in your code. That was the right way to pass it as embed URL. Paired with text/html type, Iframely would no to convert it into iFrame. What you were missing is the sizing information. You could either give "aspect-ratio" in the object, or, say, just height to make the embed stretch 100% of the width. To make a fixed iFrame, you can just pass width & height.
  • rel inline is the secondary rel, which is meant to indicate whether embed can be rendered via JavaScript or not. You need a main one too. I suggest [CONFIG.R.app, CONFIG.R.ssl, CONFIG.R.html5]. The flag for inline/js status isn't necessary if you return data as href rather than html. Iframely knows that iFrames are JS-friendly.
  • Last but not least, in v0.8.6 we added an option to use "*" as a mixin. It adds all generic mixins, and basically means that plugin will add an embed rather than take complete control: mixins: ["*"]

from iframely.

j0k3r avatar j0k3r commented on July 23, 2024

I've updated the domain file with your recommandations:

module.exports = {
    re: [
        /^http[s]?:\/\/cf.datawrapper.de\/(.+?)(?:[\/](?:index\.html)?)?$/
    ],

    mixins: [
        "*"
    ],

    getLink: function(urlMatch) {
        return {
            type: CONFIG.T.text_html,
            rel: [CONFIG.R.app, CONFIG.R.ssl, CONFIG.R.html5],
            href: "http://cf.datawrapper.de/" + urlMatch[1] + "/",
            height: 350
        }
    },

    getMeta: function() {
        return {
            site: 'datawrapper',
        };
    },

    tests: [
        "http://cf.datawrapper.de/zjCKi/2/",
        "http://cf.datawrapper.de/Gx44C/21/",
        "http://cf.datawrapper.de/RrO5t/2/"
    ]
};

But it doesn't generate the iframe:

{
    "meta": {
        "title": "Montant total des amendes infligées par les régulateurs américains",
        "canonical": "http://cf.datawrapper.de/zjCKi/2/"
    },
    "links": [
        {
            "href": "http://cf.datawrapper.de/favicon.ico",
            "type": "image",
            "rel": [
                "icon"
            ]
        }
    ]
}

from iframely.

iparamonau avatar iparamonau commented on July 23, 2024

That would mean that domain plugin isn't called. I suggest to verify the regex, perhaps escape dots \.?
I just ran your code locally with /^https?:\/\/cf\.datawrapper\.de\/([a-zA-Z0-9]+)\//i and it works fine. Not sure if it's the correct one though.

Also, did you know there's a local debug tool at http://localhost:8061/debug ?

from iframely.

iparamonau avatar iparamonau commented on July 23, 2024

.@nleush mentions that your regex matches, but there might be another issue at Iframely core here.

There is a validator at Iframely core that removes embeds with iframe src = canonical address (or original URL). In your case, the urlMatch[1] would be like zjCKi/2 and you'll end up having iFrame exactly the same as URL (from your tests).

That validator is for generic parsers, especially for Open Graph. A lot of people just put og:video=canonical. Unfortunately, we can not remove this check. To work it around, you could add some query string to iFrame src, like ?for=iframely or something.

from iframely.

j0k3r avatar j0k3r commented on July 23, 2024

Of course I know the debug tool, I mostly used to test the domain 😉

And THANKS for that point @nleush I started to dig into the core.js to find why my regex is valid outside IFramely but not inside.

It works great now.
Thanks guys 👍

from iframely.

j0k3r avatar j0k3r commented on July 23, 2024

@iparamonau Should I submit a PR to add this domain in plugins?

from iframely.

iparamonau avatar iparamonau commented on July 23, 2024

@j0k3r Sure, would be great. Thanks!

from iframely.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.