lib/nesta/helpers.rb
# Generates the full path to a given page in the app.
# Takes Rack routers and reverse proxies into account.
# With Sinatra::Helpers included you could get the same
# effect with uri(page_path, false) but this is here to avoid
# depending on Sinatra::Helpers.
#
# If absolute is true, we'll return a full URI.  Note that unlike
# Sinatra's uri method, this deaults to false instead of true.
Generates the full path to a given page in the app.
Takes Rack routers and reverse proxies into account.
With Sinatra::Helpers included you could get the same
effect with uri(page_path, false) but this is here to avoid
depending on Sinatra::Helpers.

If absolute is true, we'll return a full URI.  Note that unlike
Sinatra's uri method, this deaults to false instead of true.
Generates the full path to a given page in the app . Takes Rack routers and reverse proxies into account . With Sinatra :: Helpers included you could get the same effect with uri ( page_path false ) but this is here to avoid depending on Sinatra :: Helpers . If absolute is true we ' ll return a full URI . Note that unlike Sinatra ' s uri method this deaults to false instead of true .
def path_to(page_path, absolute = false)
        host = ''
        if absolute
          host << "http#{'s' if request.ssl?}://"
          if (request.env.include?("HTTP_X_FORWARDED_HOST") or 
              request.port != (request.ssl? ? 443 : 80))
            host << request.host_with_port
          else
            host << request.host
          end
        end
        uri_parts = [host]
        uri_parts << request.script_name.to_s if request.script_name
        uri_parts << page_path
        File.join(uri_parts)
      end
def path_to ( page_path , absolute = false ) host = '' if absolute host << "http#{'s' if request.ssl?}://" if ( request . env . include? ( "HTTP_X_FORWARDED_HOST" ) or request . port != ( request . ssl? ? 443 : 80 ) ) host << request . host_with_port else host << request . host end end uri_parts = [ host ] uri_parts << request . script_name . to_s if request . script_name uri_parts << page_path File . join ( uri_parts ) end
Generates the full path to a given page in the app.
Generates the full path to a given page in the app .
page_path
<not_specific>
absolute
<not_specific>