<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3058984838" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/6010" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/6010/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/pull/6010">#6010</a> added truncated diary entries to profile pages. The truncation procedure is different from from others already in use. It gets html, strips tags and does the standard rails truncation to 150 chars:</p>
<div class="highlight highlight-source-ruby" dir="auto"><pre class="notranslate"><span class="pl-en">truncate</span><span class="pl-kos">(</span><span class="pl-en">strip_tags</span><span class="pl-kos">(</span><span class="pl-en">entry</span><span class="pl-kos">.</span><span class="pl-en">body</span><span class="pl-kos">.</span><span class="pl-en">to_html</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-pds">:length</span> <span class="pl-c1">=></span> <span class="pl-c1">150</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">So it's truncate to plaintext. This is similar to richtext <code class="notranslate">.description</code> for <code class="notranslate">og:description</code> from <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="2452526540" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/openstreetmap-website/issues/5056" data-hovercard-type="pull_request" data-hovercard-url="/openstreetmap/openstreetmap-website/pull/5056/hovercard" href="https://github.com/openstreetmap/openstreetmap-website/pull/5056">#5056</a>. I experimented using <code class="notranslate">entry.body.description</code> instead of <code class="notranslate">truncate(...)</code>. One thing that I wanted to change in <code class="notranslate">.description</code> is a truncation separator. This is what this PR does.</p>
<p dir="auto">Before:<br>
<a href="https://github.com/user-attachments/assets/5746fb99-6df5-4f85-ad59-7cf38aec28c7">image.png (view on web)</a></p>
<p dir="auto">After:<br>
<a href="https://github.com/user-attachments/assets/e90a20a6-009f-42be-9cd7-1def036ab35b">image.png (view on web)</a></p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/openstreetmap/openstreetmap-website/pull/6071'>https://github.com/openstreetmap/openstreetmap-website/pull/6071</a></p>
<h4>Commit Summary</h4>
<ul>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/6071/commits/8dd7eb805fba099f83535126059704b1fc193c66" class="commit-link">8dd7eb8</a> Rename DESCRIPTION_MAX_LENGTH</li>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/6071/commits/0d1517279292e5aec8e03e906402c01a6fd0328d" class="commit-link">0d15172</a> Replace RichText consts with a shorter symbol in tests</li>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/6071/commits/7d9a45f33acc0bb75ecdecdb493e90507622da2f" class="commit-link">7d9a45f</a> Truncate rich text descriptions at word boundaries if not too short</li>
<li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/6071/commits/3cba2a6cf100bb9c9ec1c5e1dedf0e7eb66e46a3" class="commit-link">3cba2a6</a> Allow word separator to consist of multiple spaces</li>
</ul>
<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/6071/files">2 files</a>)</p>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/6071/files#diff-6854f233485e4f1bf82ed21283e3637f9114d7c5431b80926ba2f5657b54e9fb">lib/rich_text.rb</a>
(13)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/openstreetmap-website/pull/6071/files#diff-c1cefbd36a92f5d74850361751b9b01c7d326221cfa8c15c0c071008165de745">test/lib/rich_text_test.rb</a>
(42)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/6071.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/6071.patch</a></li>
<li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/6071.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/6071.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/6071">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLPTCEKLD7YGVZTKJZD3BHIIZAVCNFSM6AAAAAB6KA42VSVHI2DSMVQWIX3LMV43ASLTON2WKOZTGEYDKNZRGAZDCNQ">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLMDHDYW5CWVVJU2CWL3BHIIZA5CNFSM6AAAAAB6KA42VSWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHLSHLARA.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/6071</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/6071",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/6071",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>