Category: Liferay

What’s new in liferay 7?

Liferay 7 was a major release that introduces several new features and improvements over previous versions of Liferay.

Here are some of the notable new features in Liferay 7:
  1. Modular architecture: It will allows developers to build and deploy individual components as separate modules with modular architecture. This makes it easier to develop, test, and deploy Liferay components.
  2. React-based UI: Liferay 7 introduces a new UI framework built with React, a popular JavaScript library for building user interfaces. The new UI framework provides a modern, responsive, and intuitive user experience.
  3. Content Management System (CMS): Liferay 7 includes a new CMS that provides an intuitive and easy-to-use interface for managing content, pages, and sites. The CMS allows users to create and manage content without the need for technical skills.
  4. Personalized experiences: Liferay 7 introduces features for creating personalized experiences for users based on their preferences, behaviors, and interests. This includes features for segmenting and targeting audiences, and for personalizing the content and layout of pages.
  5. Improved performance: Liferay 7 includes faster page loading times, improved scalability, and reduced resource utilization.
  6. Improved security: Liferay 7 includes several security improvements, including support for OAuth2 and OpenID Connect, improved password policies, and enhanced access control.
  7. Microservices support: Liferay 7 includes support for building and deploying microservices, which are small, independent, and modular components that can be deployed and managed separately. This allows developers to build and deploy Liferay components as microservices, making it easier to manage and scale their applications.

These are just some of the new features and improvements in Liferay 7. If you are considering upgrading to Liferay 7, it is important to carefully evaluate your specific needs and requirements, and to consult with an expert in Liferay development.

Angular 4 integration with Liferay DXP and Firebase

Angular and Firebase seed

A simple starter project demonstrating the basic concepts of Angular and Firebase integration.

Firebase

Firebase helps to build better Realtime Web Application and mobile apps for all the platforms to grow your business.

It provides the functionality like Realtime databases, Analytic, Cloud Messaging and Crash Reporting so we can move quickly and focus on our users. We can also test and deploy our application on Firebase Hosting With Free SSL Certificate. We can use Firebase on client-side app developers (both web & mobile)

Before installing the Firebase, First of all, we need to make sure that below mention software installed properly with appropriate version as mentioned below.

Getting Started

  • Make sure you have node.js installed version 6+
  • Make sure you have NPM installed version 3.9+
  • Deploy using gradle or Eclipse Liferay tools

Install

Run this command in same project directory

npm install

Setting up the Project

  • Create a project in the Console.
  • Click to Create New Project.
  • If you already have a project, click Add App from the project overview page.
  • Click to “Add Firebase” to your web app.
  • Note the initialization code snippet, which you will need to replace in environment.ts file.

src\main\resources\META-INF\resources\enviroments – sample code

  // Initialize
  // TODO: Replace with your project's customized code snippet
  production: false,
  firebase : {
    apiKey: "<API_KEY>",
    authDomain: "<PROJECT_ID>.firebaseapp.com",
    databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
    storageBucket: "<BUCKET>.appspot.com",
    messagingSenderId: "<SENDER_ID>",
  };
  firebase.initializeApp(config);

Angular and Liferay DXP Github Code

Liferay 7 DXP Tops Google Trends

Liferay 7 DXP Scale is based on the average worldwide traffic in one year. Awesome!

Recently released Liferay 7 DXP (Liferay Digital Experience Platform) saves the scale of graph in google trends.

Benefits

  • Single, consolidated platform
  • Securely handle private data
  • Easy-to-use interfaces
  • Microservices architecture
  • Easy to integrate and customize
  • Front-end developers can use any popular framework they like (Angular,React)

Liferay trend on google before releasing Liferay 7

How to create a theme in Liferay 7 DXP

Here is the list of software that required to create liferay 7 DXP theme

  1. NodeJS – for yomen,gulp and generator-liferay-theme
  2. Ruby Installed – Ruby is to create SaSS and Compass CSS elements
  3. Yo – Node JS plugin
  4. Gulp – Node JS Plugin

Installing Node and NPM

First we need to download and install the node if you have already installed and configured Node, feel free to skip this section. We can download Node.js from http://nodejs.org and follow the instructions mentioned here:

Download the installer for your operating system from http://nodejs.org/. Nodejs provides different installer as per your platform. It also include the npm package manager

  •  If the installation asks for the system restart, then restart your computer.
  • Once the system is restarted, we can check whether Node.js was set up properly or not.
  •  Open the command prompt and run the following command to make sure you are installing latest version:
    • node –version // to verify the version

Configure the NPM Path and environment

After NodeJS installation we need to configure the NPM path. we will create .npmrc config file and set manually npm-packages path to keep these plugins at one directory.

Create .npmrc file at user Home directory C:/User/{user-name} with below parameters:

prefix=C:/Users/harmeet.singh/.npm-packages
NPM_PACKAGES=C:/Users/harmeet.singh/.npm-packages
NODE_PATH=%NODE_PATH%:%NPM_PACKAGES%/lib/node_modules

