Commit a486da55 authored by Milan's avatar Milan

add basic logviewer to admin page

parent 948f9253
class AdminController < ApplicationController
before_filter :authenticate, :except => [:login]
def index
end
@logs = `tail -n 100 log/minetest.log`
end
end
module AdminHelper
end
<% if logged_in? %>
<h1>Admin</h1>
<button type="button" class="btn btn-primary pull-right" style="margin-top:-5rem;">Refresh</button>
<pre id="tail" style="height:600px;"><%= @logs %></pre>
<% content_for(:after) do %>
<script>
tailScroll();
function updateDiv(){
$('#tail').triggerevent(function(){
$('#tail').html(newContent);
});
setInterval(updateDiv, 1000);
}
$("button").click(function (e) {
window.location.reload(true);
});
function tailScroll() {
var height = $("#tail").get(0).scrollHeight;
$("#tail").animate({
scrollTop: height
}, 500);
}
</script>
<% end %>
<% else %>
<h1> nope </h1>
<% end %>
USER = 'admin'
PASSWORD = '123'
......@@ -30,7 +30,6 @@ end
controller :admin do
get 'admin' => 'admin#index', :as => 'admin'
get 'login' => 'admin#login', :as => 'login'
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment