Skip to content

Commit

Permalink
Merge branch '529talp' of https://github.com/GTFB/Altrp into 529talp
Browse files Browse the repository at this point in the history
  • Loading branch information
talp-525 committed Apr 8, 2022
2 parents efd2f06 + b770574 commit c58b4f0
Show file tree
Hide file tree
Showing 308 changed files with 13,071 additions and 4,634 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public/modules/editor
public/modules/reports
public/modules/reports-new

package-lock.json
yarn.lock
*.conf
rootCA.crt
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@

## Changelog

### 1.0.2
* Fix Section Width


### 1.0.1
* Fix Elements Conditions Display
* Fix HTML in JSON-data for Templates
* Add Styles for Custom Areas
* Show Section Background on Front-end
* Fix Login Action for Elements

### 1.0.0
* Release version

### 0.20.25
* Some Fixes for Section
+ Add Video Background for Sections
Expand Down
4 changes: 4 additions & 0 deletions altrpnjs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ storage/
app/AltrpModels/
app/AltrpControllers/
app/AltrpPlugins/
app/altrp-listeners/
start/altrp-routes/
/resources/views/altrp

cert.pem
key.pem
3 changes: 3 additions & 0 deletions altrpnjs/app/Controllers/AltrpBaseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export default class AltrpBaseController {
protected setCustomizerData(path:string, data:any){
_.set(this.customizerData, path, data)
}
protected unsetCustomizerData(path:string){
_.unset(this.customizerData, path)
}
protected getCustomizerData(path:string, _default:any = null):any{
return _.get(this.customizerData, path, _default)
}
Expand Down
175 changes: 175 additions & 0 deletions altrpnjs/app/Controllers/Http/GlobalTemplateStylesController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
// import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'

import GlobalStyle from "App/Models/GlobalStyle";
import { v4 as uuid } from "uuid";
import Template from "App/Models/Template";
import is_null from "../../../helpers/is_null";
import data_set from "../../../helpers/data_set";
import data_get from "../../../helpers/data_get";
import is_array from "../../../helpers/is_array";

export default class GlobalTemplateStylesController {
public async index() {

try {
const globalStyles = await GlobalStyle.query()

const groups = {};

globalStyles.forEach((style) => {
if(!groups[style.type]) groups[style.type] = [];

groups[style.type].push(style)
})
return groups
} catch (e) {
console.log(e)
return {}
}
}

public async store({ request, response }) {
const data = request.body()

if(!data.type || !data.settings) {
response.status(500)
return "fill all fields"
}

data.guid = uuid()

try {
const style = await GlobalStyle.create(data)
return style
} catch (e) {
console.log(e)
}
}

public async destroy({request}) {
const params = request.params();
const id = parseInt(params.id);

const style = await GlobalStyle.query().where("id", id).firstOrFail()

style.delete()

return {
success: true
}
}

public async update({request, response}) {
const params = request.params();
const id = parseInt(params.id);

const style = await GlobalStyle.query().where("id", id).firstOrFail()

const body = request.body();


switch (style.type) {
case "color":
const data = JSON.parse(style.settings);

data.name = body.name ?? data.name;
data.color = body.color ?? data.color;
data.colorPickedHex = body.colorPickedHex ?? data.colorPickedHex;
data.colorRGB = body.colorRGB ?? data.colorRGB;

style.settings = JSON.stringify(data);
break
}

if(!style.save()) {
response.status(409)
return "Save failed"
}

await this.updateStylesInAllTemplates(style)

return style
}

private async updateStylesInAllTemplates(style) {
let templates = await Template.all();
templates.forEach((template) => {
this.replaceGlobalStyles(template, style.guid, style.settings);
});
}

public replaceGlobalStyles(element, guid, style)
{
let elementData = JSON.parse(element.data);
elementData = GlobalTemplateStylesController.recursiveReplaceGlobalStyles(elementData, guid, style);
console.log(elementData)
element.data = JSON.stringify(elementData);
element.save();
}

public static recursiveReplaceGlobalStyles(data, guid, style) {
if(data.settings.global_styles_storage) {
const globalStylesStorage = data.settings.global_styles_storage

if(globalStylesStorage.length > 0) {
globalStylesStorage.forEach(s => {
if(!is_null(s)) {
if(s.search("typographic") !== -1) {
data_set(data, "settings.__altrpFonts__", s)
}

if(s.search("gradient-first-color:") !== -1) {
const currentSetting = s.replace('gradient-first-color:', '')

s = currentSetting;

const dataSettings = data_get(data, `settings.${currentSetting}`);

if(!is_array(dataSettings) && dataSettings <= 0) return;

const newColor = style["color"];
const oldColor = style["firstColor"];
const newValue = dataSettings.value.replace(oldColor, newColor);

dataSettings.secondColor = newColor;
dataSettings.value = newValue

style = dataSettings
}

if(s.search("gradient-second-color:") !== -1) {
const currentSetting = s.replace('gradient-second-color:', '')

s = currentSetting;

const dataSettings = data_get(data, `settings.${currentSetting}`);

if(!is_array(dataSettings) && dataSettings <= 0) return;

const newColor = style["color"];
const oldColor = style["secondColor"];
const newValue = dataSettings.value.replace(oldColor, newColor);

dataSettings.secondColor = newColor;
dataSettings.value = newValue

style = dataSettings
}

data_set(data, 'settings.' + s, style);
}
})
}
}

if(data.children.length > 0) {
data.children.forEach((child, idx) => {
if(child !== null) {
data.children[idx] = GlobalTemplateStylesController.recursiveReplaceGlobalStyles(child, guid, style)
}
})
}

return data
}
}
22 changes: 22 additions & 0 deletions altrpnjs/app/Controllers/Http/IndicesController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Env from "@ioc:Adonis/Core/Env";
import {HttpContextContract} from "@ioc:Adonis/Core/HttpContext";
import Drive from '@ioc:Adonis/Core/Drive'
import Application from '@ioc:Adonis/Core/Application'
import path from "path";


export default class IndicesController {
async admin({view}) {
Expand Down Expand Up @@ -37,6 +39,16 @@ export default class IndicesController {
}))
}

public async serviceWorker({response}) {
const pathToPublic = path.join(__dirname, "../", "../", "../", "../", "public", "sw.js");

response.header("Content-Type", "text/javascript")

const file = await Drive.get(pathToPublic)

return file
}

// public frontApp({ view }) {
// return view.render('front-app', Edge({
// hAltrp: Env.get("PATH_ENV") === "production" ? "/modules/front-app/h-altrp.js" : null
Expand Down Expand Up @@ -108,6 +120,16 @@ export default class IndicesController {
}
}

public async changelog({ response }) {
const pathToPublic = path.join(__dirname, "../", "../", "../", "../", "README.md");

const file = await Drive.get(pathToPublic)

response.header('Content-type', 'text/plain');

return file.toString()
}

public async favicons({params, response}) {
response.header('Content-type', 'image/png');

Expand Down
6 changes: 2 additions & 4 deletions altrpnjs/app/Controllers/Http/RobotsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export default class RobotsController {
author: robot.user.name,
...robot.serialize(),
categories: robot.categories.map(category => {
return {
category: category
}
return category
})
}

Expand Down Expand Up @@ -49,7 +47,7 @@ export default class RobotsController {
})

for (const option of categories) {
const category = await Category.find(option.value);
const category = await Category.query().where("guid", option.value).first();

if(!category) {
response.status(404)
Expand Down
Loading

0 comments on commit c58b4f0

Please sign in to comment.