Class: Action

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

Direct Known Subclasses

Json, Main

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



9
10
11
# File 'lib/bloggit/server.rb', line 9

def content_type
  @content_type
end

#reqObject (readonly)

Returns the value of attribute req.



9
10
11
# File 'lib/bloggit/server.rb', line 9

def req
  @req
end

#resObject (readonly)

Returns the value of attribute res.



9
10
11
# File 'lib/bloggit/server.rb', line 9

def res
  @res
end

Instance Method Details

#do_GET(req, res) ⇒ Object



10
11
12
13
14
15
# File 'lib/bloggit/server.rb', line 10

def do_GET(req, res)
	@req = req; @res = res
	@content_type = "text/html"
	@res.body = get
	@res['Content-Type'] = @content_type
end

#do_POST(req, res) ⇒ Object



16
17
18
19
20
21
# File 'lib/bloggit/server.rb', line 16

def do_POST(req, res)
	@req = req; @res = res
	@content_type = "text/html"
	@res.body = post
	@res['Content-Type'] = @content_type
end

#getObject



22
# File 'lib/bloggit/server.rb', line 22

def get; "GET not defined"; end

#postObject



23
# File 'lib/bloggit/server.rb', line 23

def post; "POST not defined"; end

#render(template, binding = binding) ⇒ Object



24
25
26
27
28
# File 'lib/bloggit/server.rb', line 24

def render(template, binding=binding)
	source = IO.read(File.join(File.dirname(__FILE__), 'client', 'templates', "#{template}.rhtml"))
	puts "Rendering #{source}"
	ERB.new(source).result(binding)
end

#siteObject



29
30
31
# File 'lib/bloggit/server.rb', line 29

def site
	Bloggit::Server.active_site
end