Add entity recognition in user bios as well
This commit is contained in:
parent
8608f06bca
commit
47d206666b
@ -87,6 +87,20 @@ func TestUserFeed(t *testing.T) {
|
|||||||
assert.Len(including_quote_tweets, 10)
|
assert.Len(including_quote_tweets, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUserFeedWithEntityInBio(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
require := require.New(t)
|
||||||
|
|
||||||
|
resp := do_request(httptest.NewRequest("GET", "/michaelmalice", nil))
|
||||||
|
require.Equal(resp.StatusCode, 200)
|
||||||
|
|
||||||
|
root, err := html.Parse(resp.Body)
|
||||||
|
require.NoError(err)
|
||||||
|
bio_entities := cascadia.QueryAll(root, selector(".user-bio .entity"))
|
||||||
|
require.Len(bio_entities, 1)
|
||||||
|
assert.Equal(bio_entities[0].FirstChild.Data, "@SheathUnderwear")
|
||||||
|
}
|
||||||
|
|
||||||
func TestUserFeedMissing(t *testing.T) {
|
func TestUserFeedMissing(t *testing.T) {
|
||||||
require := require.New(t)
|
require := require.New(t)
|
||||||
|
|
||||||
@ -344,7 +358,7 @@ func TestLongTweet(t *testing.T) {
|
|||||||
require.Equal(resp.StatusCode, 200)
|
require.Equal(resp.StatusCode, 200)
|
||||||
root, err := html.Parse(resp.Body)
|
root, err := html.Parse(resp.Body)
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
paragraphs := cascadia.QueryAll(root, selector(".tweet-text"))
|
paragraphs := cascadia.QueryAll(root, selector(".tweet .text"))
|
||||||
assert.Len(paragraphs, 22)
|
assert.Len(paragraphs, 22)
|
||||||
|
|
||||||
twt, err := profile.GetTweetById(scraper.TweetID(1695110851324256692))
|
twt, err := profile.GetTweetById(scraper.TweetID(1695110851324256692))
|
||||||
|
@ -100,7 +100,7 @@ ul.inline-dotted-list li:last-child:after {
|
|||||||
line-height: 0;
|
line-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.author-info, .tweet-text {
|
.author-info, .tweet .text {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,15 +147,15 @@ a.entity {
|
|||||||
color: var(--color-twitter-blue);
|
color: var(--color-twitter-blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
.tweet-text {
|
.tweet .text {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 0.4em;
|
margin-bottom: 0.4em;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
.focused-tweet .tweet-text {
|
.focused-tweet .text {
|
||||||
font-size: 1.4em;
|
font-size: 1.4em;
|
||||||
}
|
}
|
||||||
.focused-tweet .quoted-tweet .tweet-text {
|
.focused-tweet .quoted-tweet .text {
|
||||||
font-size: unset;
|
font-size: unset;
|
||||||
}
|
}
|
||||||
.tweet-content video {
|
.tweet-content video {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="tweet"
|
<div class="tweet"
|
||||||
{{if (not (eq $main_tweet.ID (focused_tweet_id)))}}
|
{{if (not (eq $main_tweet.ID (focused_tweet_id)))}}
|
||||||
hx-post="/tweet/{{$main_tweet.ID}}"
|
hx-post="/tweet/{{$main_tweet.ID}}"
|
||||||
hx-trigger="click target::not(.tweet-text)"
|
hx-trigger="click"
|
||||||
hx-target="body"
|
hx-target="body"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
hx-push-url="true"
|
hx-push-url="true"
|
||||||
@ -50,23 +50,7 @@
|
|||||||
</span>
|
</span>
|
||||||
<span class="vertical-container-1">
|
<span class="vertical-container-1">
|
||||||
<div class="tweet-content">
|
<div class="tweet-content">
|
||||||
{{range (splitList "\n" $main_tweet.Text)}}
|
{{template "text-with-entities" $main_tweet.Text}}
|
||||||
<p class="tweet-text" hx-trigger="click consume">
|
|
||||||
{{range (get_entities .)}}
|
|
||||||
{{if (eq .EntityType 1)}}
|
|
||||||
<!-- Mention -->
|
|
||||||
<a class="entity" href="/{{.Contents}}">@{{.Contents}}</a>
|
|
||||||
{{else if (eq .EntityType 2)}}
|
|
||||||
<!-- Hashtag -->
|
|
||||||
<a class="entity" href="/search/%23{{.Contents}}">#{{.Contents}}</a>
|
|
||||||
{{else}}
|
|
||||||
<!-- Just text -->
|
|
||||||
{{.Contents}}
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
</p>
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{range $main_tweet.Images}}
|
{{range $main_tweet.Images}}
|
||||||
<img src="/content/images/{{.LocalFilename}}" style="max-width: 45%"/>
|
<img src="/content/images/{{.LocalFilename}}" style="max-width: 45%"/>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
{{template "following-button" $user}}
|
{{template "following-button" $user}}
|
||||||
</div>
|
</div>
|
||||||
<div class="user-bio">
|
<div class="user-bio">
|
||||||
<span>{{$user.Bio}}</span>
|
{{template "text-with-entities" $user.Bio}}
|
||||||
</div>
|
</div>
|
||||||
{{if $user.Location}}
|
{{if $user.Location}}
|
||||||
<div class="user-location bio-info-with-icon">
|
<div class="user-location bio-info-with-icon">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user