diff --git a/backend/app_sdk/Dockerfile b/backend/app_sdk/Dockerfile index 75ec12c4..d4646ff4 100644 --- a/backend/app_sdk/Dockerfile +++ b/backend/app_sdk/Dockerfile @@ -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 diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 789c4b72..2c21d584 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -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): diff --git a/backend/app_sdk/build.sh b/backend/app_sdk/build.sh index 83e9355a..5abb5960 100644 --- a/backend/app_sdk/build.sh +++ b/backend/app_sdk/build.sh @@ -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 diff --git a/backend/app_sdk/requirements.txt b/backend/app_sdk/requirements.txt index 60b59271..60502c8d 100644 --- a/backend/app_sdk/requirements.txt +++ b/backend/app_sdk/requirements.txt @@ -1,2 +1,3 @@ urllib3==1.25.9 requests==2.25.1 +liquidpy==0.6.3 diff --git a/frontend/src/components/ParsedAction.jsx b/frontend/src/components/ParsedAction.jsx index 7dbdaad6..f20c3fdf 100644 --- a/frontend/src/components/ParsedAction.jsx +++ b/frontend/src/components/ParsedAction.jsx @@ -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 = + //