-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s9_event_social: Set og:description from s9y_event_metadesc. #45
Conversation
serendipity_event_metadesc makes it possible to specify a description for every entry that is used to set the "description" meta tag. This description, if present, should be used for the "og:description" meta tag, too. Using the first 200 chars can remain as a fallback solution. Signed-off-by: Thomas Hochstein <thh@inter.net>
Signed-off-by: Thomas Hochstein <thh@inter.net>
Perhaps someone has a better solution - I mostly pulled the code from s9y_event_metadesc, which seems to have another (better?) fallback. The full code there is:
The HTML escaping is done like this:
I've got no idea what I'm not really happy with that kind of copy&paste code duplication anyway, but didn't see an easy way to avoid it. One could, I think, put the code in a central function for getting the|a description - but I'll leave that to the more experienced developers. :) |
I can't properly test this. The metadesc plugin just does not work for me, it is not setting any description, but it breaks how my theme is setting the entry title. It is supposed to just pick of text enclosed in the tags specified in the configuration, no? Maybe me testing is not necessary. The code itself is smalland should work, at least if it works for you that is good enough for me. My Feedback:
I'll merge the pull request, make the small change and augment the version number. But we can still discuss of course and do additional changes. Thanks for the PR! |
Based on #45, slightly modified to use strip_tags instead
The plugin will add some input elements to the "advanced_options" part of the editor, see attached screenshot (German language).
Okay, thanks! - I'm not familier with the s9y code base at all, so did not much more than copy & paste from the metadesc plugin (which seems to be quite a bit older). It got that check with commit /d2d298ab41905ff3c7ee7757c98c439efaf71f77 about 2 years ago (from you, it seems 😀 ).
The user supplied description may contain single or double quotes which have to be escaped (or replaced by something else), I think, as they will break the meta element otherwise. A description like
Of course not! The metadesc plugin will apply strip_tags() later on, as it seems, but only if it discovers a And I'm not sure what will happen to other markup, like markdown, in the first 200 chars ... The metadesc plugin does it wrong, while the social plugin does the right thing. I wonder why ...
Thanks! - We'll have to escape quotes, I think. |
Thanks! That does not work for me. Well, separate bug, maybe something broke that in the current git master.
You're perfectly right. Do you want to add that yourself in a second PR?
The social plugin uses a very weird way to get the entry text. It could be that, or it is just that the markup plugin did not run yet. |
Can do. - Wouldn't it work to just add serendipity_specialchars() again, or is there more to do?
I have both plugins at the end of my plugin list, one after the other, so it's not the execution order. But I took that point to the forums, see Markup filtern - nicht nur HTML. |
That would be enough :) |
See #46, then. |
Currently s9y_event_social is using the first 200 chars of the entry body for the "og:description" meta tag.
The plugin s9y_event_metadesc makes it possible to specify a description for every entry that is used to set the "description" meta tag. This description, if present, should be used for the "og:description" meta tag, too. Using the first 200 chars can remain as a fallback solution.
At least the description from s9y_event_metadesc needs to be HTML-escaped. I think that goes for the first 200 chars from the body, too.
See http://board.s9y.org/viewtopic.php?f=10&t=20762&start=75 for a discussion (in German).