MyBB Community Forums

Full Version: Link Highlighter Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am putting this request for a plugin.

The plugin should be able to highlight any url posted by the members in the forum. Whether it is tweet or a link to another article. Like this.

[Image: 1.jpg]


[Image: 2.jpg]
Hello vk_knight

That is a very interesting idea. We'll look into this very soon at ModMyBB.

We'll keep you posted
@KevinVR Got the idea by seeing Xenforo boards.ToungueWink
Any updates regarding this plugin people?
interesting im waiting this one too
Today I woke up inspired to add this feature to Link Tools as flagged as a possibility here. I have a bunch of ideas, but would love to hear what you guys are actually looking for. Am about to start coding, so get in quick. :-)

Here are some preliminary questions that I have:
  1. Should link previews be auto-inserted into the post during drafting of the post, perhaps as a tag which the editor then renders: [linkpreview]https://link.to/preview.html[/linkpreview]? Advantage of this approach: the poster can delete or move them before posting. Or should they be auto-inserted (without tags to control their placement/existence) only when the post is rendered? Advantages of this approach: the previews cannot be removed, and are consistently placed - which admins might appreciate. Should either approach be configurable either per-forum, per-usergroup, or for the board as as whole?
  2. Where in the post should link previews be inserted? If the sole contents of a post is a link, then the answer is easy: just append the preview to the post. But what if it is in the middle of a paragraph, or a list? Should the preview then be inserted after the paragraph/list (or at the end of the list item?)? Or should previews simply always be appended to the end of the post (kind of like attachments)? Finally, should each of these options be configurable, either per-post or for the board as a whole?
And here are my current ideas:
  1. Add the following three ACP settings:

    1. Enable link previews for:
      • All domains.
      • No domains.
      • Only domains with link helpers.
      • Only domains with 3rd-party link helpers. [see below]
      • Only the following domains.
      • All domains except the following domains.
    2. Link preview whitelisted/blacklisted domains. (A free-form list of domains, or perhaps of regexes to match domains against).
    3. Disable link previews for links within this board's domain:
      • Yes
      • No
  2. Create a new base/default class "LinkHelper". This class would provide basic/generic functionality to generate a link preview given the link and its HTML. The preview's code would be stored in the plugin's urls database table - a new column would be added for this purpose. Another column would be added to indicate the datetime at which the preview was last generated.
  3. Any preview images downloaded (and optionally resized or otherwise manipulated) by an object of the LinkHelper class would be stored in a custom directory under uploads.
  4. Add two directories under inc/plugins/linktools: link-helpers-dist and link-helpers-3rd-party. These would contain classes which extend the LinkHelper class, and which Link Tools would auto-load. The first directory would contain link helpers distributed with the plugin and officially supported. The second would contain helpers obtained elsewhere or custom-written.
  5. Each link helper would stipulate the domain(s) for which it generates previews, potentially via a (set of) regex(es), as well as an integer priority (negative, zero, or positive). If multiple link helpers match the domain of a link for which a preview is to be generated, the link helper to be used is chosen by the following simple criteria:

    1. 3rd-party link helpers take precedence over distributed link helpers.
    2. Thereafter, the link helper with the highest priority takes precedence. If any two link helpers have the same precedence, the choice is made arbitrarily.
  6. Make a manual "Regenerate Preview" feature available for any given link in case its target page has changed since the preview was last generated. Check the datetime at which the link was last regenerated to prevent flooding.
  7. Also, auto-regenerate a preview after a given amount of time has elapsed (say, perhaps, a week?).
  8. Provide a new entry under Tools & Maintenance => Recount & Rebuild to regenerate all link previews. This would be especially useful when either of the two new ACP settings were changed.
  9. Also, though, auto-generate missing previews on-the-fly as needed, so that the Recount/Rebuild tool doesn't need to be run - that Recount/Rebuild tool would simply be useful to speed up page rendering by ensuring that on-the-fly generation is not necessary.
  10. Finally, provide a function to invalidate all cached link previews (another database column would be provided for this purpose) so that every preview was auto-generated on-the-fly the next time it was needed, again making it unnecessary to use the Recount/Rebuild tool.

OK, that's about it so far. Suggestions and comments welcome.
I think perhaps some domain white or black list settings so your plugin works on the mycode_url template. They should be appended to the end of the paragraph, I think this is how services like Discord do it.

Quote:Any preview images downloaded (and optionally resized or otherwise manipulated) by an object of the LinkHelper class would be stored in a custom directory under uploads.

