Module: Burp

Defined in:
lib/burp_cms.rb,
lib/burp/engine.rb,
lib/burp/version.rb,
app/lib/burp/link.rb,
app/lib/burp/page.rb,
app/lib/burp/util.rb,
app/lib/burp/group.rb,
app/lib/burp/access.rb,
app/models/burp/menu.rb,
app/models/burp/file_model.rb,
app/models/burp/page_model.rb,
app/lib/burp/util/upload_handler.rb,
app/helpers/burp/application_helper.rb,
app/controllers/burp/error_controller.rb,
app/controllers/burp/files_controller.rb,
app/controllers/burp/links_controller.rb,
app/controllers/burp/menus_controller.rb,
app/controllers/burp/pages_controller.rb,
app/controllers/burp/groups_controller.rb,
app/controllers/burp/static_controller.rb,
app/controllers/burp/application_controller.rb

Overview

All paths to directories are expected to end with a slash.

Like this /home/darwin/

Defined Under Namespace

Modules: ApplicationHelper, Util Classes: Access, ApplicationController, CatchAllController, Engine, ErrorController, FileModel, FilesController, Group, GroupsController, Link, LinksController, Menu, MenusController, Page, PageModel, PagesController, StaticController

Constant Summary collapse

VERSION =
"1.7.1"
@@content_directory =
nil
@@access_builder =
nil
{}

Class Method Summary collapse

Class Method Details

.add_menu_processor(name, &block) ⇒ Object



92
93
94
# File 'lib/burp_cms.rb', line 92

def self.add_menu_processor(name, &block)
  @@menu_processors[name] = block
end

.content_directoryObject

Returns the content directory to use.



42
43
44
# File 'lib/burp_cms.rb', line 42

def self.content_directory
  Thread.current[:thread_local_content_directory] || @@content_directory || Rails.root.join('app/cms/').to_s
end

.find_page(path) ⇒ Object



16
17
18
19
20
21
# File 'lib/burp_cms.rb', line 16

def self.find_page(path)
  page_model = Burp::PageModel.find(path)
  if page_model 
    Page.new(:snippets => page_model.snippets, :title => page_model.title, :page_id => page_model.id, :meta_description => page_model.meta_description)
  end
end

.global_content_directory=(path) ⇒ Object

Sets the content directory



59
60
61
62
# File 'lib/burp_cms.rb', line 59

def self.global_content_directory=(path)
  raise "#{path} does not end with '/'" unless path.end_with?('/')
  @@content_directory = path
end


72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/burp_cms.rb', line 72

def self.menu(request)
  group = Group.new("") 
  group.children << Link.new(:name => "Pages", :url => "/burp/pages")
  if Burp::Menu.count == 1
    group.children << Link.new(:name => "Menu", :url => "/burp/menus/#{Burp::Menu.all.first.name}/edit")
  else
    group.children << Link.new(:name => "Menus", :url => "/burp/menus")
  end
  group.children << Link.new(:name => "Files", :url => "/burp/files")
  group.children << Link.new(:name => "Help", :url => "/burp/help", :class => "help-link")
  
  @@menu_processors.values.each do |block|
    block.call(group, request)
  end
  
  group
end

.new_access_instance(request, controller) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/burp_cms.rb', line 25

def self.new_access_instance(request, controller)
  if @@access_builder
    @@access_builder.call(request, controller)
  else
    Burp::Access.new
  end
end

.set_access_builder(&block) ⇒ Object



33
34
35
# File 'lib/burp_cms.rb', line 33

def self.set_access_builder &block
  @@access_builder = block
end

.thread_local_content_directory=(path) ⇒ Object

Sets the content directory for the current thread



67
68
69
70
# File 'lib/burp_cms.rb', line 67

def self.thread_local_content_directory=(path)
  raise "#{path} does not end with '/'" unless path.end_with?('/')
  Thread.current[:thread_local_content_directory] = path
end

.with_content_directory(path, &block) ⇒ Object

Runs the block with the content directory temporarly set to the supplied path



49
50
51
52
53
54
# File 'lib/burp_cms.rb', line 49

def self.with_content_directory(path,&block)
  self.thread_local_content_directory = path
  block.call
ensure  
  self.thread_local_content_directory = nil
end