diff --git a/app/controllers/api/projects_controller.rb b/app/controllers/api/projects_controller.rb index 1ebb350f9..c11463d8e 100644 --- a/app/controllers/api/projects_controller.rb +++ b/app/controllers/api/projects_controller.rb @@ -5,9 +5,9 @@ module Api class ProjectsController < ApiController before_action :authorize_user, only: %i[create update index destroy] - before_action :load_project, only: %i[show update destroy show_context] + before_action :load_project, only: %i[show update destroy show_context], unless: -> { params[:id] == "blank-scratch-starter" } before_action :load_projects, only: %i[index] - load_and_authorize_resource + load_and_authorize_resource unless: -> { params[:id] == "blank-scratch-starter" } before_action :verify_lesson_belongs_to_school, only: :create after_action :pagination_link_header, only: %i[index] @@ -17,6 +17,9 @@ def index end def show + if params[:id] == "blank-scratch-starter" + render :scratch_starter, formats: [:json] and return + end if !@project.school_id.nil? && @project.lesson_id.nil? project_with_user = @project.with_user(current_user) @user = project_with_user[1] diff --git a/app/views/api/projects/scratch_starter.json.jbuilder b/app/views/api/projects/scratch_starter.json.jbuilder new file mode 100644 index 000000000..9a95f830c --- /dev/null +++ b/app/views/api/projects/scratch_starter.json.jbuilder @@ -0,0 +1,42 @@ +json.meta do + json.vm "11.5.0" + json.agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36" + json.semver "3.0.0" +end + +json.targets do + json.array! [ + { + name: "Stage", + lists: {}, + tempo: 60, + blocks: {}, + sounds: [], + volume: 100, + isStage: true, + comments: {}, + costumes: [ + { + name: "backdrop1", + md5ext: "cd21514d0531fdffb22204e0ec5ed84a.svg", + assetId: "cd21514d0531fdffb22204e0ec5ed84a", + dataFormat: "svg", + rotationCenterX: 240, + rotationCenterY: 180 + } + ], + variables: { + "`jEk@4|i[#Fk?(8x)AV.-my variable": ["my variable", 0] + }, + broadcasts: {}, + layerOrder: 0, + videoState: "on", + currentCostume: 0, + videoTransparency: 50, + textToSpeechLanguage: nil + } + ] +end + +json.monitors [] +json.extensions [] \ No newline at end of file