class WikiMD::App

Main Sinatra application

Constants

TYPE_MARKDOWN
TYPE_TEXT

Public Instance Methods

asset_path(name) click to toggle source

returns the URI for a static asset.

@param name [#to_s] name of the asset file @return [String] the full URI

# File lib/wikimd/app.rb, line 47
def asset_path(name)
  url("assets/#{name}")
end
class_for_diff(line) click to toggle source

CSS class for a diff line

@param line [String] the line in question @return [String] “addition”, if the line starts with “+”, “removal” if

the line starts with "-", nil otherwise.
# File lib/wikimd/app.rb, line 85
def class_for_diff(line)
  case line[0]
  when '+'
    'addition'
  when '-'
    'removal'
  end
end
edit_path(path) click to toggle source

URL helper for the Edit page of a document

@param path [String] relative path of the document in the Repository @return [String] full URI to the edit page

# File lib/wikimd/app.rb, line 76
def edit_path(path)
  url('/e/' + path)
end
history_path(path) click to toggle source

URL helper for the History page of a document

@param path [String] relative path of the document in the Repository @return [String] full URI to the history page

# File lib/wikimd/app.rb, line 68
def history_path(path)
  url('/h/' + path)
end
octicon(name) click to toggle source

Include an Octicon! (see octicons.github.com/)

@param name [#to_s] Name of the Octicon @return [String] HTML Code for the Octicon

# File lib/wikimd/app.rb, line 55
def octicon(name)
  %(<span class="octicon octicon-#{name}"></span>)
end
tree_root() click to toggle source

Get the directory-Tree from the root of the repo

# File lib/wikimd/app.rb, line 60
def tree_root
  repo.tree
end

Private Instance Methods

files_set() click to toggle source

create or return the Search Index

# File lib/wikimd/app.rb, line 187
def files_set
  if settings.fs_created + 12 < Time.now
    settings.fs = FuzzySet.new(repo.files)
    settings.fs_created = Time.now
  end
  settings.fs
end
render_markdown(markdown) click to toggle source

Render Markdown to HTML

# File lib/wikimd/app.rb, line 177
def render_markdown(markdown)
  settings.markdown_renderer.render(markdown)
end
repo() click to toggle source

create or return Repository

# File lib/wikimd/app.rb, line 182
def repo
  settings.repo
end