question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Post API: formats & new plaintext field

See original GitHub issue

In 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 the markdown field? see #8479
  • 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:closed
  • Created 6 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ErisDScommented, Oct 31, 2017

@kirrg001 FYI I agree, let’s rename the amp field and then close this. We can think about optimising amp later if needed.

0reactions
kirrg001commented, Jan 2, 2018

rename amp field to comment_id

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.

Right now if you have AMP enabled and you request the AMP format via the API, you would receive nothing. This is definitely a bug. That means, the AMP generation has to be triggered

Let’s wait till it get’s raised as a bug. Not critical in my opinion.

Closing.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found