-
Notifications
You must be signed in to change notification settings - Fork 9
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
[rdf] Include JSON-LD in pages #216
Conversation
* Add an alternate link. * Because search engines don't follow those links, also include the JSON-LD in the page. * Tested against Google's structured data testing tool (https://search.google.com/structured-data/testing-tool).
@Dirklectisch Please review and merge if ok. |
@@ -20,6 +20,8 @@ | |||
|
|||
m_find_value(#rdf_resource{} = Rdf, #m{value = undefined} = M, _Context) -> | |||
M#m{value = Rdf}; | |||
m_find_value(Id, #m{value = undefined}, Context) when is_integer(Id) -> | |||
mochijson2:encode(ginger_json_ld:serialize(to_triples(Id, Context))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ddeboer I think this will be a problem for when you are using a model to chain a query. For example m.rdf[id].predicate will not work anymore? You could use the to_value function to realise the actual value and return and #m record here instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But m_value
is only triggered for {{ m.rdf }}
, not {{ m.rdf[id] }}
.
Anyway, there shouldn’t be a problem, because of the is_integer
guard. You
- either pass an RDF resource (
m.rdf[id.rdf]['http://bla.com/some_predicate']
) - or call
m.rdf[id]
with an integer (rsc id) and without any arguments, which will dump the whole thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry missed the guard. Tested the branch locally on JHM seems to work. I'll merge it now.
BTW. I do think m_value is called for when you do {{ m.rdf[id] }}
if you return an m# record.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Enjoy dd7cc1e. 😉
Fix #179.