Sha256: 130f6a8e6cd4263d01188e6a737fa659bb2cee6fcff3ea559136e17414786ded

Contents?: true

Size: 1.21 KB

Versions: 14

Compression:

Stored size: 1.21 KB

Contents

module Pulitzer
  module PostsHelper

    def link_to_posts(post_type, plural_label, singular_label)
      if post_type.plural?
        link_to plural_label, posts_path(post_type_id: post_type.id)
      else
        link_to singular_label, edit_post_path(post_type.singleton_post)
      end
    end

    def link_back_to_posts(post_type, plural_label, singular_label)
      if post_type.plural?
        link_to plural_label, pulitzer.posts_path(post_type_id: post_type.id)
      else
        link_to singular_label, pulitzer.post_types_path
      end
    end

    def render_video(element)
      content_tag(:iframe, nil, src: element.video_link) if element.video_link
    end

    def render_element(element)
      if element.image_type?
        image_tag(element.image_url(:thumb)) if element.image?
      elsif element.video_type?
        render_video(element)
      else
        element.body.html_safe if element.body
      end
    end

    def humanize_class_name(klass)
      underscore_class_name(klass).humanize
    end

    def underscore_class_name(klass)
      klass.delete(":").underscore
    end

    def select2_html_options(tag_model)
      { class: 'seletct2-pulitzer-tags', data: { select2_trigger: true } }
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pulitzer-0.13.1 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.12.5 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.13.0 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.12.4 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.12.3 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.12.2 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.12.1 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.12.0 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.11.3 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.11.2 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.11.1 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.11.0 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.10.3 app/helpers/pulitzer/posts_helper.rb
pulitzer-0.10.2 app/helpers/pulitzer/posts_helper.rb