0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server
Hannah Wolfe 9eadeb9fbb Prep shared API URL util for use on external sites
refs #5942, #6150

There were a few key problems I was looking to solve with this:

- Introduce a single point of truth for what the URL for accessing the API should be
- Provide a simple way to configure the utility (much like a true SDK)

As of this commit, this utility is still automatically available in a Ghost theme.
To use it on an external site, the code would look like:

```
<script type="text/javascript" src="http://my-ghost-blog.com/shared/ghost-url.min.js"></script>
<script type="text/javascript">
ghost.init({
   clientId: "<your-client-id>",
   clientSecret: "<your-client-secret>"
});
</script>
```

To achieve this, there have been a number of changes:

- A new `apiUrl` function has been added to config, which calculates the correct URL. This needs to be unified with the other url generation functions as a separate piece of work.
- The serveSharedFile middleware has been updated, so that it can serve files from / or /shared and to substitute `{{api-url}}` as it does `{{blog-url}}`.
- ghost-url.js and ghost-url.min.js have been updated to be served via the serveSharedFile middleware
- ghost-url.js has been changed slightly, to take the url from an inline variable which is substituted the first time it is served
- `{{ghost_head}}` has been updated, removing the api url handling which is now in config/url.js and removing the configuration of the utility in favour of calling `init()` after the script is required
- `{{ghost_head}}` has also had the meta tags for client id and secret removed
- tests have been updated
2015-12-15 11:50:46 +00:00
..
api Cache permalinks & postsPerPage on config.theme 2015-12-15 08:16:53 +00:00
apps fixing 'undefined is not a function' error when loading apps 2015-12-04 23:00:37 -06:00
config Prep shared API URL util for use on external sites 2015-12-15 11:50:46 +00:00
controllers Cache permalinks & postsPerPage on config.theme 2015-12-15 08:16:53 +00:00
data Cache permalinks & postsPerPage on config.theme 2015-12-15 08:16:53 +00:00
errors No more soft 404s in pagination 2015-12-10 15:00:02 +00:00
events Set a higher maxListeners value 2015-10-09 19:27:49 +01:00
helpers Prep shared API URL util for use on external sites 2015-12-15 11:50:46 +00:00
mail Email error message cleanup 2015-10-16 12:07:09 +02:00
middleware Prep shared API URL util for use on external sites 2015-12-15 11:50:46 +00:00
models Cache permalinks & postsPerPage on config.theme 2015-12-15 08:16:53 +00:00
permissions Public API 2015-10-22 15:28:47 +02:00
routes No more soft 404s in pagination 2015-12-10 15:00:02 +00:00
storage deps: grunt-jscs@2.1.0 2015-10-12 19:21:16 +01:00
translations foundation work for server-side i18n support: 2015-07-27 18:47:10 -04:00
utils Change server-side labs utility to be synchronous 2015-12-03 16:05:50 +00:00
views Fixup broken error page styles 2015-06-08 12:14:58 +01:00
filters.js Misc grunt /dev updates 2015-05-28 20:25:14 +01:00
ghost-server.js Startup message explicitly mentions production 2015-08-11 18:01:36 +01:00
i18n.js foundation work for server-side i18n support: 2015-07-27 18:47:10 -04:00
index.js Email error message cleanup 2015-10-16 12:07:09 +02:00
update-check.js Remove forum mentions 2015-09-29 13:10:04 +02:00