Class: Integral::Backend::BlockListsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/integral/backend/block_lists_controller.rb

Overview

Block Lists controller

Instance Method Summary collapse

Methods inherited from BaseController

#activities, #activity, #create, #destroy, #duplicate, #edit, #list, #new, #update

Instance Method Details

#block_listsObject

Maybe able to get rid of the content here



40
41
42
43
44
# File 'app/controllers/integral/backend/block_lists_controller.rb', line 40

def block_lists
  res = BlockEditor::BlockList.reusable.map { |block_list| { id: block_list.id, title: { raw: block_list.name }, content: block_list.content } }

  render json: res, status: 200, layout: false
end

#current_policyBasePolicy

Returns current authorization policy.

Returns:



34
35
36
# File 'app/controllers/integral/backend/block_lists_controller.rb', line 34

def current_policy
  policy(Integral::Page.new)
end

#indexObject



8
9
10
# File 'app/controllers/integral/backend/block_lists_controller.rb', line 8

def index
  redirect_to list_backend_block_lists_url
end

#showObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/integral/backend/block_lists_controller.rb', line 12

def show
  if params["_locale"].present?
    block_list = BlockEditor::BlockList.reusable.find(params[:id])
    res = {
      id: block_list.id,
      status: "publish",
      name: "wp_block",
      title: {
        raw: block_list.name
      },
      content: {
        raw: block_list.content
      }
    }

    render json: res, status: 200, layout: false
  else
    redirect_to edit_backend_block_list_url(@resource.id)
  end
end

#wp_typeObject



46
47
48
# File 'app/controllers/integral/backend/block_lists_controller.rb', line 46

def wp_type
  render json: { "rest_base" => "block_list" }, status: 200, layout: false
end

#wp_typesObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/integral/backend/block_lists_controller.rb', line 50

def wp_types
  res = {
    "wp_block" => {
      "rest_base": "block_lists",
      "labels": {
        "singular_name": "Block Lists"
      }
    }
  }

  render json: res, status: 200, layout: false
end