mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 18:06:23 +00:00
39 lines
819 B
Ruby
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
|