| |   |
| 5 | 5 | #require './lib/merb_radiant.rb' |
| 6 | 6 | |
| 7 | 7 | module MerbRadiant |
| 8 | | VERSION = 0.1.0 |
| 8 | VERSION = "0.1.0" |
| 9 | 9 | end |
| 10 | 10 | |
| 11 | 11 | |
| … | … | |
| 25 | 25 | # Merb |
| 26 | 26 | ############################################################################## |
| 27 | 27 | |
| 28 | | require 'rubygems' |
| 29 | 28 | Gem.clear_paths |
| 30 | 29 | Gem.path.unshift(File.join(File.dirname(__FILE__), "gems")) |
| 31 | 30 | |
| 32 | 31 | require 'rake' |
| 33 | 32 | require 'rake/rdoctask' |
| 34 | 33 | require 'rake/testtask' |
| 35 | | require 'spec/rake/spectask' |
| 34 | #require 'spec/rake/spectask' |
| 36 | 35 | require 'fileutils' |
| 37 | 36 | require 'merb-core' |
| 38 | 37 | require 'rubigen' |
| … | … | |
| 39 | 39 | $RAKE_ENV = true |
| 40 | 40 | |
| 41 | 41 | Merb.start :environment => (ENV['MERB_ENV'] || 'development'), |
| 42 | | :adapter => 'runner', |
| 43 | | :merb_root => File.dirname(__FILE__) |
| 42 | :adapter => 'runner', |
| 43 | :merb_root => File.dirname(__FILE__) |
| 44 | 44 | |
| 45 | 45 | include FileUtils |
| 46 | 46 | # # # Get Merb plugins and dependencies |
| toggle raw diff |
--- a/Rakefile
+++ b/Rakefile
@@ -5,7 +5,7 @@ require 'hoe'
#require './lib/merb_radiant.rb'
module MerbRadiant
- VERSION = 0.1.0
+ VERSION = "0.1.0"
end
@@ -25,14 +25,13 @@ end
# Merb
##############################################################################
-require 'rubygems'
Gem.clear_paths
Gem.path.unshift(File.join(File.dirname(__FILE__), "gems"))
require 'rake'
require 'rake/rdoctask'
require 'rake/testtask'
-require 'spec/rake/spectask'
+#require 'spec/rake/spectask'
require 'fileutils'
require 'merb-core'
require 'rubigen'
@@ -40,8 +39,8 @@ require 'rubigen'
$RAKE_ENV = true
Merb.start :environment => (ENV['MERB_ENV'] || 'development'),
- :adapter => 'runner',
- :merb_root => File.dirname(__FILE__)
+ :adapter => 'runner',
+ :merb_root => File.dirname(__FILE__)
include FileUtils
# # # Get Merb plugins and dependencies |
| |   |
| 0 | | class Admin::AbstractModelController < ApplicationController |
| 1 | | attr_accessor :cache |
| 2 | | |
| 3 | | def self.model_class(model_class = nil) |
| 4 | | @model_class = model_class.to_s.camelize.constantize unless model_class.nil? |
| 5 | | @model_class |
| 6 | | end |
| 7 | | |
| 8 | | def initialize |
| 9 | | super |
| 10 | | @cache = ResponseCache.instance |
| 11 | | end |
| 12 | | |
| 13 | | def index |
| 14 | | self.models = model_class.find(:all) |
| 15 | | end |
| 16 | | |
| 17 | | def new |
| 18 | | self.model = model_class.new |
| 19 | | render :template => "admin/#{ model_symbol }/edit" if handle_new_or_edit_post |
| 20 | | end |
| 21 | | |
| 22 | | def edit |
| 23 | | self.model = model_class.find_by_id(params[:id]) |
| 24 | | handle_new_or_edit_post |
| 25 | | end |
| 26 | | |
| 27 | | def remove |
| 28 | | self.model = model_class.find(params[:id]) |
| 29 | | if request.post? |
| 30 | | model.destroy |
| 31 | | announce_removed |
| 32 | | redirect_to model_index_url |
| 33 | | end |
| 34 | | end |
| 35 | | |
| 36 | | protected |
| 37 | | |
| 38 | | def model_class |
| 39 | | self.class.model_class |
| 40 | | end |
| 41 | | |
| 42 | | def model |
| 43 | | instance_variable_get("@#{model_symbol}") |
| 44 | | end |
| 45 | | def model=(object) |
| 46 | | instance_variable_set("@#{model_symbol}", object) |
| 47 | | end |
| 48 | | |
| 49 | | def models |
| 50 | | instance_variable_get("@#{plural_model_symbol}") |
| 51 | | end |
| 52 | | def models=(objects) |
| 53 | | instance_variable_set("@#{plural_model_symbol}", objects) |
| 54 | | end |
| 55 | | |
| 56 | | def model_name |
| 57 | | model_class.name |
| 58 | | end |
| 59 | | def plural_model_name |
| 60 | | model_name.pluralize |
| 61 | | end |
| 62 | | |
| 63 | | def model_symbol |
| 64 | | model_name.underscore.intern |
| 65 | | end |
| 66 | | def plural_model_symbol |
| 67 | | model_name.pluralize.underscore.intern |
| 68 | | end |
| 69 | | |
| 70 | | def humanized_model_name |
| 71 | | model_name.underscore.humanize |
| 72 | | end |
| 73 | | |
| 74 | | def model_index_url(params = {}) |
| 75 | | send("#{ model_symbol }_index_url", params) |
| 76 | | end |
| 77 | | |
| 78 | | def model_edit_url(params = {}) |
| 79 | | send("#{ model_symbol }_edit_url", params) |
| 80 | | end |
| 81 | | |
| 82 | | def continue_url(options) |
| 83 | | options[:redirect_to] || (params[:continue] ? model_edit_url(:id => model.id) : model_index_url) |
| 84 | | end |
| 85 | | |
| 86 | | def save |
| 87 | | model.save |
| 88 | | end |
| 89 | | |
| 90 | | def announce_saved(message = nil) |
| 91 | | flash[:notice] = message || "#{humanized_model_name} saved below." |
| 92 | | end |
| 93 | | |
| 94 | | def announce_validation_errors |
| 95 | | flash[:error] = "Validation errors occurred while processing this form. Please take a moment to review the form and correct any input errors before continuing." |
| 96 | | end |
| 97 | | |
| 98 | | def announce_removed |
| 99 | | flash[:notice] = "#{humanized_model_name} has been deleted." |
| 100 | | end |
| 101 | | |
| 102 | | def announce_update_conflict |
| 103 | | flash[:error] = "#{humanized_model_name} has been modified since it was last loaded. Changes cannot be saved without potentially losing data." |
| 104 | | end |
| 105 | | |
| 106 | | def clear_model_cache |
| 107 | | cache.clear |
| 108 | | end |
| 109 | | |
| 110 | | def handle_new_or_edit_post(options = {}) |
| 111 | | options.symbolize_keys |
| 112 | | if request.post? |
| 113 | | model.attributes = params[model_symbol] |
| 114 | | begin |
| 115 | | if save |
| 116 | | clear_model_cache |
| 117 | | announce_saved(options[:saved_message]) |
| 118 | | redirect_to continue_url(options) |
| 119 | | return false |
| 120 | | else |
| 121 | | announce_validation_errors |
| 122 | | end |
| 123 | | rescue ActiveRecord::StaleObjectError |
| 124 | | announce_update_conflict |
| 125 | | end |
| 126 | | end |
| 127 | | true |
| 128 | | end |
| 129 | | end |
| toggle raw diff |
--- a/app/controllers/admin/abstract_model_controller.rb
+++ /dev/null
@@ -1,130 +0,0 @@
-class Admin::AbstractModelController < ApplicationController
- attr_accessor :cache
-
- def self.model_class(model_class = nil)
- @model_class = model_class.to_s.camelize.constantize unless model_class.nil?
- @model_class
- end
-
- def initialize
- super
- @cache = ResponseCache.instance
- end
-
- def index
- self.models = model_class.find(:all)
- end
-
- def new
- self.model = model_class.new
- render :template => "admin/#{ model_symbol }/edit" if handle_new_or_edit_post
- end
-
- def edit
- self.model = model_class.find_by_id(params[:id])
- handle_new_or_edit_post
- end
-
- def remove
- self.model = model_class.find(params[:id])
- if request.post?
- model.destroy
- announce_removed
- redirect_to model_index_url
- end
- end
-
- protected
-
- def model_class
- self.class.model_class
- end
-
- def model
- instance_variable_get("@#{model_symbol}")
- end
- def model=(object)
- instance_variable_set("@#{model_symbol}", object)
- end
-
- def models
- instance_variable_get("@#{plural_model_symbol}")
- end
- def models=(objects)
- instance_variable_set("@#{plural_model_symbol}", objects)
- end
-
- def model_name
- model_class.name
- end
- def plural_model_name
- model_name.pluralize
- end
-
- def model_symbol
- model_name.underscore.intern
- end
- def plural_model_symbol
- model_name.pluralize.underscore.intern
- end
-
- def humanized_model_name
- model_name.underscore.humanize
- end
-
- def model_index_url(params = {})
- send("#{ model_symbol }_index_url", params)
- end
-
- def model_edit_url(params = {})
- send("#{ model_symbol }_edit_url", params)
- end
-
- def continue_url(options)
- options[:redirect_to] || (params[:continue] ? model_edit_url(:id => model.id) : model_index_url)
- end
-
- def save
- model.save
- end
-
- def announce_saved(message = nil)
- flash[:notice] = message || "#{humanized_model_name} saved below."
- end
-
- def announce_validation_errors
- flash[:error] = "Validation errors occurred while processing this form. Please take a moment to review the form and correct any input errors before continuing."
- end
-
- def announce_removed
- flash[:notice] = "#{humanized_model_name} has been deleted."
- end
-
- def announce_update_conflict
- flash[:error] = "#{humanized_model_name} has been modified since it was last loaded. Changes cannot be saved without potentially losing data."
- end
-
- def clear_model_cache
- cache.clear
- end
-
- def handle_new_or_edit_post(options = {})
- options.symbolize_keys
- if request.post?
- model.attributes = params[model_symbol]
- begin
- if save
- clear_model_cache
- announce_saved(options[:saved_message])
- redirect_to continue_url(options)
- return false
- else
- announce_validation_errors
- end
- rescue ActiveRecord::StaleObjectError
- announce_update_conflict
- end
- end
- true
- end
-end |
| |   |
| 0 | | class Admin::LayoutController < Admin::AbstractModelController |
| 1 | | model_class Layout |
| 2 | | |
| 3 | | attr_accessor :cache |
| 4 | | |
| 5 | | only_allow_access_to :index, :new, :edit, :remove, |
| 6 | | :when => [:developer, :admin], |
| 7 | | :denied_url => { :controller => 'page', :action => 'index' }, |
| 8 | | :denied_message => 'You must have developer privileges to perform this action.' |
| 9 | | |
| 10 | | def initialize |
| 11 | | super |
| 12 | | @cache = ResponseCache.instance |
| 13 | | end |
| 14 | | |
| 15 | | def save |
| 16 | | saved = super |
| 17 | | model.pages.each { |page| @cache.expire_response(page.url) } if saved |
| 18 | | saved |
| 19 | | end |
| 20 | | end |
| toggle raw diff |
--- a/app/controllers/admin/layout_controller.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class Admin::LayoutController < Admin::AbstractModelController
- model_class Layout
-
- attr_accessor :cache
-
- only_allow_access_to :index, :new, :edit, :remove,
- :when => [:developer, :admin],
- :denied_url => { :controller => 'page', :action => 'index' },
- :denied_message => 'You must have developer privileges to perform this action.'
-
- def initialize
- super
- @cache = ResponseCache.instance
- end
-
- def save
- saved = super
- model.pages.each { |page| @cache.expire_response(page.url) } if saved
- saved
- end
-end
\ No newline at end of file |
| |   |
| 0 | | class Admin::PageController < Admin::AbstractModelController |
| 1 | | model_class Page |
| 2 | | before_filter :initialize_meta_rows_and_buttons, :only => [:new, :edit] |
| 3 | | attr_accessor :cache |
| 4 | | |
| 5 | | def initialize |
| 6 | | super |
| 7 | | @cache = ResponseCache.instance |
| 8 | | end |
| 9 | | |
| 10 | | def index |
| 11 | | @homepage = Page.find_by_parent_id(nil) |
| 12 | | end |
| 13 | | |
| 14 | | def new |
| 15 | | @page = request.get? ? Page.new_with_defaults(config) : Page.new |
| 16 | | @page.slug = params[:slug] |
| 17 | | @page.breadcrumb = params[:breadcrumb] |
| 18 | | @page.parent = Page.find_by_id(params[:parent_id]) |
| 19 | | render :action => :edit if handle_new_or_edit_post |
| 20 | | end |
| 21 | | |
| 22 | | def edit |
| 23 | | @page = Page.find(params[:id]) |
| 24 | | @old_page_url = @page.url |
| 25 | | handle_new_or_edit_post |
| 26 | | end |
| 27 | | |
| 28 | | def remove |
| 29 | | @page = Page.find(params[:id]) |
| 30 | | if request.post? |
| 31 | | announce_pages_removed(@page.children.count + 1) |
| 32 | | @page.destroy |
| 33 | | redirect_to page_index_url |
| 34 | | end |
| 35 | | end |
| 36 | | |
| 37 | | def clear_cache |
| 38 | | if request.post? |
| 39 | | @cache.clear |
| 40 | | announce_cache_cleared |
| 41 | | redirect_to page_index_url |
| 42 | | else |
| 43 | | render :text => 'Do not access this URL directly.' |
| 44 | | end |
| 45 | | end |
| 46 | | |
| 47 | | def add_part |
| 48 | | part = PagePart.new(params[:part]) |
| 49 | | @index = params[:index].to_i if params[:index] |
| 50 | | render(:partial => 'part', :object => part, :layout => false) |
| 51 | | end |
| 52 | | |
| 53 | | def children |
| 54 | | @parent = Page.find(params[:id]) |
| 55 | | @level = params[:level].to_i |
| 56 | | response.headers['Content-Type'] = 'text/html;charset=utf-8' |
| 57 | | render(:layout => false) |
| 58 | | end |
| 59 | | |
| 60 | | def tag_reference |
| 61 | | @class_name = params[:class_name] |
| 62 | | @display_name = @class_name.constantize.display_name |
| 63 | | end |
| 64 | | |
| 65 | | def filter_reference |
| 66 | | @filter_name = params[:filter_name] |
| 67 | | @display_name = (@filter_name + "Filter").constantize.filter_name rescue "<none>" |
| 68 | | end |
| 69 | | |
| 70 | | private |
| 71 | | |
| 72 | | def announce_saved(message = nil) |
| 73 | | flash[:notice] = message || "Your page has been saved below." |
| 74 | | end |
| 75 | | |
| 76 | | def announce_pages_removed(count) |
| 77 | | flash[:notice] = if count > 1 |
| 78 | | "The pages were successfully removed from the site." |
| 79 | | else |
| 80 | | "The page was successfully removed from the site." |
| 81 | | end |
| 82 | | end |
| 83 | | |
| 84 | | def announce_cache_cleared |
| 85 | | flash[:notice] = "The page cache was successfully cleared." |
| 86 | | end |
| 87 | | |
| 88 | | def initialize_meta_rows_and_buttons |
| 89 | | @buttons_partials ||= [] |
| 90 | | @meta ||= [] |
| 91 | | @meta << {:field => "slug", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 100}]} |
| 92 | | @meta << {:field => "breadcrumb", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 160}]} |
| 93 | | end |
| 94 | | |
| 95 | | def save |
| 96 | | parts = @page.parts |
| 97 | | parts_to_update = {} |
| 98 | | (params[:part]||{}).each {|k,v| parts_to_update[v[:name]] = v } |
| 99 | | |
| 100 | | parts_to_remove = [] |
| 101 | | @page.parts.each do |part| |
| 102 | | if(attrs = parts_to_update.delete(part.name)) |
| 103 | | part.attributes = part.attributes.merge(attrs) |
| 104 | | else |
| 105 | | parts_to_remove << part |
| 106 | | end |
| 107 | | end |
| 108 | | parts_to_update.values.each do |attrs| |
| 109 | | @page.parts.build(attrs) |
| 110 | | end |
| 111 | | if result = @page.save |
| 112 | | new_parts = @page.parts - parts_to_remove |
| 113 | | new_parts.each { |part| part.save } |
| 114 | | @page.parts = new_parts |
| 115 | | end |
| 116 | | result |
| 117 | | end |
| 118 | | |
| 119 | | def clear_model_cache |
| 120 | | @cache.expire_response(@old_page_url || @page.url) |
| 121 | | end |
| 122 | | end |
| toggle raw diff |
--- a/app/controllers/admin/page_controller.rb
+++ /dev/null
@@ -1,123 +0,0 @@
-class Admin::PageController < Admin::AbstractModelController
- model_class Page
- before_filter :initialize_meta_rows_and_buttons, :only => [:new, :edit]
- attr_accessor :cache
-
- def initialize
- super
- @cache = ResponseCache.instance
- end
-
- def index
- @homepage = Page.find_by_parent_id(nil)
- end
-
- def new
- @page = request.get? ? Page.new_with_defaults(config) : Page.new
- @page.slug = params[:slug]
- @page.breadcrumb = params[:breadcrumb]
- @page.parent = Page.find_by_id(params[:parent_id])
- render :action => :edit if handle_new_or_edit_post
- end
-
- def edit
- @page = Page.find(params[:id])
- @old_page_url = @page.url
- handle_new_or_edit_post
- end
-
- def remove
- @page = Page.find(params[:id])
- if request.post?
- announce_pages_removed(@page.children.count + 1)
- @page.destroy
- redirect_to page_index_url
- end
- end
-
- def clear_cache
- if request.post?
- @cache.clear
- announce_cache_cleared
- redirect_to page_index_url
- else
- render :text => 'Do not access this URL directly.'
- end
- end
-
- def add_part
- part = PagePart.new(params[:part])
- @index = params[:index].to_i if params[:index]
- render(:partial => 'part', :object => part, :layout => false)
- end
-
- def children
- @parent = Page.find(params[:id])
- @level = params[:level].to_i
- response.headers['Content-Type'] = 'text/html;charset=utf-8'
- render(:layout => false)
- end
-
- def tag_reference
- @class_name = params[:class_name]
- @display_name = @class_name.constantize.display_name
- end
-
- def filter_reference
- @filter_name = params[:filter_name]
- @display_name = (@filter_name + "Filter").constantize.filter_name rescue "<none>"
- end
-
- private
-
- def announce_saved(message = nil)
- flash[:notice] = message || "Your page has been saved below."
- end
-
- def announce_pages_removed(count)
- flash[:notice] = if count > 1
- "The pages were successfully removed from the site."
- else
- "The page was successfully removed from the site."
- end
- end
-
- def announce_cache_cleared
- flash[:notice] = "The page cache was successfully cleared."
- end
-
- def initialize_meta_rows_and_buttons
- @buttons_partials ||= []
- @meta ||= []
- @meta << {:field => "slug", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 100}]}
- @meta << {:field => "breadcrumb", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 160}]}
- end
-
- def save
- parts = @page.parts
- parts_to_update = {}
- (params[:part]||{}).each {|k,v| parts_to_update[v[:name]] = v }
-
- parts_to_remove = []
- @page.parts.each do |part|
- if(attrs = parts_to_update.delete(part.name))
- part.attributes = part.attributes.merge(attrs)
- else
- parts_to_remove << part
- end
- end
- parts_to_update.values.each do |attrs|
- @page.parts.build(attrs)
- end
- if result = @page.save
- new_parts = @page.parts - parts_to_remove
- new_parts.each { |part| part.save }
- @page.parts = new_parts
- end
- result
- end
-
- def clear_model_cache
- @cache.expire_response(@old_page_url || @page.url)
- end
-end |
| |   |
| 0 | | class Admin::UserController < Admin::AbstractModelController |
| 1 | | model_class User |
| 2 | | |
| 3 | | only_allow_access_to :index, :new, :edit, :remove, |
| 4 | | :when => :admin, |
| 5 | | :denied_url => {:controller => 'page', :action => :index}, |
| 6 | | :denied_message => 'You must have administrative privileges to perform this action.' |
| 7 | | |
| 8 | | def preferences |
| 9 | | @user = current_user |
| 10 | | if valid_params? |
| 11 | | handle_new_or_edit_post( |
| 12 | | :redirect_to => page_index_url, |
| 13 | | :saved_message => 'Your preferences have been saved.' |
| 14 | | ) |
| 15 | | else |
| 16 | | announce_bad_data |
| 17 | | end |
| 18 | | end |
| 19 | | |
| 20 | | def remove |
| 21 | | if current_user.id.to_s == params[:id].to_s |
| 22 | | announce_cannot_delete_self |
| 23 | | redirect_to user_index_url |
| 24 | | else |
| 25 | | super |
| 26 | | end |
| 27 | | end |
| 28 | | |
| 29 | | private |
| 30 | | |
| 31 | | def announce_cannot_delete_self |
| 32 | | flash[:error] = 'You cannot delete yourself.' |
| 33 | | end |
| 34 | | |
| 35 | | def announce_bad_data |
| 36 | | flash[:error] = 'Bad form data.' |
| 37 | | end |
| 38 | | |
| 39 | | def valid_params? |
| 40 | | hash = (params[:user] || {}).symbolize_keys |
| 41 | | (hash.keys - [:password, :password_confirmation, :email]).size == 0 |
| 42 | | end |
| 43 | | end |
| toggle raw diff |
--- a/app/controllers/admin/user_controller.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-class Admin::UserController < Admin::AbstractModelController
- model_class User
-
- only_allow_access_to :index, :new, :edit, :remove,
- :when => :admin,
- :denied_url => {:controller => 'page', :action => :index},
- :denied_message => 'You must have administrative privileges to perform this action.'
-
- def preferences
- @user = current_user
- if valid_params?
- handle_new_or_edit_post(
- :redirect_to => page_index_url,
- :saved_message => 'Your preferences have been saved.'
- )
- else
- announce_bad_data
- end
- end
-
- def remove
- if current_user.id.to_s == params[:id].to_s
- announce_cannot_delete_self
- redirect_to user_index_url
- else
- super
- end
- end
-
- private
-
- def announce_cannot_delete_self
- flash[:error] = 'You cannot delete yourself.'
- end
-
- def announce_bad_data
- flash[:error] = 'Bad form data.'
- end
-
- def valid_params?
- hash = (params[:user] || {}).symbolize_keys
- (hash.keys - [:password, :password_confirmation, :email]).size == 0
- end
-end |
| |   |
| 0 | | module Admin::NodeHelper |
| 1 | | |
| 2 | | def render_node(page, locals = {}) |
| 3 | | @current_node = page |
| 4 | | locals.reverse_merge!(:level => 0, :simple => false).merge!(:page => page) |
| 5 | | render :partial => 'node', :locals => locals |
| 6 | | end |
| 7 | | |
| 8 | | def show_all? |
| 9 | | @controller.action_name == 'remove' |
| 10 | | end |
| 11 | | |
| 12 | | def expanded_rows |
| 13 | | unless @expanded_rows |
| 14 | | @expanded_rows = case |
| 15 | | when rows = cookies[:expanded_rows] |
| 16 | | rows.split(',').map { |x| Integer(x) rescue nil }.compact |
| 17 | | else |
| 18 | | [] |
| 19 | | end |
| 20 | | |
| 21 | | if homepage and !@expanded_rows.include?(homepage.id) |
| 22 | | @expanded_rows << homepage.id |
| 23 | | end |
| 24 | | end |
| 25 | | @expanded_rows |
| 26 | | end |
| 27 | | |
| 28 | | def expanded |
| 29 | | show_all? || expanded_rows.include?(@current_node.id) |
| 30 | | end |
| 31 | | |
| 32 | | def padding_left(level) |
| 33 | | (level * 22) + 4 |
| 34 | | end |
| 35 | | |
| 36 | | def children_class |
| 37 | | unless @current_node.children.empty? |
| 38 | | if expanded |
| 39 | | " children-visible" |
| 40 | | else |
| 41 | | " children-hidden" |
| 42 | | end |
| 43 | | else |
| 44 | | " no-children" |
| 45 | | end |
| 46 | | end |
| 47 | | |
| 48 | | def virtual_class |
| 49 | | @current_node.virtual? ? " virtual": "" |
| 50 | | end |
| 51 | | |
| 52 | | def expander |
| 53 | | unless @current_node.children.empty? |
| 54 | | image((expanded ? "collapse" : "expand"), |
| 55 | | :class => "expander", :alt => 'toggle children', |
| 56 | | :title => '') |
| 57 | | else |
| 58 | | "" |
| 59 | | end |
| 60 | | end |
| 61 | | |
| 62 | | def icon |
| 63 | | icon_name = @current_node.virtual? ? 'virtual-page' : 'page' |
| 64 | | image(icon_name, :class => "icon", :alt => 'page-icon', :title => '') |
| 65 | | end |
| 66 | | |
| 67 | | def node_title |
| 68 | | %{<span class="title">#{ @current_node.title }</span>} |
| 69 | | end |
| 70 | | |
| 71 | | def page_type |
| 72 | | display_name = @current_node.class.display_name |
| 73 | | if display_name == 'Page' |
| 74 | | "" |
| 75 | | else |
| 76 | | %{<small class="info">(#{ display_name })</small>} |
| 77 | | end |
| 78 | | end |
| 79 | | |
| 80 | | def spinner |
| 81 | | image('spinner.gif', |
| 82 | | :class => 'busy', :id => "busy-#{@current_node.id}", |
| 83 | | :alt => "", :title => "", |
| 84 | | :style => 'display: none;') |
| 85 | | end |
| 86 | | end |
| toggle raw diff |
--- a/app/helpers/admin/node_helper.rb
+++ /dev/null
@@ -1,87 +0,0 @@
-module Admin::NodeHelper
-
- def render_node(page, locals = {})
- @current_node = page
- locals.reverse_merge!(:level => 0, :simple => false).merge!(:page => page)
- render :partial => 'node', :locals => locals
- end
-
- def show_all?
- @controller.action_name == 'remove'
- end
-
- def expanded_rows
- unless @expanded_rows
- @expanded_rows = case
- when rows = cookies[:expanded_rows]
- rows.split(',').map { |x| Integer(x) rescue nil }.compact
- else
- []
- end
-
- if homepage and !@expanded_rows.include?(homepage.id)
- @expanded_rows << homepage.id
- end
- end
- @expanded_rows
- end
-
- def expanded
- show_all? || expanded_rows.include?(@current_node.id)
- end
-
- def padding_left(level)
- (level * 22) + 4
- end
-
- def children_class
- unless @current_node.children.empty?
- if expanded
- " children-visible"
- else
- " children-hidden"
- end
- else
- " no-children"
- end
- end
-
- def virtual_class
- @current_node.virtual? ? " virtual": ""
- end
-
- def expander
- unless @current_node.children.empty?
- image((expanded ? "collapse" : "expand"),
- :class => "expander", :alt => 'toggle children',
- :title => '')
- else
- ""
- end
- end
-
- def icon
- icon_name = @current_node.virtual? ? 'virtual-page' : 'page'
- image(icon_name, :class => "icon", :alt => 'page-icon', :title => '')
- end
-
- def node_title
- %{<span class="title">#{ @current_node.title }</span>}
- end
-
- def page_type
- display_name = @current_node.class.display_name
- if display_name == 'Page'
- ""
- else
- %{<small class="info">(#{ display_name })</small>}
- end
- end
-
- def spinner
- image('spinner.gif',
- :class => 'busy', :id => "busy-#{@current_node.id}",
- :alt => "", :title => "",
- :style => 'display: none;')
- end
-end |
| |   |
| 0 | | module Admin::PageHelper |
| 1 | | include Admin::NodeHelper |
| 2 | | |
| 3 | | def meta_errors? |
| 4 | | !!(@page.errors[:slug] or @page.errors[:breadcrumb]) |
| 5 | | end |
| 6 | | |
| 7 | | def tag_reference(class_name) |
| 8 | | returning String.new do |output| |
| 9 | | class_name.constantize.tag_descriptions.sort.each do |tag_name, description| |
| 10 | | output << render(:partial => "tag_reference", |
| 11 | | :locals => {:tag_name => tag_name, :description => description}) |
| 12 | | end |
| 13 | | end |
| 14 | | end |
| 15 | | |
| 16 | | def filter_reference(filter_name) |
| 17 | | unless filter_name.blank? |
| 18 | | filter_class = (filter_name + "Filter").constantize |
| 19 | | filter_class.description.blank? ? "There is no documentation on this filter." : filter_class.description |
| 20 | | else |
| 21 | | "There is no filter on the current page part." |
| 22 | | end |
| 23 | | end |
| 24 | | |
| 25 | | def default_filter_name |
| 26 | | @page.parts.empty? ? "" : @page.parts[0].filter_id |
| 27 | | end |
| 28 | | |
| 29 | | def homepage |
| 30 | | @homepage ||= Page.find_by_parent_id(nil) |
| 31 | | end |
| 32 | | end |
| toggle raw diff |
--- a/app/helpers/admin/page_helper.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-module Admin::PageHelper
- include Admin::NodeHelper
-
- def meta_errors?
- !!(@page.errors[:slug] or @page.errors[:breadcrumb])
- end
-
- def tag_reference(class_name)
- returning String.new do |output|
- class_name.constantize.tag_descriptions.sort.each do |tag_name, description|
- output << render(:partial => "tag_reference",
- :locals => {:tag_name => tag_name, :description => description})
- end
- end
- end
-
- def filter_reference(filter_name)
- unless filter_name.blank?
- filter_class = (filter_name + "Filter").constantize
- filter_class.description.blank? ? "There is no documentation on this filter." : filter_class.description
- else
- "There is no filter on the current page part."
- end
- end
-
- def default_filter_name
- @page.parts.empty? ? "" : @page.parts[0].filter_id
- end
-
- def homepage
- @homepage ||= Page.find_by_parent_id(nil)
- end
-end |
| |   |
| 2 | 2 | Gem.clear_paths |
| 3 | 3 | Gem.path.unshift(Merb.root / "gems") |
| 4 | 4 | |
| 5 | |
| 5 | 6 | # Make the app's "lib" directory a place where ruby files get "require"d from |
| 6 | 7 | $LOAD_PATH.unshift(Merb.root / "lib") |
| 7 | 8 | |
| 9 | ### Uncomment for ActiveRecord ORM |
| 10 | use_orm :activerecord |
| 11 | |
| 12 | unless defined? RADIANT_ROOT |
| 13 | if File.directory?(root_path = "#{Merb.root}/vendor/radiant") |
| 14 | RADIANT_ROOT = root_path |
| 15 | else |
| 16 | environment = IO.readlines("#{File.dirname(__FILE__)}/radiant_environment.rb").reject { |l| l.strip =~ /^#/ }.join |
| 17 | environment =~ /[^#]\s*RADIANT_GEM_VERSION\s*=\s*(["'])([\d.]+)\1/ |
| 18 | version = $2 |
| 19 | |
| 20 | require 'rubygems' |
| 21 | if version and (radiant_gem = Gem.cache.search('radiant', version).first) |
| 22 | if self.class.method_defined?(:gem) |
| 23 | gem "radiant", "=#{version}" |
| 24 | require "radiant" |
| 25 | else |
| 26 | require_gem "radiant", "=#{version}" |
| 27 | end |
| 28 | else |
| 29 | STDERR.puts %( |
| 30 | Cannot find gem or source for Radiant #{version}: |
| 31 | Install the missing gem with 'gem install -v=#{version} radiant', or change |
| 32 | environment.rb to define RADIANT_GEM_VERSION with your desired version. |
| 33 | ) |
| 34 | exit 1 |
| 35 | end |
| 36 | end |
| 37 | end |
| 38 | |
| 39 | load File.join(RADIANT_ROOT, 'con |