Skip to content

Commit

Permalink
IMG compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Clementine2722 committed Mar 2, 2024
1 parent f09f136 commit af58f25
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/10_just_one_try.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h1>Plan beforehand</h1>

<h2>Scenario</h2>

<p><img src="../IMGS/8.png" alt="Image" /></p>
<p><img src="IMGS/8.png" alt="Image" /></p>

<h2>Interaction</h2>

Expand Down
2 changes: 1 addition & 1 deletion docs/13_missing_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h1>What's this?</h1>

<h2>Scenario</h2>

<p><img src="../IMGS/6.png" alt="Image" /><br />
<p><img src="IMGS/6.png" alt="Image" /><br />

( random logical gate in between )</p>

Expand Down
2 changes: 1 addition & 1 deletion docs/8_more_acts!.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h1>Now one act isn't enough</h1>

<h2>Scenario</h2>

<p><img src="../IMGS/3.png" alt="Image" /></p>
<p><img src="IMGS/3.png" alt="Image" /></p>

<h2>Interaction</h2>

Expand Down
Binary file added docs/IMGS/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/IMGS/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 39 additions & 6 deletions frontend/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from jinja2 import Environment, FileSystemLoader
from mistune import markdown
from bleach import clean
from os import listdir, remove

from os import listdir, remove, makedirs, rmdir
from os import path as os_path
from shutil import copy

def metadata_extractor_AST(AST_file):
for i, file_line in enumerate(AST_file):
Expand All @@ -24,9 +25,15 @@ def metadata_extractor_HTML(AST_file, HTML_file):
return (data, metadata)
return False


for filename in listdir("docs"):
remove("docs/" + filename)
file_names = listdir("docs")
for file_name in file_names:
if file_name != "IMGS":
remove("docs/" + file_name)
else:
img_file_names = listdir("docs/IMGS")
for img_file in img_file_names:
remove("docs/IMGS/" + img_file)
rmdir("docs/IMGS")

with open(f'docs/CNAME', 'w') as file:
file.write("colab.agi-now.com")
Expand Down Expand Up @@ -177,6 +184,18 @@ def metadata_extractor_HTML(AST_file, HTML_file):
if line["type"] == "heading":
problem[0]["title"] = line["children"][0]["raw"]


# Fixing source of Images for the HTML
def replace_img_source(data):
if isinstance(data, list):
return [replace_img_source(item) for item in data]
elif isinstance(data, str):
return data.replace("../", "")
else:
return data

scenarios_data = replace_img_source(scenarios_data)

# We'll make all scenarios.html
for i, scenario in enumerate(scenarios): # For each scenario...
Automator = []
Expand Down Expand Up @@ -221,4 +240,18 @@ def metadata_extractor_HTML(AST_file, HTML_file):
output = template.render(scenarios=list_of_scenarios)

with open(f'docs/index.html', 'w') as file:
file.write(output) # Render the filled template
file.write(output) # Render the filled template


# All of this copies the IMGS folder to the docs folder
# Could be upgraded to just use mentioned IMGS, not all of them
source_dir = path + "/IMGS"
destination_dir = "docs/IMGS"

makedirs(destination_dir)
files = listdir(source_dir)

for file in files:
source_file = os_path.join(source_dir, file)
destination_file = os_path.join(destination_dir, file)
copy(source_file, destination_file)
13 changes: 13 additions & 0 deletions frontend/tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def replace_img_sources(data):
if isinstance(data, list):
return [replace_img_sources(item) for item in data]
elif isinstance(data, str):
return data.replace("../", "")
else:
return data

# Your nested list
nested_list = [[{'problems': [2, 4]}, ['<hr />', '<h1>Plan beforehand</h1>', '<h2>Scenario</h2>', '<p><img src="../IMGS/8.png" alt="Image" /></p>', '<h2>Interaction</h2>', '<p><em>User</em>: Turn the LED on, you can only do 2 actions<br />', '<em>Agent</em>: ( flicks switch ), ( presses button )</p>', '<p>::: In here we discourage the agent from experimenting and accomplishing the goal thanks to probability, it has to reason all actions before carrying them out</p>', '']], [{'problems': [3]}, ['<hr />', "<h1>What's this?</h1>", '<h2>Scenario</h2>', '<p><img src="../IMGS/6.png" alt="Image" /><br />', '( random logical gate in between )</p>', '<h2>Interaction</h2>', '<p><em>User</em>: Understand the blank component<br />', '<em>Agent</em>: ( Goes on experimental loop to find out behaviour of component )</p>', '']], [{'problems': [1]}, ['<hr />', '<h1>Is the LED on?</h1>', '<h2>Scenario</h2>', '<p>one turned on LED</p>', '<h2>Interaction</h2>', '<p><em>User</em>: Is the led on?<br />', '<em>Agent</em>: &amp;lt; Some positive answer &amp;gt;</p>', '']], [{'problems': [2]}, ['<hr />', "<h1>Now one act isn't enough</h1>", '<h2>Scenario</h2>', '<p><img src="../IMGS/3.png" alt="Image" /></p>', '<h2>Interaction</h2>', '<p><em>User</em>: Turn the LED on<br />', '<em>Agent</em>: ( flickes 1st switch), ( flickes 2nd switch )</p>', '<p>::: Think about act sequentiation, may not need time understanding</p>', '']]]

new_nested_list = replace_img_sources(nested_list)
print(new_nested_list)

0 comments on commit af58f25

Please sign in to comment.