#416: Added Liquid formattinggit status

This commit is contained in:
frikky
2021-08-03 00:33:48 +02:00
parent a6a18acd3c
commit e8b7b2b444
5 changed files with 46 additions and 7 deletions
+3 -3
View File
@@ -6,11 +6,11 @@ RUN apk --no-cache add --update alpine-sdk libffi libffi-dev musl-dev openssl-de
RUN mkdir /install
WORKDIR /install
COPY requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt
FROM base
COPY --from=builder /install /usr/local
COPY requirements.txt /requirements.txt
RUN pip3 install -r /requirements.txt
COPY __init__.py /app/walkoff_app_sdk/__init__.py
COPY app_base.py /app/walkoff_app_sdk/app_base.py
+38 -1
View File
@@ -10,6 +10,8 @@ import urllib.parse
import http.client
import urllib3
import hashlib
from liquid import Liquid
import liquid
class AppBase:
__version__ = None
@@ -1509,6 +1511,31 @@ class AppBase:
print("Error in decoder: %s" % e)
return returndata, is_loop
def parse_liquid(template):
#print("Inside liquid with glob: %s" % globals())
try:
#print(globals())
print("Running with \"%s\"" % template)
run = Liquid(template, {'mode': 'python'})
ret = run.render(**globals())
return ret
#try:
#run = Liquid(template)
#return ret
#except liquid.exceptions.LiquidSyntaxError as e:
# run = Liquid(template, {'mode': 'python'})
# ret = run.render(**globals())
# return ret
#except liquid.exceptions.LiquidRenderError as e:
# print("Render error: %s" % e)
except liquid.exceptions.LiquidRenderError as e:
print("Render error: %s" % e)
except liquid.exceptions.LiquidSyntaxError as e:
print("Syntax error: %s" % e)
return template
# Parses parameters sent to it and returns whether it did it successfully with the values found
def parse_params(action, fullexecution, parameter):
# Skip if it starts with $?
@@ -1518,7 +1545,8 @@ class AppBase:
# Matches with space in the first part, but not in subsequent parts.
# JSON / yaml etc shouldn't have spaces in their fields anyway.
#match = ".*?([$]{1}([a-zA-Z0-9 _-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,})[$/, ]?"
match = ".*?([$]{1}([a-zA-Z0-9 _-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,})"
#match = ".*?([$]{1}([a-zA-Z0-9 _-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,})"
match = ".*?([$]{1}([a-zA-Z0-9_-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,})" # Removed space - no longer ok
# Regex to find all the things
if parameter["variant"] == "STATIC_VALUE":
@@ -1640,6 +1668,15 @@ class AppBase:
except json.decoder.JSONDecodeError as e:
parameter["value"] = parameter["value"].replace(to_be_replaced, value)
# Just here in case it breaks
# Implemented 02.08.2021
print("Pre liquid: %s" % parameter["value"])
try:
parameter["value"] = parse_liquid(parameter["value"])
except:
pass
print("POST liquid: %s" % parameter["value"])
return "", parameter["value"], is_loop
def run_validation(sourcevalue, check, destinationvalue):
+1 -1
View File
@@ -3,7 +3,7 @@
### DEFAULT
NAME=shuffle-app_sdk
VERSION=0.9.05
VERSION=0.9.06
docker rmi docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION --force
docker build . -f Dockerfile -t frikky/shuffle:app_sdk -t frikky/$NAME:$VERSION -t docker.pkg.github.com/frikky/shuffle/$NAME:$VERSION -t ghcr.io/frikky/$NAME:$VERSION
+1
View File
@@ -1,2 +1,3 @@
urllib3==1.25.9
requests==2.25.1
liquidpy==0.6.3
+3 -2
View File
@@ -8,7 +8,7 @@ import { useTheme } from '@material-ui/core/styles';
import NestedMenuItem from "material-ui-nested-menu-item";
//import NestedMenuItem from "./NestedMenu.jsx";
import {Popper, TextField, Drawer, Button, Paper, Grid, Tabs, InputAdornment, Tab, ButtonBase, Tooltip, Select, MenuItem, Divider, Dialog, Modal, DialogActions, DialogTitle, InputLabel, DialogContent, FormControl, IconButton, Menu, Input, FormGroup, FormControlLabel, Typography, Checkbox, Breadcrumbs, CircularProgress, Switch, Fade} from '@material-ui/core';
import {Popper, TextField, TextareaAutosize, Drawer, Button, Paper, Grid, Tabs, InputAdornment, Tab, ButtonBase, Tooltip, Select, MenuItem, Divider, Dialog, Modal, DialogActions, DialogTitle, InputLabel, DialogContent, FormControl, IconButton, Menu, Input, FormGroup, FormControlLabel, Typography, Checkbox, Breadcrumbs, CircularProgress, Switch, Fade} from '@material-ui/core';
import {GetApp as GetAppIcon, Search as SearchIcon, ArrowUpward as ArrowUpwardIcon, Visibility as VisibilityIcon, Done as DoneIcon, Close as CloseIcon, Error as ErrorIcon, FindReplace as FindreplaceIcon, ArrowLeft as ArrowLeftIcon, Cached as CachedIcon, DirectionsRun as DirectionsRunIcon, Add as AddIcon, Polymer as PolymerIcon, FormatListNumbered as FormatListNumberedIcon, Create as CreateIcon, PlayArrow as PlayArrowIcon, AspectRatio as AspectRatioIcon, MoreVert as MoreVertIcon, Apps as AppsIcon, Schedule as ScheduleIcon, FavoriteBorder as FavoriteBorderIcon, Pause as PauseIcon, Delete as DeleteIcon, AddCircleOutline as AddCircleOutlineIcon, Save as SaveIcon, KeyboardArrowLeft as KeyboardArrowLeftIcon, KeyboardArrowRight as KeyboardArrowRightIcon, ArrowBack as ArrowBackIcon, Settings as SettingsIcon, LockOpen as LockOpenIcon, ExpandMore as ExpandMoreIcon, VpnKey as VpnKeyIcon} from '@material-ui/icons';
import Autocomplete from '@material-ui/lab/Autocomplete';
@@ -685,9 +685,10 @@ const ParsedAction = (props) => {
const clickedFieldId = "rightside_field_"+count
var datafield =
//<TextareaAutosize
<TextField
disabled={disabled}
style={{backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius, border: selectedActionParameters[count].required || selectedActionParameters[count].configuration ? "2px solid #f85a3e" : "",}}
style={{backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius, border: selectedActionParameters[count].required || selectedActionParameters[count].configuration ? "2px solid #f85a3e" : "", color: "white", width: "100%", fontSize: "1em",}}
InputProps={{
style:{
color: "white",