From 4480c5a3c270e52fe236e17e1bbcebc175cdb9ef Mon Sep 17 00:00:00 2001 From: Yohei Yasukawa Date: Sat, 5 Apr 2025 17:49:53 +0900 Subject: [PATCH] =?UTF-8?q?Dojo=20=E7=B5=B1=E8=A8=88=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E3=81=AE=E4=B8=80=E8=A6=A7=E3=83=9A=E3=83=BC=E3=82=B8=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=81=97=E3=80=81=E5=80=8B=E5=88=A5=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=A8=E3=81=AE=E5=B0=8E=E7=B7=9A=E3=82=82?= =?UTF-8?q?=E8=A8=AD=E7=BD=AE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/dojos_controller.rb | 10 +-- app/helpers/application_helper.rb | 5 -- app/views/dojos/index.html.erb | 106 ++++++++++++++++++++++++++++ app/views/dojos/show.html.erb | 5 ++ 4 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 app/views/dojos/index.html.erb diff --git a/app/controllers/dojos_controller.rb b/app/controllers/dojos_controller.rb index 91730216e..8bba99c75 100644 --- a/app/controllers/dojos_controller.rb +++ b/app/controllers/dojos_controller.rb @@ -2,13 +2,13 @@ class DojosController < ApplicationController # GET /dojos[.json] def index - @dojo_data = [] + @dojos = [] Dojo.order(order: :asc).all.each do |dojo| - @dojo_data << { + @dojos << { id: dojo.id, url: dojo.url, name: dojo.name, - logo: "https://coderdojo.jp#{dojo.logo}", + logo: root_url + dojo.logo[1..], order: dojo.order, counter: dojo.counter, is_active: dojo.is_active, @@ -21,8 +21,8 @@ def index respond_to do |format| # No corresponding View for now. # Only for API: GET /dojos.json - format.html { redirect_to root_url(anchor: 'dojos') } - format.json { render json: @dojo_data } + format.html # => app/views/dojos/index.html.erb + format.json { render json: @dojos } end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ab89f20c1..d3b540fde 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -78,11 +78,6 @@ def lazy_image_tag(source, options={}) end end - # NOTE: Delete this helper to avoid overriding when /dojos routing is added. - def dojos_path(options={anchor: 'dojos'}) - root_path(options) - end - def welcome_path(options={anchor: 'welcome'}) root_path(options) end diff --git a/app/views/dojos/index.html.erb b/app/views/dojos/index.html.erb new file mode 100644 index 000000000..3638ed17e --- /dev/null +++ b/app/views/dojos/index.html.erb @@ -0,0 +1,106 @@ +<% provide :title, "CoderDojo 一覧 - 統計情報" %> +<% provide :desc, "CoderDojo の公開されている統計情報をまとめたページです。" %> +<% provide :url, dojos_url %> +<% provide :meta_image, asset_path('stats_cover.png') %> + +
+ <%= lazy_image_tag "stats_cover.png", alt: "Cover Photo" %> +
+ +
+
+

☯️ + CoderDojo 一覧 - 統計情報
(公開情報のみ掲載) +

+
+

+ CoderDojo の公開されている統計情報をまとめたページです。 +
+

+
    +
  • <%= link_to '近日開催', events_path %>は含まず、<%= link_to '過去開催', stats_path %>のデータを使っています
  • +
  • 現在は活動停止中 (Inactive) の道場も含まれています
  • +
  • 下記表は <%= link_to dojos_path(format: :json), dojos_path(format: :json) %> で JSON に変換できます
  • +
+
+

+ + + +
+ + + + + + + <% @dojos.each do |dojo| %> + + + + + + <% end %> +
+ + ☯️ +
+ Dojo 名 / ID +
+
+ + 🗓 +
+ 掲載日 +
+
+ + 📝 +
+ URL +
+
+ + <%= link_to dojo_path(dojo[:id]) do %> + <%= dojo[:name] %>
+ (ID: <%= dojo[:id] %>) + <% end %> +
+
+ <%= dojo[:created_at].strftime("%F") %> + + + + + <%= CGI.unescape dojo[:url].gsub('https://', '').gsub('http://', '').gsub('www.', '').chomp('/') %> + + + +
+ +
↑ 上に戻る
+

+

+	本ページにある統計情報は、現在 Doorkeeperconnpass にのみ対応しています。
+

+
+
diff --git a/app/views/dojos/show.html.erb b/app/views/dojos/show.html.erb index 089463ee1..732e25f19 100644 --- a/app/views/dojos/show.html.erb +++ b/app/views/dojos/show.html.erb @@ -25,6 +25,7 @@ <% end %> + <%= link_to raw("» 他の Dojo 一覧を見る"), dojos_path %>