Sha256: 6a169d22a60c586c0791c84289e451920181fbe3ceeda11ff19922ad7ee87321

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

#!/usr/bin/env ruby

require 'strelka'
require 'strelka/admin'


# The Strelka admin web console.
class Strelka::AdminConsole < Strelka::App

	# The 'appid' of the route to point the application at
	ID = Strelka::ADMINSERVER_ID

	# Load some plugins
	plugins :templating, :routing, :filters, :errors


	# By default, responses are HTML
	default_type 'text/html'

	#
	# Templating
	#

	# Templating -- wrap everything in the layout
	layout 'layout.tmpl'
	templates \
		:console => 'admin/console.tmpl',
		:server  => 'admin/server.tmpl',
		:host    => 'admin/host.tmpl',
		:message => 'admin/message.tmpl'


	#
	# Filters
	#

	# Add some custom headers to all responses
	filter( :response ) do |res|
		res.headers.x_strelka_version = Strelka.version_string( true )
	end


	#
	# Routes
	#

	### Initialize some application data.
	def initialize( * )

		# Commonalize all the loggers
		Mongrel2.logger = Strelka.logger
		Configurability.logger = Strelka.logger
		Inversion.logger.level = Logger::WARN

		@adminserver = Mongrel2::Config::Server.by_uuid( ADMINSERVER_ID ).first
		@control = @adminserver.control_socket

		super
	end


	#
	# Custom Error Responses
	#

	# on_status 404, :missing
	#
	# on_status 302,304, :redirect



	#
	# App Routes
	#

	# GET / -- console view
	get do |req|
		tmpl = self.template( :console )
		tmpl.request = req
		tmpl.control = @control
		tmpl.servers = Mongrel2::Config.servers

		return tmpl
	end

end # class Strelka::AdminConsole


if __FILE__ == $0
	require 'configurability/config'

	# Commonalize all the loggers
	Mongrel2.logger = Strelka.logger
	Configurability.logger = Strelka.logger
	PluginFactory.logger = Strelka.logger

	Inversion.logger.level = Logger::WARN

	Strelka.load_config
	Strelka::AdminConsole.run
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
strelka-admin-0.0.1.pre7 data/strelka-admin/apps/strelka-admin