Class: Bloggit::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/bloggit/server.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.active_siteObject (readonly)

Returns the value of attribute active_site.



75
76
77
# File 'lib/bloggit/server.rb', line 75

def active_site
  @active_site
end

Class Method Details

.runObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/bloggit/server.rb', line 77

def run
	site = Dir.getwd.ends_with?('.blog') ? Bloggit::Site.from_file(Dir.getwd) : nil
	raise "Not a valid Bloggit site!" if site.nil?
	@active_site = site
	
	s = HTTPServer.new( 
		:Port => 3322,  
		:DocumentRoot    => File.join(File.dirname(__FILE__), 'client')
	)

	s.mount( "/main",  Main )
	s.mount( "/json",  Json )
	
	# s.mount_proc("/hello"){|req, res|
	#   res['Content-Type'] = "text/html"
	#   res.body = "<HTML>hello</HTML>"
	# }
	trap("INT"){ s.shutdown }
	s.start
end