Skip to content
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

Merged
merged 1 commit into from
Nov 9, 2016
Merged

[rdf] Include JSON-LD in pages #216

merged 1 commit into from
Nov 9, 2016

Conversation

ddeboer
Copy link
Contributor

@ddeboer ddeboer commented Nov 9, 2016

Fix #179.

* 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).
@ddeboer
Copy link
Contributor Author

ddeboer commented Nov 9, 2016

@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)));
Copy link
Contributor

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.

Copy link
Contributor Author

@ddeboer ddeboer Nov 9, 2016

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@ddeboer ddeboer Nov 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Enjoy dd7cc1e. 😉

@Dirklectisch Dirklectisch merged commit 5dea8cf into master Nov 9, 2016
@ddeboer ddeboer deleted the 179-link-to-json-ld branch November 9, 2016 12:57
@ddeboer ddeboer added this to the 0.18.0 milestone Nov 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants