Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ settings/*.json
settings/*.yaml

frontend/node_modules/
frontend-solid/node_modules/
static/libs/blockpy_server_solid/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
41 changes: 40 additions & 1 deletion controllers/endpoints/blockpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,38 @@ def load():
return load_editor(editor_information)


@blueprint_blockpy.route('/load2', methods=['GET', 'POST'])
@blueprint_blockpy.route('/load2/', methods=['GET', 'POST'])
def load2():
"""
Load the new SolidJS editor (editor2.html) explicitly.
This route forces use_solid=True regardless of query parameters.
"""
editor_information = parse_assignment_load()
# Force the use of SolidJS editor
return load_editor_solid(editor_information)


def load_editor_solid(editor_information):
"""
Render the SolidJS editor specifically.
This is a helper function for the /load2 route.
:param editor_information:
:return:
"""
by_type = {name: [] for name in ASSIGNMENT_TYPES}
for assignment in editor_information.get('assignments', []):
for name, types in ASSIGNMENT_TYPES.items():
if assignment.type in types:
by_type[name].append(assignment.id)
break

response = make_response(render_template('blockpy/editor2.html', ip=request.remote_addr,
**by_type,
**editor_information))
return response


ASSIGNMENT_TYPES = {
'quiz_questions': ('quiz', ),
'readings': ('reading', ),
Expand All @@ -143,13 +175,20 @@ def load_editor(editor_information):
:param editor_information:
:return:
"""
# Check if we should use the new SolidJS editor
use_solid_editor = safe_request.get_maybe_bool('use_solid', False) or safe_request.get_maybe_bool('editor2', False)

by_type = {name: [] for name in ASSIGNMENT_TYPES}
for assignment in editor_information.get('assignments', []):
for name, types in ASSIGNMENT_TYPES.items():
if assignment.type in types:
by_type[name].append(assignment.id)
break
response = make_response(render_template('blockpy/editor.html', ip=request.remote_addr,

# Choose template based on parameter
template_name = 'blockpy/editor2.html' if use_solid_editor else 'blockpy/editor.html'

response = make_response(render_template(template_name, ip=request.remote_addr,
**by_type,
**editor_information))
return response
Expand Down
21 changes: 21 additions & 0 deletions frontend-solid/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Dependencies
node_modules/

# Build output
dist/

# IDE
.vscode/
.idea/

# OS
.DS_Store
Thumbs.db

# Logs
*.log

# Environment variables
.env
.env.local
.env.*.local
Loading