[CDB] Magic OGP links: thumbnails and descriptions

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Scam Warning
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
User avatar
Ger
Registered User
Posts: 1152
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

[CDB] Magic OGP links: thumbnails and descriptions

Post by Ger » Thu Sep 14, 2017 8:41 am

Extension Name:Magic OGP links: thumbnails and descriptions
Author: Ger

Extension Description: Fetch plain pasted "magic urls" to render as rich content with the Open Graph Protocol tags, just like you see on Facebook, Twitter, etc.

Extension Version: 1.0.0

Requirements:
  • phpBB 3.2
  • PHP 5.4+
  • cURL
  • Libxml
  • DOMDocument
  • DOMXPath
All of these are usually available on your server when you're on a descent host.

Visitors need Javascript for the rendering, otherwise the links appear as regular phpBB links.

Features:
  • Let users simply copy and paste their links without hassle
  • Parses the OGP image, title and description in a nice looking block
  • The entire block is the link
  • Falls back to regular HTML title and meta description when possible
  • Falls back to regular phpBB links when no (sufficient) OGP data is found
  • Fetches OGP data on posting so it doesn't impact each time on rendering
  • When posting with url=... tags the OGP data isn't fetched so your users can choose use regular links in their text when they want to
Screenshots:
Image


Extension Download: https://github.com/GerB/magicogp
Last edited by Ger on Mon Nov 13, 2017 2:27 pm, edited 4 times in total.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
JoshyPHP
Code Contributor
Posts: 753
Joined: Mon Jul 11, 2011 12:28 am

Re: [3.2][ALPHA] Magic OGP URL: rich pasted links

Post by JoshyPHP » Thu Sep 14, 2017 1:18 pm

I took a quick look at the repository. Looks alright. I think you can replace this block of code:

Code: Select all

// Search image_src if no img yet
if (!isset($this->values['image'])) {
	$domxpath = new \DOMXPath($doc);
	$elements = $domxpath->query("//link[@rel='image_src']");
	if ($elements->length > 0) {
		$domattr = $elements->item(0)->attributes->getNamedItem('href');
		if ($domattr) {
			$this->values['image'] = $domattr->value;
			$this->values['image_src'] = $domattr->value;
		}
	}
}

// Still no image? Try fetching the icon
if (!isset($this->values['image'])) {
	$domxpath = new \DOMXPath($doc);
	$elements = $domxpath->query("//link[@rel='icon']");
	if ($elements->length > 0) {
		$domattr = $elements->item(0)->attributes->getNamedItem('href');
		if ($domattr) {
			$this->values['image'] = $domattr->value;
			$this->values['image_src'] = $domattr->value;
		}
	}
}
...with this:

Code: Select all

foreach (['image_src', 'icon'] as $name)
{
	$value = $domxpath->evaluate('string(//link[@rel="' . $name . '"]/@href)');
	if ($value > '')
	{
		$this->values['image']     = $value;
		$this->values['image_src'] = $value;
		break;
	}
}
You may also want to look into those XPath queries, although it's not as useful since you need to retrieve the name of the OGP property too:

Code: Select all

//meta[starts-with(@property, "og:")]/@content
//meta[starts-with(@name,     "og:")]/@content
//meta[starts-with(@property, "og:")]/@value
I wrote the thing that does the BBCodes in 3.2. Unless it broke yours, in which case it was somebody else with a similar name.

User avatar
Ger
Registered User
Posts: 1152
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2][ALPHA] Magic OGP URL: rich pasted links

Post by Ger » Thu Sep 14, 2017 1:39 pm

Thanks :)

Yeah, I copied that thingy later to check if it would make a difference. Code is still far from complete and can definitely use some optimisations here and there.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
Chrono
Registered User
Posts: 70
Joined: Fri Jul 12, 2002 2:52 am
Location: Chihuahua México
Name: Alfonso Camacho
Contact:

Re: [3.2][ALPHA] Magic OGP URL: rich pasted links

Post by Chrono » Thu Sep 14, 2017 7:31 pm

Hey... thats a cool and awesome idea :D

Can I sugest at option to show the content in vertical? nice thumb in the left whit the summary in the right :D, or some size option to personalize the output of the content :)

Keep the good work.

Cheers!
www.degeneracionx.com - Anime, Games & Nothing Else.
Anime and Games Hispanic Community (Spanish only)
Sorry for my poor english

User avatar
SalazarAG
Registered User
Posts: 665
Joined: Mon Mar 30, 2015 10:48 am

Re: [3.2][ALPHA] Magic OGP URL: rich pasted links

Post by SalazarAG » Fri Sep 15, 2017 1:45 am

Hi! Excellent extension, but does it cause conflict with Media Embed?
I'm sorry for my English. Google Translator does a bad job. :D

Toxyy
Registered User
Posts: 323
Joined: Mon Oct 24, 2016 3:22 pm

Re: [3.2][ALPHA] Magic OGP URL: rich pasted links

Post by Toxyy » Fri Sep 15, 2017 4:36 am

Is it responsive?
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

User avatar
Ger
Registered User
Posts: 1152
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2][ALPHA] Magic OGP URL: rich pasted links

