Class: Gonzui::GonzuiAbstractServlet
- Inherits:
-
HTTPServlet::AbstractServlet
- Object
- HTTPServlet::AbstractServlet
- Gonzui::GonzuiAbstractServlet
- Defined in:
- lib/gonzui/webapp/servlet.rb
Direct Known Subclasses
AdvancedSearchServlet, JSFeedServlet, MarkupServlet, SearchServlet, SourceServlet, StatisticsServlet, TopPageServlet
Constant Summary
Constants included from URIMaker
Instance Method Summary collapse
- #format_html(html) ⇒ Object
-
#get_media_type(path) ⇒ Object
ex.
- #get_mime_type(path) ⇒ Object
- #init_servlet(request, response) ⇒ Object
-
#initialize(server, config, logger, dbm, catalog_repository) ⇒ GonzuiAbstractServlet
constructor
A new instance of GonzuiAbstractServlet.
- #log(message = nil) ⇒ Object
- #make_path ⇒ Object
- #set_content_type_text_html ⇒ Object
Methods included from HTMLMaker
#make_content_script_type, #make_css, #make_footer, #make_format_select, #make_h1, #make_html, #make_license_select, #make_meta, #make_meta_and_css, #make_navi, #make_property_select, #make_script, #make_search_form, #make_spacer, #make_status_line, #make_title
Methods included from URIMaker
#decompose_search_query, #escape_path, #get_default_query_value, #get_query_value, #get_short_name, #make_advanced_search_uri, #make_doc_uri, #make_google_uri, #make_lineno_uri, #make_markup_uri, #make_search_uri, #make_search_uri_partial, #make_source_uri, #make_stat_uri, #make_top_uri, #make_uri_general, #make_uri_with_options
Methods included from GetText
#gettext, #gettext_noop, #load_catalog, #set_catalog
Methods included from Util
assert, assert_equal, assert_equal_all, assert_non_nil, assert_not_reached, benchmark, command_exist?, commify, eprintf, format_bytes, program_name, protect_from_signals, require_command, set_verbosity, shell_escape, unix?, vprintf, windows?, wprintf
Constructor Details
#initialize(server, config, logger, dbm, catalog_repository) ⇒ GonzuiAbstractServlet
Returns a new instance of GonzuiAbstractServlet.
214 215 216 217 218 219 220 221 222 |
# File 'lib/gonzui/webapp/servlet.rb', line 214 def initialize(server, config, logger, dbm, catalog_repository) @server = server @config = config @logger = logger @dbm = dbm @catalog_repository = catalog_repository @servlet_name = /(\w+)Servlet$/.match(self.class.to_s)[1].downcase @start_time = Time.now end |
Instance Method Details
#format_html(html) ⇒ Object
288 289 290 291 292 293 |
# File 'lib/gonzui/webapp/servlet.rb', line 288 def format_html(html) formatter = XMLFormatter.new formatter.add_xml_declaration formatter.add_doctype return formatter.format(html) end |
#get_media_type(path) ⇒ Object
ex. image
284 285 286 |
# File 'lib/gonzui/webapp/servlet.rb', line 284 def get_media_type(path) get_mime_type(path).split("/").first end |
#get_mime_type(path) ⇒ Object
279 280 281 |
# File 'lib/gonzui/webapp/servlet.rb', line 279 def get_mime_type(path) HTTPUtils.mime_type(path, @server[:MimeTypes]) end |
#init_servlet(request, response) ⇒ Object
299 300 301 302 303 304 |
# File 'lib/gonzui/webapp/servlet.rb', line 299 def init_servlet(request, response) @request = request @response = response parse_request init_catalog end |
#log(message = nil) ⇒ Object
306 307 308 309 310 311 312 |
# File 'lib/gonzui/webapp/servlet.rb', line 306 def log( = nil) if @logger.log("%s %s [%s]", @servlet_name, , @ip_address) else @logger.log("%s [%s]", @servlet_name, @ip_address) end end |
#make_path ⇒ Object
314 315 316 317 |
# File 'lib/gonzui/webapp/servlet.rb', line 314 def make_path path = @request.path_info.prechop return path end |
#set_content_type_text_html ⇒ Object
295 296 297 |
# File 'lib/gonzui/webapp/servlet.rb', line 295 def set_content_type_text_html @response["Content-Type"] = "text/html; charset=utf-8" end |