Longpost Technical Details – Long posts

Longpost Technical Details

Robert
@pnut developerd, #🐝 keeper
Notes on wiki.pnut.io

@33MHz on Pnut

There are two types of "long post" on Pnut. One uses the raw elements in Posts and simply creates a single post. The type this site uses is more involved and more capable, and what I'll be explaining here.

This site uses three Pnut API objects to make long posts: Channels, Messages, and Posts.

Long posts

The basic idea is to create a channel to manage the long post's metadata and permissions (draft versus published, but then create new messages in the channel to handle revisions of the post.

Channel

The channel is created first, with JSON like this:

{
  "type": "st.longpo.longpost",
  "raw": [
    {
      "type": "st.longpo.post",
      "value": {
        "title": "String",
        "category": "String",
                "global_post_id": "After publishing, this should be the ID of the Global post, if it was created"
      }
    }
  ]
}

Message

Then a message is created in the new channel, like this:

{
  "text": "String",
  "raw": [
    {
      "type": "st.longpo.content",
      "value": {
        "body": "String"
      }
    }
  ]
}

Post

Then optionally, you can broadcast the new channel to the Global stream with a custom raw. Broadcasting it to Global indicates that "comments" / replies are welcome on the post. It also publicizes it, of course.

{
  "text": "String",
  "raw": [
    {
      "type": "st.longpo.broadcast",
      "value": {
        "longpost_id": "Channel ID"
      }
    }
  ]
}

The only reason this uses a custom broadcast item on the Global post is that we don't really want normal channel invites sending clients to the channel - it would not be interpreted the way other channels would be, potentially.

Also with broadcasting to Global you should update the Channel with a new raw value in the st.longpo.post for global_post_id, referencing the Global post that was just created.

The channel can be made private again, if desired. When it's made private, the Global announcement post should be deleted.

The Future

  • "private"/limited access posts in addition to having "drafts" and "published".
  • Longer posts?
  • Better description handling (deal with mixed or broken markdown? Strip it?)
  • Ability to see posts from a user in a series/category
  • Ability to delete/edit revisions

Filed Under: "how-to"
Share Link

Tags #dev

132 approximate views

Activity: 0 Replies, 0 Reposts, 0 Bookmarks

Discussion

View on Beta

Log in to comment.