From 434bab502d55a8ba64999848c844da398256e4dd Mon Sep 17 00:00:00 2001 From: loiswells97 Date: Fri, 7 Jan 2022 15:33:53 +0000 Subject: [PATCH 1/3] Create draft PR for #1 From 61d49d2eb7e4766b7e674612d745934d9bb087d1 Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Fri, 7 Jan 2022 15:36:42 +0000 Subject: [PATCH 2/3] Added rake task adding initial python starter project --- lib/tasks/projects.rake | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 lib/tasks/projects.rake diff --git a/lib/tasks/projects.rake b/lib/tasks/projects.rake new file mode 100644 index 000000000..369b00e8e --- /dev/null +++ b/lib/tasks/projects.rake @@ -0,0 +1,87 @@ +namespace :projects do + desc "Import starter projects" + task create_starter: :environment do + + Project.find_by(identifier: "python-hello-starter")&.destroy + project = Project.new(identifier: "python-hello-starter") + project.components << Component.new(name: "main", extension: "py", content: main_content) + project.components << Component.new(name: "emoji", extension: "py", content: emoji_content) + project.components << Component.new(name: "noemoji", extension: "py", content: no_emoji_content) + project.save + end +end + +def main_content + main_content = <<-END +#!/bin/python3 + +from emoji import * +from datetime import * +from random import randint + +# Put function definitions under here + +# Useful characters :',()*_/.# + +# Put code to run under here + +print('Hello ', world) + END +end + +def emoji_content + emoji_content = <<-END +# Emoji variables to use in your project + +world = '🌍🌎🌏' +python = '🐍⌨️' +sums = '✖️➗➖➕' +calendar = '📅' +clock = '🕒' +projects = '🎨🎮🔬' +fun = '🎉🕶️' +dice = '🎲' +unicorn = '🦄' +space = '🚀' +happy = '😃' +silly = '😜' +heart = '❤️' +games = '🎮' +books = '📚' +sports = '⚽🎾👟' +green = '♻️' +nature = '🌳' +fire = '🔥' +sparkles = '✨' +plead = '🥺' +hundred = '💯' +star = '⭐' +yellow_heart = '💛' +rainbow = '🌈' + END +end + +def no_emoji_content + no_emoji_content = <<-END +# Add ASCII art alternatives +# Before emoji we used emoticons made from characters + +world = 'o' +python = '~~~-<' +happy = ':-)' +heart = '♡' # or '<3' +star = '☆' +sparkles = '✺' +silly = ';)' +sums = '+-*/' +hundred = '100!' +plead = '◔◔' +fire = '/\\' +books = '≣' +rainbow = '⌒' +dice = '⊡' +clock = '◷' +calendar = '▦' + + END +end From 2fcc25c74808f072ed4b94810e45ef02d64c703c Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Fri, 7 Jan 2022 16:56:35 +0000 Subject: [PATCH 3/3] Adding project name and returning it in the API so it can be displayed on the page --- app/views/api/projects/show.json.jbuilder | 2 +- lib/tasks/projects.rake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/api/projects/show.json.jbuilder b/app/views/api/projects/show.json.jbuilder index 84f02d921..85b6fceb7 100644 --- a/app/views/api/projects/show.json.jbuilder +++ b/app/views/api/projects/show.json.jbuilder @@ -1,3 +1,3 @@ -json.(@project, :identifier, :project_type) +json.(@project, :identifier, :project_type, :name) json.components @project.components, :id, :name, :extension, :content diff --git a/lib/tasks/projects.rake b/lib/tasks/projects.rake index 369b00e8e..4fc78988e 100644 --- a/lib/tasks/projects.rake +++ b/lib/tasks/projects.rake @@ -3,7 +3,7 @@ namespace :projects do task create_starter: :environment do Project.find_by(identifier: "python-hello-starter")&.destroy - project = Project.new(identifier: "python-hello-starter") + project = Project.new(identifier: "python-hello-starter", name: "Hello World!") project.components << Component.new(name: "main", extension: "py", content: main_content) project.components << Component.new(name: "emoji", extension: "py", content: emoji_content) project.components << Component.new(name: "noemoji", extension: "py", content: no_emoji_content)