<%= link_to("<<", main_app.hyrax_newspaper_title_path(params[:id], year: years[:previous])) if years[:previous] %> Issues: <% if (years[:all] && years[:all].count >= 1) %> <% year_select_options = Hash[years[:all].collect { |y| [y, url_for(main_app.hyrax_newspaper_title_path(params[:id], year: y))] }] %> <%= select_tag :year, options_for_select(year_select_options, selected=url_for(main_app.hyrax_newspaper_title_path(params[:id], year: years[:current]))) %> <% else %> <%= years[:current] %> <% end %> <%= link_to(">>", main_app.hyrax_newspaper_title_path(params[:id], year: years[:next])) if years[:next] %>

<% for month in 1..12 %>

<%= Date::MONTHNAMES[month] %>

<% for day_name in 0..6 %>
<%= Date::DAYNAMES[day_name][0..1] %>
<% end %>
<% month_start = Date.new(years[:current], month) %> <% month_end = ((month_start>>1)-1) %> <% month_start_print = month_start - month_start.wday %> <% month_end_print = (month_end + 6) - (month_end.wday) %> <% (month_start_print).upto(month_end_print) do |d| %> <% day_is_in_current_month = d.month == month ? true : false %>
<%= "adjacent_month" if d.month != month %> <%= "cal-#{d.strftime("%Y-%m-%d")}" %>"> <% issue = issues.select {|issue| Date.parse(issue["publication_date_dtsi"]) == d }.first %> <% if issue && day_is_in_current_month %> <%= link_to d.day, main_app.hyrax_newspaper_issue_path(issue) %> <% else %> <%= d.day %> <% end %>
<% if d.wday == 6 %>
<% end %> <% end %>
<% if month % 4 == 0 %>
<% end %> <% if month % 3 == 0 %>
<% end %> <% if month % 2 == 0 %>
<% end %> <% end %>