Module: Juli::Wiki
- Defined in:
- lib/juli/wiki.rb
Overview
When new file is added:
-
The filename becomes wikiname.
-
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:
-
The filename (wikiname) is lost.
-
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
- .build_wikinames ⇒ Object
-
.decode(str) ⇒ Object
decode ‘(’, ‘)’.
-
.encode(str) ⇒ Object
encode(=escape) ‘(’, ‘)’.
-
.wikinames ⇒ Object
global name to return wikinames data, which is just string array ordered by length in descendant.
Class Method Details
.build_wikinames ⇒ Object
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 |
.wikinames ⇒ Object
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 |