Module: Juli::Wiki

Defined in:
lib/juli/wiki.rb

Overview

When new file is added:

  1. The filename becomes wikiname.

  2. scan all of files (includes itself because this also contains the wikiname), convert token to wiki-link if exists and generate HTML.

When a file is deleted:

  1. The filename (wikiname) is lost.

  2. scan all of files (includes itself because this also contains the wikiname), convert token to wiki-link if exists and generate HTML.

Class Method Summary collapse

Class Method Details

.build_wikinamesObject



34
35
36
37
38
39
40
41
42
# File 'lib/juli/wiki.rb', line 34

def build_wikinames
  wikiname = {}
  Dir.chdir(Juli::Util.juli_repo){
    Dir.glob('**/*.txt'){|f|
      wikiname[encode(Juli::Util.to_wikiname(f))] = 1
    }
  }
  wikiname.keys.sort_by{|a| -1 * a.length}
end

.decode(str) ⇒ Object

decode ‘(’, ‘)’

EXAMPLE

‘juli(1)’ -> ‘juli(1)’



30
31
32
# File 'lib/juli/wiki.rb', line 30

def decode(str)
  str.gsub(/\\\(/, '(').gsub(/\\\)/, ')')
end

.encode(str) ⇒ Object

encode(=escape) ‘(’, ‘)’

EXAMPLE

‘juli(1)’ -> ‘juli(1)’



22
23
24
# File 'lib/juli/wiki.rb', line 22

def encode(str)
  str.gsub(/\(/, '\(').gsub(/\)/, '\)')
end

.wikinamesObject

global name to return wikinames data, which is just string array ordered by length in descendant.



46
47
48
# File 'lib/juli/wiki.rb', line 46

def wikinames
  $_wikinames ||= build_wikinames
end