This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$api = Api::get("https://lesbonneschoses.prismic.io/api"); | |
$response = $api | |
->forms() | |
->everything | |
->query(Predicates::at("document.id", "UlfoxUnM0wkXYXbX")) | |
->ref($api->master()) | |
->submit(); | |
$results = $response->getResults(); | |
$doc = $results[0]; | |
// The resolver is defined here: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api = Prismic.api('https://lesbonneschoses.prismic.io/api') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api = Prismic.api('https://lesbonneschoses.prismic.io/api') | |
response = api | |
.form('everything') | |
.query(Prismic::Predicates::at('document.type', 'product')) | |
.submit(api.master_ref) | |
# response contains all documents of type 'product', paginated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api = Prismic.api('https://lesbonneschoses.prismic.io/api') | |
response = api | |
.form('everything') | |
.query( | |
Prismic::Predicates::at('document.type', 'product'), | |
Prismic::Predicates::date_after('my.blog-post.date', 1401580800000)) | |
.submit(api.master_ref) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resolver = Prismic.link_resolver('master'){ |doc_link| "http:#localhost/#{doc_link.id}" } | |
doc = response.results[0] | |
html = doc['blog-post.body'].as_html(resolver) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resolver = Prismic.link_resolver('master'){ |doc_link| "http:#localhost/#{doc_link.id}" } | |
serializer = Prismic.html_serializer do |element, html| | |
if element.is_a?(Prismic::Fragments::StructuredText::Block::Image) | |
# Don't wrap images in a <p> tag | |
%(<img src="#{element.url}" alt="#{element.alt}" width="#{element.width}" height="#{element.height}" />) | |
else | |
nil | |
end | |
end | |
doc = response.results[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api = prismic.get("http://lesbonneschoses.prismic.io/api") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api = prismic.get("http://lesbonneschoses.prismic.io/api") | |
response = api.form("everything").ref(api.get_master())\ | |
.query(predicates.at("document.type", "product"))\ | |
.submit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api = prismic.get("http://lesbonneschoses.prismic.io/api") | |
response = api.form("everything").ref(api.get_master()) \ | |
.query(predicates.at("document.type", "product"), | |
predicates.date_after("my.blog-post.date", 1401580800000))\ | |
.submit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def link_resolver(document_link): | |
return "/document/%s/%s" % (document_link.id, document_link.slug) | |
doc = response.documents[0] | |
html = doc.as_html(link_resolver) |