Class: Controller
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Controller
- Defined in:
- lib/wiki/server.rb
Class Method Summary collapse
Instance Method Summary collapse
- #data_dir(site) ⇒ Object
- #farm_page(site = request.host) ⇒ Object
- #farm_status(site = request.host) ⇒ Object
- #identity ⇒ Object
Class Method Details
.data_root ⇒ Object
37 38 39 |
# File 'lib/wiki/server.rb', line 37 def data_root File.join APP_ROOT, "data" end |
Instance Method Details
#data_dir(site) ⇒ Object
57 58 59 |
# File 'lib/wiki/server.rb', line 57 def data_dir(site) Store.farm?(self.class.data_root) ? File.join(self.class.data_root, "farm", site) : self.class.data_root end |
#farm_page(site = request.host) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/wiki/server.rb', line 42 def farm_page(site=request.host) page = Page.new page.directory = File.join data_dir(site), "pages" page.default_directory = File.join APP_ROOT, "default-data", "pages" page.plugins_directory = File.join APP_ROOT, "node_modules" Store.mkdir page.directory page end |
#farm_status(site = request.host) ⇒ Object
51 52 53 54 55 |
# File 'lib/wiki/server.rb', line 51 def farm_status(site=request.host) status = File.join data_dir(site), "status" Store.mkdir status status end |
#identity ⇒ Object
61 62 63 64 65 66 |
# File 'lib/wiki/server.rb', line 61 def identity default_path = File.join APP_ROOT, "default-data", "status", "local-identity" real_path = File.join farm_status, "local-identity" id_data = Store.get_hash real_path id_data ||= Store.put_hash(real_path, FileStore.get_hash(default_path)) end |