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...
Comment | File | Size | Author |
---|---|---|---|
#6 | receivesubscriber-2.patch | 8.25 KB | HongPong |
#6 | receivesubscriber.patch | 6.7 KB | HongPong |
Comments
Comment #2
aleix CreditAttribution: aleix commentedComment #4
aleix CreditAttribution: aleix commentedUntil is not discussed the destination of the metainfo, it's included in excerpt as json.
Comment #5
HongPong CreditAttribution: HongPong as a volunteer and at kor group commentedTo 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.
Comment #6
HongPong CreditAttribution: HongPong as a volunteer and at kor group commentedOkay 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
Comment #7
aleix CreditAttribution: aleix commentedFutureproof. imo push it.
Comment #8
HongPong CreditAttribution: HongPong as a volunteer and at kor group commentedSweet 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.
Comment #12
aleix CreditAttribution: aleix commentedIt'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.
Comment #13
HongPong CreditAttribution: HongPong as a volunteer and at kor group commentedOh 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 :)