-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API proof of concept: forums#show #665
base: rails4
Are you sure you want to change the base?
Commits on Jul 2, 2015
-
API proof of concept: forums#show
* route is /api/forums/:id (may be slug) * versioning is done via Accept header * views are built with jbuilder * authentication is done via session cookies (or whatever the host app is using)
Configuration menu - View commit details
-
Copy full SHA for 780197a - Browse repository at this point
Copy the full SHA 780197aView commit details
Commits on Jul 7, 2015
-
Configuration menu - View commit details
-
Copy full SHA for 2df1654 - Browse repository at this point
Copy the full SHA 2df1654View commit details -
Configuration menu - View commit details
-
Copy full SHA for f0520c1 - Browse repository at this point
Copy the full SHA f0520c1View commit details
Commits on Jul 8, 2015
-
JSON API compliance: relationships go inside data.
Also abstracted some test code, in anticipation of including both topics and posts.
Configuration menu - View commit details
-
Copy full SHA for 6080de5 - Browse repository at this point
Copy the full SHA 6080de5View commit details -
Added posts count and views count.
Posts count only includes posts the current user is allowed to know about.
Configuration menu - View commit details
-
Copy full SHA for 676b2f6 - Browse repository at this point
Copy the full SHA 676b2f6View commit details
Commits on Jul 9, 2015
-
Configuration menu - View commit details
-
Copy full SHA for 1d8d680 - Browse repository at this point
Copy the full SHA 1d8d680View commit details
Commits on Jul 12, 2015
-
Allow topics to be created without first posts.
The standard UI automatically creates a post when a topic is created, but API-based UIs might not. Previously an error would be raised when creating a topic with no post, and also when approving it. Alternatively, if we want to require an initial post, we should add a validation.
Configuration menu - View commit details
-
Copy full SHA for 7e8ad68 - Browse repository at this point
Copy the full SHA 7e8ad68View commit details -
I ran into an issue where `/api/topics` was routed to TopicsController#index with a `forum_id` of `"api"`. With this change, `/api/` routes go to the API. This is a temporary fix, as it creates other problems if someone decides to start a forum called "API". We could add `api` to the reserved words list for Friendly ID, but some installations may already have an API forum. We could give the API routes a prefix that can't be generated by Friendly ID's default generator (e.g., `@api`). Or we could get rid of the prefix entirely, and just use the `Accepts` header to determine whether a request is for the HTML UI or the API.
Configuration menu - View commit details
-
Copy full SHA for c5a78c3 - Browse repository at this point
Copy the full SHA c5a78c3View commit details -
This API controller inherits basic authorization and flow control from the HTML UI controller, and overrides methods to return results via JSON API. Alternatives include: 1. Build all-new controllers for the API (as I started to do with forums), and remember to keep authorization and such in sync between the API and the HTML UI. 2. Add API functionality directly to the HTML UI controllers, using `respond_to` and conditionals. Still evaluating these options.
Configuration menu - View commit details
-
Copy full SHA for 88ca5e7 - Browse repository at this point
Copy the full SHA 88ca5e7View commit details -
Tried to cover all of the MUSTs and some of the SHOULDs from the JSON API spec. Specific errors are just returned as text messages for now. Most of the new controller code will be extracted to a mixin module. Likewise, the spec code can be extracted to shared behaviors.
Configuration menu - View commit details
-
Copy full SHA for aa614d9 - Browse repository at this point
Copy the full SHA aa614d9View commit details
Commits on Jul 13, 2015
-
Configuration menu - View commit details
-
Copy full SHA for 87019aa - Browse repository at this point
Copy the full SHA 87019aaView commit details
Commits on Jul 14, 2015
-
Also reworked TopicsController#find_topic so that (a) the API subclass can override the "not found" behavior, and (b) the method works as a `before_action` with slightly simpler code.
Configuration menu - View commit details
-
Copy full SHA for 3b2ebb7 - Browse repository at this point
Copy the full SHA 3b2ebb7View commit details
Commits on Jul 15, 2015
-
Configuration menu - View commit details
-
Copy full SHA for 30d7dce - Browse repository at this point
Copy the full SHA 30d7dceView commit details -
Configuration menu - View commit details
-
Copy full SHA for a60d5d5 - Browse repository at this point
Copy the full SHA a60d5d5View commit details -
Also fixed an internal error when a post is submitted with no attributes.
Configuration menu - View commit details
-
Copy full SHA for 3c867db - Browse repository at this point
Copy the full SHA 3c867dbView commit details
Commits on Jul 17, 2015
-
Configuration menu - View commit details
-
Copy full SHA for 95c9abf - Browse repository at this point
Copy the full SHA 95c9abfView commit details -
Also moved some PostsController action code into `before_filter`s so that the API's own `before_filter`s get a chance to act.
Configuration menu - View commit details
-
Copy full SHA for dc751a3 - Browse repository at this point
Copy the full SHA dc751a3View commit details -
Spec refactor: started abstracting API behavior.
We now have a general notion of how create, update, and show requests behave, and can focus on the specifics of what data a successful request returns. Also made api/forums#show properly return 409 Forbidden.
Configuration menu - View commit details
-
Copy full SHA for 054991a - Browse repository at this point
Copy the full SHA 054991aView commit details
Commits on Jul 19, 2015
-
Configuration menu - View commit details
-
Copy full SHA for bafbee5 - Browse repository at this point
Copy the full SHA bafbee5View commit details -
API: Inherit from ForumsController.
This is the pattern we're using for the other controllers, to get permissions checking and such. Also removed unnecessary `respond_to` from `ForumsController#show`, and wrote a test to confirm that it was unnecessary.
Configuration menu - View commit details
-
Copy full SHA for b2684a8 - Browse repository at this point
Copy the full SHA b2684a8View commit details
Commits on Jul 20, 2015
-
API: Extracted JsonApiController module.
Handles the routine mechanics of rendering the right responses.
Configuration menu - View commit details
-
Copy full SHA for 5efb90f - Browse repository at this point
Copy the full SHA 5efb90fView commit details -
Configuration menu - View commit details
-
Copy full SHA for fe776c5 - Browse repository at this point
Copy the full SHA fe776c5View commit details -
API: send user relationships, not ID attributes.
Also implemented helpers for rendering relationship JSON.
Configuration menu - View commit details
-
Copy full SHA for b97d486 - Browse repository at this point
Copy the full SHA b97d486View commit details -
API: Render included posts with a partial.
This reduces some code duplication, but as a result sends a little more info than necessary in the included post. If this is a problem, we can get around it by passing info to the partial about what relationships to reference.
Configuration menu - View commit details
-
Copy full SHA for 45b8ef9 - Browse repository at this point
Copy the full SHA 45b8ef9View commit details
Commits on Aug 18, 2015
-
Configuration menu - View commit details
-
Copy full SHA for da075e8 - Browse repository at this point
Copy the full SHA da075e8View commit details
Commits on Aug 25, 2015
-
API: Don't list unmoderated topics.
Relies on the existing permission controls in the parent controller.
Configuration menu - View commit details
-
Copy full SHA for 70e0ffe - Browse repository at this point
Copy the full SHA 70e0ffeView commit details
Commits on Sep 8, 2015
-
Merged from rails4 into api branch.
Fixed routes conflict, and RSpec 3 deprecation warnings from the API specs.
Configuration menu - View commit details
-
Copy full SHA for 92db379 - Browse repository at this point
Copy the full SHA 92db379View commit details
Commits on Sep 16, 2015
-
Added created_at field to topics list.
So the client can display a reasonable "last active" time for a topic with no posts.
Configuration menu - View commit details
-
Copy full SHA for 0543130 - Browse repository at this point
Copy the full SHA 0543130View commit details
Commits on Sep 17, 2015
-
Configuration menu - View commit details
-
Copy full SHA for 21fa728 - Browse repository at this point
Copy the full SHA 21fa728View commit details -
API: Include latest post author in topic list.
... by using the post partial instead of sending a subset of attributes.
Configuration menu - View commit details
-
Copy full SHA for 6617ae2 - Browse repository at this point
Copy the full SHA 6617ae2View commit details -
API: Reduced code duplication in topic views.
... by extracting a partial with attributes and has-one relationships.
Configuration menu - View commit details
-
Copy full SHA for fbb1e72 - Browse repository at this point
Copy the full SHA fbb1e72View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5991286 - Browse repository at this point
Copy the full SHA 5991286View commit details
Commits on Sep 29, 2015
-
Set last_post_at for topics with no posts.
It's used as a proxy for "recent topics," so it makes sense to include new topics, even if they haven't received any replies.
Configuration menu - View commit details
-
Copy full SHA for b354f5b - Browse repository at this point
Copy the full SHA b354f5bView commit details