Parse content from when type is map[string]string
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Peter Stuifzand 2020-08-22 15:00:49 +02:00
parent e582fa42bb
commit d47533c0fb
Signed by: peter
GPG Key ID: 374322D56E5209E8
3 changed files with 491 additions and 0 deletions

View File

@ -58,6 +58,16 @@ func simplifyContent(k string, v []interface{}) *microsub.Content {
var content microsub.Content
switch t := v[0].(type) {
case map[string]string:
if text, e := t["value"]; e {
content.Text = text
}
if text, e := t["html"]; e {
cleaned, err := CleanHTML(text)
if err == nil {
content.HTML = cleaned
}
}
case map[string]interface{}:
if text, e := t["value"]; e {
content.Text = text.(string)

View File

@ -19,6 +19,8 @@ package jf2_test
import (
"encoding/json"
"log"
"net/url"
"os"
"testing"
@ -215,3 +217,30 @@ func TestCleanHTMLSimpler(t *testing.T) {
assert.Equal(t, "<div>test</div><div>test2</div>", clean)
}
}
func TestConvertItemNoteWithCheckout(t *testing.T) {
f, err := os.Open("./tests/note-with-checkout.html")
if err != nil {
log.Fatal(err)
}
defer f.Close()
u, err := url.Parse("https://aaronparecki.com/2020/08/21/16/")
if err != nil {
log.Fatal(err)
}
data := microformats.Parse(f, u)
results := jf2.SimplifyMicroformatDataItems(data)
assert.Len(t, results, 1, "need 1 item")
assert.NotNil(t, results[0].Content)
assert.Equal(
t,
"not sure if it's cheaper to buy all the Microsoft Flight Simulator accessories or actually train for a pilots license 🤔 https://youtu.be/shpK1Gjvnuo",
results[0].Content.Text)
assert.Equal(
t,
"not sure if it&#39;s cheaper to buy all the Microsoft Flight Simulator accessories or actually train for a pilots license <a href=\"https://aaronparecki.com/emoji/%F0%9F%A4%94\" class=\"emoji\">🤔</a> <a href=\"https://youtu.be/shpK1Gjvnuo\"><span class=\"protocol\">https://</span>youtu.be/shpK1Gjvnuo</a>",
results[0].Content.HTML)
}

View File

@ -0,0 +1,452 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>not sure if it&#039;s cheaper to buy all the Microsoft Flight ... &bull; Aaron Parecki</title>
<link rel="alternate" type="application/mf2+json" href="https://aaronparecki.com/2020/08/21/16.json" />
<link rel="alternate" type="application/jf2+json" href="https://aaronparecki.com/2020/08/21/16.jf2" />
<link rel="alternate" type="application/activity+json" href="https://aaronparecki.com/2020/08/21/16.as2" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@aaronpk" />
<meta name="twitter:creator" content="@aaronpk" />
<meta property="og:url" content="https://aaronparecki.com/2020/08/21/16/" />
<meta property="og:type" content="website" />
<meta property="og:title" content="not sure if it&#039;s cheaper to buy all the Microsoft Flight ..." />
<meta property="og:description" content="not sure if it&#039;s cheaper to buy all the Microsoft Flight Simulator accessories or actually train for a pilots license 🤔" />
<meta property="og:site_name" content="Aaron Parecki" />
<link rel="webmention" href="https://webmention.io/aaronpk/webmention">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/semantic/2.2.6/semantic.min.css">
<script src="/assets/jquery-1.12.0.min.js"></script>
<script src="/semantic/2.2.6/semantic.min.js"></script>
<link rel="stylesheet" href="/assets/icomoon/style.css">
<link rel="stylesheet" href="/assets/weather-icons/css/weather-icons.css">
<script src="/assets/featherlight-1.5.0/featherlight.min.js"></script>
<link rel="stylesheet" href="/assets/featherlight-1.5.0/featherlight.min.css">
<link rel="stylesheet" href="/assets/admin.2.css">
<link rel="stylesheet" href="/assets/pulse.css">
<link rel="stylesheet" href="/assets/styles.8.css">
<link rel="stylesheet" href="/site/styles.1.css">
<link rel="stylesheet" href="/assets/carbon.css">
<script src="/assets/photo-albums/justified-layout.js"></script>
<script src="/assets/photo-albums/photo-layout.js"></script>
<script src="/assets/js-cookie.js"></script>
<script src="/assets/blm.js"></script>
<link rel="stylesheet" href="/assets/story.css">
<script src="/assets/story.js"></script>
<link rel="openid.delegate" href="https://aaronparecki.com/">
<link rel="openid.server" href="https://indieauth.com/openid">
</head>
<body>
<div class="sticky-footer-content">
<div class="top-bar ">
<div class="ui container">
<form action="/search" method="get" class="search item">
<div class="ui icon input">
<input type="text" name="q" placeholder="Search..." value="">
<i class="search icon"></i>
</div>
</form>
<span class="item">59&deg;F</span>
<span class="weather item">
<i class="wi wi-night-cloudy" title="Partly Cloudy in Portland"></i>
</span>
<span class="time item"></span>
<span class="battery item"></span>
<div id="logged-in-menu">
</div>
</div>
</div>
<div class="ui container">
<div class="site-header">
<div class="align-bottom">
<div class="left">
<h1><a href="/">Aaron Parecki</a></h1>
</div>
<div class="right">
<ul>
<li><a href="/articles">Articles</a></li>
<li><a href="/notes">Notes</a></li>
<li><a href="/photos">Photos</a></li>
</ul>
</div>
</div>
</div>
<div class="post-list">
<ul>
<li class="h-entry post-entry post-type-note post has-responses " id="post-id-63703">
<div style="" class="content-area has-responses ">
<div class="pad">
<div class="show-author-photo">
<div class="author u-author h-card">
<a href="/" class="u-url"><img class="u-photo p-name" src="/images/emoji/aaronpk1359.jpg" width="48" alt="Aaron Parecki"></a>
</div>
<div class="post-text e-content content-type-plain" >not sure if it's cheaper to buy all the Microsoft Flight Simulator accessories or actually train for a pilots license <a href="/emoji/🤔" class="emoji">🤔</a> <a href="https://youtu.be/shpK1Gjvnuo"><span class="protocol">https://</span>youtu.be/shpK1Gjvnuo</a></div>
</div>
</div>
<div class="metaline pad">
<i class="marker icon"></i>
<span class="p-location h-adr">
<span class="p-locality">Portland</span>,
<span class="p-region">Oregon</span>
<data class="p-latitude" value="45.53545"></data>
<data class="p-longitude" value="-122.621117"></data>
</span>
<span class="weather">
<span>&bull;</span>
<i class="wi wi-day-cloudy" title="Partly Cloudy"></i>
72&deg;F
</span>
</div>
<div class="metaline pad">
<a href="https://aaronparecki.com/2020/08/21/16/" class="u-url">
<time class="dt-published" datetime="2020-08-21T19:23:56-07:00">
Fri, Aug 21, 2020 7:23pm -07:00
</time>
</a>
<span class="syndications">
<a href="https://twitter.com/aaronpk/status/1296996514011602944" class="u-syndication syndication"><i class="twitter icon"></i></a>
<a href="https://micro.blog/aaronpk/10141453" class="u-syndication syndication"><i class="linkify icon"></i></a>
</span>
</div>
<div class="metaline responses-summary pad">
<span><i class="star empty icon"></i> <span class="p-pk-num-likes">7</span> likes</span>
<span><i class="comment outline icon"></i> <span class="p-pk-num-replies">1</span> reply</span>
</div>
<div style="clear:both;"></div>
</div>
<div class="responses" id="responses">
<ul class="facepile">
<li class="group"><i class="star empty icon"></i></li>
<!-- TODO: add overlay with twitter/facebook/instagram icon depending on author URL -->
<li class="p-like h-cite">
<a href="https://playvicious.social/users/jalcine#likes/919291" class="u-url">
<span class="p-author h-card">
<img class="u-photo" src="/assets/images/no-profile-photo.png" data-src="https://pkcdn.xyz/playvicious.social/97152daeef40e4c1178472617d12f5bc8280bdb0d49581c65ad17e24e867510a.jpg" height="36">
<a style="display:none;" class="p-name u-url" href="https://playvicious.social/users/jalcine">Jacky.</a>
</span>
</a>
</li>
<li class="p-like h-cite">
<a href="https://twitter.com/aaronpk/status/1296996514011602944#favorited-by-15733418" class="u-url">
<span class="p-author h-card">
<img class="u-photo" src="/assets/images/no-profile-photo.png" data-src="https://pkcdn.xyz/pbs.twimg.com/629d13e551d1c45ad3f98493ec7acf346427b44e3cbe7bd20b0fce78f9b13f8a.jpg" height="36">
<a style="display:none;" class="p-name u-url" href="https://twitter.com/jigpu">Jason Gerecke</a>
</span>
</a>
</li>
<li class="p-like h-cite">
<a href="https://twitter.com/aaronpk/status/1296996514011602944#favorited-by-2623" class="u-url">
<span class="p-author h-card">
<img class="u-photo" src="/assets/images/no-profile-photo.png" data-src="https://pkcdn.xyz/pbs.twimg.com/5dc815e08fbdfbecf32a4fafc0c02e86540b81417f7ea12c507c9f6e05bb753b.jpg" height="36">
<a style="display:none;" class="p-name u-url" href="https://twitter.com/dominik">Dominik Schwind</a>
</span>
</a>
</li>
<li class="p-like h-cite">
<a href="https://twitter.com/aaronpk/status/1296996514011602944#favorited-by-32492723" class="u-url">
<span class="p-author h-card">
<img class="u-photo" src="/assets/images/no-profile-photo.png" data-src="https://pkcdn.xyz/pbs.twimg.com/912bb160bdcecd290717d814baf33520b4f52807b04395a681a756249a713088.jpg" height="36">
<a style="display:none;" class="p-name u-url" href="https://twitter.com/Sebsel">Sebastiaan Andeweg</a>
</span>
</a>
</li>
<li class="p-like h-cite">
<a href="https://twitter.com/aaronpk/status/1296996514011602944#favorited-by-428759320" class="u-url">
<span class="p-author h-card">
<img class="u-photo" src="/assets/images/no-profile-photo.png" data-src="https://pkcdn.xyz/pbs.twimg.com/9dad0f51ecd5ffab84e90223dda19e4b25f89b807c1f196832508efe846ae22f.jpg" height="36">
<a style="display:none;" class="p-name u-url" href="https://twitter.com/esteelands">Esteelands 🇺🇸🏳️&zwj;🌈🏴&zwj;☠️</a>
</span>
</a>
</li>
<li class="p-like h-cite">
<a href="https://twitter.com/aaronpk/status/1296996514011602944#favorited-by-1111557022602936320" class="u-url">
<span class="p-author h-card">
<img class="u-photo" src="/assets/images/no-profile-photo.png" data-src="https://pkcdn.xyz/pbs.twimg.com/eed13c86912fc09e3c4e9ee67a5e7896caa687bdb4a2e39d695bdf8f3f97611a.png" height="36">
<a style="display:none;" class="p-name u-url" href="https://twitter.com/oidc6">Govner</a>
</span>
</a>
</li>
<li class="p-like h-cite">
<a href="https://twitter.com/aaronpk/status/1296996514011602944#favorited-by-1121423786459455488" class="u-url">
<span class="p-author h-card">
<img class="u-photo" src="/assets/images/no-profile-photo.png" data-src="https://pkcdn.xyz/pbs.twimg.com/fe0d70d573714fd107a801f833524f6a182d3f91b23de6829cfd0eb004e37a70.jpg" height="36">
<a style="display:none;" class="p-name u-url" href="https://twitter.com/zmamujee1">zaheer@cloudshell:</a>
</span>
</a>
</li>
</ul>
<div style="clear:both;"></div>
<form class="webmention-form ui form" action="https://webmention.io/aaronpk/webmention" method="post">
<div class="fields">
<div class="twelve wide field">
<label>Have you written a <a href="https://indieweb.org/responses">response</a> to this? Let me know the URL:</label>
<input type="url" name="source" class="url">
</div>
<div class="four wide field">
<label>&nbsp;</label>
<input type="submit" class="ui submit button" value="Send Webmention">
</div>
</div>
<div class="status hidden">
<div class="ui message"></div>
</div>
<input type="hidden" name="target" value="https://aaronparecki.com/2020/08/21/16/">
</form>
<ul>
<li class="p-comment h-cite comment">
<div class="p-author h-card author">
<img class="u-photo" src="/assets/images/no-profile-photo.png" data-src="https://pkcdn.xyz/micro.blog/9e89c0879164a37db7b43a1740f15b7897aba68bd57da6886b6410eef76392c6.jpg" width="48">
<a class="p-name u-url" href="https://micro.blog/sku_b">sku_b</a>
<a class="author_url" href="https://micro.blog/sku_b">micro.blog/sku_b</a>
</div>
<!-- TODO: should this be e-summary if I've truncated it or if it came from the summary? -->
<div class="e-content comment-content"><p><a href="https://micro.blog/aaronpk" rel="nofollow">@aaronpk</a> Might need an addition to your house just to make room for all of that. </p></div>
<div class="metaline">
<a href="https://micro.blog/sku_b/10143464" class="u-url">
<time class="dt-published" datetime="2020-08-22T12:28:48+00:00">
Sat, Aug 22, 2020 12:28pm +00:00
</time>
</a>
</div>
</li>
</ul>
<div style="clear:both;"></div>
</div>
</li>
</ul>
<div class="additional-info">
Posted in
<a href="/notes" class="u-p3k-channel">/notes</a>
using
<a href="https://quill.p3k.io/">quill.p3k.io</a>
</div>
</div>
</div>
</div>
<footer class="sticky-footer">
<div class="subfooter">
<div class="ui container h-card">
<div class="about">
<div class="image"><a href="/" class="u-url u-uid"><img src="/images/profile.jpg" class="u-photo"></a></div>
<div class="bio">
<div class="p-note">
<p>Hi, I'm <span class="p-name">Aaron<span style="display:none;"> Parecki</span></span>, co-founder of
<a class="p-org h-card" href="https://indieweb.org/">IndieWebCamp</a>.
I maintain <a class="p-org h-card" href="https://oauth.net/">oauth.net</a>, <a href="/oauth/">write and consult about OAuth</a>, and
am the editor of several <a href="/w3c/">W3C specifications</a>. I help people learn about <a href="https://youtube.com/aaronpk">video production and livestreaming</a>.</p>
<p>I've been <a href="/gps/">tracking my location</a> since 2008 and I wrote <a href="https://100.aaronparecki.com/">100 songs in 100 days</a>.
I've <a href="/presentations">spoken</a> at conferences around the world about
<a href="/presentations?tag=indieweb">owning your data</a>,
<a href="/oauth/">OAuth</a>,
<a href="/presentations?tag=quantifiedself">quantified self</a>,
and explained <a href="https://www.youtube.com/watch?v=FGVJ0eXTRpw">why R is a vowel</a>. <a href="/about">Read more</a>.</p> <time class="dt-bday" datetime="--12-28"></time>
<data class="p-street-address" value="818 SW 3rd Ave #437"></data>
<data class="p-locality" value="Portland"></data>
<data class="p-region" value="Oregon"></data>
<data class="p-country-name" value="USA"></data>
<data class="p-postal-code" value="97204"></data> </div>
</div>
<div class="right">
<div class="follow">
<a href="/follow?path=primary" class="ui primary button">Follow</a>
</div>
<div class="orgs">
<ul>
<li class="p-org h-card">
<img src="/images/okta.png" alt="" class="u-photo">
<a class="p-role" href="https://developer.okta.com/blog/2018/03/27/welcome-aaron-okta">Security Architect</a> at <a href="https://developer.okta.com/" class="u-url">
<span class="p-name">Okta</span>
</a>
</li>
<li class="p-org h-card">
<img src="/images/indiewebcamp.png" alt="" class="u-photo">
<a href="https://indieweb.org/" class="u-url">
<span class="p-name">IndieWebCamp</span>
</a>
<a class="p-role" href="https://indieweb.org/founders">Founder</a>
</li>
<li class="p-org h-card">
<img src="/images/ietf.ico" alt="" class="u-photo">
<a href="https://oauth.net" class="u-url">
<span class="p-name">OAuth WG</span>
</a>
<a class="p-role" href="/oauth/">Member</a>
</li>
<!--
<li class="p-org h-card">
<img src="/images/w3c.png" alt="" class="u-photo">
<a href="https://www.w3.org/" class="u-url">
<span class="p-name">W3C</span>
</a>
<a class="p-role" href="/w3c/">Editor</a>
</li>
<li class="p-org h-card">
<img src="/images/streampdx.png" alt="" class="u-photo">
<a href="https://streampdx.com" class="u-url">
<span class="p-name">Stream PDX</span>
</a>
<a class="p-role" href="https://streampdx.com/who">Co-Founder</a>
</li>
<li class="p-org h-card">
<img src="/images/backpedal.png" alt="" class="u-photo">
<a href="https://backpedal.tv" class="u-url">backpedal.tv</a>
</li>
-->
<li><br></li>
<!--
<li><img src="/images/spotify.ico" alt=""> <a href="/sunshine-indie-pop/">Sunshine Indie Pop</a></li>
<li>
<img src="/images/microphone.png" alt="">
<a class="p-callsign u-url" href="https://w7apk.com">W7APK</a>
</li>
-->
<li>⭐️ <a href="https://aaronparecki.com/life-stack/">Life Stack</a></li>
<li>⚙️ <a href="https://aaronparecki.com/home-automation/">Home Automation</a></li>
<li>🎥 <a href="https://youtube.com/aaronpk">YouTube</a></li>
</ul>
<link rel="pgpkey" href="/key.txt">
<link rel="me" href="sms:+15035678642">
<link rel="me" href="https://micro.blog/aaronpk"> </div>
<div class="search">
<form action="/search" method="get">
<div class="ui fluid icon input">
<input type="text" name="q" placeholder="Search..." value="">
<i class="search icon"></i>
</div>
</form>
</div>
</div>
</div>
<div class="channels">
<ul class="footer-links">
<li><a href="/all">All</a></li>
<li><a href="/articles">Articles</a></li>
<li><a href="/bookmarks">Bookmarks</a></li>
<li><a href="/notes">Notes</a></li>
<li><a href="/photos">Photos</a></li>
<li><a href="/replies">Replies</a></li>
<li><a href="/reviews">Reviews</a></li>
<li><a href="/sleep">Sleep</a></li>
<li><a href="/trips">Trips</a></li>
<li><a href="/videos">Videos</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</div>
<div class="elsewhere">
<ul class="footer-links">
<li><a href="https://twitter.com/aaronpk" rel=""><i class="twitter icon"></i></a></li>
<li><a href="https://youtube.com/aaronpk" rel=""><i class="youtube play icon"></i></a></li>
<li><a href="https://github.com/aaronpk" rel=""><i class="github icon"></i></a></li>
<li><a href="http://foursquare.com/aaronpk" rel=""><i class="foursquare icon"></i></a></li>
<li><a href="http://www.linkedin.com/in/aaronparecki" rel=""><i class="linkedin icon"></i></a></li>
<li><a href="https://facebook.com/aaronpk" rel=""><i class="facebook icon"></i></a></li>
<li><a href="https://instagram.com/aaronpk" rel=""><i class="instagram icon"></i></a></li>
<li><a href="http://flickr.com/aaronpk" rel=""><i class="flickr icon"></i></a></li>
<li><a href="http://aaronpk.eventbrite.com/" rel=""><i class="icon-eventbrite icon"></i></a></li>
<li><a href="https://speakerdeck.com/aaronpk" rel=""><i class="linkify icon"></i></a></li>
<li><a href="http://www.slideshare.net/aaronpk" rel=""><i class="slideshare icon"></i></a></li>
<li><a href="http://www.last.fm/user/aaron_pk" rel=""><i class="lastfm icon"></i></a></li>
<li><a href="https://kit.co/aaronpk" rel=""><i class="linkify icon"></i></a></li>
<li><a href="https://www.w3.org/users/59996" rel=""><i class="icon-w3c icon"></i></a></li>
<li><a href="https://aaronparecki.com/aaronpk" rel=""><i class="linkify icon"></i></a></li>
<li><a href="https://cash.me/$aaronpk" rel=""><i class="icon-squarecash icon"></i></a></li>
<li><a href="https://venmo.com/aaronpk" rel=""><i class="icon-venmo icon"></i></a></li>
<li><a href="https://paypal.me/apk" rel=""><i class="paypal icon"></i></a></li>
<li><a href="mailto:aaron@parecki.com" rel=""><i class="mail icon"></i></a></li>
</ul>
</div>
</div>
</div>
<div class="footer">
<a href="/login" class="hidden-login"></a>
<div>
<span>&copy; 1999-2020 by Aaron Parecki.</span>
<span>Powered by <a href="https://indieweb.org/p3k">p3k</a>.</span>
<span>This site supports <a href="https://webmention.net/">Webmention</a>.</span>
</div>
<div>
<span>Except where otherwise noted, text content on this site is licensed
under a <a href="http://creativecommons.org/licenses/by/3.0/" rel="license">Creative Commons Attribution 3.0 License</a>.</span>
</div>
<div class="badges" style="padding-top: 8px;">
<a href="https://indieweb.org/"><img src="/assets/badges/indieweb.png" width="80" height="15" alt="IndieWebCamp" style="image-rendering: pixelated;"></a>
<a href="http://microformats.org/"><img src="/assets/badges/microformats.png" width="80" height="15" alt="Microformats" style="image-rendering: pixelated;"></a>
<a href="https://indieweb.org/Webmention"><img src="/assets/badges/webmention.png" width="80" height="15" alt="Webmention" style="image-rendering: pixelated;"></a>
<img src="/assets/badges/w3c-valid-html.png" width="80" height="15" alt="W3C HTML5" style="image-rendering: pixelated;">
<a href="http://creativecommons.org/licenses/by/3.0/"><img src="/assets/badges/cc-commons.png" width="80" height="15" alt="Creative Commons" style="image-rendering: pixelated;"></a>
</div>
</div>
</footer>
<input type="hidden" id="permalink" value="https://aaronparecki.com/2020/08/21/16/">
<script src="/assets/script.js"></script>
<script src="/assets/webmention.js"></script>
<script src="/assets/admin.js"></script>
<script>
// Lolz. https://www.youtube.com/watch?v=EZpdEljk5dY
// thanks seblog.nl!
let photo = document.querySelector('.about .image img')
if(photo) {
window.addEventListener('deviceorientation', (e) => {
let tiltLR = e.gamma; let tiltFB = e.beta;
photo.style.transform = `rotate(${tiltLR * -1}deg)`
})
}
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-4617305-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>