From b2322dd90abcca591150287bf3cf8773a6938498 Mon Sep 17 00:00:00 2001 From: Graham Trott Date: Sun, 24 May 2020 12:23:59 +0100 Subject: [PATCH] Development --- mostrami/resources/ecs/mostrami.txt | 133 +++++++------- mostrami/resources/ecs/scripted.txt | 16 +- mostrami/resources/ecs/steps.txt | 67 ++++--- mostrami/resources/json/demo.json | 44 +++-- mostrami/resources/json/test.json | 274 +--------------------------- mostrami/rest.php | 4 +- 6 files changed, 149 insertions(+), 389 deletions(-) diff --git a/mostrami/resources/ecs/mostrami.txt b/mostrami/resources/ecs/mostrami.txt index d083925..72cb832 100644 --- a/mostrami/resources/ecs/mostrami.txt +++ b/mostrami/resources/ecs/mostrami.txt @@ -11,10 +11,10 @@ div Tabs div Tab div ScriptName - div DefaultsPanel + div StepsPanel div BlocksPanel div ContentPanel - div StepsPanel + div DefaultsPanel span Status span Span input NameEditor @@ -26,10 +26,10 @@ img Delete img Cycle a Link - module DefaultsModule + module StepsModule module BlocksModule module ContentModule - module StepsModule + module DefaultsModule variable Mobile variable Current variable Content @@ -46,7 +46,7 @@ variable Message variable Section variable Item - variable Array + variable CurrentScriptName variable N ! The browser @@ -162,9 +162,9 @@ L2: index SectionButton to 0 create SectionButton in Tab set the style of SectionButton to `width:100%` - set the content of SectionButton to `Defaults` - create DefaultsPanel in ContentDiv - set the style of DefaultsPanel to `position:absolute;left:0;top:0;width:100%;height:100%;` + set the content of SectionButton to `Steps` + create StepsPanel in ContentDiv + set the style of StepsPanel to `position:absolute;left:0;top:0;width:100%;height:100%;` create Tab in Tabs set the style of Tab to `display:inline-block;width:` cat N cat `px` index SectionButton to 1 @@ -186,24 +186,13 @@ L2: index SectionButton to 3 create SectionButton in Tab set the style of SectionButton to `width:100%` - set the content of SectionButton to `Steps` - create StepsPanel in ContentDiv - set the style of StepsPanel to `position:absolute;left:0;top:0;width:100%;height:100%;` + set the content of SectionButton to `Defaults` + create DefaultsPanel in ContentDiv + set the style of DefaultsPanel to `position:absolute;left:0;top:0;width:100%;height:100%;` - put -1 into Section - on click SectionButton - begin - put the index of SectionButton into N - if Section is not -1 - begin - index SectionButton to Section - set style `background` of SectionButton to `` - end - put N into Section - index SectionButton to Section - set style `background` of SectionButton to `lightgray` - gosub to UpdateCurrentSection - end + put 0 into Section + index SectionButton to 0 + on click SectionButton gosub to SelectSection ! Create the file browser create Overlay in Body @@ -232,8 +221,8 @@ L2: on click New begin - gosub to StopTestModule - if Content is not Current +! gosub to StopTestModule + if Presentation is not Current begin if confirm `Content has changed. Do you want to save it?` begin @@ -243,14 +232,16 @@ L2: set the content of Status to `No script name has been given` go to ResetStatus end - if PasswordValid rest post Content to `_save/json~` cat Name - else put Content into storage as CurrentName + if PasswordValid rest post Presentation to `_save/json/` cat Name + else put Presentation into storage as CurrentName end end clear FileIsOpen set the content of NameEditor to empty - put empty into Content - put Content into Current + put empty into CurrentScriptName + put empty into Presentation + put empty into Current + gosub to UpdateCurrentSection end on click Open go to DoOpen @@ -264,14 +255,17 @@ L2: set the content of Status to `No script name has been given` go to ResetStatus end - if the position of `.ecs` in Name is -1 put Name cat `.ecs` into Name + if the position of `.json` in Name is -1 put Name cat `.json` into Name replace ` ` with `_` in Name - if Content is not Current + set the content of NameEditor to Name + if Name is not CurrentScriptName put empty into Current + if Presentation is not Current begin - if PasswordValid rest post Content to `_save/json~` cat Name - else put Content into storage as Name - put Content into Current + if PasswordValid rest post Presentation to `_save/json/` cat Name + else put Presentation into storage as Name + put Presentation into Current set the content of Status to `Presentation '` cat Name cat `' saved` + put Name into CurrentScriptName fork to ResetStatus end else @@ -292,43 +286,29 @@ L2: end if confirm `Are you sure you want to delete "` cat Name cat `"?` begin - if PasswordValid rest post Content to `_delete/json~` cat Name + if PasswordValid rest post to `_delete/json/` cat Name else remove Name from storage set the content of Status to `Script "` cat Name cat `" deleted` set the content of NameEditor to empty - put empty into Content - put Content into Current + put empty into CurrentScriptName + put empty into Presentation + put Presentation into Current go to ResetStatus end end - set Presentation to object - set Item to object - set property `global` of Presentation to Item - set property `container` of Presentation to Item - set property `defaults` of Presentation to Item - set property `blocks` of Presentation to Item - set property `content` of Presentation to Item - set Item to object - set property `comment` of Item to `Pause for a second` - set property `action` of Item to `pause` - set property `duration` of Item to 1 - set Array to array - json add Item to Array - set property `steps` of Presentation to Array - put Presentation into Current - gosub to SetupDefaults + gosub to SetupSteps gosub to SetupBlocks gosub to SetupContent - gosub to SetupSteps - gosub to UpdateCurrentSection + gosub to SetupDefaults + gosub to SelectSection stop -SetupDefaults: - if DefaultsModule is not running +SetupSteps: + if StepsModule is not running begin - rest get Script from `/resources/ecs/defaults.txt` - run Script with DefaultsPanel and Presentation as DefaultsModule + rest get Script from `/resources/ecs/steps.txt` + run Script with StepsPanel and Presentation as StepsModule end return @@ -348,23 +328,31 @@ SetupContent: end return -SetupSteps: - if StepsModule is not running +SetupDefaults: + if DefaultsModule is not running begin - rest get Script from `/resources/ecs/steps.txt` - run Script with StepsPanel and Presentation as StepsModule + rest get Script from `/resources/ecs/defaults.txt` + run Script with DefaultsPanel and Presentation as DefaultsModule end return +SelectSection: + put the index of SectionButton into N + index SectionButton to Section + set style `background` of SectionButton to `` + put N into Section + index SectionButton to Section + set style `background` of SectionButton to `lightgray` + UpdateCurrentSection: - set style `display` of DefaultsPanel to `none` + set style `display` of StepsPanel to `none` set style `display` of BlocksPanel to `none` set style `display` of ContentPanel to `none` - set style `display` of StepsPanel to `none` + set style `display` of DefaultsPanel to `none` if Section is 0 begin - set style `display` of DefaultsPanel to `block` - send to DefaultsModule + set style `display` of StepsPanel to `block` + send to StepsModule end else if Section is 1 begin @@ -378,8 +366,8 @@ UpdateCurrentSection: end else if Section is 3 begin - set style `display` of StepsPanel to `block` - send to StepsModule + set style `display` of DefaultsPanel to `block` + send to DefaultsModule end return @@ -392,7 +380,7 @@ DoOpen: begin if confirm `Content has changed. Do you want to save it?` begin - if PasswordValid rest post Content to `_save/json~` cat Name + if PasswordValid rest post Content to `_save/json/` cat Name else put Content into storage as Name end end @@ -484,6 +472,7 @@ DoOpen: SelectFile: index File to the index of FileName set the content of NameEditor to File + put File into CurrentScriptName if PasswordValid rest get Presentation from `/resources/json/` cat File else get Presentation from storage as File put Presentation into Current diff --git a/mostrami/resources/ecs/scripted.txt b/mostrami/resources/ecs/scripted.txt index 297103b..8c82325 100644 --- a/mostrami/resources/ecs/scripted.txt +++ b/mostrami/resources/ecs/scripted.txt @@ -130,7 +130,7 @@ put the content of ContentEditor into Content if Content is not Current begin - rest post Content to `_save/resources/ecs/` cat Name + rest post Content to `_save/ecs/` cat Name put Content into Current set the content of Status to `Script '` cat Name cat `' saved` fork to ResetStatus @@ -156,7 +156,7 @@ if confirm `Are you sure you want to delete '` cat Name cat `'?` begin codemirror close ContentEditor - rest post to `_delete/resources/ecs/` cat Name + rest post to `_delete/ecs/` cat Name set the content of Status to `Script '` cat Name cat `' deleted` set the content of NameEditor to empty put empty into Content @@ -168,15 +168,21 @@ stop DoOpen: - if FileIsOpen codemirror close ContentEditor put the content of ContentEditor into Content if Content is not Current begin if confirm `Content has changed. Do you want to save it?` begin - rest post Content to `_save/resources/ecs/' cat CurrentName + rest post Content to `_save/ecs/' cat CurrentName end + else stop +! begin +! codemirror attach to ContentEditor +! codemirror set content of ContentEditor to Content +! stop +! end end + if FileIsOpen codemirror close ContentEditor ! Animate the background set style `display` of Overlay to `block` @@ -268,4 +274,4 @@ CloseBrowser: ResetStatus: wait 2 set the content of Status to `` - stop + stop \ No newline at end of file diff --git a/mostrami/resources/ecs/steps.txt b/mostrami/resources/ecs/steps.txt index c1a4126..28000b9 100644 --- a/mostrami/resources/ecs/steps.txt +++ b/mostrami/resources/ecs/steps.txt @@ -10,9 +10,9 @@ div BlockTable div BlockRow div BlockData + div Row + div Cell button Step - button Save - button Delete button Header button InsertBefore button InsertAfter @@ -32,6 +32,7 @@ input URLInput img PlusIcon img DeleteIcon + img DeleteStep a Link variable Steps variable SelectedStep @@ -53,6 +54,7 @@ variable TransitionType variable ContinueTypes variable TrueFalse + variable Array variable N variable B @@ -75,21 +77,34 @@ Start: set style `display` of Panel to `flex` set style `flex-direction` of Panel to `column` + if Presentation is empty gosub to CreateNewPresentation + clear EditPanel clear StepsPanel set the content of StepsTitle to `Steps` put property `steps` of Presentation into Steps set the elements of Step to the json count of Steps + set the elements of DeleteStep to the json count of Steps put 0 into N while N is less than the elements of Step begin index Step to N - dummy - create Step in StepsPanel - set the style of Step to `width:100%;font-size:1.2em;margin:0.2em 0` + create Row in StepsPanel + set the style of Row to `display:flex;margin:0.2em 0` + create Step in Row + set the style of Step to `flex:1;font-size:1.2em` put element N of Steps into Item gosub to CheckActionSyntax set the text of Step to property `comment` of Item + create Cell in Row + set the style of Cell to `width:2.2em;text-align:center` + if N is greater than 0 + begin + index DeleteStep to N + create DeleteStep in Cell + set the style of DeleteStep to `width:1.8em` + set attribute `src` of DeleteStep to `resources/icon/stop.png` + end add 1 to N end on click Step @@ -132,6 +147,24 @@ Start: stop +CreateNewPresentation: + set Presentation to object + set Item to object + set property `global` of Presentation to Item + set property `container` of Presentation to Item + set property `defaults` of Presentation to Item + set property `blocks` of Presentation to Item + set property `content` of Presentation to Item + set Item to object + set property `comment` of Item to `Wait for user input` + set property `action` of Item to `hold` + set property `duration` of Item to 0 + set property `label` of Item to `` + set Array to array + json add Item to Array + set property `steps` of Presentation to Array + return + ! Edit a single step EditStep: put property `blocks` of Presentation into Blocks @@ -201,29 +234,15 @@ ReloadStepEditor: create TD in TR create TD in TR create InsertBefore in TD - set the style of InsertBefore to `width:10%` - set the text of InsertBefore to `<+` + set the style of InsertBefore to `width:50%` + set the text of InsertBefore to `Add Step Before` on click InsertBefore begin alert `Insert Before` end - create Save in TD - set the style of Save to `width:40%` - set the text of Save to `Save` - on click Save - begin - alert `Save` - end - create Delete in TD - set the style of Delete to `width:40%` - set the text of Delete to `Delete` - on click Delete - begin - alert `Delete` - end create InsertAfter in TD - set the style of InsertAfter to `width:10%` - set the text of InsertAfter to `+>` + set the style of InsertAfter to `width:50%` + set the text of InsertAfter to `Add Step After` on click InsertAfter begin alert `Insert After` @@ -638,4 +657,4 @@ CheckActionSyntax: put property `url` of Item into URL if URL is empty set property `url` of Item to `******` end - return + return \ No newline at end of file diff --git a/mostrami/resources/json/demo.json b/mostrami/resources/json/demo.json index 5185eb7..7b098f5 100644 --- a/mostrami/resources/json/demo.json +++ b/mostrami/resources/json/demo.json @@ -102,14 +102,19 @@ }, "flowers": { "type": "image", - "url": "img/flowers.jpg" + "url": "resources/img/flowers.jpg" }, "moon": { "type": "image", - "url": "img/moon.jpg" + "url": "resources/img/moon.jpg" } }, "steps": [ + { + "comment": "-------------------------------- Load the test module", + "action": "load", + "url": "resources/plugins/test.js" + }, { "comment": "------------------------------- Pause before we start", "action": "pause", @@ -137,7 +142,9 @@ { "comment": "----------------------------- Fade up the intro title", "action": "fade up", - "blocks": "title", + "blocks": [ + "title" + ], "duration": 3 }, { @@ -167,9 +174,17 @@ { "comment": "-------------------------------- Show the first slide", "action": "fade up", - "blocks": "body", + "blocks": [ + "body" + ], "duration": 1 }, + { + "comment": "--------------------------------- Run the test plugin", + "action": "test", + "block": "title", + "duration": 0.5 + }, { "comment": "------------------------------------- Wait 10 seconds", "action": "hold", @@ -180,7 +195,8 @@ "action": "crossfade", "block": "body", "target": "slide 2", - "duration": 1 + "duration": 1, + "label": "loop" }, { "comment": "-------------------------------------- Wait 5 seconds", @@ -201,7 +217,9 @@ { "comment": "----------------------------- Fade up the image block", "action": "fade up", - "blocks": "left image", + "blocks": [ + "left image" + ], "duration": 2 }, { @@ -224,8 +242,12 @@ { "comment": "-------------------------------- Change the body text", "action": "set content", - "block": "body", - "content": "slide 3" + "blocks": [ + { + "block": "body", + "content": "slide 3" + } + ] }, { "comment": "------------------------------------- Wait 10 seconds", @@ -242,14 +264,10 @@ ], "duration": 3 }, - { - "comment": "----------------------------------------------- Reset", - "action": "reset" - }, { "comment": "-------------------------------- Go back to the start", "action": "goto", "target": "start" } ] -} +} \ No newline at end of file diff --git a/mostrami/resources/json/test.json b/mostrami/resources/json/test.json index eeff254..f713a09 100644 --- a/mostrami/resources/json/test.json +++ b/mostrami/resources/json/test.json @@ -1,273 +1 @@ -{ - "global": { - "title": "JSON::Presenter", - "description": "A demo presentation that outlines some features of JSON::Presenter", - "aspectW": 160, - "aspectH": 89 - }, - "container": { - "border": "1px solid black", - "background": "black" - }, - "defaults": { - "fontFamily": "Times New Roman,serif", - "fontSize": 40, - "fontWeight": "normal", - "fontStyle": "normal", - "fontColor": "white", - "textAlign": "left", - "textMarginLeft": 0, - "textMarginTop": 0, - "blockLeft": 0, - "blockTop": 0, - "blockWidth": 1000, - "blockBackground": "none", - "blockBorder": "none", - "blockBorderRadius": 0 - }, - "blocks": { - "title": { - "blockTop": 300, - "blockHeight": 300, - "textAlign": "center", - "fontSize": 200, - "fontWeight": "bold", - "fontColor": "#800000" - }, - "title 2": { - "blockTop": 50, - "blockHeight": 150, - "textAlign": "center", - "fontSize": 100, - "fontWeight": "bold", - "fontColor": "#dddd00" - }, - "body": { - "blockLeft": 80, - "blockTop": 240, - "blockWidth": 840, - "blockHeight": 800, - "fontFamily": "Helvetica,sans-serif", - "fontColor": "#dddddd" - }, - "body right": { - "blockLeft": 500, - "blockTop": 200, - "blockWidth": 420, - "blockHeight": 800, - "fontFamily": "Helvetica,sans-serif", - "fontColor": "#dddddd" - }, - "left image": { - "blockLeft": 80, - "blockTop": 200, - "blockWidth": 370, - "blockHeight": 700, - "blockBorder": "1px solid black", - "blockBorderRadius": "1em" - } - }, - "content": { - "presenter title": { - "type": "text", - "content": "JSON::Presenter" - }, - "slide 1": { - "type": "text", - "content": [ - "JSON::Presenter is a presentation format using JSON scripts, and an engine that runs those scripts in a browser to create presentations. These may be similar to those created using PowerPoint or they can be considerably more elaborate, with extensive animation and even sound. In some cases they can take the place of video yet still offer a dynamic experience.", - - "Presentations can run from any host, including static; all you need is one CDN-hosted JavaScript file and you're good to go.", - - "The JSON::Presenter engine is pure JavaScript. It can be used with any JavaScript framework, or with none." - ] - }, - "slide 2": { - "type": "text", - "content": [ - "JSON::Presenter offers a range of block types and transitions that make it easy to create slick, effective presentations.", - - "This short demo illustrates some of the features of the system." - ] - }, - "slide 3": { - "type": "text", - "content": [ - "Text and image blocks can be manipulated in a variety of different ways.", - - "Any block can be resized or moved; text can be substituted or have its size or color change; images can be assigned to blocks. Any block can be faded or transformed using animations.", - - "The JSON::Presenter scripting language uses simple data JSON structures and is easy to read or write." - ] - }, - "flowers": { - "type": "image", - "url": "resources/img/flowers.jpg" - }, - "moon": { - "type": "image", - "url": "resources/img/moon.jpg" - } - }, - "steps": [ - { - "comment": "-------------------------------- Load the test module", - "action": "load", - "url": "resources/plugins/test.js" - }, - { - "comment": "------------------------------- Pause before we start", - "action": "pause", - "duration": 2, - "label": "start" - }, - { - "comment": "---------------------------------- Set up the content", - "action": "set content", - "blocks": [ - { - "block": "title", - "content": "presenter title" - }, - { - "block": "body", - "content": "slide 1" - }, - { - "block": "left image", - "content": "flowers" - } - ] - }, - { - "comment": "----------------------------- Fade up the intro title", - "action": "fade up", - "blocks": [ - "title" - ], - "duration": 3 - }, - { - "comment": "-------------------------------------- Wait 4 seconds", - "action": "hold", - "duration": 4 - }, - { - "comment": "-------------------------------- Transition the title", - "action": "transition", - "type": [ - "block position", - "block size", - "font color", - "font size" - ], - "block": "title", - "target": "title 2", - "duration": 1, - "continue": true - }, - { - "comment": "----------------------------- Pause for half a second", - "action": "pause", - "duration": 0.5 - }, - { - "comment": "-------------------------------- Show the first slide", - "action": "fade up", - "blocks": [ - "body" - ], - "duration": 1 - }, - { - "comment": "--------------------------------- Run the test plugin", - "action": "test", - "block": "title", - "duration": 0.5 - }, - { - "comment": "------------------------------------- Wait 10 seconds", - "action": "hold", - "duration": 10 - }, - { - "comment": "-------------------------------- Change the body text", - "action": "crossfade", - "block": "body", - "target": "slide 2", - "duration": 1, - "label": "loop" - }, - { - "comment": "-------------------------------------- Wait 5 seconds", - "action": "hold", - "duration": 5 - }, - { - "comment": "-------------------------- Move the body to the right", - "action": "transition", - "type": [ - "block position", - "block size" - ], - "block": "body", - "target": "body right", - "duration": 1 - }, - { - "comment": "----------------------------- Fade up the image block", - "action": "fade up", - "blocks": [ - "left image" - ], - "duration": 2 - }, - { - "comment": "-------------------------------------- Wait 8 seconds", - "action": "hold", - "duration": 8 - }, - { - "comment": "--------------------------------- Crossfade the image", - "action": "crossfade", - "block": "left image", - "target": "moon", - "duration": 1 - }, - { - "comment": "-------------------------------------- Wait 2 seconds", - "action": "hold", - "duration": 2 - }, - { - "comment": "-------------------------------- Change the body text", - "action": "set content", - "blocks": [ - { - "block": "body", - "content": "slide 3" - } - ] - }, - { - "comment": "------------------------------------- Wait 10 seconds", - "action": "hold", - "duration": 10 - }, - { - "comment": "------------------------ Fade down the title and body", - "action": "fade down", - "blocks": [ - "title", - "body", - "left image" - ], - "duration": 3 - }, - { - "comment": "-------------------------------- Go back to the start", - "action": "goto", - "target": "start" - } - ] -} +{"global":{},"container":{},"defaults":{},"blocks":{},"content":{},"steps":[{"comment":"Wait for user input","action":"hold","duration":0,"label":""}]} \ No newline at end of file diff --git a/mostrami/rest.php b/mostrami/rest.php index 4c7abdb..4d5d87c 100644 --- a/mostrami/rest.php +++ b/mostrami/rest.php @@ -176,7 +176,7 @@ case '_save': // Save data to a file in the resources folder // Endpoint: {site root}/easycoder/rest.php/_save/{path} - $path = getcwd() . '/' . join('/', $request); + $path = getcwd() . '/resources/' . join('/', $request); $p = strrpos($path, '/'); $dir = substr($path, 0, $p); mkdir($dir, 0777, true); @@ -190,7 +190,7 @@ case '_delete': // Delete a file in the resources folder // Endpoint: {site root}/easycoder/rest.php/_delete/{path} - $path = getcwd() . '/' . join('/', $request); + $path = getcwd() . '/resources/' . join('/', $request); if (is_dir($path)) { rmdir($path); } else {