Skip to content

Instantly share code, notes, and snippets.

@dbouwman
Last active May 17, 2016 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbouwman/2dcffb9935be273516f6a1fc3e5d470a to your computer and use it in GitHub Desktop.
Save dbouwman/2dcffb9935be273516f6a1fc3e5d470a to your computer and use it in GitHub Desktop.
Sites, Themes, Styles Oh My

Sites, Themes, Stylesheets Oh My

Definitions

Site

This contains the whole site object graph, including but not limited to:

  • site name, baseUrl etc
  • the basemap, initial extent
  • the layout (header/sections/footer)
  • the theme (see below)
  • the stylesheets (see below)

Theme

This contains a nested hash of colors, heights, images etc, that is both passes to the css generator service, AND which can be used directly by applications.

Apps that wish to simply apply a stylesheet should also request this resource and inject the approprite stylesheet.

Stylesheets

This is a nested hash of named stylesheets which have been generated usign the .theme

Routes

Site /api/v2/sites/:id

This is the main CRUD resource for sites. PUT/PATCH/DELETE requests require the Authorization header that must contain a valid ArcGIS Online Token.

The same payload will round-trip, but changes to the .stylesheets node will be ignored by the server-side.

On POST or PATCH the server side will use the .theme node to generate new stylesheets.

Example Payload

GET /api/v2/sites/484

{
  "data": {
    "id": "484",
    "type": "site",
    "attributes": {
      "title": "Jupe222 BETA Site",
      "url": "http://jupe222.dc.opendatadev.arcgis.com",
      "public": true,
      "updatedAt": "2016-05-17T14:46:57.594Z",
      "uiVersion": "2.0",
      "updatedBy": "dcadmin",
      "subdomain": "jupe222",
      "defaultExtent": {
        "type": "extent",
        "xmin": -8793683.17521301,
        "ymin": 4234636.76755458,
        "xmax": -8711084.11304442,
        "ymax": 4311221.63239462,
        "spatialReference": {
          "wkid": 102100
        }
      },
      "layout": {
        "sections": [],
        "footer": {},
        "header": {}
      },
      "theme": {
      	"logo":{
      	 	"primary": {
           		"url":"http://foo.bar.com/path/to/image.png"
         	}
        },
        "brand": {
          "primary": "#136fbf",
          "secondary": "#a9a9a9",
          "gray": "#4c4c4c"
        },
        "body": {
          "bg": "#f8f8f8"
        },
        "text": {
          "color": "#4C4C4C"
        }
      },
      "stylesheets":{
        "opendata":{
          "current": "//opendatadev.arcgis.com/api/v2/sites/jupe42.dc.opendatadev.arcgis.com/theme/stylesheets/opendata-459d72a83e10ad82c169a350aa52c3cf2a213f1e.css",
          "evergreen": "//opendatadev.arcgis.com/api/v2/sites/jupe42.dc.opendatadev.arcgis.com/theme/stylesheets/opendata.css"
        }
      }
    }
  },
  "meta": {
    "apiRoot": "https://opendatadev.arcgis.com/api/v2",
    "resourceRoot": "https://opendatadev.arcgis.com/api/v2/sites",
    "request": "https://opendatadev.arcgis.com/api/v2/sites/484?"
  }
}

Theme /api/v2/sites/:domain/theme

The theme is a public, GET-only resource that is simply a short-cut to getting the .theme node for a site.

It is functionally equivalent to /api/v2/sites/:id?fields[sites]=theme

GET /api/v2/sites/jupe42.dc.opendatadev.arcgis.com/theme

{
  "data": {
    "id": "484",
    "type": "site",
    "attributes": {
       {
        "logo":{
          "primary": {
              "url":"http://foo.bar.com/path/to/image.png"
          }
        },
        "brand": {
          "primary": "#136fbf",
          "secondary": "#a9a9a9",
          "gray": "#4c4c4c"
        },
        "body": {
          "bg": "#f8f8f8"
        },
        "text": {
          "color": "#4C4C4C"
        }
      }
    }
  },
  "meta": {
    "apiRoot": "https://opendatadev.arcgis.com/api/v2",
    "resourceRoot": "https://opendatadev.arcgis.com/api/v2/sites",
    "request": "https://opendatadev.arcgis.com/api/v2/sites/jupe42.dc.opendatadev.arcgis.com/theme"
  }
}

Stylesheets /api/v2/sites/:domain/stylesheets

The stylesheets is a public, GET-only resource that is simply a short-cut to getting the .stylesheets node for a site.

It is functionally equivalent to /api/v2/sites/:id?fields[sites]=stylesheets

GET /api/v2/sites/jupe42.dc.opendatadev.arcgis.com/stylesheets

{
  "data": {
    "id": "484",
    "type": "site",
    "attributes": {
       "opendata":{
         "current": "http://opendatadev.arcgis.com/api/v2/sites/jupe42.dc.opendatadev.arcgis.com/theme/stylesheets/opendata-459d72a83e10ad82c169a350aa52c3cf2a213f1e.css",
         "evergreen": "http://opendatadev.arcgis.com/api/v2/sites/jupe42.dc.opendatadev.arcgis.com/theme/stylesheets/opendata"
       } 
     },
  "meta": {
    "apiRoot": "https://opendatadev.arcgis.com/api/v2",
    "resourceRoot": "https://opendatadev.arcgis.com/api/v2/sites",
    "request": "https://opendatadev.arcgis.com/api/v2/sites/jupe42.dc.opendatadev.arcgis.com/stylesheets"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment