Voog.com

Layout assets

Layout assets are stylesheets, images and fonts that are needed to build a site. These go hand in hand with layouts.

Summary of layout asset endpoints

List all available layout assets

GET /admin/api/layout_assets

Get list of layout assets of current site for active design.

Example response:

Status: 200 OK
[
  {
    "id": 1,
    "filename": "bg.gif",
    "asset_type": "image",
    "content_type": "image/gif",
    "size": 139,
    "width": 1000,
    "height": 800,
    "editable": false,
    "url": "http://helloworld.voog.co/admin/api/layout_assets/1",
    "public_url": "http://helloworld.voog.co/images/bg.gif",
    "created_at": "2014-01-01T15:28:24.000Z",
    "updated_at": "2014-01-01T15:28:24.000Z",
    "updater": {
      "id": 1,
      "email": "user@example.com",
      "firstname": "John",
      "lastname": "Smith",
      "name": "John Smith",
      "url": "http://helloworld.voog.co/admin/api/people/1
    }
  },
  {
    "id": 2,
    "filename": "style.css",
    "asset_type": "stylesheet",
    "content_type": "text/css",
    "size": 12016,
    "width": null,
    "height": null,
    "editable": true,
    "url": "http://helloworld.voog.co/admin/api/layout_assets/2",
    "public_url": "http://helloworld.voog.co/stylesheets/style.css",
    "created_at": "2014-01-01T15:28:24.000Z",
    "updated_at": "2014-01-01T15:28:24.000Z",
    "updater": {
      "id": 1,
      "email": "user@example.com",
      "firstname": "John",
      "lastname": "Smith",
      "name": "John Smith",
      "url": "http://helloworld.voog.co/admin/api/people/1
    }
  }
]

Parameters

  • per_page - elements per response (default: 50; maximum: 250).
  • page - requested page (default: 1).

Filter attributes

Read more about filters.

  • Object layout_asset attributes: id, filename, asset_type, content_type, size, width, height, updater_id, created_at, updated_at.
  • Object updater attributes: id, email, firstname, lastname. Applies only for custom design layouts.

Create a new layout asset

POST /admin/api/layout_assets

For text based files (CSS, JavaScript files), file content can be sent in data attribute.

For binary files (images, fonts), use a multi part POST request. The size and width/height parameters are read directly from the file itself (if present). Expected form field name for file is file.

NB! Creating a file is allowed only when current site is using custom design. See site site.custom_design attribute.

Example data (for text based files):

{
  "filename": "reset.css",
  "data": "h1, h2, h3, h4, h5, h6 { font-size:100%; }"
}

Example response:

Status: 201 Created
{
  "id": 3,
  "filename": "reset.css",
  "asset_type": "stylesheet",
  "content_type": "text/css",
  "size": 12016,
  "width": null,
  "height": null,
  "editable": true,
  "url": "http://helloworld.voog.co/admin/api/layout_assets/3",
  "public_url": "http://helloworld.voog.co/stylesheets/reset.css",
  "created_at": "2014-01-08T15:45:48.000Z",
  "updated_at": "2014-01-08T15:45:48.000Z",
  "updater": {
    "id": 1,
    "email": "user@example.com",
    "firstname": "John",
    "lastname": "Smith",
    "name": "John Smith",
    "url": "http://helloworld.voog.co/admin/api/people/1
  }
}

Parameters

Required minimum set of parameters are:

  • filename - unique filename.

Optional parameters:

  • data - file content as string.
  • file - multipart file object.
  • content_type - its automatically detected from file name when not present.

Get data for layout asset

GET /admin/api/layout_assets/1

Note that to get the asset itself, you should use the url provided in the path parameter in the response body.

Example request:

GET http://helloworld.voog.co/admin/api/layout_assets/3

Example response:

Status: 200 OK
{
  "id": 3,
  "filename": "reset.css",
  "asset_type": "stylesheet",
  "content_type": "text/css",
  "size": 12016,
  "width": null,
  "height": null,
  "editable": true,
  "url": "http://helloworld.voog.co/admin/api/layout_assets/3",
  "public_url": "http://helloworld.voog.co/stylesheets/reset.css",
  "created_at": "2014-01-08T15:45:48.000Z",
  "updated_at": "2014-01-08T15:45:48.000Z",
  "updater": {
    "id": 1,
    "email": "user@example.com",
    "firstname": "John",
    "lastname": "Smith",
    "name": "John Smith",
    "url": "http://helloworld.voog.co/admin/api/people/1
  }
}

Update attributes of layout asset

PUT /admin/api/layout_assets/1

This request updates the layout asset with provided attributes.

Update request is allowed only when current site is using custom design. See site site.custom_design attribute.

Example request:

PATCH http://helloworld.voog.co/admin/api/layout_assets/3

Example data:

{
  "data": "h1, h2, h3, h4, h5, h6 { font-size:100%; }"
}

Example response:

Status: 200 OK
{
  "id": 3,
  "filename": "reset.css",
  "asset_type": "stylesheet",
  "content_type": "text/css",
  "size": 12016,
  "width": null,
  "height": null,
  "editable": true,
  "url": "http://helloworld.voog.co/admin/api/layout_assets/3",
  "public_url": "http://helloworld.voog.co/stylesheets/reset.css",
  "created_at": "2014-01-08T15:45:48.000Z",
  "updated_at": "2014-01-08T16:00:00.000Z",
  "updater": {
    "id": 1,
    "email": "user@example.com",
    "firstname": "John",
    "lastname": "Smith",
    "name": "John Smith",
    "url": "http://helloworld.voog.co/admin/api/people/1
  }
}

Parameters

Accepted parameters:

  • data - file content as string or multipart file.

NB! File name nor file type are not changeable.

Remove layout asset

DELETE /admin/api/layout_assets/1

This request deletes the layout asset from the database.

Delete request is allowed only when current site is using custom design. See site site.custom_design attribute.

Example request:

DELETE http://helloworld.voog.co/admin/api/layout_assets/1

Example response:

Status: 204 No Content