Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GunkaArtur committed Mar 28, 2024
1 parent b72fa54 commit 4948476
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 477 deletions.
23 changes: 11 additions & 12 deletions brizy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Plugin URI: https://brizy.io/
* Author: Brizy.io
* Author URI: https://brizy.io/
* Version: 2.4.43
* Version: 2.4.41
* Text Domain: brizy
* License: GPLv3
* Domain Path: /languages
Expand All @@ -17,25 +17,24 @@
$_SERVER['HTTPS'] = 'on';
}

define('BRIZY_DEVELOPMENT', true);
define('BRIZY_LOG', false);
define('BRIZY_VERSION', '2.4.43');
define('BRIZY_DEVELOPMENT', false );
define('BRIZY_LOG', false );
define('BRIZY_VERSION', '2.4.41');
define('BRIZY_MINIMUM_PRO_VERSION', '2.4.15');
define('BRIZY_MINIMUM_COMPILER_VERSION', '282-wp');
define('BRIZY_EDITOR_VERSION', BRIZY_DEVELOPMENT ? 'dev' : '282-wp');
define('BRIZY_SYNC_VERSION', '282');
define('BRIZY_EDITOR_VERSION', BRIZY_DEVELOPMENT ? 'dev' : '279-wp' );
define('BRIZY_SYNC_VERSION', '279');
define('BRIZY_FILE', __FILE__);
define('BRIZY_PLUGIN_BASE', plugin_basename(BRIZY_FILE));
define('BRIZY_PLUGIN_PATH', dirname(BRIZY_FILE));
define('BRIZY_PLUGIN_URL', rtrim(plugin_dir_url(BRIZY_FILE), "/"));
define('BRIZY_MAX_REVISIONS_TO_KEEP', 30);

include_once rtrim(BRIZY_PLUGIN_PATH, "/").'/autoload.php';
include_once rtrim(BRIZY_PLUGIN_PATH, "/").'/languages/main.php';
include_once rtrim(BRIZY_PLUGIN_PATH, "/") . '/autoload.php';
include_once rtrim(BRIZY_PLUGIN_PATH, "/") . '/languages/main.php';

if (BRIZY_DEVELOPMENT) {
$dotenv = new \Symfony\Component\Dotenv\Dotenv('APP_ENV');
$dotenv->load(__DIR__.'/.env');
$dotenv->load(__DIR__ . '/.env');
}

add_action('plugins_loaded', 'brizy_load');
Expand Down Expand Up @@ -119,7 +118,7 @@ function brizy_install()
Brizy_Logger::install();
add_option('brizy-regenerate-permalinks', 1);
do_action('brizy-activated');
set_transient('brizy_admin_notice', true, 7200);
set_transient( 'brizy_admin_notice', true, 7200 );
}

function brizy_clean()
Expand All @@ -131,7 +130,7 @@ function brizy_clean()

function brizy_load_text_domain()
{
load_plugin_textdomain('brizy', false, dirname(plugin_basename(__FILE__)).'/languages');
load_plugin_textdomain('brizy', false, dirname(plugin_basename(__FILE__)) . '/languages');
}

new Brizy_Compatibilities_Init();
36 changes: 35 additions & 1 deletion public/editor-client/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Config, getConfig } from "@/config";
import { DefaultBlock, PagesAPI } from "@/types/DefaultTemplate";
import { ConfigDCItem } from "@/types/DynamicContent";
import { GlobalBlock } from "@/types/GlobalBlocks";
import { Page } from "@/types/Page";
import { Rule } from "@/types/PopupConditions";
import { Project } from "@/types/Project";
import { ResponseWithBody } from "@/types/Response";
import { ConfigDCItem } from "@/types/DynamicContent";
import {
CreateSavedBlock,
CreateSavedLayout,
Expand All @@ -15,6 +16,7 @@ import {
} from "@/types/SavedBlocks";
import { ScreenshotData } from "@/types/Screenshots";
import { t } from "@/utils/i18n";
import { Json } from "@brizy/readers";
import { Literal } from "../utils/types";
import {
GetCollections,
Expand Down Expand Up @@ -1206,3 +1208,35 @@ export const updateGlobalBlocks = async (
};

//#endregion

// region Default Pages
export const getDefaultPages = async (): Promise<{
blocks: PagesAPI[];
categories: Record<string, string>;
}> => {
const res = await fetch(
// temporary solution, wait until new API will come via config
"https://phplaravel-1109775-4184176.cloudwaysapps.com/api/get-pages-chunk"
).then((r) => r.json());

return {
blocks: res.collections,
categories: res.categories
};
};

export const getDefaultPage = async (
slug: string
): Promise<{
items: DefaultBlock[];
}> => {
const data = await fetch(
// temporary solution, wait until new API will come via config
`https://j6dfq8pl41.b-cdn.net/api/get-page-data?page_slug=${slug}`
).then((r) => r.json());

return Json.read(data[0].pageData) as {
items: DefaultBlock[];
};
};
// endregion
19 changes: 4 additions & 15 deletions public/editor-client/src/defaultTemplates/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Json } from "@brizy/readers";
import { getDefaultPage, getDefaultPages } from "@/api";
import { Config } from "../config";
import {
BlocksArray,
Expand All @@ -21,7 +21,7 @@ import {
} from "../types/DefaultTemplate";
import { t } from "../utils/i18n";
import { tempConverterKit } from "./tempComverters";
import { convertPages, convertToCategories, fetchAllLayouts1 } from "./utils";
import { convertPages, convertToCategories } from "./utils";

const defaultKits = (
config: Config
Expand Down Expand Up @@ -298,16 +298,11 @@ const defaultPages = (
// @ts-expect-error: temporary solution, wait until new API will come via config
const { layoutsUrl } = config.api.templates;
const imageUrl = "https://cloud-1de12d.b-cdn.net/media/iW=1024&iH=1024/";
const apiLayoutsUrl1 =
"https://phplaravel-1109775-4184176.cloudwaysapps.com/api";
const apiPagesUrl = "https://j6dfq8pl41.b-cdn.net/api";

return {
async getMeta(res, rej) {
try {
const { blocks, categories } = await fetchAllLayouts1(
`${apiLayoutsUrl1}/get-pages-chunk`
);
const { blocks, categories } = await getDefaultPages();

res({
blocks: convertPages(blocks, imageUrl),
Expand All @@ -319,13 +314,7 @@ const defaultPages = (
},
async getData(res, rej, { slug }) {
try {
const data = await fetch(
`${apiPagesUrl}/get-page-data?page_slug=${slug}`
).then((r) => r.json());

const pageData = Json.read(data[0].pageData) as {
items: DefaultBlock[];
};
const pageData = await getDefaultPage(slug);

res({
blocks: [...pageData.items]
Expand Down
Loading

0 comments on commit 4948476

Please sign in to comment.