Initial commit of the HEAD branch of the ELinks CVS repository, as of
[elinks/images.git] / contrib / ruby / hooks.rb
blobbbf8e79620e14ece34c612a67289d6b079181768
1 # = hooks.rb - ELinks/Ruby hooks
3 # == Module Constants
5 # The following global module constants are defined
7 # * ELinks::VERSION     - The ELinks version. :-P
9 # * ELinks::HOME        - The path to ELinks configuration files
11 # == Debugging Scripts
13 # When debugging you can use either
15 #       p(obj, ...)
17 # or
19 #       message(string)
21 # to print message strings. The printed strings will be shown in a message
22 # box.
25 # Called when the user enters something into the goto URL dialog.
27 def ELinks::goto_url_hook(url, current_url)
28     case url
29     when /^localhost$/
30         return "http://localhost/"
32     when /test-ruby/
33         # Dump the exported variables.
34         message(ELinks::VERSION + " - " + ELinks::HOME);
35         return current_url
36     end
38     return url
39 end
42 # Called when the user decides to load some document by following a link,
43 # entering an URL in the goto URL dialog, loading frames from a frameset (?)
44 # etc.
46 def ELinks::follow_url_hook(url)
47     return url
48 end
51 # Called when a HTML document has been loaded - before the document rendering
52 # begins. Makes it possible to fix up bad HTML code, remove tags etc.
54 def ELinks::pre_format_html_hook(url, html)
55     return html
56 end
59 # Determining what proxy, if any, should be used to load a requested URL.
60 # The hook should return:
62 # * "PROXY:PORT" - to use the specified proxy
63 # * ""           - to not use any proxy
64 # * nil          - to use the default proxies
66 def ELinks::proxy_hook(url)
67     return nil
68 end
71 # Called when ELinks quits and can be used to do required clean-ups
73 def ELinks::quit_hook
74 end