Skip to content

Commit cc22864

Browse files
committed
Merge branch 'main' into add-coderdojo-harima
2 parents d3f5978 + db185b4 commit cc22864

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+4065
-156
lines changed

.github/workflows/brakeman.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Brakeman Security Scan
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
jobs:
8+
brakeman:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Ruby
16+
uses: ruby/setup-ruby@v1
17+
with:
18+
ruby-version: .ruby-version
19+
bundler-cache: true
20+
21+
- name: Install dependencies
22+
run: bundle install --jobs 4 --retry 3
23+
24+
- name: Run Brakeman
25+
run: bundle exec brakeman --ignore-config config/brakeman.ignore --exit-on-warn --quiet

.github/workflows/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Auto-merge Dependabot PRs
2+
on:
3+
pull_request:
4+
# Allows you to run this workflow manually from the Actions tab
5+
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
dependabot:
14+
runs-on: ubuntu-latest
15+
if: github.actor == 'dependabot[bot]'
16+
steps:
17+
- uses: yasslab/dependabot_auto_merge@main
18+
with:
19+
github-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
# or operating system, you probably want to add a global ignore instead:
55
# git config --global core.excludesfile '~/.gitignore_global'
66

7-
# Ignore CLAUDE.md for now
7+
# Ignore Claude Code related files for security and privacy
88
CLAUDE.md
9+
.claude/
910

1011
# Ignore text file to write news article with internal API:
1112
# https://github.com/coderdojo-japan/coderdojo.jp/pull/1433

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,6 @@ group :development, :test do
7979
# NOTE: This enable GitHub Codespaces. Uncomment for YAGNI.
8080
# https://github.com/coderdojo-japan/coderdojo.jp/pull/1526
8181
#gem 'mini_racer'
82+
83+
gem 'brakeman', require: false
8284
end

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ GEM
109109
bootstrap-sass (3.4.1)
110110
autoprefixer-rails (>= 5.2.1)
111111
sassc (>= 2.0.0)
112+
brakeman (7.1.0)
113+
racc
112114
builder (3.3.0)
113115
capybara (3.40.0)
114116
addressable
@@ -489,6 +491,7 @@ DEPENDENCIES
489491
aws-sdk-s3 (~> 1)
490492
bootsnap
491493
bootstrap-sass
494+
brakeman
492495
capybara
493496
connpass_api_v2
494497
csv

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@ We use `SCRIVITO_TENANT` and `SCRIVITO_API_KEY` keys in production, but they are
207207

208208
## [:books:](#howto-develop-docs) 4. 他、開発に関する資料
209209

