Commit 630bc05d authored by Bat's avatar Bat
Browse files

Add new instances

parent 8df30a10
Amber::Server.configure do |app|
pipeline :web do
pipeline :web, :admin do
# Plug is the method to use connect a pipe (middleware)
# A plug accepts an instance of HTTP::Handler
plug Amber::Pipe::PoweredByAmber.new
......@@ -30,8 +30,6 @@ Amber::Server.configure do |app|
end
routes :web do
get "/", HomeController, :index
get "/configure", HomeController, :show_configure
post "/configure", HomeController, :configure
......@@ -53,4 +51,9 @@ Amber::Server.configure do |app|
get "/blogs/new", BlogController, :new
post "/blogs", BlogController, :create
end
routes :admin do
get "/admin", AdminController, :index
post "/admin/instances", AdminController, :new_instance
end
end
class AdminController < ApplicationController
def index
instances = Repo.all(Instance).not_nil!
title = "Administration"
template "index.ecr"
end
def new_instance
instance = Instance.new
instance.name = params["hostname"]
instance.hostname = params["hostname"]
Repo.insert(instance)
redirect_to(controller: :admin, action: :index, status: 302)
end
end
<main>
<h1>
Administration
</h1>
<h2>
Federation
</h2>
<ul>
<% instances.each do |i| %>
<li><%= i.name %> &mdash; <%= i.hostname %></li>
<% end %>
</ul>
<form action="/admin/instances" method="POST">
<%= csrf_tag %>
<label for="hostname">Hostname</label>
<input name="hostname" />
<input type="submit" value="Federate"/>
</form>
</main>
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