Sha256: a8b5026f5f9a01d4161c6766de7655d1a3b45c3fba6d6e43189a442561dde378

Contents?: true

Size: 615 Bytes

Versions: 2

Compression:

Stored size: 615 Bytes

Contents

require 'erb'
OPRO_MD_ROOT=File.join(File.dirname(__FILE__), '../../views/oauth/docs/markdown/')


class Oauth::DocsController < ApplicationController
  helper_method :render_doc

  def index
  end

  def show
    @doc = params[:id]
  end

  def render_doc(name)
    str = read_file(name.to_s)
    str = parse_erb(str)
    str = parse_markdown(str)
    str.html_safe
  end

  private

  def parse_erb(str)
    ERB.new(str).result(binding)
  end

  def parse_markdown(str)
    BlueCloth.new(str).to_html
  end

  def read_file(name)
    name = OPRO_MD_ROOT + name
    File.open(name + '.md.erb' ).read.to_s
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opro-0.0.1.pre1.0.1 app/controllers/oauth/docs_controller.rb
opro-0.0.1.pre app/controllers/oauth/docs_controller.rb