|
[HepData-svn] r1857 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pagesblackhole at projects.hepforge.org blackhole at projects.hepforge.orgWed Apr 22 12:36:31 BST 2015
Author: whalley Date: Wed Apr 22 12:36:30 2015 New Revision: 1857 Log: adding yaml format code Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java Wed Apr 22 12:34:55 2015 (r1856) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/webapp/pages/View.java Wed Apr 22 12:36:30 2015 (r1857) @@ -42,7 +42,7 @@ parseBaseViewContext(context); // Handle pattern parsing separately - Pattern patt = Pattern.compile("\\A" + "(short|long|full|plain.txt|yoda|aida|pyroot.py|root|mpl|bdms|hepml|scavis.py|input|marcxml|json)" + "\\Z", + Pattern patt = Pattern.compile("\\A" + "(short|long|full|plain.txt|yoda|aida|pyroot.py|root|mpl|bdms|hepml|scavis.py|input|marcxml|json|yaml)" + "\\Z", Pattern.CASE_INSENSITIVE); Pattern patt2 = Pattern.compile("\\A" + "(irn\\d+)" + "\\Z",Pattern.CASE_INSENSITIVE); String stype = "i"; @@ -67,6 +67,7 @@ if (fmt.equals("hepml")) return asHepML(); if (fmt.equals("marcxml")) return asMarcXML(); if (fmt.equals("json")) return asJSON(); + if (fmt.equals("yaml")) return asYAML(); if (fmt.equals("bdms")) return asBDMS(); if (fmt.equals("input")) return asINPUT(context); if (fmt.equals("plain.txt")) return asPlain(); @@ -145,6 +146,16 @@ return new TextStreamResponse("text/plain", asJSON); } + public Object getYamlContext() { + return formatContext("yaml"); + } + public StreamResponse asYAML() { + Paper p = getPaper(); + String asYAML = YamlFormatter.format(p); + if (asYAML == null) { + asYAML = "No valid paper specified"; + } + return new TextStreamResponse("text/plain", asYAML); } public Object getBdmsContext() { return formatContext("bdms"); }
More information about the HepData-svn mailing list |