From c331e069755fc775281d26209667007b87187c2c Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Fri, 19 Feb 2016 18:18:14 +0000 Subject: [PATCH] Restructure Configuration API endpoint refs #6421, #6525 - The configuration API endpoint was a bit of an animal: - It's used currently in two ways, once for general config, another for the about page. - These two things are different, and would require different permissions in future. - There was also both a browse and a read version, even though only browse was used. - The response from the browse was being artificially turned into many objects, when its really just one with multiple keys - The new version treats each type of config as a different single object with several keys - The new version therefore only has a 'read' request - A basic read request with no key will return basic config that any client would need - A read request with the about key returns the about config - A read request with a different key could therefore return some other config --- ghost/admin/app/index.html | 8 ++++---- ghost/admin/app/routes/about.js | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ghost/admin/app/index.html b/ghost/admin/app/index.html index 1b3d24e432..fddadc8673 100644 --- a/ghost/admin/app/index.html +++ b/ghost/admin/app/index.html @@ -31,13 +31,13 @@ - {{#each configuration}} - + {{#each configuration as |config key|}} + {{/each}} - {{#unless skip_google_fonts}} + {{#if configuration.useGoogleFonts.value}} - {{/unless}} + {{/if}} diff --git a/ghost/admin/app/routes/about.js b/ghost/admin/app/routes/about.js index f20db7a353..36a7a9bc4f 100644 --- a/ghost/admin/app/routes/about.js +++ b/ghost/admin/app/routes/about.js @@ -18,7 +18,7 @@ export default AuthenticatedRoute.extend(styleBody, { model() { let cachedConfig = this.get('cachedConfig'); - let configUrl = this.get('ghostPaths.url').api('configuration'); + let configUrl = this.get('ghostPaths.url').api('configuration', 'about'); if (cachedConfig) { return cachedConfig; @@ -26,12 +26,8 @@ export default AuthenticatedRoute.extend(styleBody, { return this.get('ajax').request(configUrl) .then((configurationResponse) => { - let configKeyValues = configurationResponse.configuration; + let [cachedConfig] = configurationResponse.configuration; - cachedConfig = {}; - configKeyValues.forEach((configKeyValue) => { - cachedConfig[configKeyValue.key] = configKeyValue.value; - }); this.set('cachedConfig', cachedConfig); return cachedConfig;