module Apipie::Helpers

Attributes

url_prefix[RW]

Public Instance Methods

full_url(path) click to toggle source
# File lib/apipie/helpers.rb, line 9
def full_url(path)
  unless @url_prefix
    @url_prefix = ""
    if rails_prefix = ENV["RAILS_RELATIVE_URL_ROOT"]
      @url_prefix << rails_prefix
    end
    @url_prefix << Apipie.configuration.doc_base_url
  end
  path = path.sub(%r^\//,"")
  ret = "#{@url_prefix}/#{path}"
  ret.insert(0,"/") unless ret =~ %r\A[.\/]/
  ret.sub!(%r\/*\Z/,"")
  ret
end
include_javascripts() click to toggle source
# File lib/apipie/helpers.rb, line 24
def include_javascripts
  %w[ bundled/jquery-1.7.2.js
      bundled/bootstrap-collapse.js
      bundled/prettify.js
      apipie.js ].map do |file|
    "<script type='text/javascript' src='#{Apipie.full_url("javascripts/#{file}")}'></script>"
  end.join("\n").html_safe
end
include_stylesheets() click to toggle source
# File lib/apipie/helpers.rb, line 33
def include_stylesheets
  %w[ bundled/bootstrap.min.css
      bundled/prettify.css
      bundled/bootstrap-responsive.min.css ].map do |file|
    "<link type='text/css' rel='stylesheet' href='#{Apipie.full_url("stylesheets/#{file}")}'/>"
  end.join("\n").html_safe
end
markup_to_html(text) click to toggle source
# File lib/apipie/helpers.rb, line 3
def markup_to_html(text)
  Apipie.configuration.markup.to_html(text.strip_heredoc)
end