Skip to content

Commit

Permalink
Place the portal template into a seperate file
Browse files Browse the repository at this point in the history
  • Loading branch information
6167656e74323431 committed Jul 8, 2020
1 parent 41220b3 commit 0c94a49
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
18 changes: 2 additions & 16 deletions karby-server.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'date'
require 'erb'
require 'json'
require 'securerandom'
require 'sinatra'
Expand All @@ -24,22 +25,7 @@ def tablify dated_files
parts = Dir["#{PRE_AGGREGATION_DIR}/*.log"].map{|path| DatedFile.new(path.split("/")[-1], File::Stat.new(path).ctime)}.sort_by(&:creation_date).reverse

headers "Content-Type" => "text/html"
body %{<style>
* {font-family: sans-serif;}
div.expandable {display: none;}
input:checked + label + div.expandable {display: block;}
table, th, td {border: 1px solid black; border-collapse: collapse;}
th, td {padding: 5px;}
</style>
<input type=\"checkbox\" id=\"aggregated\"><label for=\"aggregated\">Show Aggregated Logs</label>
<div class=\"expandable\">
#{tablify(aggregated)}
</div>
<hr>
<input type=\"checkbox\" id=\"parts\"><label for=\"parts\">Show Log Parts</label>
<div class=\"expandable\">
#{tablify(parts)}
</div>}.delete("\n").squeeze(" ")
erb :index, :locals => {:aggregated => tablify(aggregated), :parts => tablify(parts)}
end

get '/raw/*.log' do |file|
Expand Down
35 changes: 35 additions & 0 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Karby</title>
<style>
* {
font-family: sans-serif;
}
div.expandable {
display: none;
}
input:checked + label + div.expandable {
display: block;
}
table, th, td {
border: 1px solid black; border-collapse: collapse;
}
th, td {
padding: 5px;
}
</style>
</head>
<body>
<input type="checkbox" id="aggregated"><label for="aggregated">Show Aggregated Logs</label>
<div class="expandable">
<%= aggregated %>
</div>
<hr>
<input type="checkbox" id="parts"><label for="parts">Show Log Parts</label>
<div class="expandable">
<%= parts %>
</div>
</body>
</html>

0 comments on commit 0c94a49

Please sign in to comment.