Skip to content
Snippets Groups Projects
Commit 35e1d1bd authored by Andreas Schärtl's avatar Andreas Schärtl
Browse files

show config on main page

parent e4f56308
Branches
No related tags found
No related merge requests found
......@@ -40,13 +40,21 @@ public class Config {
return environmentValue;
}
log.warn("could not read environment variable {}, falling back to configuration file", environmentKey);
log.debug("could not read environment variable {}, falling back to configuration file", environmentKey);
// try to read the configuration from the configuration file;
// this is useful when debugging and running this application as
// a regular application on a manually administred server
try {
final ResourceBundle bundle = ResourceBundle.getBundle("uloapi");
return bundle.getString(configFileKey);
} catch (NullPointerException e) {
log.warn(e.getMessage());
log.error("could not look up configuration option {}/{}; aborting", environmentKey, configFileKey);
System.exit(1);
}
throw new IllegalStateException("should not be reachable");
}
}
package info.mathhub.uloapi.html;
import info.mathhub.uloapi.config.Config;
import info.mathhub.uloapi.query.Query;
import info.mathhub.uloapi.query.Statistics;
import info.mathhub.uloapi.query.Timer;
......@@ -21,7 +22,7 @@ public class Routes {
private Routes() {};
public static final TemplateViewRoute index = (Request request, Response response) -> {
return new ModelAndView(null, "index.flt");
return new ModelAndView(withGlobals(null), "index.flt");
};
public static final TemplateViewRoute statistics = (Request request, Response response) -> {
......@@ -33,7 +34,7 @@ public class Routes {
model.put("statistics_is_writeable", Boolean.toString(statistics.isWriteable));
model.put("statistics_data_dir", statistics.dataDir);
return new ModelAndView(model, "statistics.flt");
return new ModelAndView(withGlobals(model), "statistics.flt");
};
public static final TemplateViewRoute queries = (Request request, Response response) -> {
......@@ -47,7 +48,7 @@ public class Routes {
model.put("inductive_statements", inductiveStatements);
model.put("inductive_statements_duration", inductiveStatementsDuration);
return new ModelAndView(model, "queries.flt");
return new ModelAndView(withGlobals(model), "queries.flt");
};
public static final TemplateViewRoute explore = (Request request, Response response) -> {
......@@ -57,7 +58,7 @@ public class Routes {
final Map<String, Object> model = new HashMap<>();
model.put("contributors", contributors);
return new ModelAndView(model, "explore.flt");
return new ModelAndView(withGlobals(model), "explore.flt");
};
public static final TemplateViewRoute exploreContributor = (Request request, Response response) -> {
......@@ -70,6 +71,27 @@ public class Routes {
model.put("contributor", contributor);
model.put("contributions", contributions);
return new ModelAndView(model, "explore_contributor.flt");
return new ModelAndView(withGlobals(model), "explore_contributor.flt");
};
/**
* Add some global values we always need to argument {@code model}.
*
* @param model The model to patch. If this argument is {@code null} this method returns a new model with only
* the globals in it.
* @return Argument {@code model} if it was not {@code null}, otherwise returns the new model.
*/
private static Map<String, Object> withGlobals(Map<String, Object> model) {
if (model == null) {
model = new HashMap<>();
}
final String serverUrl = Config.serverUrl();
model.put("global_server_url", serverUrl);
final String repository = Config.repository();
model.put("global_repository", repository);
return model;
}
}
......@@ -72,6 +72,14 @@
<@page_main/>
</main>
<footer>
<#if global_server_url??>
GraphDB Server <code>${global_server_url}</code> |
</#if>
<#if global_repository??>
GraphDB Repository <code>${global_repository}</code> |
</#if>
<a href="https://gl.kwarc.info/supervision/schaertl_andreas/-/tree/master/src/ulo-storage-endpoint">
Source Code
</a>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment