diff --git a/Gemfile b/Gemfile index 7b98eda..37f5eaa 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,2 @@ -# A sample Gemfile -source "https://rubygems.org" -gem 'github-pages' \ No newline at end of file +source 'https://rubygems.org' +gem 'github-pages', group: :jekyll_plugins diff --git a/README.md b/README.md index 7af2b16..00995cb 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,64 @@ -# WP-API Documentation Site -This repository is the source for -[WP-API's documentation](http://wp-api.github.io). We're working on making this -documentation [the best in the world][gh-1], but we're not there yet! +# WP REST API Documentation Site -[gh-1]: https://github.com/WP-API/WP-API.github.io/issues/1 +This repository is the source for [wp-api.org][gh-1]. It powers documentation for the +[WP REST API (WP-API)][gh-2] plugin. We are working on making this documentation +the [best in the world][gh-3], but we're not there yet! -## Running locally +**[Read the Docs ☞][gh-1]** + +[gh-1]: http://wp-api.org +[gh-2]: https://github.com/WP-API/WP-API +[gh-3]: https://github.com/WP-API/WP-API.github.io/issues/1 + + +## Running Locally + +This site is hosted on Github pages and powered by Jekyll. + + ```bash + bundle install + bundle exec jekyll serve -w + ``` + +then visit `localhost:4000` in your favorite browser. You can learn more about +using Jekyll and Github pages from their [documentation](https://help.github.com/articles/using-jekyll-with-pages/). + +### Using Vagrant We recommend using Vagrant. Here's how you do that: -```bash -$ vagrant up -$ vagrant ssh - -# Following commands are now executed on the box -# These install everything you need -$ cd /vagrant -$ sudo apt-get update -$ sudo apt-get install ruby1.9.3 rubygems make -$ sudo gem install bundler -$ bundle install - -# To run the site: -$ jekyll serve -``` + ```bash + $ vagrant up + $ vagrant ssh + + # Following commands are now executed on the box + # These install everything you need + $ cd /vagrant + $ sudo apt-get update + $ sudo apt-get install ruby1.9.3 rubygems make + $ sudo gem install bundler + $ bundle install + + # To run the site: + $ jekyll serve + ``` + + +## Style Guide + +This guide is a limited implementation of [Carwin's Markdown Style Guidelines](https://github.com/carwin/markdown-styleguide). + +- Wrap all lines at 80 characters. +- Denote **bold** text using the asterisk format: `**bold text**`. +- Denote _italic_ text using the underscore format: `_emphasized text_`. +- Force a linebreak by ending a line with two spaces, no more. +- Header text must use the `atx-style` with no closing `#` character. +- Include a space between the `#` and the text of the Header. +- List item lines exceeding 80 characters should, when wrapped, align + vertically with the beginning of the preceding line's text. +- **Inline code** must use single backticks and must not have spaces between + the backtick characters and the code. +- **Fenced code blocks** must be preceded and followed by a newline. +- When used inside _list items_, **fenced code blocks** must be indented as if + they were one level deeper that the list item that contains them. + diff --git a/_config.yml b/_config.yml index 02941f8..413e2cb 100644 --- a/_config.yml +++ b/_config.yml @@ -1,5 +1,9 @@ baseurl: / -pygments: true +encoding: utf-8 +highlighter: pygments markdown: kramdown kramdown: input: GFM + line_width: 80 +gems: + - jekyll-redirect-from diff --git a/_includes/header.html b/_includes/header.html index 5996781..80399c9 100644 --- a/_includes/header.html +++ b/_includes/header.html @@ -3,14 +3,16 @@
-

WP REST API

+

WP REST API (v1 – Deprecated)

diff --git a/_layouts/guide.html b/_layouts/guide.html index 9d295c2..af6a7ac 100644 --- a/_layouts/guide.html +++ b/_layouts/guide.html @@ -1,5 +1,5 @@ --- -title: WP REST API Documentation +title: WP REST API (v1) Documentation - deprecated --- @@ -16,12 +16,12 @@ - + - - + + {% include header.html %} diff --git a/_layouts/internals.html b/_layouts/internals.html index 6dd4f80..10b2b7d 100644 --- a/_layouts/internals.html +++ b/_layouts/internals.html @@ -1,5 +1,5 @@ --- -title: WP REST API Documentation +title: WP REST API (v1) Documentation - deprecated --- @@ -16,12 +16,12 @@ - + - - + + {% include header.html %} diff --git a/guides.md b/guides.md index 0e529cb..54852bd 100644 --- a/guides.md +++ b/guides.md @@ -1,5 +1,5 @@ --- -title: WP REST API Documentation +title: WP REST API (v1) Documentation - deprecated layout: guide --- Guides diff --git a/guides/authentication.md b/guides/authentication.md index 6f22219..9f24a7f 100644 --- a/guides/authentication.md +++ b/guides/authentication.md @@ -1,5 +1,5 @@ --- -title: WP REST API Documentation +title: WP REST API (v1) Documentation - deprecated layout: guide --- Authentication @@ -29,7 +29,7 @@ Custom data models can extend `wp.api.models.Base` to ensure this is sent correctly for any custom requests. For developers making manual Ajax requests, the nonce will need to be passed -with each request. The API uses nonces with the action set to `wp_api`. These +with each request. The API uses nonces with the action set to `wp_json`. These can then be passed to the API via the `_wp_json_nonce` data parameter (either POST data or in the query for GET requests), or via the `X-WP-Nonce` header. @@ -72,6 +72,7 @@ you'll need to create a "consumer". This is an identifier for the application, and includes a "key" and "secret", both needed to link to your site. To create the consumer, run the following on your server: + ```bash $ wp oauth1 add diff --git a/guides/extending.md b/guides/extending.md index d013bb1..1469027 100644 --- a/guides/extending.md +++ b/guides/extending.md @@ -355,5 +355,5 @@ improving the built-in APIs. * [Internal Implementation][]: Learn about how the REST server works internally. [API Philosophy]: ../internals/philosophy.html -[Schema]: ../schema.html +[Schema]: ../../ [Internal Implementation]: ../internals/implementation.html diff --git a/guides/getting-started.md b/guides/getting-started.md index b9c05da..a8af490 100644 --- a/guides/getting-started.md +++ b/guides/getting-started.md @@ -473,6 +473,6 @@ get exploring! * [Authentication][auth]: Explore authentication options [Working with Posts]: working-with-posts.html -[schema]: ../schema.html -[auth]: ../authentication.html +[schema]: ../../ +[auth]: authentication.html [basic-auth-plugin]: https://github.com/WP-API/Basic-Auth diff --git a/guides/working-with-posts.md b/guides/working-with-posts.md index e0b57e2..be0aaea 100644 --- a/guides/working-with-posts.md +++ b/guides/working-with-posts.md @@ -4,25 +4,16 @@ layout: guide --- Working with Posts ================== -Back in the [Getting Started][] guide we used posts to demonstrate how to work -with the API, but only touched on some of the details. Let's take a more -detailed look at the Post API. +Back in the [Getting Started][] guide we used posts to demonstrate how to work with the API, but only touched on some of the details. Let's take a more detailed look at the Post API. Before We Start --------------- -This guide assumes you have a basic knowledge of the API, as well as the -prerequisites noted in the [Getting Started] guide. If you haven't already, make -sure you read that guide to ensure you know the basics. +This guide assumes you have a basic knowledge of the API, as well as the prerequisites noted in the [Getting Started] guide. If you haven't already, make sure you read that guide to ensure you know the basics. -This guide also assumes that you know how to send requests given how to use -them, so the examples will be HTTP requests. I recommend reading the cURL manual -or using a higher level tool if you don't know how to wrangle cURL. +This guide also assumes that you know how to send requests given how to use them, so the examples will be HTTP requests. I recommend reading the cURL manual or using a higher level tool if you don't know how to wrangle cURL. -The examples also pretend that your JSON base URL (`wp-json` in the main WP -directory) is located at `/`, which is probably not the case. For example, if -your base URL is `http://example.com/wp-json` and the example request is -`GET /posts`, you should should actually send the following: +The examples also pretend that your JSON base URL (`wp-json` in the main WP directory) is located at `/`, which is probably not the case. For example, if your base URL is `http://example.com/wp-json` and the example request is `GET /posts`, you should should actually send the following: GET /wp-json/posts HTTP/1.1 Host: example.com @@ -32,40 +23,22 @@ Higher level HTTP clients can usually handle this for you. Post Entities and Collections ----------------------------- -As mentioned previously, we can send a GET request to the main posts route to -get posts: +As mentioned previously, we can send a GET request to the main posts route to get posts: GET /posts HTTP/1.1 -This returns a list of Post objects. From a technical point of view, each object -is called an Entity (in this case, Post Entities), while the endpoint returns a -Collection (here, a Post Collection). +This returns a list of Post objects. From a technical point of view, each object is called an Entity (in this case, Post Entities), while the endpoint returns a Collection (here, a Post Collection). -Post Entities have certain [defined properties][schema], although which are set -depend on the context. For example, with embedded entities certain properties -may have different values; while the post parent entity is embedded, the parent -field inside this is only the ID. +Post Entities have certain [defined properties][schema], although which are set depend on the context. For example, with embedded entities certain properties may have different values; while the post parent entity is embedded, the parent field inside this is only the ID. Collection Views ---------------- -Post Collections can be modified by using various query string parameters. One -that you may already know is the `page` parameter. This parameter is used for -pagination, and while you can set it manually, it's also sent via the Link -headers to point you to the next and previous pages. A `context` parameter is -also available that we'll talk about later. +Post Collections can be modified by using various query string parameters. One that you may already know is the `page` parameter. This parameter is used for pagination, and while you can set it manually, it's also sent via the Link headers to point you to the next and previous pages. A `context` parameter is also available that we'll talk about later. -You can also change the post type via the `type` parameter. It's recommended -that you check the [available post types](#custom-post-types) before doing this, -as plugins may change what's available. +You can also change the post type via the `type` parameter. It's recommended that you check the [available post types](#custom-post-types) before doing this, as plugins may change what's available. -The last parameter is the `filter` parameter. This gives you full access to the -[WP_Query][] parameters, to alter the query to your liking. Depending on the -level of access you have, not all parameters will be available, so check the -[schema][] for the available parameters. A good assumption to make is that -anything you can put in a query on the site itself (such as `?s=...` for -searches) will be available. You can specify filter parameters in a request -using [array-style URL formatting][]. +The last parameter is the `filter` parameter. This gives you full access to the [WP_Query][] parameters, to alter the query to your liking. Depending on the level of access you have, not all parameters will be available, so check the [schema][] for the available parameters. A good assumption to make is that anything you can put in a query on the site itself (such as `?s=...` for searches) will be available. You can specify filter parameters in a request using [array-style URL formatting][]. Creating and Editing Posts @@ -79,22 +52,11 @@ The main posts route also has a creation endpoint: "title": "My Post Title" } -Here we send a Post entity that we've created locally to the server. These Post -entities are the same as Post entities served up by the server, but excluding -some fields which are immutable. For example, the ID and timezone fields cannot -be changed. +Here we send a Post entity that we've created locally to the server. These Post entities are the same as Post entities served up by the server, but excluding some fields which are immutable. For example, the ID and timezone fields cannot be changed. -When editing posts, it's helpful to pass the `edit` context along with your -request. This gives you extra data useful for editing, such as the unfiltered -content and title. This is not required, however it is recommended, as the -normal content and title fields have been filtered to correct HTML (such as via -the `wpautop` function), making them less than optimal for editing. +When editing posts, it's helpful to pass the `edit` context along with your request. This gives you extra data useful for editing, such as the unfiltered content and title. This is not required, however it is recommended, as the normal content and title fields have been filtered to correct HTML (such as via the `wpautop` function), making them less than optimal for editing. -You can also pass an `If-Unmodified-Since` header when editing posts with the -previous modification date to ensure that you don't accidentally overwrite edits -made in the meantime. Note that while dates in the `modified` field of the post -are in [RFC3339][] format, this header requires the use of [RFC1123][] (similar -to [RFC822][]). (Sorry about that, but the HTTP standard requires it.) +You can also pass an `If-Unmodified-Since` header when editing posts with the previous modification date to ensure that you don't accidentally overwrite edits made in the meantime. Note that while dates in the `modified` field of the post are in [RFC3339][] format, this header requires the use of [RFC1123][] (similar to [RFC822][]). (Sorry about that, but the HTTP standard requires it.) [RFC3339]: http://tools.ietf.org/html/rfc3339 [RFC1123]: http://tools.ietf.org/html/rfc1123 @@ -103,13 +65,9 @@ to [RFC822][]). (Sorry about that, but the HTTP standard requires it.) Custom Post Types ----------------- -Custom post types can be queried via the main post routes (`/posts` and -children) when they have been made public. The type can be set via the `type` -query parameter. +Custom post types can be queried via the main post routes (`/posts` and children) when they have been made public. The type can be set via the `type` query parameter. -Before working with custom post types, you should first check that the API has -support for the post type that you want to work with. This data is available via -the read-only APIs at `/posts/types`: +Before working with custom post types, you should first check that the API has support for the post type that you want to work with. This data is available via the read-only APIs at `/posts/types`: GET /posts/types HTTP/1.1 @@ -207,11 +165,7 @@ This should return a list of the available types: } } -The `meta.links.archives` value gives a nicer way to access given post type -archives for HATEOAS supporters and should always be used rather than manually -setting the `type` parameter directly, as CPTs may create their own route -structure instead. The `labels` fields should also always be used when -displaying the field, as these are run through WordPress' translations. +The `meta.links.archives` value gives a nicer way to access given post type archives for HATEOAS supporters and should always be used rather than manually setting the `type` parameter directly, as CPTs may create their own route structure instead. The `labels` fields should also always be used when displaying the field, as these are run through WordPress' translations. A similar API exists for post statuses at `/posts/statuses`: @@ -277,15 +231,12 @@ A similar API exists for post statuses at `/posts/statuses`: Next Steps ---------- -You should now understand more advanced usage of the post-related APIs, and be -able to implement a fully compliant client for the API. You might now want to -take a look at the other APIs, or look at documentation on the specifics. +You should now understand more advanced usage of the post-related APIs, and be able to implement a fully compliant client for the API. You might now want to take a look at the other APIs, or look at documentation on the specifics. -* [Schema][schema]: Full documentation of every parameter for the APIs. * [Extending the API][]: Create your own API endpoints. [Getting Started]: getting-started.html [Extending the API]: extending.html -[schema]: ../schema.html +[schema]: ../../ [WP_Query]: http://codex.wordpress.org/Class_Reference/WP_Query [array-style URL formatting]: ../compatibility.html#inputting-data-as-an-array diff --git a/index-deprecated.html b/index-deprecated.html new file mode 100644 index 0000000..50ebcfc --- /dev/null +++ b/index-deprecated.html @@ -0,0 +1,107 @@ +--- +title: WP REST API (v1) Documentation - deprecated +--- + + + + + + + + {{ page.title }} + + + + + + + + + + + + + + + + + + + +{% include header.html %} + +
+ +{% include sidebar.html %} + +

This site is for the legacy version (v1) of the API. View Version 2 Documentation

+ +
+
+ +{% include footer.html %} diff --git a/index.html b/index.html index a37697d..5be2320 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,7 @@ --- -title: WP API Documentation +title: WP REST API Documentation +redirect_to: + - http://v2.wp-api.org/ --- @@ -10,96 +12,42 @@ {{ page.title }} - - - - - - - + - - - - - + + -{% include header.html %} + + +
+ +
+ + +
+
{% include sidebar.html %} -
+ + +
{% include footer.html %} diff --git a/internals.md b/internals.md index 666b2b1..50cdda0 100644 --- a/internals.md +++ b/internals.md @@ -1,5 +1,5 @@ --- -title: WP REST API Documentation +title: WP REST API (v1) Documentation - deprecated layout: internals --- Internals diff --git a/internals/implementation.md b/internals/implementation.md index ea77134..7046097 100644 --- a/internals/implementation.md +++ b/internals/implementation.md @@ -1,5 +1,5 @@ --- -title: WP REST API Documentation +title: WP REST API (v1) Documentation - deprecated layout: internals --- diff --git a/internals/philosophy.md b/internals/philosophy.md index dd4ed8b..9e6a9ce 100644 --- a/internals/philosophy.md +++ b/internals/philosophy.md @@ -1,5 +1,5 @@ --- -title: WP REST API Documentation +title: WP REST API (v1) Documentation - deprecated layout: internals --- diff --git a/internals/release-process.md b/internals/release-process.md index a855760..06c260f 100644 --- a/internals/release-process.md +++ b/internals/release-process.md @@ -1,34 +1,60 @@ --- -title: WP REST API Documentation +title: WP REST API (v1) Documentation - deprecated layout: internals --- Release Process =============== -Here's the process used to generate new releases for the API plugin. -* Write changelog items for this release. Generate these automatically with the - following script: +Time to cook up a new release? Here's the recipe for the baker. - SINCE=$1 - if [[ -z $SINCE ]]; then - echo "usage: changelog " - exit 1 - fi +1. Bump the version in the code (key parts are the plugin header, and version +constant, but grepping is the best way to find them all) - OUTPUT=$(git log $SINCE... --reverse --format="format:- %w(80,0,4)%B") - OUTPUT=$(echo "$OUTPUT" | awk -v nlines=2 "/^ *git-svn-id:/ {for (i=0; i code:hover::-webkit-scrollbar-thumb { font-weight: bold; display: inline-block; padding: 3px 25px; - border: solid 2px #2badad; - -webkit-border-radius: 20px; - border-radius: 20px; + -webkit-border-radius: 3px; + border-radius: 3px; margin-right: 15px; } .button, .button:visited { - background: #2badad; + background: #008CBA; color: #fff; text-shadow: none; } @@ -599,6 +598,9 @@ body.no-literate .content pre > code:hover::-webkit-scrollbar-thumb { .header h1 a:hover { color: #505050; } +.header h1 span { + font-size: 0.78em; +} .header li a { font-size: 0.78em; color: #eff0f1; @@ -608,6 +610,12 @@ body.no-literate .content pre > code:hover::-webkit-scrollbar-thumb { .header li a:hover { color: #6ABCDD; } +.header li a.v2-link { + background: #008CBA; + border-radius: 3px; + text-align: center; +} + @media (min-width: 480px) /* Tablet & Desktop */ { .header h1 { float: left; @@ -836,4 +844,14 @@ code .comment { .title-area > div { position: relative; z-index: 1; -} \ No newline at end of file +} +.v2-pointer { + padding-top: 3em; + width: 100%; + text-align: center; + font-family: Open Sans,sans-serif; +} +.v2-pointer .button { + font-size: 2em; + margin: 0 0 1em 0; +}