Differences between revisions 4 and 5
Revision 4 as of 2013-11-11 10:31:43
Size: 1772
Comment:
Revision 5 as of 2014-04-08 14:34:27
Size: 2777
Comment: documenting what's actually required to have MARMOTTA-482 working
Deletions are marked like this. Additions are marked like this.
Line 32: Line 32:
That would allow advanced users to customize the user interface by directly hacking the [[http://freemarker.org|freemarker]] templates. For instance, to provide a customized HTML view of the RDF resources. But of course it requires to be very careful doing it for not breaking the user interface renderization. That would allow advanced users to customize the user interface by directly hacking the [[http://freemarker.org|freemarker]] templates. For instance, to provide a customized HTML view of the RDF resources. But of course it requires to be very careful doing it for not breaking the templating.

If you would need to automatically [[https://issues.apache.org/jira/browse/MARMOTTA-482|deploy the templates on startup]], you can add an event handler like this to your custom application:

{{{
public void systemInitialised(@Observes SystemStartupEvent event) {
    String template = TemplatingService.ERROR_TPL;
    File templateDir = new File(configurationService.getHome(), TemplatingService.PATH);
    final File tpl = new File(templateDir, template);
    if (!tpl.exists()) {
        final InputStream in = this.getClass().getResourceAsStream("/" + template);
        if (in != null) {
            try {
                log.debug("Copying custom template {}", template);
                FileUtils.copyInputStreamToFile(in, tpl);
            } catch (IOException e) {
                log.error("Error copying custom template '{}': {}", template, e.getMessage());
            }
        } else {
            log.error("Custom template {} not found, so ignoring", template);
        }
    }
}
}}}

Customizing Marmotta

There are some things Marmotta allows to customize.

Style

Besides the default style, you could customize the style of the admin interface. For that, you may need you set some concrete configurations:

kiwi.pages.startup = path/to/custom/welcome.html
kiwi.pages.project = custom
kiwi.pages.style_path = path/to/custom/style/
kiwi.pages.project.custom.logo = path/to/custom/logo.png
kiwi.pages.project.custom.footer = My custom project, developed with <a href="http://marmotta.incubator.apache.org">Apache Marmotta</a>

Where:

  • kiwi.pages.startup sets the custom page to use as welcome page

  • kiwi.pages.project assert that Marmotta will use a custom style

  • kiwi.pages.style_path indicates the base path were look for the normativle css files (see for example the custom style that LMF uses)

  • kiwi.pages.project.custom.logo is the relative url to the custom logo

  • kiwi.pages.project.custom.footer allows to write a custom footer

Templates

Since version 3.2, the templates Marmotta internally uses are being copied to the home directory on deployment (/path/to/marmotta/templates):

  • admin.ftl is the template used to build the admin user interface

  • rdfhtml.ftl renders RDF resources as HTML

  • 404.ftl provides the error page when a requested resources is not found

That would allow advanced users to customize the user interface by directly hacking the freemarker templates. For instance, to provide a customized HTML view of the RDF resources. But of course it requires to be very careful doing it for not breaking the templating.

If you would need to automatically deploy the templates on startup, you can add an event handler like this to your custom application:

public void systemInitialised(@Observes SystemStartupEvent event) {
    String template = TemplatingService.ERROR_TPL;
    File templateDir = new File(configurationService.getHome(), TemplatingService.PATH);
    final File tpl = new File(templateDir, template);
    if (!tpl.exists()) {
        final InputStream in = this.getClass().getResourceAsStream("/" + template);
        if (in != null) {
            try {
                log.debug("Copying custom template {}", template);
                FileUtils.copyInputStreamToFile(in, tpl);
            } catch (IOException e) {
                log.error("Error copying custom template '{}': {}", template, e.getMessage());
            }
        } else {
            log.error("Custom template {} not found, so ignoring", template);
        }
    }
}

Customizing (last edited 2016-05-13 18:41:08 by SergioFernandez)