Skip to content
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

✨ Add ?formats param to Posts API #8305

Merged
merged 1 commit into from
May 30, 2017
Merged

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Apr 10, 2017

This PR is a bit weird, and very lacking in tests.

I'm not particularly happy with the implementation - there's duplication of the properties at the API and model layer. I think this is a symptom of a much larger problem with regard to separation of concerns between the model & API layer - and one that's not worth fixing right now.

Note: I've implemented this such that if you did something like:

/posts/?formats=mobiledoc,html&fields=id,title

You'd get all 4 fields returned, and don't have to specify the formats in both formats and fields. This is a little bit inconsistent with what happens if you did:

/posts/?include=tags&fields=id,title

Where you'd only get the id and title fields, despite having requested tags.

I thought about this, and came to the conclusion that the concepts are different enough that it makes sense. Having to duplicate formats in a fields request is weird because they're both column names.

However, include=tags represents a whole object, not just a single field, and so eventually we want to be able to support something like

/posts/?include=tags&fields=id,title,tag.name

or

/posts/?include=tags&fields=id,title,tag.*

refs #8275

  • Adds support for formats param
  • Returns html by default
  • Can optionally return other formats by providing a comma-separated list

TODO:

  • revisit implementation - can we do this without duplication? (maybe track this as a separate task)
  • add some tests
  • ensure that ?fields can't be used to override ?formats in confusing ways
  • add admin PR (🎨 use formats query param Admin#718)

@kirrg001 kirrg001 self-assigned this May 25, 2017
@kirrg001
Copy link
Contributor

This works pretty good already. Thanks for pre-work 🙃
I will add some tests and look at the duplicated code occurrences.
The admin panel will request the following formats: mobiledoc & plaintext.

However, include=tags represents a whole object, not just a single field, and so eventually we want to be able to support something like

Agree, i can see what you mean. A tag doesn't contain a huge data set, just some short strings. Something we can improve in the future, but i wouldn't raise an issue out of it. Let me know if you would like to 👍

@kirrg001 kirrg001 force-pushed the formats branch 3 times, most recently from bd92417 to 14444b8 Compare May 29, 2017 16:22
refs TryGhost#8275

- Adds support for formats param
- Returns html by default
- Can optionally return other formats by providing a comma-separated list
@kirrg001 kirrg001 changed the title [WIP] ✨ Add ?formats param to Posts API ✨ Add ?formats param to Posts API May 29, 2017
@kirrg001 kirrg001 assigned kevinansfield and unassigned kirrg001 May 29, 2017
kevinansfield added a commit to kevinansfield/Ghost-Admin that referenced this pull request May 30, 2017
refs TryGhost#718, TryGhost/Ghost#8305
- meta description preview in the PSM was relying on the `html` field which is no longer queried - see TryGhost#718 and TryGhost/Ghost#8305
- restores live preview that was in LTS but removed whilst implementing mobiledoc because we had no quick way of rendering mobiledoc->text
- adds a boolean argument to the `formatMarkdown` util that can disable the replacement of `<script>` and `<iframe>` tags so that the inserted text isn't rendered when converting HTML to text
kevinansfield added a commit to kevinansfield/Ghost-Admin that referenced this pull request May 30, 2017
refs TryGhost#718, TryGhost/Ghost#8305
- meta description preview in the PSM was relying on the `html` field which is no longer queried - see TryGhost#718 and TryGhost/Ghost#8305
- restores live preview that was in LTS but removed whilst implementing mobiledoc because we had no quick way of rendering mobiledoc->text
- adds a boolean argument to the `formatMarkdown` util that can disable the replacement of `<script>` and `<iframe>` tags so that the inserted text isn't rendered when converting HTML to text
@kevinansfield kevinansfield merged commit 3e60941 into TryGhost:master May 30, 2017
@kevinansfield kevinansfield deleted the formats branch May 30, 2017 10:40
kirrg001 pushed a commit to TryGhost/Admin that referenced this pull request May 30, 2017
refs #718, refs TryGhost/Ghost#8305

- meta description preview in the PSM was relying on the `html` field which is no longer queried - see #718 and TryGhost/Ghost#8305
- restores live preview that was in LTS but removed whilst implementing mobiledoc because we had no quick way of rendering mobiledoc->text
- adds a boolean argument to the `formatMarkdown` util that can disable the replacement of `<script>` and `<iframe>` tags so that the inserted text isn't rendered when converting HTML to text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants