Skip to content

Instantly share code, notes, and snippets.

View pedroblandim's full-sized avatar

Pedro Blandim Andrade pedroblandim

View GitHub Profile
import { AsyncThunk, AsyncThunkAction } from "@reduxjs/toolkit";
type AsyncThunkReturnType<C extends AsyncThunkAction<any, any, any>> = C extends AsyncThunkAction<infer T, any, any> ? T : unknown;
export type GetAsyncThunkReturnType<T extends AsyncThunk<any, any, any>> = AsyncThunkReturnType<ReturnType<T>>;
@pedroblandim
pedroblandim / get-widget-template-instance-layout.sql
Created July 4, 2023 20:34
Liferay PSQL Query: Pegar página (layout) que possui um Asset Publisher com um modelo x
select g."name", g.friendlyurl, l.friendlyurl, l."name", pp.portletid, pp.plid from portletpreferencevalue ppv
inner join portletpreferences pp on pp.portletpreferencesid = ppv.portletpreferencesid
inner join layout l on l.plid = pp.plid
inner join group_ g on g.groupid = l.groupid
where ppv."name" = 'displayStyle' -- displayStyle é o name do input de modelo no asset publisher
and smallvalue = 'ddmTemplate_5408463' -- 5408463 é o templateKey
@pedroblandim
pedroblandim / Envio de email.groovy
Last active October 5, 2023 17:46
Simplify Liferay - Vídeo: Configurando servidor de email
import com.liferay.mail.kernel.model.MailMessage;
import com.liferay.mail.kernel.service.MailServiceUtil;
import javax.mail.internet.InternetAddress;
MailMessage mailMessage = new MailMessage();
mailMessage.setHTMLFormat(true);
mailMessage.setBody("set body here");
mailMessage.setFrom(new InternetAddress("fromAddress","fromName"));
@pedroblandim
pedroblandim / dev-docker-compose.yaml
Last active January 12, 2024 04:26
Liferay docker compose
version: "3.8"
services:
liferay:
image: liferay/portal:7.4.3.19-ga19
container_name: tomcat
networks:
- fs72sp1
depends_on:
- postgres
environment:
@pedroblandim
pedroblandim / main.js
Created November 3, 2022 02:15
Liferay: Usando React em um fragmento
"use strict";
const e = React.createElement;
const { useState, useEffect } = React;
// TODO pegar campos editáveis de um campo editável que só aparece na página de edição
const BibliotecaDeArquivos = (props) => {
const [searchValue, setSearchValue] = useState('');
function handleSearch(keywords) {
@pedroblandim
pedroblandim / getLocalizedCustomFieldValue.ftl
Created August 29, 2022 08:04
LIFERAY: Get localized custom field value on widget template
<#function getLocalizedCustomFieldValue navItem customFieldName>
<#assign customField = navItem.getLayout().getExpandoBridge().getAttribute(customFieldName)>
<#if customField??>
<#list customField?keys as key>
<#if key == locale>
<#return customField?values[key_index]!"" />
</#if>
</#list>
<#else>
<#return "" />
@pedroblandim
pedroblandim / Get language key with resourcebundle.java
Created July 28, 2022 17:54
Liferay: Get language key without themedisplay or request
@Activate
public void activate() {
ResourceBundle resourceBundle = ResourceBundle.getBundle(
"content.Language", LocaleUtil.getDefault());
String value = LanguageUtil.get(resourceBundle, "key");
}
@pedroblandim
pedroblandim / Corpo da requisição de criação de Blog.json
Last active July 21, 2022 23:34
Simplify Liferay - Vídeo: Descobrindo as APIs Rest NATIVAS dos LIFERAY
{
"alternativeHeadline": "Título alternativo da notícia vai aqui",
"articleBody": "Corpo da notícia vai aqui",
"datePublished": "2021-02-10T06:30:17.780Z",
"description": "Descrição da notícia vai aqui",
"headline": "Título da notícia vai aqui",
"viewableBy": "Anyone"
}
@pedroblandim
pedroblandim / clay-icons.ftl
Created July 14, 2022 03:24
Liferay: Use clay icons o Freemaker
<@clay["icon"] symbol="times" />
@pedroblandim
pedroblandim / liferay-notification.js
Created June 27, 2022 20:18
Liferay - JS notification sample
AUI().use("liferay-notification", () => {
new Liferay.Notification({
closeable: true,
delay: {
hide: 5000,
show: 0,
},
duration: 1500,
message: "Test message",
render: true,