Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stretch3 の申請フォームを登録して ChatGPT2Scratch を利用できるように #1664

Merged
merged 2 commits into from
Mar 16, 2025
Merged
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
17 changes: 17 additions & 0 deletions app/assets/stylesheets/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
21 changes: 21 additions & 0 deletions app/controllers/stretch3s_controller.rb
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions app/models/stretch3.rb
Original file line number Diff line number Diff line change
@@ -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
74 changes: 74 additions & 0 deletions app/views/stretch3s/new.html.haml
Original file line number Diff line number Diff line change
@@ -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: '例: [email protected]'
.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
\ から自由に入手できます。
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions db/migrate/20250315124619_create_stretch3s.rb
Original file line number Diff line number Diff line change
@@ -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
11 changes: 10 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Binary file added public/img/stretch3_openai.webp
Binary file not shown.