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

Revision acb84c08c1bbcc83036b9cad70f6a3c5d60865c4 => current


Lineacb84c08c1bbcc83036b9cad70f6a3c5d60865c4current
1<!DOCTYPE html><!DOCTYPE html>
2<html><html>
3 <head> <head>
40 <!-- end icons / favicons --> <!-- end icons / favicons -->
41
42 <link rel="alternate" type="application/rss+xml" title="tech.interfluidity.com updates" href="../../../../feed/index.rss"> <link rel="alternate" type="application/rss+xml" title="tech.interfluidity.com updates" href="../../../../feed/index.rss">
43 <link rel="alternate" type="application/x-all-item-rss+xml" title="tech.interfluidity.com - all items" href="https://tech.interfluidity.com/all-item-feed/index.rss">
44 <link rel="alternate" type="application/rss+xml" title="interfluidity - all blogs" href="https://www.interfluidity.com/unify-rss/all-blogs.rss"> <link rel="alternate" type="application/rss+xml" title="interfluidity - all blogs" href="https://www.interfluidity.com/unify-rss/all-blogs.rss">
45 <link rel="alternate" type="application/rss+xml" title="interfluidity - all blogs and microblogs" href="https://www.interfluidity.com/unify-rss/all-blogs-and-microblogs.rss"> <link rel="alternate" type="application/rss+xml" title="interfluidity - all blogs and microblogs" href="https://www.interfluidity.com/unify-rss/all-blogs-and-microblogs.rss">
46 <link rel="alternate" type="application/x-single-item-rss+xml" title="Feedletter tutorial" href="index.rss">
47 <link rel="stylesheet" href="../../../../css/style.css"> <link rel="stylesheet" href="../../../../css/style.css">
48 <link rel="stylesheet" href="../../../../css/highlightjs/steve-night-owl.css"><!-- theme for highlight.js --> <link rel="stylesheet" href="../../../../css/highlightjs/steve-night-owl.css"><!-- theme for highlight.js -->
49 <script src="../../../../js/highlight/highlight.min.js"></script> <script src="../../../../js/highlight/highlight.min.js"></script>
84 <h1><a href="index.html">Feedletter tutorial</a></h1> <h1><a href="index.html">Feedletter tutorial</a></h1>
85 <hr class="below-title"> <hr class="below-title">
86 </div> </div>
87 <div class="update-prepend rss-description-exclude">
88 <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>
89 <hr>
90 </div>
91 <div class="entry-body"> <div class="entry-body">
92 <div class="flexmark markdown"> <div class="flexmark markdown">
93 <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>
988 </ul> </ul>
989 <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>
990 <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>
991 <div class="note">
992 <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>
993 <ol>
994 <li>
995 <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>
996 <li>
997 <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>
998 </ol>
999 <p>Just use <code>com.mchange.feedletter.Customizer</code>, and</p>
1000 <pre><code class="language-scala">( subscribableName : SubscribableName, subscriptionManager : SubscriptionManager, feedUrl : FeedUrl, contents : Seq[ItemContent] ) => Seq[ItemContent]
1001</code></pre>
1002 <p>under newer versions of <code>feedletter</code>.</p>
1003 </div>
1004 <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>
1005 <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>
1006 <pre><code class="language-plaintext">$ mkdir src/tutorial <pre><code class="language-plaintext">$ mkdir src/tutorial
1092 <p>One feedletter instance can host as many feeds and subscribables as you like.</p> <p>One feedletter instance can host as many feeds and subscribables as you like.</p>
1093 <p>Restyling your subscribables, or writing customizers and bespoke untemplates for them, can take longer. Developing custom front-ends is time-consuming detail work.</p> <p>Restyling your subscribables, or writing customizers and bespoke untemplates for them, can take longer. Developing custom front-ends is time-consuming detail work.</p>
1094 <p>I'd love it if you gave <em>feedletter</em> a try!</p> <p>I'd love it if you gave <em>feedletter</em> a try!</p>
1095 <hr>
1096 <p><strong>Update:</strong> I've <a href="../../../../2025/01/14/syndicating-rss-to-mastodon-and-bluesky-with-feedletter/index.html">added a tutorial</a> on using feedletter to syndicate post announcements from RSS to Mastodon and BlueSky.</p>
1097 </div> </div>
1098 </div> </div>
1099 <div class="entry-footer"> <div class="entry-footer">
1100 <div class="post-metainfo"> <div class="post-metainfo">
1101 <a href="index.html">10:30 AM EST</a> <div class="updated-note">
1102 <a href="index.html#major-updates">Last major update at 2024-06-20 @ 01:10 PM EDT</a>
1103 </div>
1104 <div>
1105 <a href="index.html" class="pubtime">10:30 AM EST</a>
1106 </div>
1107 </div> </div>
1108 </div> </div>
1109</article></article>
1119 <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>
1120 </div> </div>
1121 </div> </div>
1122 <div id="update-history" class="update-history">
1123 <h3 class="update-history-title"><a id="major-updates" href=""></a>Major revisions:</h3>
1124 <ul>
1125 <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>
1126 <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>
1127 </ul>
1128 <div class="update-history-note">
1129 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 2025-01-14 @ 04:05 PM EST.
1130 </div>
1131 </div>
1132</div><!-- after-article --></div><!-- after-article -->
1133 </div> </div>
1134 <div id="right-sidebar"> <div id="right-sidebar">
1135 </div> </div>
1136 </div> </div>
1137 </body> </body>
1138</html></html>