Embed web page within post


  • GNU/Linux

    Just a quick question is it possible to do ? Haven't tried before, having trouble figuring it out. Especially with the markdown

    Noticed embed.ly but it's sort of not what I wanted. Help would be greatly appreciated



  • @Codejet You'd embed a webpage using an iFrame, which you'd need to create a plugin for (assuming there's not one already), but DO NOT allow normal members to post iFrames. All it takes is one person to iframe a webpage containing an auto downloading exe virus or something and you've got a recipe for bad things to happen.


  • Community Rep

    You would run into a problem with iframes, most medium-large sites block iframe requests completely.


  • GNU/Linux

    Thanks for the information. Good to know

    Hmm sounds like its excluded from default markdown syntax because, most likely these reasons.

    I was sifting through Markdown tutorials all I could find is [[embed ]] and [youtube] type embed in the default markdown. Nothing that used embed to embed html's. Noticed this thing called oembed , looked quite powerful, yet completely confusing to a lame brain like me.

    The only real issue I have with embed.ly is that it takes ages to update, refresh a card (if its in you category you see code for 3-4 seconds before it updates to a card. That and it updates every single url in your NodeBB 😞

    Also noticed unless you land on a page with the embed.ly card embeded, up until then you will only see code not the card on every page.


  • GNU/Linux

    Managed to change embed.ly's core to actually iframe embed an entire web page.

    Question with regards to iframe's and auto width's and height's

    Does Nobebb have any such variables/properties to use maybe within ?<script>

    I can auto size the width using width="100%" or wdith:100%

    height is proving difficult

    also with content.replace(oldcode, withnew) how can you make sure the user is uid=admin or which ever

    being that the above poster mentioned don't let normal users use this shortcode/plugin

    maybe someone could help me with an if(uid=0) {} somewhere just after the content.match


  • GNU/Linux

    with the content.match(myembedcode)

    what is the appropriate markdown regexp to use to make this the variable to be the markdown string in a post.

     var myembedcode = ![embed_html](url_goes_here)
    

  • Global Moderator

    Do you want the iframe to automatically adjust to the height of the contents? If so, this is only possible either if you get the site's html with an ajax request or if the site's url meets the same origin policy.


  • GNU/Linux

    @pitaj said:

    Do you want the iframe to automatically adjust to the height of the contents? If so, this is only possible either if you get the site's html with an ajax request or if the site's url meets the same origin policy.

    Yeah. Would be good. I was thinking maybe you already have some sort of code in the core already for setting dimensions say with use with iphone and ipad.

    What sort of Ajax request would take the given url and be able to store those settings in the request. Then use them in the width and height dimensions in the iframe code.

    (function(module) {
        "use strict";
    
        var EmbedWebPage = {},
            embed = '<iframe id="iFrame" src="$1" style="width: 100%;border:0;" width="100%" height="3000" frameBorder="0" scrolling="no"></iframe>';
        var embedcode = /<a href="(.+)">.+<\/a>/g;
    
        EmbedWebPage.parse = function(data, callback) {
            if (!data || !data.postData || !data.postData.content) {
                return callback(null, data);
            }
            if (data.postData.content.match(embedcode)) {
                data.postData.content = data.postData.content.replace(embedcode, embed);
            }
            callback(null, data);
    
        };
    
        module.exports = EmbedWebPage;
    }(module));
    

    I would like to trigger the embed without using direct url's, my regexp is not great though


  • GNU/Linux

    var EmbedWikipedia = {},
            embed = '<iframe id="iFrame" height="3000" frameBorder="0" scrolling="no" style="width: 100%;border:0" width="100%" src="https://en.wikipedia.org/wiki/$1"></iframe>';
        var embedcode = /<a href="(?:https:\/\/)?(?:en\.)?(?:wikipedia\.org)\/(?:wiki\/)?(.+)<\/a>/g;
    

    use https:// for embedding wikipedia pages, http:// for making them links .. woohoo 👯


  • GNU/Linux

    any help with doing some pre checks with this plugin ? a test to see if uid=1 so that users can't access this embed


 

Suggested Topics

| |

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.