mirror of https://github.com/M66B/FairEmail.git
JSN-LD improvements
This commit is contained in:
parent
999a77e2c4
commit
f40de46250
|
@ -1,3 +1,5 @@
|
|||
<div>
|
||||
<strong><a style="font-size: larger;" href="<!--$.potentialAction.url-->"><!--$.potentialAction.name--></a></strong>
|
||||
<strong>
|
||||
<a style="font-size: larger;" href="<!--$.potentialAction.url-->"><!--$.potentialAction.name--></a>
|
||||
</strong>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div>
|
||||
<span><strong>Reservation ID: </strong><!--$.reservationId--></span><br>
|
||||
<span><strong>Reservation number: </strong><!--$.reservationNumber--></span><br>
|
||||
<span><strong>Status: </strong><!--$.reservationStatus--></span><br>
|
||||
<span><strong>Passenger: </strong><!--$.underName.name--></span><br>
|
||||
<span><strong>Flight: </strong><!--$.reservationFor.flightNumber--></span><br>
|
||||
<span><strong>Operated by: </strong><!--$.reservationFor.provider.name--></span><br>
|
||||
|
|
|
@ -43,14 +43,17 @@ import java.util.Locale;
|
|||
|
||||
// https://json-ld.org/
|
||||
// https://schema.org/
|
||||
// https://schema.org/EmailMessage
|
||||
// https://schema.org/FlightReservation
|
||||
// https://developers.google.com/gmail/markup/reference/flight-reservation
|
||||
// https://structured.email/content/introduction/getting_started.html
|
||||
|
||||
public class JsonLd {
|
||||
private Object jroot;
|
||||
private Throwable error = null;
|
||||
|
||||
private static final String URI_SCHEMA_ORG = "https://schema.org";
|
||||
private static final String HTTP_SCHEMA_ORG = "http://schema.org";
|
||||
private static final String HTTPS_SCHEMA_ORG = "https://schema.org";
|
||||
private static final String PLACEHOLDER_START = "<!--";
|
||||
private static final String PLACEHOLDER_END = "-->";
|
||||
|
||||
|
@ -79,8 +82,8 @@ public class JsonLd {
|
|||
String jtype = jobject.getString("@type");
|
||||
Log.i("JSON-LD template " + jcontext + "=" + jtype);
|
||||
|
||||
if (!URI_SCHEMA_ORG.equals(jcontext) &&
|
||||
!"http://schema.org".equals(jcontext)) {
|
||||
if (!HTTP_SCHEMA_ORG.equals(jcontext) &&
|
||||
!HTTPS_SCHEMA_ORG.equals(jcontext)) {
|
||||
Log.e("JSON-LD " + jcontext + "?=" + jtype);
|
||||
return null;
|
||||
}
|
||||
|
@ -113,8 +116,10 @@ public class JsonLd {
|
|||
value = JsonPath.read(document, placeholder);
|
||||
if (value == null)
|
||||
value = "";
|
||||
if (value.startsWith(URI_SCHEMA_ORG + "/"))
|
||||
value = unCamelCase(value.substring(URI_SCHEMA_ORG.length() + 1));
|
||||
if (value.startsWith(HTTP_SCHEMA_ORG + "/"))
|
||||
value = unCamelCase(value.substring(HTTP_SCHEMA_ORG.length() + 1));
|
||||
else if (value.startsWith(HTTPS_SCHEMA_ORG + "/"))
|
||||
value = unCamelCase(value.substring(HTTPS_SCHEMA_ORG.length() + 1));
|
||||
} catch (PathNotFoundException ex) {
|
||||
Log.i(ex);
|
||||
value = "";
|
||||
|
@ -204,8 +209,10 @@ public class JsonLd {
|
|||
getHtml(context, v, indent + 1, holder);
|
||||
} else {
|
||||
String _v = v.toString();
|
||||
if (_v.startsWith(URI_SCHEMA_ORG + "/"))
|
||||
_v = unCamelCase(_v.substring(URI_SCHEMA_ORG.length() + 1));
|
||||
if (_v.startsWith(HTTP_SCHEMA_ORG + "/"))
|
||||
_v = unCamelCase(_v.substring(HTTP_SCHEMA_ORG.length() + 1));
|
||||
else if (_v.startsWith(HTTPS_SCHEMA_ORG + "/"))
|
||||
_v = unCamelCase(_v.substring(HTTPS_SCHEMA_ORG.length() + 1));
|
||||
holder.appendElement("span").text(_v);
|
||||
holder.appendElement("br");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue