made imprint, about and help configurable
This commit is contained in:
parent
ba843df5b5
commit
1a9d710892
5 changed files with 79 additions and 13 deletions
|
@ -15,6 +15,7 @@ import org.apache.commons.codec.binary.Base64InputStream;
|
|||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.rap.rwt.RWT;
|
||||
import org.eclipse.rap.rwt.client.service.UrlLauncher;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.ImageData;
|
||||
|
@ -35,6 +36,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.I18nSupport;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.LocTextKey;
|
||||
import ch.ethz.seb.sebserver.gui.service.i18n.PolyglotPageService;
|
||||
import ch.ethz.seb.sebserver.gui.service.page.PageContext;
|
||||
|
@ -52,6 +54,14 @@ public class DefaultPageLayout implements TemplateComposer {
|
|||
|
||||
private static final Logger log = LoggerFactory.getLogger(DefaultPageLayout.class);
|
||||
|
||||
private static final LocTextKey ABOUT_TEXT_KEY = new LocTextKey("sebserver.overall.about");
|
||||
private static final LocTextKey IMPRINT_TEXT_KEY = new LocTextKey("sebserver.overall.imprint");
|
||||
private static final LocTextKey HELP_TEXT_KEY = new LocTextKey("sebserver.overall.help");
|
||||
|
||||
private static final LocTextKey ABOUT_MARKUP_TEXT_KEY = new LocTextKey("sebserver.overall.about.markup");
|
||||
private static final LocTextKey IMPRINT_MARKUP_TEXT_KEY = new LocTextKey("sebserver.overall.imprint.markup");
|
||||
private static final LocTextKey HELP_LINK_TEXT_KEY = new LocTextKey("sebserver.overall.help.link");
|
||||
|
||||
public static final int LOGO_IMAGE_MAX_WIDTH = 400;
|
||||
public static final int LOGO_IMAGE_MAX_HEIGHT = 80;
|
||||
|
||||
|
@ -259,14 +269,54 @@ public class DefaultPageLayout implements TemplateComposer {
|
|||
rowLayout.marginRight = 20;
|
||||
footerRight.setLayout(rowLayout);
|
||||
|
||||
this.widgetFactory.labelLocalized(
|
||||
footerLeft,
|
||||
CustomVariant.FOOTER,
|
||||
new LocTextKey("sebserver.overall.imprint"));
|
||||
this.widgetFactory.labelLocalized(
|
||||
footerLeft,
|
||||
CustomVariant.FOOTER,
|
||||
new LocTextKey("sebserver.overall.about"));
|
||||
final I18nSupport i18nSupport = this.widgetFactory.getI18nSupport();
|
||||
if (StringUtils.isNoneBlank(i18nSupport.getText(IMPRINT_TEXT_KEY, ""))) {
|
||||
final Label imprint = this.widgetFactory.labelLocalized(
|
||||
footerLeft,
|
||||
CustomVariant.FOOTER,
|
||||
IMPRINT_TEXT_KEY);
|
||||
|
||||
imprint.addListener(SWT.MouseUp, event -> {
|
||||
try {
|
||||
pageContext.publishPageMessage(IMPRINT_TEXT_KEY, IMPRINT_MARKUP_TEXT_KEY);
|
||||
} catch (final Exception e) {
|
||||
log.error("Invalid markup for 'Imprint'", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (StringUtils.isNoneBlank(i18nSupport.getText(ABOUT_TEXT_KEY, ""))) {
|
||||
final Label about = this.widgetFactory.labelLocalized(
|
||||
footerLeft,
|
||||
CustomVariant.FOOTER,
|
||||
ABOUT_TEXT_KEY);
|
||||
|
||||
about.addListener(SWT.MouseUp, event -> {
|
||||
try {
|
||||
pageContext.publishPageMessage(ABOUT_TEXT_KEY, ABOUT_MARKUP_TEXT_KEY);
|
||||
} catch (final Exception e) {
|
||||
log.error("Invalid markup for 'About'", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (StringUtils.isNoneBlank(i18nSupport.getText(HELP_TEXT_KEY, ""))) {
|
||||
final Label help = this.widgetFactory.labelLocalized(
|
||||
footerLeft,
|
||||
CustomVariant.FOOTER,
|
||||
HELP_TEXT_KEY);
|
||||
|
||||
help.addListener(SWT.MouseUp, event -> {
|
||||
try {
|
||||
final String link = i18nSupport.getText(HELP_LINK_TEXT_KEY, "");
|
||||
if (StringUtils.isNoneBlank(link)) {
|
||||
final UrlLauncher urlLauncher = RWT.getClient().getService(UrlLauncher.class);
|
||||
urlLauncher.openURL(link);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
this.widgetFactory.labelLocalized(
|
||||
footerRight,
|
||||
CustomVariant.FOOTER,
|
||||
|
|
|
@ -258,9 +258,12 @@ public class PageContextImpl implements PageContext {
|
|||
public void publishPageMessage(final LocTextKey title, final LocTextKey message) {
|
||||
final MessageBox messageBox = new Message(
|
||||
getShell(),
|
||||
this.i18nSupport.getText(title),
|
||||
(title != null)
|
||||
? this.i18nSupport.getText(title)
|
||||
: "",
|
||||
this.i18nSupport.getText(message),
|
||||
SWT.NONE);
|
||||
|
||||
messageBox.setMarkupEnabled(true);
|
||||
messageBox.open(null);
|
||||
}
|
||||
|
@ -334,4 +337,5 @@ public class PageContextImpl implements PageContext {
|
|||
this.onOK.accept(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,12 @@
|
|||
################################
|
||||
|
||||
sebserver.overall.version=SEB Server Version : {0}
|
||||
sebserver.overall.imprint=Imprint
|
||||
sebserver.overall.imprint=
|
||||
sebserver.overall.imprint.markup=
|
||||
sebserver.overall.about=About
|
||||
sebserver.overall.about.markup=<span class='h1'>SEB Server About Example</span><br/><br/>This is an example how an About-Page can look like.<h3><br/><h4>By simply define the markup HTML content within the message.propertie configuration of specified language
|
||||
sebserver.overall.help=Documentation
|
||||
sebserver.overall.help.link=https://www.safeexambrowser.org/news_en.html
|
||||
|
||||
sebserver.overall.message.leave.without.save=You are leaving this page without saved changes!\nThe unsaved changes will be lost.\Are you sure to leave the page?
|
||||
sebserver.overall.upload=Please Select
|
||||
|
|
|
@ -3,8 +3,12 @@
|
|||
################################
|
||||
|
||||
sebserver.overall.version=SEB Server Version : {0}
|
||||
sebserver.overall.imprint=Imprint
|
||||
sebserver.overall.about=About
|
||||
sebserver.overall.imprint=
|
||||
sebserver.overall.imprint.markup=
|
||||
sebserver.overall.about=
|
||||
sebserver.overall.about.markup=
|
||||
sebserver.overall.help=Dokumentation
|
||||
sebserver.overall.help.link=https://www.safeexambrowser.org/news_de.html
|
||||
|
||||
sebserver.overall.message.leave.without.save=You are leaving this page without saved changes!\nThe unsaved changes will be lost.\Are you sure to leave the page?
|
||||
sebserver.overall.upload=Bitte Ausw\u00E4hlen
|
||||
|
|
|
@ -3,8 +3,12 @@
|
|||
################################
|
||||
|
||||
sebserver.overall.version=SEB Server Version : {0}
|
||||
sebserver.overall.imprint=Imprint
|
||||
sebserver.overall.imprint=
|
||||
sebserver.overall.imprint.markup=
|
||||
sebserver.overall.about=About
|
||||
sebserver.overall.about.markup=<span style='font-family: Arial, Helvetica,sans-serif;font-size: 25px;font-weight: normal;font-style: normal;color: rgb(31, 64, 122);'>SEB Server About Example</span><br/><br/><span style='font-family: Arial, Helvetica,sans-serif;font-size: 18px;font-weight: bold;font-style: normal;'>1. This is an example of how an About-Page can look like.</span><br/><br/><span style='font-family: Arial, Helvetica,sans-serif;font-size: 14px;font-weight: normal;font-style: normal;'>By simply define the markup HTML content within the message.propertie configuration of specified language</span>
|
||||
sebserver.overall.help=Documentation
|
||||
sebserver.overall.help.link=https://www.safeexambrowser.org/news_en.html
|
||||
|
||||
sebserver.overall.message.leave.without.save=You have unsaved changes!\nAre you sure you want to leave the page?\The changes will be lost.
|
||||
sebserver.overall.upload=Please Select
|
||||
|
|
Loading…
Reference in a new issue