June 14, 2016

Wordpress accesspress-parallax theme - add or update translation

I wanted to add a Czech translation to the wordpress theme, so there are some steps how to do it.
First of all, download PoEdit, editor for Wordpress translation.
Than go to the wp-content/themes/accesspress-parallax/languages on your FTP server.
There should be cs_CZ.po file with Czech translation, if it is missing, copy accesspress-parallax.pot (just english template) and open it in PoEdit app. For example if you want to translate button with text "Read more", than find this string and write your translation. Than save this file as cs_CZ.po file, and last but not least, export this file to "MO" file with "File->Compile to MO..." option.
Than copy both ".po" and ".mo" files back to the wp-content/themes/accesspress-parallax/languages folder.

May 23, 2016

Import of the certificate to the java Keystore

From certification authority we get three files:


Intermediate_CA_chain.cer (certificate chain)

SERVER_CERTIFICATE.cer (server certificate)

PRIVATE_KEY.key (private key)



  1. Conversion from PEM to PKCS#7
    on the page https://www.ssls.cz/converter.html is conversion PEM (.cer, .crt, .pem) to PKCS#7 (.p7b, .p7c, .p7s),
    (we will use server certificate = SERVER_CERTIFICATE.cer and Intermediate CA (Intermediate_CA_chain.cer)), so I made a .p7b file (NEW.p7b).

    Maybe the following command can be also used instead of the previous step with web form (I did not try this):

    
    
    openssl crl2pkcs7 -nocrl -certfile SERVER_CERTIFICATE.cer -out NEW.p7b -certfile Intermediate_CA_chain.cer),
    
    

    Finally I have created NEW.cer (our new certificate chain) file with following:
    
    openssl pkcs7 -print_certs -in NEW.p7b -out NEW.cer
    
    

    (maybe it could be OK to skip the step 1. and just use Intermediate_CA_chain.cer instead of the NEW.cer - I did not try this)
  2. Import of the private key (PRIVATE_KEY.key) and server certificate (SERVER_CERTIFICATE.cer) to the java keystore (game_keystore.jks)
    (https://secure.marumoto.us/motowiki/tiki-index.php?page=Import+a+private+key+and+certificate+into+a+Java+Keystore)

    
    openssl pkcs12 -export -in SERVER_CERTIFICATE.cer -inkey PRIVATE_KEY.key -out KEYSTORE.p12 -name game_key
    
    keytool -importkeystore -srckeystore KEYSTORE.p12 -srcstoretype PKCS12 -destkeystore game_keystore.jks
    
    
  3. Import of the chain of certificates to the SAME keystore (game_keystore.jks) with THE SAME ALIAS as in the previous step
    
    keytool -importcert -trustcacerts -alias game_key -file NEW.cer -keystore game_keystore.jks -storepass SECRET_PASSWORD -keypass SECRET_PASSWORD
    
    

      Finally it is possible to view the content of the final java keystore:

    
    keytool -list -v -keystore game_keystore.jks
    
    

May 2, 2016

Wordpress theme accesspress-parallax

For some client we were creating a new "single-page" website, and we have chosen https://wordpress.org/themes/accesspress-parallax/, simple, well-arranged layout, with some handy customization, I can recommend it.

April 29, 2016

Prestashop theme alysum - add a new menu item

I wanted add an item to the menu in the alysum theme, but I was not able to do it in the FlexMenu module, because I always get an "Not Connect - Verify Network" alert, and clearing the prestashop cache did not help, so I decided to add it in the database. Simply open the db table ps_pk_flexmenu_menus and add a new record and so for ps_pk_flexmenu_menus_lang

April 18, 2016

Prestashop set Currency depending on the language (Prestashop version 1.6)

UPDATE
Based on the prestashop forum:
https://www.prestashop.com/forums/topic/52019-change-currency-automatically-when-switching-from-one-language-to-another/?p=1834832
Find ChangeCurrencyController.php and change this:
$this->context->cookie->id_currency = (int)$currency->id;

to:

$this->context->cookie->id_currency = (int)$currency->id;
$this->context->cookie->id_currency_changed = 1;

Find Tools.php and in function "switchLanguage" find and change line:

$language = new Language($id_lang);


to:


$language = new Language($id_lang);
            
            // added for hard currency linked switch
            switch($id_lang) {
                case 1: //if lang_id that's changed to currency id = 1 than...
                    Tools::switchCurrencyLinked(1);
                    break;
                case 2:
                    Tools::switchCurrencyLinked(2);
                    break;
                case 3: //and so on ....
                    Tools::switchCurrencyLinked(3);
                    break;
               }


Immediately after end of function public static function switchLanguage insert new function:

/**
     * Change cookie currency with Language when hard currency linked switch - janoo
     *
     */
     public static function switchCurrencyLinked($cookieLanguage)
    {
        global $cookie;

        if (! (int)$cookie->id_currency_changed)
        {
            $cookie->id_currency = $cookieLanguage;
            Tools::setCurrency($cookie);
        }
        else
        {
            $cookie->id_currency_changed = 0;
        }
    }



Credits goes to Devein, Chris2407 and janoo, Thanks!



OLD VERSION: In Prestashop Back Office, find ID for each currency and each language you want to use, (Language ID you can find in Back Office at "Localization -> Languages -> Edit:English" and in url you can see parameter "&id_lang=1&", the same for Currency)
than edit
classes/controller/FrontController.php in your Prestashop folder, find
$currency = Tools::setCurrency($this->context->cookie);
and add the following (so at the end it would be like this):
         if ($this->context->cookie->id_lang == 1){
           $this->context->cookie->id_currency = 2;
         }else{
           $this->context->cookie->id_currency = 1;
         }

        $currency = Tools::setCurrency($this->context->cookie);
Number "1" should be your Prestahop language ID (number "1" here is just an example), also "2" and "1" should be your Prestahop Currency ID.
This works for Prestashop version 1.6.

April 10, 2016

My personal TO READ list

Recently I have read these books and I would highly recommend them to all, not just IT people or technically skilled :-)


