Problem/Motivation

With the use of mf2 or schema.org parsers used in the implementation of webmentions we can obtain a lot of metadata(as explained in https://indieweb.org/Semantic_Linkbacks ) from a received linkback. But the main module linkback entity has no fields to store it, so by now excerpt is used.

Proposed resolution

Add a field to store json serialized data obtained from source mapping. It will allow dynamic metainfo.

Another option may be adding static types (as told in https://indieweb.org/Semantic_Linkbacks) and add some other fields: author, author url, author image, but I think that this way we will find some monolithic handicaps whenever some other metainfo needs to be obtained; think about rsvp Events or some schema.org "Thing"s as Books, Events, or Recipes... that are linkbacking to our site...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aleix created an issue. See original summary.

aleix’s picture

Title: Incoming linkback metainfo » Store received linkback metainfo

  • aleix committed 53bb34e on 8.x-1.x
    Issue #2866516: Store received linkback metainfo
    
aleix’s picture

Until is not discussed the destination of the metainfo, it's included in excerpt as json.

HongPong’s picture

To give a little more flexibility later I think it would be good to make an $options parameter in this area. It could be used later to instruct for example the way tokens could be used to build the excerpts or other aspects of the entity field.

In /src/EventSubscriber/WebmentionReceiveSubscriber.php I think we should make an empty array $options as the last param on public function processWebmention and protected function saveLinkback.

saveLinkback should be renamed saveLinkbackEntity .

processWebmention could be renamed processWebmentionIntoLinkbackEntity .

I will try and have a patch with this and some other ideas within about a day. After a few changes I think we can say this is a good enough API to finally release a version.

HongPong’s picture

Status: Active » Needs review
FileSize
6.7 KB
8.25 KB

Okay I changed a few other things and also extracted the json encode to its own function generateExcerptFromMetadata so that it could be controlled later with a config option to pick something else instead of json if someone wanted to.

Also based on what my IDE seems to be saying I think
protected function saveLinkbackEntity($source, $target, EntityInterface $local_entity, $linkback, array $metainfo, $options = array()) {
$local_entity should be LinkbackInterface not EntityInterface.

I got tired and included the same as https://www.drupal.org/node/2871666 accidentally. Best regards

aleix’s picture

Futureproof. imo push it.

HongPong’s picture

Sweet thanks for checking it out. I will put it in later tonight. Let me know if you like the similar idea on #2871880: Make Linkback Entity / interface fieldable . I would like to get these extra $options committed so we can do an alpha release for Drupalcon if possible, to minimize issues with more API changes in the future.

  • HongPong committed 59a99b1 on 8.x-1.x
    Issue #2866516 by HongPong: linkbackreceiver typo around metadata...
  • HongPong committed d62f022 on 8.x-1.x
    Issue #2866516 by HongPong: linkbackreceiver typo around metadata...

  • HongPong committed 33f583a on 8.x-1.x
    Issue #2866516 by HongPong: Fixes on Received linkback metainfo
    
    

  • aleix committed 11de98c on 8.x-1.x
    Issue #2871880 by HongPong, aleix: Make Linkback Entity / interface...
aleix’s picture

Version: » 8.x-1.x-dev
Status: Needs review » Fixed

It's done, every field created by user can be mapped through [text and link] field settings ("admin/structure/linkback/manage/fields" > edit) in linkback structure ( admin/structure/linkback) ) to a json property stored in metainfo, by now rdf mapping and microformat mapping can be done. When Linkback is presaved it will create the values in every field that has some mapping defined.

A thirdparty options on each field will bring options to get the value of json object to set the field. The code to bring the mapping through fields is done in Linkback entity class, don't know if this place is correct, but I found that this is the better as I need a many fields based operations and communications. Suggestions or changes are welcome....

Despite the fullfillment of the metainfo field is by now only done in webmention, I have written the alter of the field settings in linkback main module, as I think that these rdf and microformats mapping are useful for both webmention and pingback.
Maybe in next future we can implement mf2/rdf parsing to pingback component, as the semantic linking can be done independently of the linkback handler. Take as a transition plan, until webmentions conquers the heart of all these wordpressers using 2002 techonolgies.

If we need new mappings by a new submodule we need to add thirparty settings to field and manipulate json parsing to fill requirements.

HongPong’s picture

Oh sweet this is fantastic. I think after checking for coder notices we can tag alpha1. I will take a shot that kind of cleanup today. Cheer :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.