Class: Gonzui::JSFeedServlet
- Inherits:
-
GonzuiAbstractServlet
- Object
- HTTPServlet::AbstractServlet
- GonzuiAbstractServlet
- Gonzui::JSFeedServlet
- Defined in:
- lib/gonzui/webapp/jsfeed.rb
Constant Summary
Constants included from URIMaker
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from GonzuiAbstractServlet
#format_html, #get_media_type, #get_mime_type, #init_servlet, #initialize, #log, #make_path, #set_content_type_text_html
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
This class inherits a constructor from Gonzui::GonzuiAbstractServlet
Class Method Details
.mount_point ⇒ Object
14 15 16 |
# File 'lib/gonzui/webapp/jsfeed.rb', line 14 def self.mount_point "jsfeed" end |
Instance Method Details
#do_GET(request, response) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gonzui/webapp/jsfeed.rb', line 18 def do_GET(request, response) init_servlet(request, response) path = make_path log(path) from = to = nil if m = /^(\d+)-(\d+)$/.match(request.query_string) from = m[1].to_i to = m[2].to_i end if from and to path_id = @dbm.get_path_id(path) if path_id content = @dbm.get_content(path_id) lineno = 0 lines = [] range = Range.new(from, to) content.each_line {|line| lineno += 1 if range.include?(lineno) line_with_lineno = sprintf("%5d: %s", lineno, line) line_with_lineno.chop! lines.push(HTMLUtils.escape(line_with_lineno)) end } snippet = lines.join("<br />") response.body = sprintf("document.writeln('<pre>%s</pre>');", snippet) response['Content-Type'] = "application/x-javascript" else response.body = sprintf("%s: not found", path) response.status = 404 response['Content-Type'] = "text/html" end else response.body = "invalid query" response['Content-Type'] = "text/html" end end |