-
Notifications
You must be signed in to change notification settings - Fork 450
/
Copy pathsite_index.rb
63 lines (57 loc) · 1.37 KB
/
site_index.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class SiteIndex < Erector::Widget
needs :site_name, :locale
attr_accessor :site_name
def categorized_sites
{
'setup' => [
'installfest'
],
'rails' => [
'intro-to-rails',
'job-board',
'message-board',
'testing-rails-applications'
],
'frontend' => [
'frontend',
'javascript-snake-game',
'javascript-to-do-list',
'javascript-to-do-list-with-react'
],
'ruby' => [
'learn-to-code',
'ruby'
]
}
end
def sites
return @sites if @sites
@sites = Dir.glob("#{Site.sites_dir}/**").map { |filename| File.basename(filename) }.sort
end
def site_category category
li Titleizer.title_for_page(category), class: 'category'
end
def site_link site
if site == site_name
return li Titleizer.title_for_page(site_name), class: 'current'
end
path = "/#{site}/"
li do
a(Titleizer.title_for_page(site), :href => path)
end
end
def content
ul :class => "dropdown-menu" do
categorized_sites.each do |category, category_sites|
site_category category
category_sites.each do |site|
site_link site
end
end
site_category I18n.t('sites.other_categories')
(sites - categorized_sites.values.flatten).each do |site|
site_link site
end
end
end
end