Skip to content

Commit

Permalink
Fixed #186, fixed #185, fixed #184 and fixed #183
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
dzc34 committed Sep 29, 2018
1 parent d510dba commit 1d5b339
Show file tree
Hide file tree
Showing 13 changed files with 467 additions and 128 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ none
- [#182 - Upgraded spring-security (4.2.8 instead of 4.2.7)](https://github.com/Asqatasun/Contrast-Finder/issues/182)

### Bug
none
- [#184 - Webapp: modify the title tag when the form is on error to inform the user](https://github.com/Asqatasun/Contrast-Finder/issues/184)

### Improvement
none
- [#183 - Added config. informations in the logs when starting the webapp](https://github.com/Asqatasun/Contrast-Finder/issues/183)
- [#185 - Added new configuration option for logging colors results](https://github.com/Asqatasun/Contrast-Finder/issues/185)
- [#186 - Webapp: added new page to provide build ID (commit hash)](https://github.com/Asqatasun/Contrast-Finder/issues/186)

### Refactoring
none
Expand Down
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}



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}



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

}
Loading

0 comments on commit 1d5b339

Please sign in to comment.