From e759481583c3be2924a32f068b917b2d1f5ad9bb Mon Sep 17 00:00:00 2001 From: Jerome Lacoste Date: Thu, 7 Jan 2016 23:07:56 +0100 Subject: [PATCH 1/4] Alternative to PR #524 - add missing close div --- lib/assets/summary.html.erb | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/assets/summary.html.erb b/lib/assets/summary.html.erb index 6929098..a1416ac 100644 --- a/lib/assets/summary.html.erb +++ b/lib/assets/summary.html.erb @@ -170,24 +170,25 @@

<% elsif @screenshots.count > 0 %> - <% last_size = nil %> <% sc = @screenshots.find_all { |s| s.language == language } %> - <% sc.sort {|a, b| [a.screen_size, a.path] <=> [b.screen_size, b.path]}.each do |screenshot| %> + <% sc_by_size = sc.group_by { |i| i.screen_size } %> - <% new_row = (last_size != screenshot.screen_size or last_size == nil) %> + <% sc_by_size.keys.sort.each do |screen_size| %> + <% screenshots = sc_by_size[screen_size].sort { |a, b| [a.path] <=> [b.path] } %> - <% if new_row and last_size != nil %> - - <% end %> + <% screenshots.each_with_index do |screenshot, index| %> - <% if new_row %> -

<%= screenshot.formatted_name %>

-
- <% end %> - - + <% if index == 0 %> +

<%= screenshot.formatted_name %>

+
+ <% end %> - <% last_size = screenshot.screen_size %> + + + <% if index == (screenshots.count - 1) %> +
+ <% end %> + <% end %> <% end %> <% else %> From 0aa79a508a01b3ca45ce4194c1324f5deb959a5f Mon Sep 17 00:00:00 2001 From: Jerome Lacoste Date: Fri, 8 Jan 2016 12:04:52 +0100 Subject: [PATCH 2/4] Preview screenshots: simplify the looping logic as we can make assumptions on the presence of screenshots --- lib/assets/summary.html.erb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/assets/summary.html.erb b/lib/assets/summary.html.erb index a1416ac..97ee73b 100644 --- a/lib/assets/summary.html.erb +++ b/lib/assets/summary.html.erb @@ -175,20 +175,14 @@ <% sc_by_size.keys.sort.each do |screen_size| %> <% screenshots = sc_by_size[screen_size].sort { |a, b| [a.path] <=> [b.path] } %> - - <% screenshots.each_with_index do |screenshot, index| %> - - <% if index == 0 %> -

<%= screenshot.formatted_name %>

+ <%# we are guaranteed to have at least one element because of the group_by %> +

<%= screenshots[0].formatted_name %>

- <% end %> + <% screenshots.each do |screenshot| %> - - <% if index == (screenshots.count - 1) %> -
- <% end %> <% end %> +
<% end %> <% else %> From c998aba09b3cbef9ab2882c765f9aaaf27987545 Mon Sep 17 00:00:00 2001 From: Jerome Lacoste Date: Fri, 8 Jan 2016 13:04:26 +0100 Subject: [PATCH 3/4] Make the Preview document HTML5 valid --- lib/assets/summary.html.erb | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/assets/summary.html.erb b/lib/assets/summary.html.erb index 97ee73b..15fdd35 100644 --- a/lib/assets/summary.html.erb +++ b/lib/assets/summary.html.erb @@ -1,9 +1,10 @@ + deliver - <%= @app_name %> - +