public PrismicContext(string endpoint, prismic.Api api, string maybeRef, prismic.DocumentLinkResolver linkResolver) { this.endpoint = endpoint; this.api = api; this.maybeRef = maybeRef; this.linkResolver = linkResolver; }
public String AsHtml(DocumentLinkResolver linkResolver, HtmlSerializer htmlSerializer) { String html = ""; foreach(KeyValuePair<String,Fragment> fragment in Fragments) { html += ("<section data-field=\"" + fragment.Key + "\">"); html += GetHtml(fragment.Key, linkResolver, htmlSerializer); html += ("</section>"); } return html.Trim(); }
public String AsHtml(DocumentLinkResolver linkResolver, HtmlSerializer htmlSerializer) { String html = ""; foreach (KeyValuePair <String, Fragment> fragment in Fragments) { html += ("<section data-field=\"" + fragment.Key + "\">"); html += GetHtml(fragment.Key, linkResolver, htmlSerializer); html += ("</section>"); } return(html.Trim()); }
public static String GetHtml(Fragment fragment, DocumentLinkResolver resolver, HtmlSerializer serializer) { if (fragment == null) { return(""); } if (fragment is fragments.StructuredText) { return(((fragments.StructuredText)fragment).AsHtml(resolver, serializer)); } if (fragment is fragments.Number) { return(((fragments.Number)fragment).AsHtml()); } if (fragment is fragments.Color) { return(((fragments.Color)fragment).AsHtml()); } if (fragment is fragments.Text) { return(((fragments.Text)fragment).AsHtml()); } if (fragment is fragments.Date) { return(((fragments.Date)fragment).AsHtml()); } if (fragment is fragments.Embed) { return(((fragments.Embed)fragment).AsHtml()); } else if (fragment is fragments.Image) { return(((fragments.Image)fragment).AsHtml(resolver)); } else if (fragment is fragments.WebLink) { return(((fragments.WebLink)fragment).AsHtml()); } else if (fragment is fragments.DocumentLink) { return(((fragments.DocumentLink)fragment).AsHtml(resolver)); } else if (fragment is fragments.Group) { return(((fragments.Group)fragment).AsHtml(resolver)); } else if (fragment is fragments.SliceZone) { return(((fragments.SliceZone)fragment).AsHtml(resolver)); } return(""); }
/** * Return the URL to display a given preview * @param token as received from Prismic server to identify the content to preview * @param linkResolver the link resolver to build URL for your site * @param defaultUrl the URL to default to return if the preview doesn't correspond to a document * (usually the home page of your site) * @return the URL you should redirect the user to preview the requested change */ public async Task <String> PreviewSession(String token, DocumentLinkResolver linkResolver, String defaultUrl) { var tokenJson = await this.prismicHttpClient.fetch(token, logger, cache); var mainDocumentId = tokenJson["mainDocument"]; if (mainDocumentId == null) { return(defaultUrl); } var resp = await Form("everything") .Query(Predicates.at("document.id", mainDocumentId.ToString())) .Ref(token) .Submit(); if (resp.Results.Count == 0) { return(defaultUrl); } return(linkResolver.Resolve(resp.Results[0])); }
public static String GetHtml(Fragment fragment, DocumentLinkResolver resolver, HtmlSerializer serializer) { if (fragment == null) return ""; if (fragment is fragments.StructuredText) { return ((fragments.StructuredText)fragment).AsHtml(resolver, serializer); } if(fragment is fragments.Number) { return ((fragments.Number)fragment).AsHtml(); } if(fragment is fragments.Color) { return ((fragments.Color)fragment).AsHtml(); } if(fragment is fragments.Text) { return ((fragments.Text)fragment).AsHtml(); } if(fragment is fragments.Date) { return ((fragments.Date)fragment).AsHtml(); } if(fragment is fragments.Embed) { return ((fragments.Embed)fragment).AsHtml(); } else if(fragment is fragments.Image) { return ((fragments.Image)fragment).AsHtml(resolver); } else if(fragment is fragments.WebLink) { return ((fragments.WebLink)fragment).AsHtml(); } else if(fragment is fragments.DocumentLink) { return ((fragments.DocumentLink)fragment).AsHtml(resolver); } else if(fragment is fragments.Group) { return ((fragments.Group)fragment).AsHtml(resolver); } else if (fragment is fragments.SliceZone) { return ((fragments.SliceZone)fragment).AsHtml(resolver); } return ""; }
public String AsHtml(DocumentLinkResolver linkResolver) { return(AsHtml(linkResolver, null)); }
public String GetHtml(String field, DocumentLinkResolver resolver, HtmlSerializer serializer) { Fragment fragment = Get(field); return(WithFragments.GetHtml(fragment, resolver, serializer)); }
public String GetHtml(String field, DocumentLinkResolver resolver) { return(GetHtml(field, resolver, null)); }
/** * Return the URL to display a given preview * @param token as received from Prismic server to identify the content to preview * @param linkResolver the link resolver to build URL for your site * @param defaultUrl the URL to default to return if the preview doesn't correspond to a document * (usually the home page of your site) * @return the URL you should redirect the user to preview the requested change */ public async Task<String> PreviewSession(String token, DocumentLinkResolver linkResolver, String defaultUrl) { var tokenJson = await this.prismicHttpClient.fetch(token, logger, cache); var mainDocumentId = tokenJson["mainDocument"]; if (mainDocumentId == null) { return (defaultUrl); } var resp = await Form ("everything") .Query (Predicates.at ("document.id", mainDocumentId.ToString ())) .Ref (token) .Submit (); if (resp.Results.Count == 0) { return defaultUrl; } return linkResolver.Resolve (resp.Results[0]); }
public String AsHtml(DocumentLinkResolver linkResolver) { return AsHtml(linkResolver, null); }
public String GetHtml(String field, DocumentLinkResolver resolver, HtmlSerializer serializer) { Fragment fragment = Get(field); return WithFragments.GetHtml(fragment, resolver, serializer); }
public String GetHtml(String field, DocumentLinkResolver resolver) { return GetHtml (field, resolver); }