210-
開発に関する資料は [/docs](https://github.com/coderdojo-japan/coderdojo.jp/tree/main/docs) や下記サイトにまとめてあります (最新順)。必要に応じて適宜ご参照ください。
210+
開発に関する資料は [/doc](https://github.com/coderdojo-japan/coderdojo.jp/tree/main/doc) や下記サイトにまとめてあります (最新順)。必要に応じて適宜ご参照ください。
211211

212212
- [[EN] Inside Web Development of coderdojo.jp](https://www.youtube.com/watch?v=7WR2ulUJwvQ&list=PL94GDfaSQTmKxMzXVMzzdl-zCmzgitQFP&index=8) (English Talk on YouTube by [@nanophate](https://github.com/nanophate))
213213
- [DojoCast を Jekyll から Rails に移行しました](https://yasslab.jp/ja/posts/migrate-dojocast-from-jekyll-to-rails)
214-
- [新規 Dojo の追加方法 - GitHub](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/docs/how_to_add_dojo.md)
214+
- [新規 Dojo の追加方法 - GitHub](https://github.com/coderdojo-japan/coderdojo.jp/blob/main/doc/how_to_add_dojo.md)
215215
- [子どものためのプログラミング道場『CoderDojo』の Ruby/Rails 活用事例](https://speakerdeck.com/yasulab/case-study-of-how-coderdojo-japan-uses-ruby)
216216
- [CoderDojo を支える Rails CMS の活用事例 - Speaker Deck](https://speakerdeck.com/yasulab/case-study-rails-cms-for-coderdojo)
217217
- [2020年 coderdojo.jp 開発ふりかえり](https://note.com/yasslab/n/nb42fb058d4a0?magazine_key=m7ed183f728c3)

app/assets/stylesheets/custom.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,3 +1072,10 @@ section {
10721072
line-height: 1.7em;
10731073
color: #909090;
10741074
}
1075+
1076+
/* Stats and Dojos table styling */
1077+
.stats-table {
1078+
td.inactive-item {
1079+
background-color: gainsboro;
1080+
}
1081+
}

app/controllers/dojos_controller.rb

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,95 @@
11
class DojosController < ApplicationController
22

3-
# GET /dojos[.json]
3+
# GET /dojos[.html|.json|.csv]
44
def index
5+
# yearパラメータがある場合の処理
6+
if params[:year].present?
7+
begin
8+
year = params[:year].to_i
9+
# 有効な年の範囲をチェック
10+
unless year.between?(2012, Date.current.year)
11+
flash[:inline_alert] = "指定された年は無効です。2012年から#{Date.current.year}年の間で指定してください。"
12+
return redirect_to dojos_path(anchor: 'table')
13+
end
14+
15+
@selected_year = year
16+
year_end = Time.zone.local(@selected_year).end_of_year
17+
18+
# その年末時点でアクティブだった道場を取得
19+
dojos_scope = Dojo.active_at(year_end)
20+
@page_title = "#{@selected_year}年末時点のCoderDojo一覧"
21+
rescue ArgumentError
22+
flash[:inline_alert] = "無効な年が指定されました"
23+
return redirect_to dojos_path(anchor: 'table')
24+
end
25+
else
26+
# yearパラメータなしの場合(既存の実装そのまま)
27+
dojos_scope = Dojo.all
28+
end
29+
530
@dojos = []
6-
Dojo.includes(:prefecture).order(order: :asc).all.each do |dojo|
31+
dojos_scope.includes(:prefecture).order(is_active: :desc, order: :asc).each do |dojo|
32+
# 年が選択されている場合は、その年末時点でのアクティブ状態を判定
33+
# 選択されていない場合は、現在の is_active を使用
34+
is_active_at_selected_time = if @selected_year
35+
# その年末時点でアクティブだったかを判定
36+
# inactivated_at が nil(まだアクティブ)または選択年より後に非アクティブ化
37+
dojo.inactivated_at.nil? || dojo.inactivated_at > Time.zone.local(@selected_year).end_of_year
38+
else
39+
dojo.is_active
40+
end
41+
742
@dojos << {
843
id: dojo.id,
944
url: dojo.url,
1045
name: dojo.name,
1146
logo: root_url + dojo.logo[1..],
1247
order: dojo.order,
1348
counter: dojo.counter,
14-
is_active: dojo.is_active,
49+
is_active: is_active_at_selected_time,
1550
prefecture: dojo.prefecture.name,
1651
created_at: dojo.created_at,
1752
description: dojo.description,
53+
inactivated_at: dojo.inactivated_at, # CSV用に追加
1854
}
1955
end
56+
57+
# counter合計を計算(/statsとの照合用)
58+
@counter_sum = @dojos.sum { |d| d[:counter] }
59+
60+
# 情報メッセージを設定
61+
if @selected_year
62+
# /statsページと同じ計算方法を使用
63+
# 開設数 = その年に新規開設されたDojoのcounter合計
64+
year_begin = Time.zone.local(@selected_year).beginning_of_year
65+
year_end = Time.zone.local(@selected_year).end_of_year
66+
new_dojos_count = Dojo.where(created_at: year_begin..year_end).sum(:counter)
67+
68+
# 合計数 = その年末時点でアクティブだったDojoのcounter合計
69+
total_dojos_count = Dojo.active_at(year_end).sum(:counter)
70+
71+
# 表示用の日付テキスト
72+
display_date = "#{@selected_year}年末"
73+
display_date = Date.current.strftime('%Y年%-m月%-d日') if @selected_year == Date.current.year
74+
75+
flash.now[:inline_info] = "#{display_date}時点のアクティブな道場を表示中<br>(開設数: #{new_dojos_count} / 合計数: #{total_dojos_count})".html_safe
76+
else
77+
# 全期間表示時の情報メッセージ
78+
flash.now[:inline_info] = "全期間の道場を表示中(非アクティブ含む)"
79+
end
2080

2181
respond_to do |format|
22-
# No corresponding View for now.
23-
# Only for API: GET /dojos.json
24-
format.html # => app/views/dojos/index.html.erb
82+
format.html { render :index } # => app/views/dojos/index.html.erb
2583
format.json { render json: @dojos }
84+
format.csv do
85+
# ファイル名を年に応じて設定
86+
filename = if @selected_year
87+
"dojos_#{@selected_year}.csv"
88+
else
89+
"dojos_all.csv"
90+
end
91+
send_data render_to_string, type: :csv, filename: filename
92+
end
2693
end
2794
end
2895

app/controllers/sotechsha2_pages_controller.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/controllers/sotechsha_pages_controller.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)