Class: Controller

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/wiki/server.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.data_rootObject



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

#identityObject



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