| Class | Site |
| In: |
app/models/site.rb
|
| Parent: | ActiveRecord::Base |
A Site can be a BaselineProcess (static, published website from EPF) or a Wiki, which is an enhanced EPFC site. Baseline Processes are used to create or update Wiki sites.
Creation or update of a Wiki is a two step process for performance reasons. This way the second step can be performed using a job that runs at night.
More information:
array of HTML files that are candate Wikification
# File app/models/site.rb, line 97
97: def self.files_html(path)
98: paths = Array.new
99: (Dir.entries(path) - [".", ".."]).each do |entry|
100: new_path = File.expand_path(entry, path)
101: if FileTest.directory?(new_path)
102: paths = paths + Site.files_html(new_path)
103: else
104: paths << new_path if !HTML_FILE_PATTERN.match(entry).nil? && WIKI_FILE_PATTERN.match(entry).nil?
105: end
106: end
107: return paths
108: end
Method templates returns current versions of pages from the Wiki ‘Templates’. These pages are templates for creating new pages.
# File app/models/site.rb, line 77
77: def self.templates
78: w = Wiki.find_by_title('Templates')
79: raise "No Templates Wiki was found. There should always be a Wiki with title 'Templates' to provide templates for creating new pages" if !w
80: returning tpls = [] do
81: w.pages.each do |p|
82: tpls << p.current_version if p.current_version # NOTE: a new checked out Template has no current version
83: end
84: end
85: end
# File app/models/site.rb, line 58
58: def baseline_process?
59: return self.class.name == 'BaselineProcess'
60: end
# File app/models/site.rb, line 44
44: def baseline_processes_candidate
45: returning bp_candidate = [] do
46: if self.status == 'Ready' # TODO
47: Site.find_baseline_processes.each do |bp|
48: bp_candidate << bp unless self.baselines.include?(bp.baseline)
49: end
50: end
51: end
52: end
# File app/models/site.rb, line 40
40: def content_scanned?
41: return !self.content_scanned_on.nil?
42: end
# File app/models/site.rb, line 110
110: def files_wikifiable
111: raise 'Path can\'t be blank' if self.path.blank?
112: logger.info("Finding wikifiable files in #{self.path}")
113: returning paths = [] do
114: Site.files_html(self.path).each do |path2|
115: #logger.info("#{path2}")
116: paths << path2 unless Page::ELEMENT_TYPE_PATTERN.match(IO.readlines(path2).join("\n")).nil?
117: end
118: end
119: end
# File app/models/site.rb, line 62
62: def path
63: return "#{ENV['EPFWIKI_ROOT_DIR']}#{ENV['EPFWIKI_PUBLIC_FOLDER']}/#{ENV['EPFWIKI_WIKIS_FOLDER']}/#{self.folder}" if self.wiki?
64: return "#{ENV['EPFWIKI_ROOT_DIR']}#{ENV['EPFWIKI_PUBLIC_FOLDER']}/#{ENV['EPFWIKI_SITES_FOLDER']}/#{self.folder}"
65: end
# File app/models/site.rb, line 67
67: def rel_path
68: return self.path.gsub(ENV['EPFWIKI_ROOT_DIR'] + "#{ENV['EPFWIKI_PUBLIC_FOLDER']}/",'')
69: end
# File app/models/site.rb, line 87
87: def unzip_upload
88: logger.info("Unzipping upload #{self.path2zip}")
89: raise "Folder #{self.path} exists" if File.exists?(self.path)
90: cmdline = "unzip -q \"#{self.path2zip}\" -d \"#{self.path}\""
91: logger.debug("Executing command #{cmdline}")
92: unzip_success = system(cmdline)
93: raise "Error executing command #{cmdline}: #{$?}" if !unzip_success
94: end