Post API: formats & new plaintext field
See original GitHub issueIn certain cases, we need to have a plain text version of a post. This means adding a new field to the DB of plaintext
and converting the HTML on save.
As an additional consideration, we added the amp field (which does much the same thing) without really thinking about the additional overhead to the API - the AMP html is only useful in the case that we are rendering AMP. Equally, only the editor will need the mobiledoc content, and a blog really only needs HTML.
This leads to the idea of adding a ?formats=html,plaintext
parameter to the API. The default would be html
, but html, amp, mobiledoc & plaintext would all be available.
The tasks are as follows:
Required for beta:
- Add a new
plaintext
field to the posts table -
Remove thesee #8479markdown
field? - Auto-fill
plaintext
with a full plaintext version of the post on save - Add
?formats
to the API & return just html by default - editor requests mobiledoc/plaintext
-
rename amp field to comment_id(tracked here https://github.com/TryGhost/Team/issues/42)
Post-beta improvements
- Auto-fill
amp
on save as well! (This is not done yet!) - Update the amp code to request AMP specifically
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Web API Request/Response Data Formats - Media Types
Here, you will learn how Web API handles different formats of request and response data. Media Type. Media type (aka MIME type) specifies...
Read more >how to post plain text to ASP.NET Web API endpoint?
Actually it's a shame that web API doesn't have a MediaTypeFormatter for plain text. Here is the one I implemented. It can also...
Read more >Submitting a POST Request to the REST API | Junos OS
Use an HTTP POST request to send single or multiple RPC requests to the REST API. ... format='text/plain'/>" —header "Accept: application/json".
Read more >POST - HTTP - MDN Web Docs
The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header....
Read more >Encoding data for POST requests - JakeArchibald.com
Here's where things go wrong: body: `text=${text}` . Unescaped text is added into a format with defined encoding. It's similar to SQL/HTML ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kirrg001 FYI I agree, let’s rename the amp field and then close this. We can think about optimising amp later if needed.
This is tracked in https://github.com/TryGhost/Team/issues/42.
If we now rename the amp column to comment_id, the field would be always empty except you did an import of content to remember the old comment id. This is because the comment_id is always the post id. That is somehow weird and not really clean.
A thought. If we would import post including the ID field, we don’t need to remember the old comment_id anymore. Object ID’s are time and random based, i guess it’s okay to import posts including the ID field. The only edge case i can think of, is importing a post twice with the same ID, but this post would get ignored.
This is just a thought or let’s say, an easier and different approach. That’s why i would like to tackle this in the next major and give this topic a little more attention.
Let’s wait till it get’s raised as a bug. Not critical in my opinion.
Closing.