5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 18:06:23 +00:00
panel/lib/sutty/site.rb
2017-10-05 16:42:32 -03:00

39 lines
819 B
Ruby

# frozen_string_literal: true
require 'sinatra/base'
require 'sinatra/namespace'
require 'sinatra/reloader' if ENV['RACK_ENV'] == 'development'
require 'sinatra_warden'
require_relative 'login'
require_relative 'post'
require_relative '../sutty'
module Sutty
# El gestor de sitios
class Site < Sinatra::Base
use Sutty::Login
register Sinatra::Warden
register Sinatra::Namespace
set :root, Sutty.root
set :read, false
configure :development do
register Sinatra::Reloader
end
namespace '/sites/:name' do
before do
authorize! '/login' if ENV['RACK_ENV'] == 'production'
@site = Sutty.find(params['name'])
@site.read if @site.posts.docs.empty?
end
get do
haml :'sites/show'
end
use Sutty::Post
end
end
end