Conditional process, update and then save post's HTML


#1

Hi there,

I’m running the latest Ghost with Casper, and I want to post podcasts. As of now, there’s no good way to do that, and due to lack of podcasters using Ghost, I don’t expect this to become core functionality. Here’s what I’m trying to accomplish:

  1. When a post contains an .mp3 url, it will become a podcast
  2. Some code will be injected right above this URL and will display an HTML5-compatible player (say, wavesurfer.js)
  3. URL itself will be updated to a proper link: “Download Episode #xxx
  4. A proper enclosure tag will be created and injected into the post as invisible code (?)
  5. This enclosure will be available for this particular post in RSS for further syndication
  6. This updated post will be saved back into the database

I’m not really sure about the best way to approach this. I’ve been able to make points 1 through 3 work with content helper, so whenever there’s an mp3 url in the post, it becomes a media player with the download link below.

How do I add an enclosure to the post so it appears in the RSS? And what’s the proper way to take this whole post object afterwards and post it back to the database as an update (I’m using MySQL at the time)?

Any suggestions and pointers are very welcome, as documentation is limited and not always clear about accomplishing this kind of thing. Thank you!


#2

What you would like to do requires working on the core.

I don’t know if that might be an alternative option for you, but you could achieve some of the above mentioned points easily by using the dynamic routing feature. This will also give you the option to create your own RSS feed:

  1. When a post contains an .mp3 url, it will become a podcast

Manually tag it with podcast

  1. Some code will be injected right above this URL and will display an HTML5-compatible player (say, wavesurfer.js)
  2. URL itself will be updated to a proper link: “Download Episode #xxx

Custom template that uses some js for podcast posts

  1. A proper enclosure tag will be created and injected into the post as invisible code (?)
  2. This enclosure will be available for this particular post in RSS for further syndication
  3. This updated post will be saved back into the database

I don’t think this will be necessary. You’ll define your very own routes and create an RSS template only for podcast posts, which are separate from the normal posts.

Hope, that helps!


#3

It certainly does help, Aileen, thank you so much! I’d share my work on GitHub once tested and ready for other podcasters to use.


#4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.