Sha256: e7eb13b3bc29738979ae93125317a7cf84415aebee0eb78bfeb8c4d5f6e7504b

Contents?: true

Size: 855 Bytes

Versions: 22

Compression:

Stored size: 855 Bytes

Contents

#!/usr/bin/env ruby

require 'sinatra/base'

module Sinatra
  module LinkToHelper
    # from http://gist.github.com/98310
    def link_to(url_fragment, mode=:path_only)
      case mode
      when :path_only
        base = request.script_name
      when :full_url
        if (request.scheme == 'http' && request.port == 80 ||
            request.scheme == 'https' && request.port == 443)
          port = ""
        else
          port = ":#{request.port}"
        end
        base = "#{request.scheme}://#{request.host}#{port}#{request.script_name}"
      else
        raise "Unknown script_url mode #{mode}"
      end
      "#{base}#{url_fragment}"
    end
  end

  module PageTitleHelper
    def page_title(string)
      @page_title = string
    end

    def include_page_title
      @page_title ? "#{@page_title} | Visage" : "Visage"
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
visage-app-0.2.1 lib/visage/helpers.rb
visage-app-0.2.0 lib/visage/helpers.rb