Post by Ger » Fri Sep 15, 2017 6:54 am

SalazarAG wrote:
Fri Sep 15, 2017 1:45 am
Hi! Excellent extension, but does it cause conflict with Media Embed?
Haven't tried it yet. I'd say: take a test and let me know :P
This is the very first version of this extension, not much more than a proof-of-concept.
Toxyy wrote:
Fri Sep 15, 2017 4:36 am
Is it responsive?
It scales just like any other text and image in a post.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
Ger
Registered User
Posts: 1152
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2][ALPHA] Magic OGP URL: rich pasted links

Post by Ger » Fri Sep 15, 2017 7:52 am

Chrono wrote:
Thu Sep 14, 2017 7:31 pm
Can I sugest at option to show the content in vertical? nice thumb in the left whit the summary in the right :D, or some size option to personalize the output of the content :)
Missed this earlier.

I've added some simple styling in ./ext/ger/magicogp/styles/prosilver/theme/magicogp.css
If you want to, you can add or override these definitions in your own stylesheet.

You might want to do something like this:

Code: Select all

.ogpblock img {
	width: 150px;
}
.ogptext {
	width: calc(100% - 180px);
}
That should cover it. Be aware though that this extension is far from ready so I might change the default style definitions and that they mess with your additions.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
SalazarAG
Registered User
Posts: 665
Joined: Mon Mar 30, 2015 10:48 am

Re: [3.2][ALPHA] Magic OGP URL: rich pasted links

Post by SalazarAG » Sun Sep 17, 2017 1:46 am

Ger wrote:
Fri Sep 15, 2017 6:54 am
SalazarAG wrote:
Fri Sep 15, 2017 1:45 am
Hi! Excellent extension, but does it cause conflict with Media Embed?
Haven't tried it yet. I'd say: take a test and let me know :P
This is the very first version of this extension, not much more than a proof-of-concept.
Toxyy wrote:
Fri Sep 15, 2017 4:36 am
Is it responsive?
It scales just like any other text and image in a post.
Hi, I tested the two extensions and had no conflicts. Very good. Congratulations for your work.
I'm sorry for my English. Google Translator does a bad job. :D

User avatar
Ger
Registered User
Posts: 1152
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2][ALPHA] Magic OGP URL: rich pasted links

Post by Ger » Sun Sep 17, 2017 6:36 am

Thanks!
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
Ger
Registered User
Posts: 1152
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2][BETA] Magic OGP URL: rich pasted links

Post by Ger » Mon Sep 18, 2017 1:01 pm

Most functions seem to be working well, so I upped this to BETA.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
Ger
Registered User
Posts: 1152
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: [3.2][RC] Magic OGP links: thumbnails and descriptions

Post by Ger » Wed Oct 04, 2017 8:21 am

I tweaked the styling a bit, see the updated screenshot in TS.
Since everything seems to work smoothly I intend to release this soon.
Checkout my extensions: Simple CMS, Feed post bot, Modbreak, Magic OGP links and Live topic update

Like my work? Buy me a coffee to keep it coming. :ugeek:

User avatar
Chrono
Registered User
Posts: 70
Joined: Fri Jul 12, 2002 2:52 am
Location: Chihuahua México
Name: Alfonso Camacho
Contact:

Re: [3.2][RC] Magic OGP links: thumbnails and descriptions

Post by Chrono » Thu Oct 05, 2017 8:49 pm

Ger wrote:
Wed Oct 04, 2017 8:21 am
I tweaked the styling a bit, see the updated screenshot in TS.
Since everything seems to work smoothly I intend to release this soon.
Nice. Im gonna checkit out :)

Cheers!
www.degeneracionx.com - Anime, Games & Nothing Else.
Anime and Games Hispanic Community (Spanish only)
Sorry for my poor english

User avatar
Froddelaar
Registered User
Posts: 503
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: [3.2][RC] Magic OGP links: thumbnails and descriptions

Post by Froddelaar » Thu Oct 05, 2017 10:28 pm

It should pull an image from the link, to share your post on social media like Facebook :lol:
Naaah it works great! Thank you!
I'm A Stupid F*ck.. And Proud Of it!
Download +34.000 arcade extension games @ ~ https://www.froddelpower.be ~

Dutch Extension Translations @ https://github.com/Solidjeuh
Donations are always welcome @ https://www.froddelpower.be/donation

User avatar
Theriddler1
Registered User
Posts: 440
Joined: Sat Aug 27, 2011 11:00 pm
Location: NL
Contact:

Re: [3.2][RC] Magic OGP links: thumbnails and descriptions

Post by Theriddler1 » Tue Oct 10, 2017 9:46 am

tested your extension Ger, nice work but i can only see it parsed when previewing the post
after posting the link is not parsed anymore

example: https://peppersrusforum.nl/viewtopic.php?p=44321#p44321
Theriddler - Moderator @ phpBB.nl | phpBBservice.nl Team-member
ImageSupport Tools | Image My Extensions | buy me a beer Image

Locked

Return to “Extensions in Development”

Who is online

Users browsing this forum: Bermudez, JohnnyBigSpuds, MohamedAG, Tbot [Bot] and 27 guests

cron