Module: Admin::PostsHelper

Defined in:
lib/ecrire/app/helpers/admin/posts_helper.rb

Instance Method Summary collapse

Instance Method Details

#edit_content_tag(post) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ecrire/app/helpers/admin/posts_helper.rb', line 15

def (post)
   :article, id: 'PostBody', postid: @post.id,
    class: %w(content),
    as: 'Editor.Content',
    contenteditable: true,
    href: admin_post_path(@post.id) do |div|

      namespace = Pathname.new(Rails.application.secrets.s3['namespace'] || '')

      if Rails.application.secrets.has_key?(:s3)
        div['data-bucket'] = Rails.application.secrets.s3['bucket']
        div['data-url'] = Rails.application.secrets.s3['url']
        div['data-access-key'] = Rails.application.secrets.s3['access_key']
        div['data-signature'] = image_form_signature(image_form_policy(@post))
        div['data-policy'] = image_form_policy(@post)
        div['data-namespace'] = namespace + @post.id.to_s
      end

      yield if block_given?
    end
end

#post_tags(post) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/ecrire/app/helpers/admin/posts_helper.rb', line 4

def (post)
  if post.tags.any?
    tags = post.tags.map(&:name).join(', ') << '.'
  else
    tags = 'No tag yet.'
  end

  tags << ' ' << link_to('Change tags', (post), remote: true)
   :div, tags.html_safe, class: %w(tags), as: 'Post.Tags'
end