require "roda" require_relative "rank_king" module RankKing class Web < Roda plugin :named_templates plugin :public plugin :render plugin :symbol_views template(:layout) { <<~ERB } <%= ["Rank King", @page_title].compact.join(" - ") %>

Rank King

<%= yield %>
ERB template(:pools) { <<~ERB }

Pools

ERB template(:pool) { <<~ERB }

<%= @pool.name %>

Axes

Items

    <% @pool.items.each do |item| %>
  1. <%= item.title %>
  2. <% end %>
ERB template(:axis) { <<~ERB }

<%= @axis.pool.name %> - <%= @axis.name %>

Items

<% @axis.ratings.sort_by { -_1.ordinal }.each.with_index do |rating, i| %> <% end %>
<%= i+1 %> <%= rating.item.title %> <%= rating.ordinal.round(1) %> <%= rating.mu.round(1) %> <%= rating.sigma.round(1) %>
<% @game.each.with_index do |item, i| %> <% end %>
ERB template(:theme) { <<~ERB }
1
2
3
4

Accent

Text Color 1

Text Color 2


Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

ERB route do |r| r.on "static" do r.public end r.root do r.redirect "/pools" end r.on "pools" do r.is do @pools = Pool.all :pools end r.on Integer do |id| @pool = Pool[id] r.is do :pool end r.on "axes" do r.on Integer do |id| @axis = Axis[id] r.is "rank" do items = r.params.values_at("item_0", "item_1").map { Item[_1] } winner, loser = items.partition { _1.id == r.params.fetch("winner").to_i }.flatten RankKing.rank(@axis, winner:, loser:) r.redirect "/pools/#{@pool.id}/axes/#{@axis.id}" end r.is do @game = RankKing.suggest_game(@axis).shuffle :axis end end end end end r.is "theme" do :theme end end end end