Diff of /2024/01/29/feedletter-tutorial/index.html

Revision acb84c08c1bbcc83036b9cad70f6a3c5d60865c4 => current


Lineacb84c08c1bbcc83036b9cad70f6a3c5d60865c4current
1<!DOCTYPE html><!DOCTYPE html>
2<html><html>
3 <head> <head>
82 <h1><a href="index.html">Feedletter tutorial</a></h1> <h1><a href="index.html">Feedletter tutorial</a></h1>
83 <hr class="below-title"> <hr class="below-title">
84 </div> </div>
85 <div class="update-prepend rss-description-exclude">
86 <em> ➣  This post was meaningfully revised at 2024-06-20 @ 01:10 PM EDT. The previous revision is <a href="index-oldcommit-acb84c08c1bbcc83036b9cad70f6a3c5d60865c4.html">here</a>, diff <a href="index-diff-acb84c08c1bbcc83036b9cad70f6a3c5d60865c4-to-current.html">here</a>. (See <a href="index.html#update-history">update history</a>.) </em>
87 <hr>
88 </div>
89 <div class="entry-body"> <div class="entry-body">
90 <div class="flexmark markdown"> <div class="flexmark markdown">
91 <p>I've been working for some time on a service to turn RSS feeds into e-mail newsletters, which I've called <a href="https://github.com/swaldman/feedletter"><em>feedletter</em></a>.</p> <p>I've been working for some time on a service to turn RSS feeds into e-mail newsletters, which I've called <a href="https://github.com/swaldman/feedletter"><em>feedletter</em></a>.</p>
986 </ul> </ul>
987 <p>For each subscribable, you can define just one of each kind of customizer, but customers can perform any number of steps internally.</p> <p>For each subscribable, you can define just one of each kind of customizer, but customers can perform any number of steps internally.</p>
988 <p>For an example, we'll build a content customizer. Both of our feeds frequently embed YouTube videos as <code>iframe</code> HTML elements in their blog posts. Unfortunately, mail clients generally do not render this form of embedded content, leaving awkward empty-spaces in and sometimes mangling the formatting of our newsletters.</p> <p>For an example, we'll build a content customizer. Both of our feeds frequently embed YouTube videos as <code>iframe</code> HTML elements in their blog posts. Unfortunately, mail clients generally do not render this form of embedded content, leaving awkward empty-spaces in and sometimes mangling the formatting of our newsletters.</p>
989 <div class="note">
990 <p>As of <code>feedletter-v0.0.13</code> (released June 19, 2024), the API has changed slightly from that documented in this tutorial.</p>
991 <ol>
992 <li>
993 <p><code>Customizer</code> is no longer in the package <code>com.mchange.feedletter.style</code>, but in the base <code>com.mchange.feedletter</code> package. (This is because customizers now apply more broadly than styling nowtifications. They can be used, for example, to filter subscribables by author or category.)</p></li>
994 <li>
995 <p>Individual <code>Customizer</code> types — which are just functions — no longer include a <code>withinTypeId : String</code> argument. <code>withinTypeId</code> is how <code>feedletter</code> binds multiple items into a single notification (for example in a weekly digest feed). The several posts that will be notified share a <code>withinTypeId</code>. However, the nature and format of these IDs are really implementation details of <code>feedletter</code> and its <code>SubscriptionManager</code> classes, so we are not exposing them to customizers.</p></li>
996 </ol>
997 <p>Just use <code>com.mchange.feedletter.Customizer</code>, and</p>
998 <pre><code class="language-scala">( subscribableName : SubscribableName, subscriptionManager : SubscriptionManager, feedUrl : FeedUrl, contents : Seq[ItemContent] ) => Seq[ItemContent]
999</code></pre>
1000 <p>under newer versions of <code>feedletter</code>.</p>
1001 </div>
1002 <p>So let's build a content customizer that replaces these with well-behaved <code>div</code> elements containing links to the resources that would have been in the <code>iframe</code>. We'll include a <code>class="embedded"</code> attribute on the <code>div</code> elements, so that we will be able to style them however we want.</p> <p>So let's build a content customizer that replaces these with well-behaved <code>div</code> elements containing links to the resources that would have been in the <code>iframe</code>. We'll include a <code>class="embedded"</code> attribute on the <code>div</code> elements, so that we will be able to style them however we want.</p>
1003 <p>Writing customizers in writing Scala code. We'll use the excellent <a href="https://jsoup.org/">jsoup</a> library to manipulate HTML. We'll give ourselves space to work by creating a <code>tutorial</code> package in our installation's <code>src</code> directory, and then exiting a file called <code>core.scala</code> inside that.</p> <p>Writing customizers in writing Scala code. We'll use the excellent <a href="https://jsoup.org/">jsoup</a> library to manipulate HTML. We'll give ourselves space to work by creating a <code>tutorial</code> package in our installation's <code>src</code> directory, and then exiting a file called <code>core.scala</code> inside that.</p>
1004 <pre><code class="language-plaintext">$ mkdir src/tutorial <pre><code class="language-plaintext">$ mkdir src/tutorial
1094 </div> </div>
1095 <div class="entry-footer"> <div class="entry-footer">
1096 <div class="post-metainfo"> <div class="post-metainfo">
1097 <a href="index.html">10:30 AM EST</a> <div class="updated-note">
1098 <a href="index.html#major-updates">Last major update at 2024-06-20 @ 01:10 PM EDT</a>
1099 </div>
1100 <div>
1101 <a href="index.html" class="pubtime">10:30 AM EST</a>
1102 </div>
1103 </div> </div>
1104 </div> </div>
1105</article></article>
1115 <a href="../../../02/04/style-by-mail-in-feedletter/index.html">Style-by-mail in feedletter →</a> <a href="../../../02/04/style-by-mail-in-feedletter/index.html">Style-by-mail in feedletter →</a>
1116 </div> </div>
1117 </div> </div>
1118 <div id="update-history" class="update-history">
1119 <h3 class="update-history-title"><a id="major-updates" href=""></a>Major revisions:</h3>
1120 <ul>
1121 <li><span class="update-timestamp"><i>2024-06-20 @ 01:10 PM EDT</i></span> — Add note to Section 16, "Advanced: Customize the content" documenting <i>feedletter</i> API changes that slightly modify this section of the tutorial. (<a href="index-diff-acb84c08c1bbcc83036b9cad70f6a3c5d60865c4-to-current.html">diff</a>)</li>
1122 <li><span class="update-timestamp"><i> <a href="index-oldcommit-acb84c08c1bbcc83036b9cad70f6a3c5d60865c4.html">2024-01-29 @ 10:30 AM EST</a></i></span> — Initial publication.</li>
1123 </ul>
1124 <div class="update-history-note">
1125 Timestamps represent "major", substantative revisions. There may have been subsequent typo fixes and language reworkings within a major revision, after the time displayed. For a more complete and fine-grained update history, you can view the <a href="https://github.com/swaldman/tech.interfluidity.com/commits/main/">git repository commit history</a>. The most recent minor modification of this entry occurred 2024-06-20 @ 01:06 PM EDT.
1126 </div>
1127 </div>
1128</div><!-- after-article --></div><!-- after-article -->
1129 </div> </div>
1130 <div id="right-sidebar"> <div id="right-sidebar">
1131 </div> </div>
1132 </div> </div>
1133 </body> </body>
1134</html></html>