Skip to content

Commit

Permalink
added some more jails and helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kronn committed Apr 23, 2010
1 parent 2041591 commit 1de3141
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 17 deletions.
8 changes: 7 additions & 1 deletion engines/adva_blog/app/models/blog.rb
Expand Up @@ -6,6 +6,12 @@ def permalinks
end
end

if Rails.plugin?(:adva_safemode)
class Jail < Section::Jail
allow :archive_months, :article_counts_by_month, :articles_by_month
end
end

class << self
def content_type
'Article'
Expand All @@ -23,4 +29,4 @@ def article_counts_by_month
def articles_by_month
@articles_by_month ||= articles.published.group_by(&:published_month)
end
end
end
10 changes: 9 additions & 1 deletion engines/adva_calendar/app/helpers/calendar_events_helper.rb
Expand Up @@ -23,4 +23,12 @@ def event_dates_from_to(event)
return [event.start_date, event.end_date].compact
end
end
end

def month_navigation_url_helper
Proc.new do |date|
link_to(date.strftime(t(:'date.formats.calendar_header', :default => "%B")),
calendar_events_path({:section_id => @section.id, :year => date.year, :month => date.month}),
:class => :nav)
end
end
end
8 changes: 7 additions & 1 deletion engines/adva_calendar/app/models/calendar.rb
@@ -1,6 +1,12 @@
class Calendar < Section
has_many :events, :foreign_key => 'section_id', :class_name => 'CalendarEvent'


if Rails.plugin?(:adva_safemode)
class Jail < Section::Jail
allow :days_in_month_with_events, :events, :id
end
end

class << self
def content_type
'CalendarEvent'
Expand Down
2 changes: 1 addition & 1 deletion engines/adva_calendar/app/models/calendar_event.rb
Expand Up @@ -81,7 +81,7 @@ class CalendarEvent < ActiveRecord::Base
if Rails.plugin?(:adva_safemode)
class Jail < Safemode::Jail
allow :start_date, :end_date, :title, :user, :section, :tags, :assets, :categories, :permalink, :body, :body_html
allow :all_day?
allow :all_day?, :host, :draft?, :published?, :require_end_date?
end
end

Expand Down
2 changes: 1 addition & 1 deletion engines/adva_cms/app/models/article.rb
Expand Up @@ -14,7 +14,7 @@ class Article < Content

if Rails.plugin?(:adva_safemode)
class Jail < Content::Jail
# allow :title, :permalink, :type, :body, :comments, :author, :section, :categories, :published_at, :version
allow :primary?, :previous, :next, :has_excerpt?
end
end

Expand Down
4 changes: 2 additions & 2 deletions engines/adva_cms/lib/extensible_forms.rb
Expand Up @@ -94,7 +94,7 @@ def add_callback(stage, object_name, method, callback)
class Jail < Safemode::Jail
allow :select, :date_select, :datetime_select, :time_select, :time_zone_select, :collection_select,
:hidden_field, :label, :fields_for, :apply_form_for_options!, :field_set, :tabs, :tab, :buttons,
:render, :text_field, :password_field, :text_area, :submit
:render, :text_field, :password_field, :text_area, :submit, :check_box
end
end

Expand Down Expand Up @@ -295,4 +295,4 @@ def extract_id(tag)
end
end

ActionView::Base.default_form_builder = ExtensibleFormBuilder
ActionView::Base.default_form_builder = ExtensibleFormBuilder
6 changes: 5 additions & 1 deletion engines/adva_forum/app/helpers/forum_helper.rb
Expand Up @@ -58,4 +58,8 @@ def topic_attributes(topic, format = nil)
attrs << t(:'adva.topics.states.locked') if topic.locked?
(format || '%s') % attrs.join(', ') if attrs.present?
end
end

def anonymous_user
User.anonymous
end
end
2 changes: 1 addition & 1 deletion engines/adva_forum/app/models/post.rb
Expand Up @@ -9,7 +9,7 @@ class Post < Comment

if Rails.plugin?(:adva_safemode)
class Jail < Comment::Jail
allow :board
allow :board, :==
end
end

Expand Down
3 changes: 2 additions & 1 deletion engines/adva_forum/app/models/topic.rb
Expand Up @@ -23,6 +23,7 @@ class Topic < ActiveRecord::Base
if Rails.plugin?(:adva_safemode)
class Jail < Safemode::Jail
allow :permalink, :title, :section, :board, :last_post, :locked?, :sticky?, :site, :posts_count, :activities, :last_updated_at, :last_author_name, :author_name
allow :new_record?, :initial_post, :previous, :next, :last_page, :page, :paged?, :accept_comments?
end
end

Expand Down Expand Up @@ -131,4 +132,4 @@ def decrement_counter
section.posts_counter.decrement_by!(posts_count)
board.posts_counter.decrement_by!(posts_count) if board
end
end
end
Expand Up @@ -51,6 +51,7 @@ def delegate_methods(methods = [])
:time_zone_options_for_select, :time_zone_select, :translate,
:truncate, :url_for, :word_wrap ]
methods += [ :will_paginate ] #FIXME this is from a plugin
methods += [ :current_user, :calendar_for, :wikipage_path_with_home ] # this should be taken care of by helpermethods...
methods += ActionController::Routing::Routes.named_routes.helpers
methods.flatten.map(&:to_sym).uniq
end
Expand Down
14 changes: 7 additions & 7 deletions plugins/adva_safemode/lib/safemode/rails_ext.rb
Expand Up @@ -17,13 +17,13 @@ class Jail < RequestJail
module ActiveSupport
class TimeWithZone
class Jail < Safemode::Jail
allow %w(blank? duplicable? present?
_dump asctime ctime day dst? getgm getlocal getutc gmt?
gmt_offset gmtime gmtoff hash hour httpdate isdst iso8601
localtime mday min minus_without_duration mon month
plus_without_duration rfc2822 rfc822 sec strftime succ to_date
to_datetime to_f to_i tv_sec tv_usec usec utc utc? utc_offset
wday xmlschema yday year zone to_formatted_s).map(&:to_sym)
allow :blank?, :duplicable?, :present?
allow :_dump, :asctime, :ctime, :day, :dst?, :getgm, :getlocal, :getutc, :gmt?
allow :gmt_offset, :gmtime, :gmtoff, :hash, :hour, :httpdate, :isdst, :iso8601
allow :localtime, :mday, :min, :minus_without_duration, :mon, :month
allow :plus_without_duration, :rfc2822, :rfc822, :sec, :strftime, :succ, :to_date
allow :to_datetime, :to_f, :to_i, :tv_sec, :tv_usec, :usec, :utc, :utc?, :utc_offset
allow :wday, :xmlschema, :yday, :year, :zone, :to_formatted
end
end
end
Expand Down

0 comments on commit 1de3141

Please sign in to comment.