And some books, which I have on my TO READ List: 

Patrick Zandl - Apple: cesta k mobilům (just in Czech language)

And some non IT  books:

Patrick Zandl - Husákův děda  (just in Czech language)

Patrick Zandl - Koncernová pětiletka (just in Czech language)

April 3, 2016

Logback and Spring Boot integration

If you want to use Logback as a logging tool for your Spring Boot project, you have to set the path for your logback.xml settings in the application.properties file. Note that it is for Spring Boot in the 1.3.3 version (and later I guess). The important thing is the colon ":"

In "application.properties" file:


#Logback config file

logging.config: ${user.dir}/config/logback.xml



and the logback.xml:
<configuration debug="false">

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">

        <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->

    <encoder>

      <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{40} - %msg%n</pattern>

    </encoder>

  </appender>


  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">

    <file>log/project.log</file>

    <append>true</append>

    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

      <!-- rollover daily -->

      <fileNamePattern>log/project-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>

      <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">

        <!-- or whenever the file size reaches 10MB -->

        <maxFileSize>40MB</maxFileSize>

      </timeBasedFileNamingAndTriggeringPolicy> 

      <!-- keep 120 days' worth of history -->

      <maxHistory>120</maxHistory>

    </rollingPolicy>

    <encoder>

      <pattern>%d{HH:mm:ss.SSS} [%-5level] %-40logger - %msg%n</pattern>

    </encoder>

  </appender>


  <root level="WARN">

    <appender-ref ref="STDOUT" />

    <appender-ref ref="FILE" />

  </root>

</configuration>

Prestashop Datatrans payment module

For one of my client, I was preparing Prestashop eshop with theme - http://promokit.eu/themes/prestashop-1-6-theme-alysum/ (which is nice, I can recommend it, also documentation and support is on good level),
and I was integrating prestahop payment module by https://www.sellxed.com/, which is connected to the datatrans payment system https://www.datatrans.ch/
It is alo nice, but somehow it stopped working in that way, that payment gateways were hidden on the checkout page (technically they were on the page, but hidden by javascript) and I was not able to make it working.
I have searched all the internet, and was preparing to contact their support, then I suddenly noticed, that on the the module configuration page (for example Datatrans VISA)



there is some switch button (Payment Form Position: Use separate page OR Use payment selection page) with description
"The payment form can be displayed directly on payment method list page or on a separate page. In some cases it does not work, when the payment form is displayed on the payment page. In this cases a separate page must be used."



So I tried to change it from default configuration (Use payment selection page) to the "Use separate page" and voila, the payment gateway appeared on the checkout page! Do it with all gateways you want to enable on the checkout page.

JSON object to PostgreSQL via Hibernate

Nice article about storing JSON object to PostgreSQL database via Hibernate
http://www.vivekpatidar.com/?p=13