ElkArte Community

Extending Elk => Addons => Topic started by: forumsearch0r2 on April 28, 2018, 04:19:48 am

Title: [ADDON] OEmbed
Post by: forumsearch0r2 on April 28, 2018, 04:19:48 am
'member oEmbed? I 'member! (https://www.elkarte.net/community/index.php?topic=2442.0)

Yes, I should probably submit that to the front page. No, I won't (I try to avoid that GitHub thingy as much as possible). Give me a second way to submit a front matter file and I will consider it. Until then, I won't.  8)

This is version 1.0.6 which is the forumsearch0r version of "0.0.7 pre-alpha". It works but it could be more beautiful.

Obligatory add-on screenshot:



The README:

Quote
OEmbed Support

License
This ElkArte add-on is released under the terms of the WTFPL. Take it and do with it what the gently caress you want.
Parts of this add-on (mostly, the idea and the regular expressions) were ported from my blog software (https://www.blogcpp.org) which is also licensed under the same terms.

Features
Makes ElkArte support OEmbed, duh. Note that additional CSS is not a part of this add-on, but (e.g.) YouTube provides their own embedded stylesheets.

Requirements
This add-on won't do anything unless your PHP installation has the curl extension enabled.  By default, only JSON OEmbeds are recognized. If the xml extension is available, XML OEmbeds will be respected as well.

Donations
In case you absolutely want to make me richer, you can donate some money: PayPal. (https://paypal.me/GebtmireuerGeld)

Maybe I'll find out how Twitter's CSS can be fetched automatically or something.  ::)

Source code (https://code.rosaelefanten.org/ElkArte/dir?name=OEmbed) for the curious ones. Pull requests are appreciated unless they suck.

Enjoy or don't or whatever.
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on April 28, 2018, 02:03:56 pm
Change log etc. (will be updated):

version 1.0.1:
It seems like ElkArte supports the URL tag. OEmbed didn't. Now it does.

version 1.0.2:
A $ slipped in. PHP did not care, the code logic did though.

version 1.0.3:
Fixed a PCRE mistake introduced in 1.0.1.

version 1.0.4:
Completed dependency checking.

version 1.0.5:
Fixed the "empty message" error after trying to post a OEmbed-capable link.

version 1.0.6:
Added a cURL timeout flag.
Title: Re: [ADDON] OEmbed
Post by: Mrs. Chaos on May 10, 2018, 03:59:24 pm
Hi!
I just tried to install the addon twice. After the installations, I can not call/open the index page of the forum. Neither with link "Forum", nor by clicking on the house icon. Instead, this error message appears: preg_match_all (): Unknown modifier 'g'
What went wrong?
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 10, 2018, 04:52:17 pm
Try 1.0.3.
Title: Re: [ADDON] OEmbed
Post by: Mrs. Chaos on May 10, 2018, 05:34:21 pm
Thank you, now it works!
And thanks for the addon. :)
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 10, 2018, 06:38:58 pm
You're welcome!
Title: Re: [ADDON] OEmbed
Post by: Mrs. Chaos on May 10, 2018, 08:09:53 pm
How to embed Facebook posts? I tried it in different ways, but nothing was successful.
How can I embed such URLs, for example?

Code: [Select]
https://www.facebook.com/fontawesome/posts/1300194723417903

https://www.facebook.com/fontawesome/photos/a.905912386179474.1073741825.905911176179595/1300188240085218/?type=3
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 10, 2018, 08:27:50 pm
Does Facebook support OEmbed for that in the first place?
Title: Re: [ADDON] OEmbed
Post by: Mrs. Chaos on May 10, 2018, 09:19:09 pm
I thought Facebook would do that, but apparently that's not the case.
I found this page and thought I just have to insert a simple link, but it's a bigger thing and I don't know if that works in forums anyway.

https://developers.facebook.com/docs/plugins/oembed-endpoints?locale=en_US

Which pages officially support OEmbed?
.
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 10, 2018, 09:45:39 pm
Twitter and YouTube were both tested by me, some board software supports it as well (so does WordPress IIRC), otherwise there is no "official" list since anyone can just add OEmbed support to their site if they feel like it.

ElkArte does not, by the way.
Title: Re: [ADDON] OEmbed
Post by: Mrs. Chaos on May 10, 2018, 10:00:26 pm
Aha, okay.
It works with Instagram as well. Just like with Twitter with the date link.
Title: Re: [ADDON] OEmbed
Post by: Jason on May 15, 2018, 06:50:43 pm
Thank you @forumsearch0r2 , it works perfectly.
Title: Re: [ADDON] OEmbed
Post by: Jason on May 18, 2018, 07:28:42 pm
One issue is that, when i post YouTube link it shows

"The message has the following error or errors that must be corrected before continuing:

        The message body was left empty."
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 19, 2018, 05:23:08 pm
Which video have you tried? So I can reproduce it.
Title: Re: [ADDON] OEmbed
Post by: Jason on May 20, 2018, 09:06:19 am
Any youtube video, gives me the same error.

Url: https://www.youtube.com/watch?v=3nQNiWdeH2Q

X
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 20, 2018, 04:45:36 pm
Welcome to "things I had not tested" ... :D

Turns out that it is (mostly) impossible to have an ElkArte post which only contains HTML text without any extra text. There is no obvious way to circumvent that.

I'm on it.
Title: Re: [ADDON] OEmbed
Post by: Jason on May 27, 2018, 06:10:55 pm
@forumsearch0r2 any updates on the Addon?
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 27, 2018, 08:31:59 pm
I haven't heard back from @emanuele yet - I asked him on the IRC about a possible solution and I am still waiting. :)
Because I - personally - don't know the internals of ElkArte well enough.

Do you happen to have an idea?
Title: Re: [ADDON] OEmbed
Post by: tino on May 27, 2018, 09:28:30 pm
Can you not just add a &nbsp?

It’s not a pretty way I’ll give you that but it ‘should’ work. I think anyway...
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 27, 2018, 11:25:13 pm
I would assume that " " would appear as plain text in the posting...
Title: Re: [ADDON] OEmbed
Post by: tino on May 27, 2018, 11:26:05 pm
It should appear as a space, I would of thought?
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 27, 2018, 11:53:16 pm
No, that does not work -   seems to be counted as "no text" by ElkArte's emptiness parser.
Title: Re: [ADDON] OEmbed
Post by: Spuds on May 28, 2018, 01:46:57 am
You could try
Code: [Select]
⁣
that may not strip out

Oh .. in addition to curl you should check for xml_parser_create ... see the Ubuntu note here http://php.net/manual/en/xml.installation.php
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 28, 2018, 02:27:26 am
It does not, indeed. Thank you. (Now this is an ugly workaround... I'd like to request a plug-in hook to allow empty messages, please?)
I updated the add-on to version 1.0.4, reflecting changes that worked in my test installation. :)
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 28, 2018, 02:42:33 am
Oh .. in addition to curl you should check for xml_parser_create ... see the Ubuntu note here http://php.net/manual/en/xml.installation.php

Oh, Ubuntu. Never cease to de-amaze me.
I'm updating to 1.0.5 which checks for the "xml" extension as well...
Title: Re: [ADDON] OEmbed
Post by: ahrasis on May 28, 2018, 06:27:26 am
So long as php is properly installed, an ubuntu server should work just fine as any others. :P
Title: Re: [ADDON] OEmbed
Post by: Jason on June 18, 2018, 07:45:35 pm
@forumsearch0r2 So i can download the addon again from first post and use it?
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on June 18, 2018, 09:20:13 pm
Uhm... probably.
Title: Re: [ADDON] OEmbed
Post by: Jason on June 19, 2018, 06:34:49 pm
@forumsearch0r2 i asked that assuming you have updated the addon. If not no use in downloading it again.
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on June 19, 2018, 07:36:06 pm
I did - to 1.0.5. :)
I forgot to update the change log though.
Title: Re: [ADDON] OEmbed
Post by: Jason on June 19, 2018, 07:42:51 pm
Thank you so much, let me try it and update you!
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on June 19, 2018, 07:48:11 pm
Looking forward to the next bugs to fix!