Commits

Anonymous committed c5e3328

Fix compchem and crystallography templates

Comments (0)

Files changed (3)

compchem-handler/src/main/java/net/chempound/compchem/display/CompChemSplashPageWriter.java

 import net.chempound.rdf.CPTerms;
 import net.chempound.webapp.output.AbstractSplashPageWriter;
 import net.chempound.webapp.output.Page;
-import org.apache.commons.io.IOUtils;
 
 import javax.inject.Singleton;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URI;
 
 /**
 @Singleton
 public class CompChemSplashPageWriter extends AbstractSplashPageWriter {
 
-    private static final String headers;
-
-    static {
-        headers = read("/net/chempound/compchem/includes/headers.html");
-    }
-
-    private static String read(final String s) {
-        final InputStream in = CompChemSplashPageWriter.class.getResourceAsStream(s);
-        try {
-            return IOUtils.toString(in);
-        } catch (IOException e) {
-            throw new RuntimeException("Error reading file: " + s, e);
-        } finally {
-            IOUtils.closeQuietly(in);
-        }
-    }
-
     @Override
     protected Class<? extends Resource> getResourceType() {
         return CompChemCalculation.class;
 
     @Override
     public void write(final Model model, final URI aggregationUri, final Page page) throws IOException, TemplateException {
-        page.addHeader(headers);
-
         final BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
         final TemplateHashModel staticModels = wrapper.getStaticModels();
 

compchem-handler/src/main/resources/net/chempound/compchem/includes/headers.html

-    <!-- import jmol -->
-    <script src="${URI_BASE}/plugins/jmol/jmol/Jmol.js" type="text/javascript"></script>
-
-    <!-- import jquery -->
-    <script src="${URI_BASE}/plugins/jquery/jquery-1.4.2.js" type="text/javascript"></script>
-
-    <!-- import jmol-jquery -->
-    <script src="${URI_BASE}/plugins/jmol/jquery.jmol.js" type="text/javascript"></script>
-    <!-- import style sheet -->
-    <link href="${URI_BASE}/plugins/jmol/jquery.jmol.css" type="text/css" rel="stylesheet" />"

compchem-handler/src/main/resources/net/chempound/compchem/templates/comp.ftl

 <#-- @ftlvariable name="calculation" type="net.chempound.compchem.rdf.CompChemCalculation" -->
+<@layout.header>
+    <!-- setup Jmol -->
+    <script src="${URI_BASE}/plugins/jmol/jmol/Jmol.js" type="text/javascript"></script>
+    <script src="${URI_BASE}/plugins/jquery/jquery-1.4.2.js" type="text/javascript"></script>
+    <script src="${URI_BASE}/plugins/jmol/jquery.jmol.js" type="text/javascript"></script>
+    <link href="${URI_BASE}/plugins/jmol/jquery.jmol.css" type="text/css" rel="stylesheet" />"
+</@layout.header>
+<@layout.page>
 <div class="item compchem-calculation">
 
 <#if calculation.title??>
         });
     });
 </script>
+</@layout.page>