class Admin::PostBuilder

Public Class Methods

new(object_name, object, template, options) click to toggle source
Calls superclass method
# File lib/ecrire/app/forms/admin/post_builder.rb, line 4
def initialize(object_name, object, template, options)
  if object.draft?
    options[:html][:class] << 'autosave'
  end
  super
end

Public Instance Methods

action() click to toggle source
# File lib/ecrire/app/forms/admin/post_builder.rb, line 31
def action
  if object.published?
    button 'Save', value: 'save', form: "postEditor"
  else
    button 'Publish', value: 'publish', form: "postEditor"
  end
end
editor() click to toggle source
# File lib/ecrire/app/forms/admin/post_builder.rb, line 21
def editor
  content_tag :section, class: %w(textareas) do
    [
      text_area(:content, placeholder: t('.content'), class: %w(content active), target: 'content'),
      text_area(:stylesheet, placeholder: t('.stylesheet'), class: %w(stylesheet), target: 'stylesheet'),
      text_area(:javascript, placeholder: t('.javascript'), class: %w(javascript), target: 'javascript')
    ].join.html_safe
  end
end
errors() click to toggle source
# File lib/ecrire/app/forms/admin/post_builder.rb, line 11
def errors
  return unless object.errors.any?
  content_tag :div, class: %w(container errors) do
    [
      content_tag(:span, h(object.errors.full_messages.to_sentence)),
      link_to("x", "javascript:void(0)", class: %w(dismiss button))
    ].join.html_safe
  end
end
method_missing(method, *args, &block) click to toggle source
# File lib/ecrire/app/forms/admin/post_builder.rb, line 43
def method_missing(method, *args, &block)
  @template.send(method, *args, &block)
end
t(*args) click to toggle source
# File lib/ecrire/app/forms/admin/post_builder.rb, line 39
def t(*args)
  I18n.t args[0], scope: %w(admin form post)
end