ElkArte Community

Extending Elk => Addons => Topic started by: forumsearch0r2 on April 27, 2018, 10:19:48 pm

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

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:

(Link-5754)

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, 08:03:56 am
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, 09:59:24 am
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, 10:52:17 am
Try 1.0.3.
Title: Re: [ADDON] OEmbed
Post by: Mrs. Chaos on May 10, 2018, 11:34:21 am
Thank you, now it works!
And thanks for the addon. :)
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 10, 2018, 12:38:58 pm
You're welcome!
Title: Re: [ADDON] OEmbed
Post by: Mrs. Chaos on May 10, 2018, 02: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, 02: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, 03: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, 03: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, 04: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, 12:50:43 pm
Thank you @forumsearch0r2 , it works perfectly.
Title: Re: [ADDON] OEmbed
Post by: Jason on May 18, 2018, 01: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, 11:23:08 am
Which video have you tried? So I can reproduce it.
Title: Re: [ADDON] OEmbed
Post by: Jason on May 20, 2018, 03:06:19 am
Any youtube video, gives me the same error.

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

(Link-5818)
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 20, 2018, 10:45:36 am
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, 12:10:55 pm
@forumsearch0r2 any updates on the Addon?
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 27, 2018, 02: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, 03: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, 05: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, 05:26:05 pm
It should appear as a space, I would of thought?
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on May 27, 2018, 05: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 27, 2018, 07:46:57 pm
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 27, 2018, 08:27:26 pm
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 27, 2018, 08:42:33 pm
Quote from: Spuds – 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, 12: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, 01: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, 03:20:13 pm
Uhm... probably.
Title: Re: [ADDON] OEmbed
Post by: Jason on June 19, 2018, 12: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, 01: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, 01: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, 01:48:11 pm
Looking forward to the next bugs to fix!
Title: Re: [ADDON] OEmbed
Post by: radu81 on April 20, 2021, 05:28:55 am
is this add-on compatible with elkarte 1.1? If so, please update the first post of this topic.
Also, can you add it to Elkarte Add-ons https://addons.elkarte.net/ ?

Quote from: forumsearch0r2 – It amazes me that this add-on needs to add new sites manually while mine (without any copyright removal needed) does not:
https://www.elkarte.net/community/index.php?topic=5178.0
could be that your add-on is difficult to find 
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on April 20, 2021, 05:39:00 am
It should. (As I am currently not running an ElkArte instance - which I plan to change soon -, I'd be glad about any feedback.)

How does adding add-ons work? I haven't checked that yet.
Title: Re: [ADDON] OEmbed
Post by: radu81 on April 20, 2021, 07:08:03 am
Have a look at this https://www.elkarte.net/community/index.php?topic=2325.0
I can't help since I'm not a coder and don't know how github works, if you have problems ask on forum, I'm sure that someone will answer.
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on April 20, 2021, 07:15:37 am
Ew, Git...
Title: Re: [ADDON] OEmbed
Post by: forumsearch0r2 on April 21, 2021, 12:21:54 pm
Submitted a PR. Now waiting.

edit: Didn't have to wait long.