require 'roda' require 'json' module Pears class Web < Roda plugin :render, views: "#{__FILE__}/../web/views" route do |r| r.root do r.redirect "#{request.path}index" end r.get "index" do @subjects = Pears.subjects render('index') end r.on "subjects" do r.is do r.redirect "#{request.path.delete_suffix('/subjects')}/index" end r.get String do |subject| @subjects = Pears.subjects @subject = Pears[subject.to_sym] render('show') end r.post String do |subject| @subjects = Pears.subjects @subject = Pears[subject.to_sym] @subject.reboot render('show') end end end end end