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.project = custom
kiwi.pages.startup = path/to/custom/welcome.html
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:

Templates

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

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);
        }
    }
}

Modules

You can also build your own applications based on Marmotta, both adding custom modules and/or having your own webapp launcher.

Build your custom module

There is a Maven archetype for a Marmotta Module:

mvn archetype:generate \
   -DarchetypeGroupId=org.apache.marmotta \
   -DarchetypeArtifactId=marmotta-archetype-module 

This will generate the following structure:

.
|-- pom.xml
`-- src
    `-- main
        |-- java
        `-- resources
            |-- kiwi-module.properties
            |-- META-INF
            |   `-- beans.xml
            `-- web
                `-- admin
                    |-- about.html
                    |-- configuration.html
                    `-- img
                        `-- clock_small.png

Adding it to a custom webapp launcher will give the module its own space in the admin ui.

Build your custom webapp launcher

There is a Maven archetype for a Marmotta Webapp:

mvn archetype:generate \
   -DarchetypeGroupId=org.apache.marmotta \
   -DarchetypeArtifactId=marmotta-archetype-webapp 

After that you will have a new Maven project with a structure like:

.
|-- pom.xml
`-- src
    |-- main
    |   |-- resources
    |   |   |-- default-config.properties
    |   |   |-- logback.xml
    |   |   `-- META-INF
    |   |       |-- beans.xml
    |   |       `-- persistence.xml
    |   `-- webapp
    |       |-- index.jsp
    |       `-- WEB-INF
    |           `-- web.xml
    `-- test
        `-- resources
            |-- data
            |-- META-INF
            |   |-- beans.xml
            |-- test-config.properties
            `-- WEB-INF
                `-- test-web.xml

Then, moving to the folder that Maven created, you can start it just by running one of the following command:

mvn tomcat7:run

By default it will start your new webapp at http://localhost:8080

Of course you can customize whatever you need, as soon as you do not break the general setup (servlets and filters).

Customizing (last edited 2014-08-28 07:08:33 by SergioFernandez)