Skip to content

Commit 4480c5a

Browse files
committed
Dojo 統計情報の一覧ページを作成し、個別ページとの導線も設置した
1 parent 83c2f23 commit 4480c5a

File tree

4 files changed

+116
-10
lines changed

4 files changed

+116
-10
lines changed

app/controllers/dojos_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ class DojosController < ApplicationController
22

33
# GET /dojos[.json]
44
def index
5-
@dojo_data = []
5+
@dojos = []
66
Dojo.order(order: :asc).all.each do |dojo|
7-
@dojo_data << {
7+
@dojos << {
88
id: dojo.id,
99
url: dojo.url,
1010
name: dojo.name,
11-
logo: "https://coderdojo.jp#{dojo.logo}",
11+
logo: root_url + dojo.logo[1..],
1212
order: dojo.order,
1313
counter: dojo.counter,
1414
is_active: dojo.is_active,
@@ -21,8 +21,8 @@ def index
2121
respond_to do |format|
2222
# No corresponding View for now.
2323
# Only for API: GET /dojos.json
24-
format.html { redirect_to root_url(anchor: 'dojos') }
25-
format.json { render json: @dojo_data }
24+
format.html # => app/views/dojos/index.html.erb
25+
format.json { render json: @dojos }
2626
end
2727
end
2828

app/helpers/application_helper.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ def lazy_image_tag(source, options={})
7878
end
7979
end
8080

81-
# NOTE: Delete this helper to avoid overriding when /dojos routing is added.
82-
def dojos_path(options={anchor: 'dojos'})
83-
root_path(options)
84-
end
85-
8681
def welcome_path(options={anchor: 'welcome'})
8782
root_path(options)
8883
end

app/views/dojos/index.html.erb

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<% provide :title, "CoderDojo 一覧 - 統計情報" %>
2+
<% provide :desc, "CoderDojo の公開されている統計情報をまとめたページです。" %>
3+
<% provide :url, dojos_url %>
4+
<% provide :meta_image, asset_path('stats_cover.png') %>
5+
6+
<section id='top' class='cover' style='background-color: white; max-width: 400px; margin: 0 auto;'>
7+
<%= lazy_image_tag "stats_cover.png", alt: "Cover Photo" %>
8+
</section>
9+
10+
<section id="index" class="text-center" style="margin-bottom: 100px;">
11+
<br>
12+
<h1>☯️
13+
CoderDojo 一覧 - 統計情報<br><small>(公開情報のみ掲載)</small>
14+
</h1>
15+
<br>
16+
<p style="margin: 0 0px 40px 10px; line-height: 1.5em;">
17+
CoderDojo の公開されている統計情報をまとめたページです。
18+
<br>
19+
<div class='form__terms list'>
20+
<ul style='list-style-type: "\2713\0020"; font-size: smaller;'>
21+
<li><%= link_to '近日開催', events_path %>は含まず、<%= link_to '過去開催', stats_path %>のデータを使っています</li>
22+
<li>現在は活動停止中 (Inactive) の道場も含まれています</li>
23+
<li>下記表は <code><%= link_to dojos_path(format: :json), dojos_path(format: :json) %></code> で JSON に変換できます</li>
24+
</ul>
25+
</div>
26+
</p>
27+
28+
<style type="text/css">
29+
/* URL 用のセルにクラスを付けておく想定 */
30+
table { table-layout: auto; }
31+
td {
32+
padding: 1px 10px 1px 10px;
33+
text-align: right;
34+
font-size: smaller;
35+
}
36+
td.url-cell {
37+
white-space: normal; /* 改行を許可 */
38+
word-wrap: break-word; /* 古めのブラウザ向け */
39+
overflow-wrap: break-word; /* 新しめのブラウザ向け */
40+
word-break: break-all; /* 英数字が続く場合の保険 (必要に応じて) */
41+
text-align: left;
42+
}
43+
th {
44+
padding: 10px;
45+
text-align: center;
46+
}
47+
</style>
48+
49+
<div style="margin-top: 20px;" align="center">
50+
<table border="1">
51+
<tr>
52+
<th>
53+
<small>
54+
☯️
55+
<br class='ignore-pc'>
56+
Dojo 名 / ID
57+
</small>
58+
</th>
59+
<th>
60+
<small>
61+
🗓
62+
<br class='ignore-pc'>
63+
<a href='/signup'>掲載日</a>
64+
</small>
65+
</th>
66+
<th>
67+
<small>
68+
📝
69+
<br class='ignore-pc'>
70+
URL
71+
</small>
72+
</th>
73+
</tr>
74+
<% @dojos.each do |dojo| %>
75+
<tr>
76+
<td>
77+
<small>
78+
<%= link_to dojo_path(dojo[:id]) do %>
79+
<%= dojo[:name] %><br>
80+
<small>(ID: <%= dojo[:id] %>)</small>
81+
<% end %>
82+
</small>
83+
</td>
84+
<td>
85+
<small><%= dojo[:created_at].strftime("%F") %></small>
86+
</td>
87+
<td class="url-cell">
88+
<small>
89+
<a href='<%= dojo[:url] %>'>
90+
<span title="<%= dojo[:url] %>">
91+
<%= CGI.unescape dojo[:url].gsub('https://', '').gsub('http://', '').gsub('www.', '').chomp('/') %>
92+
</span>
93+
</a>
94+
</small>
95+
</td>
96+
</tr>
97+
<% end %>
98+
</table>
99+
100+
<div style='margin-top: 60px;'><a href='#top'>&uarr; 上に戻る</a></div>
101+
<p>
102+
<pre style='white-space: pre-wrap; margin-top: 60px; margin-bottom: 30px; color: #505050;'>
103+
本ページにある統計情報は、現在 <a href='https://doorkeeper.jp/'>Doorkeeper</a><a href='http://connpass.com/'>connpass</a> にのみ対応しています。</pre>
104+
</p>
105+
</div>
106+
</section>

app/views/dojos/show.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
</ul>
2626
</div>
2727
<% end %>
28+
<small><%= link_to raw("&raquo; 他の Dojo 一覧を見る"), dojos_path %></small>
2829
</p>
2930

3031
<style type="text/css">
@@ -98,5 +99,9 @@
9899
統計情報は現在 <a href='https://doorkeeper.jp/'>Doorkeeper</a><a href='http://connpass.com/'>connpass</a> にのみ対応しています。</pre>
99100
</p>
100101
<% end %>
102+
103+
<div style='margin-top: 60px;'>
104+
<small><%= link_to raw("&raquo; 他の Dojo 一覧を見る"), dojos_path %></small>
105+
</div>
101106
</div>
102107
</section>

0 commit comments

Comments
 (0)