diff --git a/library/server/wsf/router/wsf_file_system_handler.e b/library/server/wsf/router/wsf_file_system_handler.e index f494b5b4..a3a4b57e 100644 --- a/library/server/wsf/router/wsf_file_system_handler.e +++ b/library/server/wsf/router/wsf_file_system_handler.e @@ -91,8 +91,12 @@ feature -- Access index_disabled: BOOLEAN -- Index disabled? + index_ignores_function: detachable FUNCTION [ANY, TUPLE [PATH], BOOLEAN] + -- Function to evaluate if a path is ignored or not during autoindex. + -- If `index_ignores' is Void and `index_ignores_function' is Void, use default ignore rules. + directory_index: detachable ARRAY [READABLE_STRING_8] - -- File serve if a directory index is requested + -- File serve if a directory index is requested. not_found_handler: detachable PROCEDURE [ANY, TUPLE [uri: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE]] @@ -137,6 +141,44 @@ feature -- Element change access_denied_handler := h end + set_default_index_ignores + -- Use default auto index ignores behavior. + do + index_ignores_function := Void + end + + set_index_ignores_function (fct: attached like index_ignores_function) + -- Use `fct' to compute auto index ignores behavior. + do + index_ignores_function := fct + end + +feature -- Status report + + ignoring_index_entry (p: PATH): BOOLEAN + -- Ignoring path `p' for auto index? + local + e: detachable PATH + n: READABLE_STRING_32 + do + if attached index_ignores_function as fct then + Result := fct.item ([p]) + else + -- default + e := p.entry + if e = Void then + e := p + end + if e.is_parent_symbol then + else + n := e.name + Result := n.starts_with ({STRING_32} ".") + or n.ends_with ({STRING_32} "~") + or n.ends_with ({STRING_32} ".swp") + end + end + end + feature -- Execution execute (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE) @@ -189,6 +231,11 @@ feature -- Execution uri, s: STRING_8 d: DIRECTORY l_files: LIST [PATH] + p: PATH + n: READABLE_STRING_32 + httpdate: HTTP_DATE + pf: RAW_FILE + l_is_dir: BOOLEAN do create d.make_with_path (dn) d.open_read @@ -202,11 +249,16 @@ feature -- Execution s := "[
-| Name | Last modified | Size | |
|---|---|---|---|
| ") + if l_is_dir then + s.append ("[dir]") + else + s.append (" ") + end + s.append (" | ") + s.append ("") + if p.is_parent_symbol then + s.append ("[Parent Directory] ..") + else + s.append (html_encoder.encoded_string (n)) + end + if l_is_dir then + s.append ("/") + end + + s.append (" | ") + s.append ("") + create httpdate.make_from_date_time (file_date (pf)) + httpdate.append_to_rfc1123_string (s) + s.append (" | ") + s.append ("") + if not l_is_dir then + s.append_integer (file_size (pf)) + end + s.append (" | ") + s.append ("