Module Noosfero::URL
In: lib/noosfero/url.rb

This module defines utility methods for generating URL‘s in contexts where one does not have a request (i.e. ActionMailer classes like TaskMailer).

TODO: document the use of config/web.yml in a INSTALL document

Methods

config   generate_url   included   path   port  

Included Modules

ActionController::UrlWriter

Public Class methods

[Source]

    # File lib/noosfero/url.rb, line 13
13:     def config
14:       if @config.nil?
15:         config_file = File.join(RAILS_ROOT, 'config', 'web.yml')
16:         if File.exists?(config_file)
17:           @config = YAML::load_file(config_file)
18:         else
19:           if ENV['RAILS_ENV'] == 'production'
20:             @config = {
21:             }
22:           else
23:             @config = {
24:               'path' => '',
25:               'port' => 3000
26:             }
27:           end
28:         end
29:       end
30: 
31:       @config
32:     end

[Source]

    # File lib/noosfero/url.rb, line 34
34:     def included(other_module)
35:       other_module.send(:include, ActionController::UrlWriter)
36:     end

Public Instance methods

[Source]

    # File lib/noosfero/url.rb, line 48
48:   def generate_url(options)
49:     local_options = {}
50:     local_options[:port] = self.port unless self.port.nil?
51: 
52:     url = url_for(local_options.merge(options))
53: 
54:     if self.path.blank?
55:       url
56:     else
57:       url.sub(/(http:\/\/[^\/]+(:\d+)?)\//, "\\1#{self.path}/")
58:     end
59:   end

[Source]

    # File lib/noosfero/url.rb, line 44
44:   def path
45:     Noosfero::URL.config['path']
46:   end

[Source]

    # File lib/noosfero/url.rb, line 40
40:   def port
41:     Noosfero::URL.config['port']
42:   end

[Validate]