File tree 2 files changed +40
-13
lines changed
2 files changed +40
-13
lines changed Original file line number Diff line number Diff line change @@ -89,23 +89,52 @@ preprocess do
89
89
]
90
90
91
91
@chapters = { }
92
+
93
+ @github_users = {
94
+ "jquery" => nil
95
+ }
96
+
92
97
@items . each do |item |
93
98
item [ :chapter ] = item [ :filename ] . split ( '/' ) [ 1 ]
94
99
item [ :chapter_title ] = item [ :chapter ] . gsub ( /-/ , " " ) . upcase
100
+ if item [ :github ]
101
+ @github_users [ item [ :github ] ] = nil
102
+ else
103
+ item [ :github ] = "jquery"
104
+ end
95
105
end
96
106
107
+ @github_users . each do |username , wat |
108
+ request = Curl ::Easy . http_get ( "https://api.github.com/users/" +username )
109
+ request . perform
110
+ @github_users [ username ] = JSON . parse request . body_str
111
+ end
112
+
113
+
97
114
@groupedItems = @items . group_by { |item | item [ :chapter ] }
98
115
116
+ @orderedItems = [ ]
117
+
99
118
@chapterOrder . each do |folder |
100
119
myitems = @groupedItems [ folder ]
101
120
@chapters [ folder ] = { }
102
121
@chapters [ folder ] [ :items ] = @groupedItems [ folder ] . sort_by { |i | i [ :section ] || 0 }
122
+ @orderedItems = @orderedItems + @chapters [ folder ] [ :items ]
103
123
@chapters [ folder ] [ :title ] = folder . gsub ( /-/ , " " ) . upcase
104
124
@chapters [ folder ] [ :folder ] = folder
105
125
end
106
126
107
- @site . config [ :chapterOrder ] = @chapterOrder
127
+ @items . each do |item |
128
+ i = item [ :ordinal_index ] = @orderedItems . index ( item )
129
+ if i
130
+ item [ :next_item ] = @orderedItems [ i +1 ]
131
+ item [ :previous_item ] = @orderedItems [ i -1 ]
132
+ end
133
+ item [ :github_user ] = @github_users [ item [ :github ] ]
134
+ end
135
+
108
136
@site . config [ :chapters ] = @chapters
137
+ @site . config [ :orderedItems ] = @orderedItems
109
138
end
110
139
111
140
compile '/assets/*' do
Original file line number Diff line number Diff line change 1
1
< div class ="clearfix meta ">
2
2
< div class ="github ">
3
- < %if @item[:github] %>
4
- < % github_user = @item[:github] || "jquery" %>
5
- < % user_request = Curl::Easy.http_get("https://api.github.com/users/"+github_user) %>
6
- < % user_request.perform %>
7
- < % user_obj = JSON.parse(user_request.body_str) %>
8
- < img src ="<%= user_obj[ "avatar_url "] %> " class="avatar" />
9
- < h3 class ="author "> By < a href ="<%= user_obj[ "html_url "] %> "> < %= user_obj["name"] %> </ a > </ h3 >
10
- < % else %>
11
- < h3 class ="author "> By < %= @item[:attribution] %> </ h3 >
12
- < % end %>
3
+ < img src ="<%= @item[:github_user][ "avatar_url "] %> " class="avatar" />
4
+ < h3 class ="author "> By < a href ="<%= @item[:github_user][ "html_url "] %> "> < %= @item[:github_user]["name"] %> </ a > </ h3 >
13
5
</ div >
14
6
< div class ="feedback ">
15
7
< h4 > Suggestions? Problems? Feedback?</ h4 >
@@ -22,6 +14,12 @@ <h4>Suggestions? Problems? Feedback?</h4>
22
14
</ div >
23
15
24
16
< div class ="clearfix pagination ">
25
- < a href ="# " class ="previous "> < span class ="article "> jQuery for Designers</ span > < span class ="direction "> Previous</ span > </ a >
26
- < a href ="# " class ="next "> < span class ="article "> $(document).ready()</ span > < span class ="direction "> Next</ span > </ a >
17
+
18
+ < % if @item[:previous_item] %>
19
+ < a href ="<%= @item[:previous_item].path %> " class ="previous "> < span class ="article "> < %= @item[:previous_item][:title] %> </ span > < span class ="direction "> Previous</ span > </ a >
20
+ < % end %>
21
+ < % if @item[:next_item] %>
22
+ < a href ="<%= @item[:next_item].path %> " class ="next "> < span class ="article "> < %= @item[:next_item][:title] %> </ span > < span class ="direction "> Next</ span > </ a >
23
+ < % end %>
24
+
27
25
</ div >
You can’t perform that action at this time.
0 commit comments