Module: Virgo::Admin::PostHelper
- Defined in:
- app/helpers/virgo/admin/post_helper.rb
Instance Method Summary collapse
- #admin_post_category_options(category = nil, depth = 0) ⇒ Object
- #admin_post_month_options ⇒ Object
- #admin_post_status_options ⇒ Object
Instance Method Details
#admin_post_category_options(category = nil, depth = 0) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/virgo/admin/post_helper.rb', line 26 def (category=nil, depth=0) = [] if category.nil? categories = Category.top_level else categories = [category] end categories.each do |cat| # base case spaces = (0..depth-1).map{|i| " " }.join("") select_option = ["#{spaces}#{cat.name}".html_safe, cat.id] << select_option cat.children.each do |child| += (child, depth + 1) end end end |
#admin_post_month_options ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/virgo/admin/post_helper.rb', line 4 def return [] if Post.where.not(publish_at: nil).empty? min_date = Post.minimum(:publish_at).try(:to_date) max_date = Time.now.to_date date_range = min_date..max_date month_names = [] added = {} date_range.map {|d| date = Date.new(d.year, d.month, 1) if added[date].nil? month_names << [date.to_s(:month_and_year), date.to_s(:db)] added[date] = true end }.uniq month_names.reverse end |
#admin_post_status_options ⇒ Object
49 50 51 |
# File 'app/helpers/virgo/admin/post_helper.rb', line 49 def Post.status_names end |