class WikiMD::App
Main Sinatra application
Constants
- TYPE_MARKDOWN
- TYPE_TEXT
Public Instance Methods
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
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
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
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
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
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
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 to HTML
# File lib/wikimd/app.rb, line 177 def render_markdown(markdown) settings.markdown_renderer.render(markdown) end
create or return Repository
# File lib/wikimd/app.rb, line 182 def repo settings.repo end