Class: Nwiki::Core::Wiki
- Inherits:
-
Object
- Object
- Nwiki::Core::Wiki
- Defined in:
- lib/nwiki/core/wiki.rb
Class Method Summary collapse
Instance Method Summary collapse
- #author ⇒ Object
- #find(path) ⇒ Object
- #find_directory(path) ⇒ Object
- #find_page_or_file(path) ⇒ Object
-
#initialize(path) ⇒ Wiki
constructor
A new instance of Wiki.
- #log ⇒ Object
- #subtitle ⇒ Object
- #title ⇒ Object
Constructor Details
Class Method Details
.canonicalize_path(path) ⇒ Object
15 16 17 18 |
# File 'lib/nwiki/core/wiki.rb', line 15 def self.canonicalize_path path unescaped_path = URI.unescape(path).force_encoding(repo_filename_encoding) unescaped_path.sub(/^\//, '') end |
.parser ⇒ Object
11 12 13 |
# File 'lib/nwiki/core/wiki.rb', line 11 def self.parser Orgmode::Parser end |
.repo_filename_encoding ⇒ Object
7 8 9 |
# File 'lib/nwiki/core/wiki.rb', line 7 def self.repo_filename_encoding Encoding::UTF_8 end |
Instance Method Details
#author ⇒ Object
61 62 63 |
# File 'lib/nwiki/core/wiki.rb', line 61 def @access. end |
#find(path) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/nwiki/core/wiki.rb', line 25 def find path canonicalized_path = self.class.canonicalize_path path if canonicalized_path == '' find_directory(canonicalized_path) else find_page_or_file(canonicalized_path) end end |
#find_directory(path) ⇒ Object
47 48 49 50 51 |
# File 'lib/nwiki/core/wiki.rb', line 47 def find_directory path files = @access.all_files Directory.encoding = self.class.repo_filename_encoding Directory.new(path, files.map(&:path)) end |
#find_page_or_file(path) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nwiki/core/wiki.rb', line 34 def find_page_or_file path entry = @access.find_file do |entry_path| path == entry_path.sub(/\.org$/){ '' } end return nil unless entry if entry.path =~ /\.org$/ path = entry.path.sub(/\.org$/){ '' } Page.new(path, entry.text, self.class.parser) else File.new(entry.path, entry.content) end end |
#log ⇒ Object
65 66 67 |
# File 'lib/nwiki/core/wiki.rb', line 65 def log @access.log end |
#subtitle ⇒ Object
57 58 59 |
# File 'lib/nwiki/core/wiki.rb', line 57 def subtitle @access.subtitle end |
#title ⇒ Object
53 54 55 |
# File 'lib/nwiki/core/wiki.rb', line 53 def title @access.title end |