Now we need to install yomen and gulp plugin by giving below command:

  • npm install -g yo
  • npm install -g gulp

Ruby Installation

Now we need to install ruby sass and compass.

Then run the below command with gem keyword such as (gem sources -r https://rubygems.org):

  • sources -r https://rubygems.org
  • sources -a http://rubygems.org
  • install sass compass

Steps for creating a theme in Liferay 7 DXP

  • Create one folder in your local drive where you want to create your theme.
  • Now open the cmd in same folder
  • Next run this command —yo liferay-theme

  • Enter your Theme name “My First Liferay 7 Theme (no need to give “-” between spaces) press enter
  • Next —-enter (it will ask you..would you like to use as ID)
  • Then select liferay theme version 7.0 or 6.2
  • Next — enter the path of app server directory
  • then enter the URL of your site – http://localhost:8080

Now we need to update the theme package.json to use Ruby SaSS and Compass by default it use Node SaSS:

  • Edit package.json in you theme directory folder and set rubySass to true
  • templateLanguage to vm (by default it set to “ftl”)

We have change vm in liferay-look-and-feel.xml file because you will get below error: SERVLET_CONTEXT_/templates/portal_normal.ftl does not exist

Run gulp build to build the theme

Note: if you get the below error while build your theme:

Starting ‘build:compile-ruby-sass’…
error build/_css/aui/lexicon/lexicon-base/mixins/_nameplates.scss (Line 14: Invalid CSS after “(max-width: “: expected expression (e.g. 1px, bold), was “$screen-xs-max)”)

To solve this error do this:

edit the file “\theme-folder\node_modules\liferay-frontend-theme-unstyled\css\aui\lexicon\lexicon-base\_nameplates.scss” and comment below code:

//.nameplate-label-autofit-xs-max {
// @include nameplate-label-autofit('max-width: $screen-xs-max');
//}

Run gulp build deploy again to deploy your theme and start your development

Note:  Make sure your are connected with internet while creating theme.

wkhtmltopdf – Generating PDF and Images

wkhtmltopdf is amazing  open source (LGPLv3) command line tool wkhtmltopdf to render HTML to PDF and various image formats using the Qt WebKit rendering engine. These run entirely “headless” and do not require any service.

There is also a C library, if you’re into that kind of thing.

How to use wkhtmltopdf ?

  1. Download a precompiled binary or build from source
  2. Create your HTML document that you want to convert into a PDF (or image)
  3. Run your HTML document through the tool.
    For example, if I really like the treatment LiferayUI has done to their logo today and want to capture it forever as a PDF:wkhtmltopdf https://liferayui.com liferayui.pdf
Global Options:
      --collate                       Collate when printing multiple copies
                                      (default)
      --no-collate                    Do not collate when printing multiple
                                      copies
      --cookie-jar <path>             Read and write cookies from and to the
                                      supplied cookie jar file
      --copies <number>               Number of copies to print into the pdf
                                      file (default 1)
  -d, --dpi <dpi>                     Change the dpi explicitly (this has no
                                      effect on X11 based systems)
  -H, --extended-help                 Display more extensive help, detailing
                                      less common command switches
  -g, --grayscale                     PDF will be generated in grayscale
  -h, --help                          Display help
      --htmldoc                       Output program html help
      --image-dpi <integer>           When embedding images scale them down to
                                      this dpi (default 600)
      --image-quality <integer>       When jpeg compressing images use this
                                      quality (default 94)
      --license                       Output license information and exit
  -l, --lowquality                    Generates lower quality pdf/ps. Useful to
                                      shrink the result document space
      --manpage                       Output program man page
  -B, --margin-bottom <unitreal>      Set the page bottom margin
  -L, --margin-left <unitreal>        Set the page left margin (default 10mm)
  -R, --margin-right <unitreal>       Set the page right margin (default 10mm)
  -T, --margin-top <unitreal>         Set the page top margin
  -O, --orientation <orientation>     Set orientation to Landscape or Portrait
                                      (default Portrait)
      --page-height <unitreal>        Page height
  -s, --page-size <Size>              Set paper size to: A4, Letter, etc.
                                      (default A4)
      --page-width <unitreal>         Page width
      --no-pdf-compression            Do not use lossless compression on pdf
                                      objects
  -q, --quiet                         Be less verbose
      --read-args-from-stdin          Read command line arguments from stdin
      --readme                        Output program readme
      --title <text>                  The title of the generated pdf file (The
                                      title of the first document is used if not
                                      specified)
  -V, --version                       Output version information and exit

Additional options

That’s amazing, I’ve always wanted to turn LiferayUI homepage into a PDF, but I want a table of contents as well.

There are lot’s of command line options. You can check out the auto-generated wkhtmltopdf options.

You can also add custom Header and Footer in PDF using page option.

wkhtmltopdf --header-html header.html https://liferayui.com liferayui.pdf