Perhaps some cache mechanism should be added instead for updating the preview image if possible #7). But more importantly make it easy (with hooks?) for plugins to modify the location of the stored (image files) data. I'm thinking about sites storing images outside the forum file system (CDN).

I have thought about coding such a feature myself, but I have never got around it I will probably never do. But I have seen some interesting libraries to accomplish it (I think you don't use libraries for your current stable release):
https://github.com/oscarotero/Embed
Thanks for the feedback, Omar.

(2021-01-28, 09:38 PM)Omar G. Wrote: [ -> ]I think perhaps some domain white or black list settings

I suggested above providing three new plugin settings, the first of which includes the option to white/blacklist domains - do you mean something on top of this, or did you simply just miss them in my admittedly long list?

(2021-01-28, 09:38 PM)Omar G. Wrote: [ -> ]so your plugin works on the mycode_url template.

If you mean that the plugin should pull the same links out of posts that are pulled out for the mycode_url template, then, yes, it will do that (and already does). It will also work for bare URLs (again, as it already does). I think though that link previews will be disabled for video tags. Or am I misunderstanding you?

(2021-01-28, 09:38 PM)Omar G. Wrote: [ -> ]They should be appended to the end of the paragraph, I think this is how services like Discord do it.

Fair enough - sounds like a good way to do it.

(2021-01-28, 09:38 PM)Omar G. Wrote: [ -> ]
Quote:Any preview images downloaded (and optionally resized or otherwise manipulated) by an object of the LinkHelper class would be stored in a custom directory under uploads.

Perhaps some cache mechanism should be added instead for updating the preview image if possible #7). But more importantly make it easy (with hooks?) for plugins to modify the location of the stored (image files) data. I'm thinking about sites storing images outside the forum file system (CDN).

Now I'm even wondering whether downloading images at all is a bad idea given that it potentially violates copyright. Perhaps images should simply be linked to on their original sites. The only problems with that are that some sites block images that are not referred from the site itself and that some images may have an excessively large file size for a preview.

(2021-01-28, 09:38 PM)Omar G. Wrote: [ -> ]I have thought about coding such a feature myself, but I have never got around it I will probably never do. But I have seen some interesting libraries to accomplish it (I think you don't use libraries for your current stable release):
https://github.com/oscarotero/Embed

I don't use libraries, no, and would prefer to keep it that way, but if I was to use one, that sure looks like a good one!
Quote:I suggested above providing three new plugin settings, the first of which includes the option to white/blacklist domains - do you mean something on top of this, or did you simply just miss them in my admittedly long list?

I just forgot to remove these once I read that part of your post Toungue

Quote:Or am I misunderstanding you?

No, that was it.

Quote:The only problems with that are that some sites block images that are not referred from the site itself and that some images may have an excessively large file size for a preview.

I don't think this is an issue as usually meta data images are meant to be accessible by outsiders. If sites block them for specific sites like Facebook well, you can't please or work around everybody. If the image isn't accessible perhaps display no image or a stock image. The same applies if images have some copyright, I would assume sites like Facebook do some kind of caching as well.

Also, you can purge the cache for old images (posts accessed too long ago) to control the size of it. Then rebuild on request. Perhaps even ignoring bots for the display of images or embeds altogether.
(2021-01-28, 11:59 PM)Omar G. Wrote: [ -> ]
Quote:The only problems with that are that some sites block images that are not referred from the site itself and that some images may have an excessively large file size for a preview.

I don't think this is an issue as usually meta data images are meant to be accessible by outsiders. If sites block them for specific sites like Facebook well, you can't please or work around everybody. If the image isn't accessible perhaps display no image or a stock image.

Good point: mostly, I'd hope, in the modern age, a page will provide an image specifically aimed at social media snippets. If not, yes, a stock image will suffice.

(2021-01-28, 11:59 PM)Omar G. Wrote: [ -> ]Perhaps even ignoring bots for the display of images or embeds altogether.

That's an interesting idea. I'm not sure though that it would gain us much performance-wise. Are there other reasons to show different contents to bots than to regular users?

In any case, a development update:

I have made good progress on this feature today - not as much as I'd hoped for, but that's par for the course.

Currently implemented are (1) the new settings and (2) the infrastructure for Link Helpers, including prioritisation, and including the  generation of (a) preview(s) when posting (a) link(s).

Yet to implement is the display of link previews in the appropriate (or any) location in a post, as well as the other features planned above such as the Recount & Rebuild functionality.

The day is not over yet though...
Pages: 1 2