-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#183 - Added config. informations in the logs when starting the webapp #184 - Webapp: modify the title tag when the form is on error to inform the user #185 - Added new configuration option for logging colors result #186 - Webapp: added new page to provide build ID (commit hash)
- Loading branch information
Showing
13 changed files
with
467 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
docker/SNAPSHOT-local/test_config-file/50.loggingColorsResult_compact/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
FROM asqatasun/contrast-finder:pre-requisites_Ubuntu-18.04_tomcat-8.5 | ||
|
||
# #### usage ###################################################### | ||
# | ||
# --- Building this docker image | ||
# docker build -t asqatasun/contrast-finder:SNAPSHOT_local . | ||
# | ||
# --- Launch a container | ||
# docker run -p 127.0.0.1:8087:8080 --name contrast.finder -d asqatasun/contrast-finder:SNAPSHOT_local | ||
# | ||
# --- Playing with this docker image | ||
# docker exec -ti contrast.finder /bin/cat /softwares-version.txt | ||
# docker exec -ti contrast.finder /bin/bash | ||
# docker logs -f contrast.finder | ||
# | ||
# #### FROM ###################################################### | ||
# asqatasun/contrast-finder:pre-requisites_Ubuntu-18.04_tomcat-8.5 https://github.com/Asqatasun/Contrast-Finder/blob/master/docker/pre-requisites/pre-requisites_Ubuntu-18.04_tomcat-8.5/Dockerfile | ||
# |-- ubuntu:18.04 https://github.com/tianon/docker-brew-ubuntu-core/blob/dist-amd64/bionic/Dockerfile | ||
################################################################### | ||
|
||
# environment variables | ||
ENV CONTRAST_FINDER_RELEASE="0.9.3-SNAPSHOT" | ||
ENV LOGGING="compact" | ||
# loggingColorsResult = compact | full | no (default) | ||
|
||
# Add contrast-finder .war | ||
ADD contrast-finder-webapp_${CONTRAST_FINDER_RELEASE}.tar.gz /root | ||
|
||
# Install contrast-finder | ||
RUN cd /root/contrast-*/install/ && \ | ||
mv -v contrast-*.war contrast-finder.war && \ | ||
mv -v contrast-*.war /var/lib/tomcat8/webapps && \ | ||
rm -rf /root/contrast-* && \ | ||
echo "loggingColorsResult=${LOGGING}" >> ${CONF_FILE} && \ | ||
echo ${CONTRAST_FINDER_RELEASE} >> ${INFO_FILE} && \ | ||
echo "\n--- ${CONF_FILE} ---" >> ${INFO_FILE} && \ | ||
cat ${CONF_FILE} >> ${INFO_FILE} && \ | ||
echo "\n--- Logs -----------" >> ${INFO_FILE} && \ | ||
echo "${TOMCAT_LOG}" >> ${INFO_FILE} && \ | ||
echo "${LOG_FILE}" >> ${INFO_FILE} && \ | ||
echo "--------------------" >> ${INFO_FILE} && \ | ||
cat ${INFO_FILE} > ${LOG_FILE} && echo "-- Install: Ok" | ||
|
||
# Health Check of the Docker Container | ||
# ----> see asqatasun/contrast-finder:pre-requisites_Ubuntu-18.04_tomcat-8.5 | ||
|
||
CMD service tomcat8 start ; \ | ||
tail -f -n 50 ${TOMCAT_LOG} \ | ||
${LOG_FILE} | ||
|
||
|
||
|
52 changes: 52 additions & 0 deletions
52
docker/SNAPSHOT-local/test_config-file/51.loggingColorsResult_full/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
FROM asqatasun/contrast-finder:pre-requisites_Ubuntu-18.04_tomcat-8.5 | ||
|
||
# #### usage ###################################################### | ||
# | ||
# --- Building this docker image | ||
# docker build -t asqatasun/contrast-finder:SNAPSHOT_local . | ||
# | ||
# --- Launch a container | ||
# docker run -p 127.0.0.1:8087:8080 --name contrast.finder -d asqatasun/contrast-finder:SNAPSHOT_local | ||
# | ||
# --- Playing with this docker image | ||
# docker exec -ti contrast.finder /bin/cat /softwares-version.txt | ||
# docker exec -ti contrast.finder /bin/bash | ||
# docker logs -f contrast.finder | ||
# | ||
# #### FROM ###################################################### | ||
# asqatasun/contrast-finder:pre-requisites_Ubuntu-18.04_tomcat-8.5 https://github.com/Asqatasun/Contrast-Finder/blob/master/docker/pre-requisites/pre-requisites_Ubuntu-18.04_tomcat-8.5/Dockerfile | ||
# |-- ubuntu:18.04 https://github.com/tianon/docker-brew-ubuntu-core/blob/dist-amd64/bionic/Dockerfile | ||
################################################################### | ||
|
||
# environment variables | ||
ENV CONTRAST_FINDER_RELEASE="0.9.3-SNAPSHOT" | ||
ENV LOGGING="full" | ||
# loggingColorsResult = compact | full | no (default) | ||
|
||
# Add contrast-finder .war | ||
ADD contrast-finder-webapp_${CONTRAST_FINDER_RELEASE}.tar.gz /root | ||
|
||
# Install contrast-finder | ||
RUN cd /root/contrast-*/install/ && \ | ||
mv -v contrast-*.war contrast-finder.war && \ | ||
mv -v contrast-*.war /var/lib/tomcat8/webapps && \ | ||
rm -rf /root/contrast-* && \ | ||
echo "loggingColorsResult=${LOGGING}" >> ${CONF_FILE} && \ | ||
echo ${CONTRAST_FINDER_RELEASE} >> ${INFO_FILE} && \ | ||
echo "\n--- ${CONF_FILE} ---" >> ${INFO_FILE} && \ | ||
cat ${CONF_FILE} >> ${INFO_FILE} && \ | ||
echo "\n--- Logs -----------" >> ${INFO_FILE} && \ | ||
echo "${TOMCAT_LOG}" >> ${INFO_FILE} && \ | ||
echo "${LOG_FILE}" >> ${INFO_FILE} && \ | ||
echo "--------------------" >> ${INFO_FILE} && \ | ||
cat ${INFO_FILE} > ${LOG_FILE} && echo "-- Install: Ok" | ||
|
||
# Health Check of the Docker Container | ||
# ----> see asqatasun/contrast-finder:pre-requisites_Ubuntu-18.04_tomcat-8.5 | ||
|
||
CMD service tomcat8 start ; \ | ||
tail -f -n 50 ${TOMCAT_LOG} \ | ||
${LOG_FILE} | ||
|
||
|
||
|
157 changes: 157 additions & 0 deletions
157
webapp/src/main/java/org/asqatasun/contrastfinder/webapp/controller/AbstractController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
/* | ||
* Contrast Finder | ||
* Copyright (C) 2008-2018 Asqatasun.org | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Contact us by mail: asqatasun AT asqatasun DOT org | ||
*/ | ||
package org.asqatasun.contrastfinder.webapp.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
/** | ||
* abstract controller | ||
*/ | ||
@Controller | ||
public abstract class AbstractController { | ||
|
||
/** | ||
* logger for current class | ||
* usage : LOGGER.info("log message"); | ||
* LOGGER.warn("warning message"); | ||
* LOGGER.debug("debug message"); | ||
* LOGGER.error("error message"); | ||
*/ | ||
protected final Logger LOGGER = LoggerFactory.getLogger(this.getClass()); | ||
|
||
|
||
/** | ||
* main view name | ||
*/ | ||
protected String mainPageView; | ||
|
||
/** | ||
* piwik analytics key | ||
* default is '' | ||
* can be override in the following file: | ||
* /etc/contrast-finder/contrast-finder.conf | ||
*/ | ||
@Value("${piwik_analytics_key:}") | ||
protected String piwikAnalyticsKey; | ||
|
||
/** | ||
* piwik analytics server URL | ||
* default is '' | ||
* can be override in the following file: | ||
* /etc/contrast-finder/contrast-finder.conf | ||
*/ | ||
@Value("${piwik_analytics_server:}") | ||
protected String piwikAnalyticServer; | ||
|
||
/** | ||
* default algorithm ("HSV") | ||
* used only in this.initAccueil() | ||
* HSV = a range of valid colors | ||
* Rgb = valid colors and very close to initial color | ||
* | ||
* can be override in the following file: | ||
* /etc/contrast-finder/contrast-finder.conf | ||
* | ||
* a bad value is fixed by the default algo ("HSV") in ColorModel class | ||
*/ | ||
@Value("${default_algorithm:HSV}") | ||
// @Value("${default_algorithm:HSV}") | ||
// @Value("${default_algorithm:Rgb}") | ||
protected String defaultAlgorithm; | ||
|
||
|
||
/** | ||
* Give crawlers instructions | ||
* searchEngineInclude = "yes" | ||
* searchEngineInclude = "no" (default) | ||
* = disallow search engines from showing HTML pages in their results | ||
* | ||
* can be override in the following file: | ||
* /etc/contrast-finder/contrast-finder.conf | ||
*/ | ||
@Value("${searchEngineInclude:no}") | ||
protected String searchEngineInclude; | ||
|
||
/** | ||
* environment | ||
* env = debug | ||
* env = prod (default) | ||
* | ||
* can be override in the following file: | ||
* /etc/contrast-finder/contrast-finder.conf | ||
*/ | ||
@Value("${env:prod}") | ||
protected String env; | ||
|
||
/** | ||
* logging colors result | ||
* compact = log message on 1 line | ||
* full = log message on several lines | ||
* no = no logging (default) | ||
* | ||
* can be override in the following file: | ||
* /etc/contrast-finder/contrast-finder.conf | ||
*/ | ||
@Value("${loggingColorsResult:no}") | ||
// @Value("${loggingColorsResult:compact}") | ||
// @Value("${loggingColorsResult:full}") | ||
// @Value("${loggingColorsResult:no}") | ||
protected String loggingColorsResult; | ||
|
||
|
||
|
||
public AbstractController() {} | ||
|
||
|
||
/** | ||
* - set main view name (this.mainPageView) | ||
* - log the config values | ||
* | ||
* notice: called at the launch of servlet | ||
*/ | ||
public void setMainPageView(String formView) { | ||
this.mainPageView = formView; | ||
LOGGER.info("config env : " + env ); | ||
LOGGER.info("config piwikKey : " + piwikAnalyticsKey ); | ||
LOGGER.info("config piwikServer : " + piwikAnalyticServer ); | ||
LOGGER.info("config defaultAlgorithm : " + defaultAlgorithm ); | ||
LOGGER.info("config searchEngineInclude : " + searchEngineInclude ); | ||
LOGGER.info("config loggingColorsResult : " + loggingColorsResult ); | ||
} | ||
|
||
/** | ||
* Preparing the common data and populating the model before returning the view | ||
* @param model model of the page | ||
*/ | ||
protected void addCommonViewData(final Model model, String pageName) { | ||
model.addAttribute("env", env); | ||
model.addAttribute("piwikKey", piwikAnalyticsKey); | ||
model.addAttribute("piwikServer", piwikAnalyticServer); | ||
model.addAttribute("searchEngineInclude", searchEngineInclude); | ||
model.addAttribute("defaultAlgorithm", defaultAlgorithm); | ||
model.addAttribute("pageName", pageName); | ||
} | ||
|
||
} |
Oops, something went wrong.