diff --git a/app/assets/stylesheets/custom.scss b/app/assets/stylesheets/custom.scss index 56342d708..f97900d26 100644 --- a/app/assets/stylesheets/custom.scss +++ b/app/assets/stylesheets/custom.scss @@ -1055,3 +1055,20 @@ section { line-height: 1.7em; color: #909090; } + +.stretch3-notes { + margin-top: 100px; + font-size: 11.8px; + line-height: 1.7em; + color: #909090; +} + +.stretch3-eyecatch-container { + height: 35rem; + margin-bottom: 50px; +} + +.stretch3-eyecatch { + border-radius: 10px; + object-fit: cover; +} diff --git a/app/controllers/stretch3s_controller.rb b/app/controllers/stretch3s_controller.rb new file mode 100644 index 000000000..84babde4f --- /dev/null +++ b/app/controllers/stretch3s_controller.rb @@ -0,0 +1,21 @@ +class Stretch3sController < ApplicationController + def new + @stretch3 = Stretch3.new + end + + def create + @stretch3 = Stretch3.new(stretch3_params) + if @stretch3.save + # NOTE: coderdojo.jp ドメインから遷移すると Stretch3 側で ChatGPT2Scratch の API キーが不要になる処理が走る + redirect_to 'https://stretch3.github.io', allow_other_host: true + else + render :new + end + end + + private + + def stretch3_params + params.require(:stretch3).except(:term_of_use).permit(:email, :parent_name, :participant_name, :dojo_name) + end +end diff --git a/app/models/stretch3.rb b/app/models/stretch3.rb new file mode 100644 index 000000000..f67a1901e --- /dev/null +++ b/app/models/stretch3.rb @@ -0,0 +1,6 @@ +class Stretch3 < ApplicationRecord + validates :email, presence: true + validates :parent_name, presence: true + validates :participant_name, presence: true + validates :dojo_name, presence: true +end diff --git a/app/views/stretch3s/new.html.haml b/app/views/stretch3s/new.html.haml new file mode 100644 index 000000000..30110f520 --- /dev/null +++ b/app/views/stretch3s/new.html.haml @@ -0,0 +1,74 @@ +- provide(:title, 'Stretch3 x OpenAI Azure for Non-profit プログラム申請') +- provide(:desc, 'Stretch3 から OpenAI の API を呼び出せる拡張機能 ChatGPT2Scratch を API キー不要で利用するための申請フォームです。') +- provide(:url, '/stretch3') +- provide(:meta_image, '/img/stretch3_openai.webp') + +.container + %section.introduction{style: "padding: 50px 0px;"} + %div.text-center + %h1{style: "line-height: 1.4em;"} + Stretch3 x OpenAI + %br + Azure for Non-profit プログラム申請 + .stretch3-eyecatch-container + = lazy_image_tag '/img/stretch3_openai.webp', + alt: 'ポケモン・ワークショップのカバー画像', + min: true, + class: 'stretch3-eyecatch', + style: 'box-shadow: 0 2.5rem 2rem -2rem hsl(200 50% 20% / 40%);' + %p + Stretch3 は自作の拡張機能を使えるように改造した Scratch です。 + %p + この申請フォームは OpenAI の Chat API を呼び出す拡張機能 ChatGPT2Scratch を + %br + API キー不要で利用出来るようにするための申請フォームです。 + %br + これにより本来有料の Chat API を無料で利用できます。 + %p + 利用規約は、 + %b<> 保護者の方が参加者と一緒に + ご確認いただくようお願い致します。 + + = form_with model: @stretch3, url: stretch3_path, class: 'form' do |f| + .field + = f.label :email, "メールアドレス" + = f.email_field :email, required: true, autocomplete: "email", class: "form__field", placeholder: '例: example@gmail.com' + .field + = f.label :parent_name, "保護者の名前" + = f.text_field :parent_name, required: true, autocomplete: "name", class: "form__field", placeholder: '例: 幸田 道場' + .field + = f.label :participant_name, "参加者の名前" + = f.text_field :participant_name, required: true, autocomplete: "name", class: "form__field", placeholder: '例: 幸田 道子' + .field + = f.label :dojo_name, "道場名" + = f.text_field :dojo_name, required: true, class: "form__field", placeholder: '例: CoderDojo 柏' + .form__terms + %h2.form__h2 利用規約 + %ul + %li + %small + = link_to 'https://learn.microsoft.com/ja-jp/azure/ai-services/responsible-use-of-ai-overview', target: '_blank' do + Azure AI サービスにおける AI の責任ある使用 + に従うことy + %li + %small + %b<> 事前に保護者から同意を得ること + %br + (参考: #{link_to '文部科学省 - 生成AIの利活用に関するガイドライン','https://www.mext.go.jp/a_menu/other/mext_02412.html', target: '_blank'}) + %li + %small CoderDojo 以外の用途で使う場合は、一般社団法人 CoderDojo Japan からの書面による許諾を事前に得るようお願いします。 + %p + %small + ※ 本サービスは Azure AI の利用上限に達した場合、または上記事項への違反で使用できなくなった場合などの理由により、予告なく無効化される場合もあります。あらかじめご了承いただけると幸いです。 + .field.text-center + = f.check_box :term_of_use, required: true + = f.label :term_of_use, "上記の利用規約に同意する", style: "display:inline" + + = f.submit "申し込んで利用開始する", class: "form__submit" + .text-center + %small 送信後、Stretch3 のページへ移動します。 + + %p.stretch3-notes + Scratchは、Scratch財団がMITメディアラボのライフロング・キンダーガーテン・グループの協力により開発しているプロジェクトです。 + %a{href: "https://scratch.mit.edu", rel: "noopener", target: "_blank"}<> scratch.mit.edu + \ から自由に入手できます。 diff --git a/config/routes.rb b/config/routes.rb index 0160dcc0a..118856d59 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -69,6 +69,8 @@ get "/podcast", to: redirect('/podcasts') get "/podcasts/feed" => "podcasts#feed" get "/stats" => "stats#show" + get "/stretch3" => "stretch3s#new" + post "/stretch3" => "stretch3s#create" get "/pokemon" => "pokemons#new" #post "/pokemon" => "pokemons#create" #get "/pokemon/download" => "pokemons#show" diff --git a/db/migrate/20250315124619_create_stretch3s.rb b/db/migrate/20250315124619_create_stretch3s.rb new file mode 100644 index 000000000..d27bc8e25 --- /dev/null +++ b/db/migrate/20250315124619_create_stretch3s.rb @@ -0,0 +1,12 @@ +class CreateStretch3s < ActiveRecord::Migration[7.0] + def change + create_table :stretch3s do |t| + t.string :email, null: false + t.string :parent_name, null: false + t.string :participant_name, null: false + t.string :dojo_name, null: false + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index efd76ca78..c21a54294 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_06_18_025325) do +ActiveRecord::Schema[7.0].define(version: 2025_03_15_124619) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" @@ -91,6 +91,15 @@ t.index ["region"], name: "index_prefectures_on_region" end + create_table "stretch3s", force: :cascade do |t| + t.string "email", null: false + t.string "parent_name", null: false + t.string "participant_name", null: false + t.string "dojo_name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "upcoming_events", force: :cascade do |t| t.integer "dojo_event_service_id", null: false t.string "event_id", null: false diff --git a/public/img/stretch3_openai.webp b/public/img/stretch3_openai.webp new file mode 100644 index 000000000..aa8b89d30 Binary files /dev/null and b/public/img/stretch3_openai.webp differ