fix microformat parse author name if h-card is next to name in h-entry
parent
d2cffd68b0
commit
3be4b23159
|
@ -192,10 +192,13 @@ func Published(hEntry *microformats.Microformat) string {
|
|||
}
|
||||
|
||||
func NewAuthor(hEntry *microformats.Microformat, hCard *microformats.Microformat) IndiewebAuthor {
|
||||
name := DetermineAuthorName(hEntry)
|
||||
if name == "" {
|
||||
name := ""
|
||||
if hCard != nil {
|
||||
name = DetermineAuthorName(hCard)
|
||||
}
|
||||
if name == "" {
|
||||
name = DetermineAuthorName(hEntry)
|
||||
}
|
||||
picture := DetermineAuthorPhoto(hEntry)
|
||||
if picture == "" {
|
||||
picture = DetermineAuthorPhoto(hCard)
|
||||
|
|
|
@ -313,28 +313,52 @@ func TestReceiveTargetThatDoesNotPointToTheSourceDoesNothing(t *testing.T) {
|
|||
assert.Empty(t, repo.GetAllToModerate("brainbaking.com").Data)
|
||||
}
|
||||
|
||||
func TestConvertBodyToIndiewebDataWithComplicatedDataStillFindsName(t *testing.T) {
|
||||
wm := mf.Mention{
|
||||
Source: "https://pauho.net/2022/05/04/662325/",
|
||||
Target: "https://brainbaking.com/post/2022/04/cool-things-people-do-with-their-blogs/",
|
||||
func TestConvertBodyToIndiewebDataWithComplicatedData(t *testing.T) {
|
||||
cases := []struct {
|
||||
source string
|
||||
target string
|
||||
mockFile string
|
||||
expectedAuthorName string
|
||||
}{
|
||||
{
|
||||
"https://pauho.net/2022/05/04/662325/",
|
||||
"https://brainbaking.com/post/2022/04/cool-things-people-do-with-their-blogs/",
|
||||
"../../../mocks/indieweb-complicated-data.html",
|
||||
"Paul Houlihan",
|
||||
},
|
||||
{
|
||||
"https://ruk.ca/favourite/drought",
|
||||
"https://brainbaking.com/post/2022/05/drought/",
|
||||
"../../../mocks/indieweb-hcard-next-to-name.html",
|
||||
"Peter Rukavina",
|
||||
},
|
||||
}
|
||||
|
||||
cnf := &common.Config{
|
||||
AllowedWebmentionSources: []string{
|
||||
"brainbaking.com",
|
||||
},
|
||||
}
|
||||
|
||||
recv := &Receiver{
|
||||
Conf: cnf,
|
||||
}
|
||||
src, err := ioutil.ReadFile("../../../mocks/indieweb-complicated-data.html")
|
||||
assert.NoError(t, err)
|
||||
for _, tc := range cases {
|
||||
t.Run("indieweb author "+tc.expectedAuthorName, func(t *testing.T) {
|
||||
wm := mf.Mention{
|
||||
Source: tc.source,
|
||||
Target: tc.target,
|
||||
}
|
||||
|
||||
body := string(src)
|
||||
data := microformats.Parse(strings.NewReader(body), wm.SourceUrl())
|
||||
indieweb := recv.convertBodyToIndiewebData(body, wm, data)
|
||||
src, err := ioutil.ReadFile(tc.mockFile)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "Paul Houlihan", indieweb.Author.Name)
|
||||
body := string(src)
|
||||
data := microformats.Parse(strings.NewReader(body), wm.SourceUrl())
|
||||
indieweb := recv.convertBodyToIndiewebData(body, wm, data)
|
||||
|
||||
assert.Equal(t, tc.expectedAuthorName, indieweb.Author.Name)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProcessSourceBodyAnonymizesBothAuthorPictureAndNameIfComingFromSilo(t *testing.T) {
|
||||
|
|
|
@ -0,0 +1,240 @@
|
|||
<!DOCTYPE html>
|
||||
<!--[if lt IE 7]><html class="lt-ie9 lt-ie8 lt-ie7" lang="en" dir="ltr"><![endif]-->
|
||||
<!--[if IE 7]><html class="lt-ie9 lt-ie8" lang="en" dir="ltr"><![endif]-->
|
||||
<!--[if IE 8]><html class="lt-ie9" lang="en" dir="ltr"><![endif]-->
|
||||
<!--[if gt IE 8]><!--><html lang="en" dir="ltr" prefix="og: http://ogp.me/ns# content: http://purl.org/rss/1.0/modules/content/ dc: http://purl.org/dc/terms/ foaf: http://xmlns.com/foaf/0.1/ rdfs: http://www.w3.org/2000/01/rdf-schema# sioc: http://rdfs.org/sioc/ns# sioct: http://rdfs.org/sioc/types# skos: http://www.w3.org/2004/02/skos/core# xsd: http://www.w3.org/2001/XMLSchema#"><!--<![endif]-->
|
||||
<head>
|
||||
<!--[if IE]><![endif]-->
|
||||
<meta charset="utf-8" />
|
||||
<link href="https://ruk.ca/sites/ruk.ca/themes/at_ruk/images/iphone-retina-120x120.png" rel="apple-touch-icon" sizes="120x120" />
|
||||
<link href="https://ruk.ca/sites/ruk.ca/themes/at_ruk/images/ipad-retina-152x152.png" rel="apple-touch-icon" sizes="152x152" />
|
||||
<link href="https://ruk.ca/sites/ruk.ca/themes/at_ruk/images/ipad-standard-76x76.png" rel="apple-touch-icon" sizes="76x76" />
|
||||
<link href="https://ruk.ca/sites/ruk.ca/themes/at_ruk/images/default-60x60.png" rel="apple-touch-icon" />
|
||||
<link href="https://ruk.ca/sites/ruk.ca/themes/at_ruk/images/default-60x60.png" rel="shortcut icon" />
|
||||
<link rel="search" type="application/opensearchdescription+xml" href="https://ruk.ca/opensearch.xml" title="ruk.ca" />
|
||||
<link rel="shortcut icon" href="https://ruk.ca/sites/ruk.ca/files/ruk_favicon_2.ico" type="image/vnd.microsoft.icon" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<meta name="MobileOptimized" content="width" />
|
||||
<meta name="HandheldFriendly" content="true" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="rating" content="general" />
|
||||
<meta name="generator" content="Drupal 7 (http://drupal.org)" />
|
||||
<link rel="canonical" href="https://ruk.ca/favourite/drought" />
|
||||
<link rel="shortlink" href="https://ruk.ca/node/26419" />
|
||||
<meta name="geo.position" content="46.23587,-63.12412" />
|
||||
<meta name="geo.placename" content="Charlottetown" />
|
||||
<meta name="geo.region" content="PE-CA" />
|
||||
<meta name="icbm" content="46.23587,-63.12412" />
|
||||
<meta property="og:site_name" content="ruk.ca" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="https://ruk.ca/favourite/drought" />
|
||||
<meta property="og:title" content="Drought" />
|
||||
<meta property="og:description" content="The personal blog of Peter Rukavina." />
|
||||
<meta property="og:latitude" content="46.23587" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta property="og:longitude" content="-63.12412" />
|
||||
<meta property="og:street_address" content="100 Prince Street" />
|
||||
<meta property="og:locality" content="Charlottetown" />
|
||||
<meta property="og:region" content="PE" />
|
||||
<meta property="og:postal_code" content="C1A 4R4" />
|
||||
<meta name="twitter:url" content="https://ruk.ca/favourite/drought" />
|
||||
<meta property="og:country_name" content="Canada" />
|
||||
<meta name="twitter:title" content="Drought" />
|
||||
<meta property="og:email" content="peter@rukavina.net" />
|
||||
<meta name="twitter:description" content="The personal blog of Peter Rukavina." />
|
||||
<meta name="twitter:image" content="http://ruk.ca/sites/ruk.ca/files/ruk-square-opengraph.png" />
|
||||
<meta name="twitter:image:width" content="665" />
|
||||
<meta name="twitter:image:height" content="665" />
|
||||
<meta itemprop="name" content="Drought" />
|
||||
<meta itemprop="description" content="The personal blog of Peter Rukavina." />
|
||||
<meta itemprop="image" content="http://ruk.ca/sites/ruk.ca/files/ruk-square-opengraph.png" />
|
||||
<meta name="dcterms.title" content="Drought" />
|
||||
<meta name="dcterms.creator" content="Peter Rukavina" />
|
||||
<meta name="dcterms.description" content="The personal blog of Peter Rukavina." />
|
||||
<meta name="dcterms.publisher" content="Peter Rukavina" />
|
||||
<meta name="dcterms.type" content="Text" />
|
||||
<meta name="dcterms.format" content="text/html" />
|
||||
<meta name="dcterms.identifier" content="https://ruk.ca/favourite/drought" />
|
||||
<meta name="dcterms.rights" content="Creative Commons Attribution, NonCommercial, ShareAlike License." />
|
||||
<meta name="msvalidate.01" content="E9070682EC45FF305C0128ACDED51519" />
|
||||
<meta name="google-site-verification" content="fBDPlTjIWhVDWqz7KgOVY8VIrI_r3USlvzX6stN6pLI" />
|
||||
<meta name="p:domain_verify" content="0496bb9dfaaccbd7c6e7ee13d34998f1" />
|
||||
<meta name="yandex-verification" content="682f65b30188fcb7" />
|
||||
<link rel="me" href="mailto:peter@rukavina.net" />
|
||||
<link href="https://drupal.org/user/17600" rel="me">
|
||||
<link href="https://github.com/reinvented/" rel="me">
|
||||
<link href="https://speakerdeck.com/reinvented" rel="me">
|
||||
<link href="https://vimeo.com/ruk" rel="me">
|
||||
<link href="https://www.youtube.com/reinvented" rel="me">
|
||||
<link href="https://wiki.ruk.ca/" rel="me">
|
||||
<link href="http://orcid.org/0000-0002-7690-4909" rel="me">
|
||||
<link href="https://ruk.ca/sites/ruk.ca/files/pgp/peter-rukavina.pub" rel="pgpkey">
|
||||
<link rel="openid.delegate" href="https://ruk.ca/" />
|
||||
<link rel="openid.server" href="https://openid.indieauth.com/openid" />
|
||||
<link rel="pingback" href="https://webmention.io/ruk.ca/xmlrpc" />
|
||||
<link rel="webmention" href="https://webmention.io/ruk.ca/webmention" />
|
||||
<link rel="alternate" type="application/rss+xml" title="ruk.ca » posts" href="https://ruk.ca/rss/feedburner.xml" />
|
||||
<link rel="alternate" type="application/rss+xml" title="ruk.ca » comments" href="https://ruk.ca/comments/rss" />
|
||||
<link rel="alternate" type="application/rss+xml" title="ruk.ca » sounds" href="https://ruk.ca/rss/podcast.xml" />
|
||||
<title>Drought</title>
|
||||
<script type="text/javascript">
|
||||
<!--//--><![CDATA[//><!--
|
||||
for(var fonts=document.cookie.split("advaggf"),i=0;i<fonts.length;i++){var font=fonts[i].split("="),pos=font[0].indexOf("ont_");-1!==pos&&(window.document.documentElement.className+=" "+font[0].substr(4).replace(/[^a-zA-Z0-9\-]/g,""))}if(void 0!==Storage){fonts=JSON.parse(localStorage.getItem("advagg_fonts"));var current_time=(new Date).getTime();for(var key in fonts)fonts[key]>=current_time&&(window.document.documentElement.className+=" "+key.replace(/[^a-zA-Z0-9\-]/g,""))}
|
||||
//--><!]]>
|
||||
</script>
|
||||
<link type="text/css" rel="stylesheet" href="/sites/ruk.ca/files/advagg_css/css__1AhcMJSKDbTdtFSd5SOcEiVRFgRodWm7pI8NvRKIGjI__Nui5DXKw-HRIEM24Y_OLvnlQ6-KKA82T7Ne9lfcEGXs__5iKpygb31HWZfWrSaHhI9cTqeKdkcHkkHn0OiUnu4zI.css" media="all" />
|
||||
<link type="text/css" rel="stylesheet" href="/sites/ruk.ca/files/advagg_css/css__KviPNOKtNMltlyUkYb2_SEmSa_kkbptuHJz76KxVO5U__qsEF5uDTvaIbOfGdwxwQzHzvN7FHQfFrDYbLM33_3UU__5iKpygb31HWZfWrSaHhI9cTqeKdkcHkkHn0OiUnu4zI.css" media="all" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://ruk.ca/sites/all/themes/adaptivetheme/at_core/scripts/html5.js?rbz4r6"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body class="html not-front not-logged-in no-sidebars page-node page-node- page-node-26419 node-type-favourite site-name-hidden atr-7.x-3.x">
|
||||
<div id="skip-link" class="nocontent">
|
||||
<a href="#main-content" class="element-invisible element-focusable">Skip to main content</a>
|
||||
</div>
|
||||
<div id="page-wrapper">
|
||||
<div id="page" class="container page">
|
||||
|
||||
<!-- !Leaderboard Region -->
|
||||
|
||||
<header id="header" class="clearfix" role="banner">
|
||||
|
||||
<!-- !Branding -->
|
||||
<div id="branding" class="branding-elements clearfix">
|
||||
|
||||
|
||||
<!-- !Site name and Slogan -->
|
||||
<div class="element-invisible h-group" id="name-and-slogan">
|
||||
|
||||
<h1 class="element-invisible" id="site-name"><a href="/" title="Home page">ruk.ca</a></h1>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- !Header Region -->
|
||||
<div class="region region-header"><div class="region-inner clearfix"><div id="block-block-1" class="block block-block no-title" ><div class="block-inner clearfix">
|
||||
|
||||
<div class="block-content content"><p><a href="https://ruk.ca/" id="logo" rel="me" title="ruk.ca"><img alt="ruk.ca" aria-label="Home" class="u-logo" src="https://ruk.ca/sites/ruk.ca/files/svg/ruk-square.svg" style="width: 66px; height: 66px;" /></a></p>
|
||||
</div>
|
||||
</div></div></div></div>
|
||||
</header>
|
||||
|
||||
<!-- !Navigation -->
|
||||
|
||||
<!-- !Breadcrumbs -->
|
||||
<div id="breadcrumb" class="clearfix"><nav class="breadcrumb-wrapper clearfix" role="navigation" aria-labelledby="breadcrumb-label"><h2 id="breadcrumb-label" class="element-invisible">You are here</h2><ol id="crumbs" class="clearfix"><li class="crumb crumb-first"><span typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="/">Home</a></span></li></ol></nav></div>
|
||||
<!-- !Messages and Help -->
|
||||
|
||||
<!-- !Secondary Content Region -->
|
||||
|
||||
<div id="columns" class="columns clearfix">
|
||||
<main id="content-column" class="content-column" role="main">
|
||||
<div class="content-inner">
|
||||
|
||||
<!-- !Highlighted region -->
|
||||
|
||||
<section id="main-content" class="h-entry">
|
||||
|
||||
|
||||
<!-- !Main Content Header -->
|
||||
<header id="main-content-header" class="clearfix">
|
||||
|
||||
<h1 id="page-title" class="p-name">
|
||||
Drought </h1>
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<!-- !Main Content -->
|
||||
<div id="content" class="region">
|
||||
<div id="block-system-main" class="block block-system no-title" >
|
||||
|
||||
<div class="one-column at-panel panel-display clearfix" >
|
||||
<div class="region region-one-main">
|
||||
<div class="region-inner clearfix">
|
||||
<div class="panel-pane pane-custom pane-1 no-title block">
|
||||
<div class="block-inner clearfix">
|
||||
|
||||
|
||||
|
||||
<div class="block-content">
|
||||
<p>⭐ I favourited <em><a href="https://brainbaking.com/post/2022/05/drought/" class="u-like-of">Drought</a></em> by <a href="https://brainbaking.com/post/">Wouter Groeneveld</a> on May 16, 2022 — 12:24.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> </div>
|
||||
|
||||
<!-- !Feed Icons -->
|
||||
|
||||
|
||||
</section><!-- /end #main-content -->
|
||||
|
||||
<!-- !Content Aside Region-->
|
||||
|
||||
</div><!-- /end .content-inner -->
|
||||
</main><!-- /end #content-column -->
|
||||
|
||||
<!-- !Sidebar Regions -->
|
||||
|
||||
</div><!-- /end #columns -->
|
||||
|
||||
<!-- !Tertiary Content Region -->
|
||||
|
||||
<!-- Three column 3x33 Gpanel -->
|
||||
<!-- <div class="three-3x33 gpanel clearfix "> -->
|
||||
<div class="three-3x33 at-panel panel-display clearfix">
|
||||
<div class="region region-three-33-first"><div class="region-inner clearfix"><section id="block-block-5" class="block block-block" ><div class="block-inner clearfix">
|
||||
<h2 class="block-title">About Me</h2>
|
||||
|
||||
<div class="block-content content"><div class="p-author h-card vcard" id="whoami"><a href="https://ruk.ca/sites/ruk.ca/files/picture-of-peter-rukavina.jpg"><img alt="Headshot of Peter Rukavina." class="u-photo" src="https://ruk.ca/sites/ruk.ca/files/tiny-picture-of-peter-rukavina.jpg" style="width: 100px; height: 100px; float: left; margin-right: 10px" /></a>
|
||||
<p>I am <a class="u-url" href="https://ruk.ca/" rel="author"><span class="fn n p-name"><span class="given-name p-given-name">Peter</span> <span class="family-name p-family-name">Rukavina</span></span> and this is my blog</a>. <span class="bio"> <span class="p-note"> I am a <span class="p-job-title">writer, <a href="https://ruk.ca/topics/letterpress">printer</a> and <a href="https://reinvented.net">developer</a></span>. </span> </span></p>
|
||||
|
||||
<p>To learn more about me, read my <a href="https://ruk.ca/now">/now</a>, <a href="https://ruk.ca/about-peter-rukavina">look at my bio</a>, read <a href="https://ruk.ca/speaking">presentations and speeches I’ve written</a>, listen to <a href="https://ruk.ca/sounds">audio I’ve produced</a>, see the <a href="https://ruk.ca/travels">places I’ve been</a>, or <a href="https://ruk.ca/contact-peter-rukavina">get in touch</a> (<a class="u-email" href="mailto:peter@rukavina.net" rel="me">peter@rukavina.net</a> is the quickest way).</p>
|
||||
|
||||
<p><strong>Mailing Address</strong></p>
|
||||
|
||||
<address>
|
||||
<div class="adr">
|
||||
<p class="street-address">100 Prince Street</p>
|
||||
|
||||
<p><span class="locality">Charlottetown</span>, <span class="region">PE</span></p>
|
||||
|
||||
<p class="country-name">Canada, <span class="postal-code">C1A 4R4</span></p>
|
||||
</div>
|
||||
</address>
|
||||
</div>
|
||||
</div>
|
||||
</div></section></div></div> <div class="region region-three-33-second"><div class="region-inner clearfix"><nav id="block-menu-menu-here" class="block block-menu" role="navigation"><div class="block-inner clearfix">
|
||||
<h2 class="block-title">Find Your Way</h2>
|
||||
|
||||
<div class="block-content content"><ul class="menu clearfix"><li class="first expanded"><a href="/about" title="">About ruk.ca</a><ul class="menu clearfix"><li class="first expanded"><a href="/archive" title="Monthly archive of all posts on this site.">Archive</a><ul class="menu clearfix"><li class="first leaf"><a href="/onthisday" title="Blog posts written in the past on this day of this month.">On This Day</a></li><li class="last leaf"><a href="/favourites" title="My favourite posts from other people's blogs.">Favourites</a></li></ul></li><li class="expanded"><a href="/rss" title="">RSS</a><ul class="menu clearfix"><li class="first leaf"><a href="/rss/feedburner.xml" title="">Posts</a></li><li class="leaf"><a href="/onthisday/feed" title="">On This Day</a></li><li class="leaf"><a href="/favourites/feed" title="">Favourites</a></li><li class="leaf"><a href="/comments/rss" title="">Comments</a></li><li class="last leaf"><a href="/rss/podcast.xml" title="">Podcast</a></li></ul></li><li class="leaf"><a href="https://images.ruk.ca/opml/peter_rukavina_blogroll.opml" title="A list of the blogs I subscribe to.">OPML (Blogroll)</a></li><li class="last leaf"><a href="http://eepurl.com/b-goKn" title="">Subscribe by Email</a></li></ul></li><li class="last leaf"><a href="https://shop.queensquarepress.ca" title="">Queen Square Press Shop</a></li></ul></div>
|
||||
</div></nav></div></div> <div class="region region-three-33-third"><div class="region-inner clearfix"><div id="block-search-form" class="block block-search" role="search"><div class="block-inner clearfix">
|
||||
<h2 class="block-title">Search This Website</h2>
|
||||
|
||||
<div class="block-content content"><form action="/favourite/drought" method="post" id="search-block-form" accept-charset="UTF-8"><div><div class="container-inline">
|
||||
<div class="form-item form-type-textfield form-item-search-block-form">
|
||||
<label class="element-invisible" for="edit-search-block-form--2">Search </label>
|
||||
<input title="Enter the terms you wish to search for." type="search" id="edit-search-block-form--2" name="search_block_form" value="" size="15" maxlength="128" class="form-text" />
|
||||
</div>
|
||||
<div class="form-actions form-wrapper" id="edit-actions"><input type="submit" id="edit-submit" name="op" value="Search" class="form-submit" /></div><input type="hidden" name="form_build_id" value="form-ASI8ZdbeWFfqDVWSwyX9p9JpQUNKKS4adFuhw3UCTPI" />
|
||||
<input type="hidden" name="form_id" value="search_block_form" />
|
||||
</div>
|
||||
</div></form></div>
|
||||
</div></div></div></div> </div>
|
||||
|
||||
<!-- !Footer -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue