Module: Fir
- Defined in:
- lib/fir/boot.rb,
lib/fir/util.rb,
lib/fir/admin.rb,
lib/fir/pages.rb,
lib/fir/tasks.rb,
lib/fir/static.rb,
lib/fir/helpers.rb,
lib/fir/generator.rb
Defined Under Namespace
Modules: AdminMiddleware, Helpers, Tasks, TemplateLoading
Classes: AdminAuth, AdminInterface, ErbAdapter, Generator, MarkdownAdapter, NoOpAdapter, PageRenderer, Static, TemplateAdapter
Class Method Summary
collapse
Class Method Details
.clear_cache(page) ⇒ Object
Page is a path such as you would find in a URL, not a local filesystem path
3
4
5
6
7
8
9
|
# File 'lib/fir/util.rb', line 3
def self.clear_cache(page)
directory, filename, ext = Fir.split_path(page)
path = File.join(FIR_ROOT, 'public/cache', directory, filename + '.html')
if File.exists?(path)
File.delete(path)
end
end
|
.config {|@config| ... } ⇒ Object
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/fir/util.rb', line 11
def self.config
@config ||= OpenStruct.new
yield @config if block_given?
@config.perform_caching = true if @config.force_caching
@config.perform_caching ||= false
@config.relative_url_root ||= ''
@config
end
|
.encrypt_password(password, salt) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/fir/util.rb', line 22
def self.encrypt_password(password, salt)
crypted_password = password + salt
3.times do
crypted_password = Digest::SHA512.hexdigest(crypted_password)
end
crypted_password
end
|
.generate!(args) ⇒ Object
2
3
4
|
# File 'lib/fir/generator.rb', line 2
def self.generate!(args)
::Fir::Generator.new.generate!(args)
end
|
.load_support_files ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/fir/util.rb', line 30
def self.load_support_files
Dir.glob(File.join(FIR_ROOT, 'helpers', '*.rb')).each do |helper_file|
require File.expand_path(helper_file)
mod_name = File.basename(helper_file, File.extname(helper_file)).classify
begin
mod = Object.const_get(mod_name)
rescue NameError
raise "Expected helpers/#{helper_file} to define #{mod_name}"
end
ErbAdapter.send(:include, mod)
end
end
|
.sanitize_page(page) ⇒ Object
43
44
45
|
# File 'lib/fir/util.rb', line 43
def self.sanitize_page(page)
page.gsub('../', '')
end
|
.split_path(path) ⇒ Object
returns [directories, name w/o extension, extension]
48
49
50
51
52
53
|
# File 'lib/fir/util.rb', line 48
def self.split_path(path)
ext = File.extname(path)
dirname = File.dirname(path)
dirname = '' if dirname == '.'
[dirname, File.basename(path, ext), ext]
end
|
.validate_config ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/fir/util.rb', line 55
def self.validate_config
unless @config
raise 'Fir cannot start unless you call Fir.config in config.rb.'
end
missing_options = [:site_name, :perform_caching, :relative_url_root].inject([]) do |missing, opt|
missing << opt if @config.send(opt).nil?
missing
end
unless missing_options.empty?
raise "Fir.config (in config.rb) is missing the following options: #{missing_options.join(', ')}"
end
end
|