mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2026-03-22 12:21:37 +00:00
Use boring font for consistent non-latin script appearance based on page heuristics
This commit is contained in:
parent
d211470dca
commit
7461f25ca9
13 changed files with 43 additions and 6 deletions
|
|
@ -1,6 +1,7 @@
|
|||
const constants = require("../constants")
|
||||
const {proxyProfilePic} = require("../utils/proxyurl")
|
||||
const {structure} = require("../utils/structuretext")
|
||||
const {isLatin} = require("../utils/islatin")
|
||||
|
||||
const rewriters = {
|
||||
rewrite_youtube: ["youtube.com", "www.youtube.com", "m.youtube.com", "youtu.be"],
|
||||
|
|
@ -52,6 +53,11 @@ class BaseUser {
|
|||
return structure(this.data.biography)
|
||||
}
|
||||
|
||||
bioIsLatin() {
|
||||
if (typeof this.data.biography !== "string") return true
|
||||
return isLatin(this.data.biography)
|
||||
}
|
||||
|
||||
getTtl(scale = 1) {
|
||||
const expiresAt = this.cachedAt + constants.caching.resource_cache_time
|
||||
const ttl = expiresAt - Date.now()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const collectors = require("../collectors")
|
|||
const {structure, removeTrailingHashtags} = require("../utils/structuretext")
|
||||
const TimelineBaseMethods = require("./TimelineBaseMethods")
|
||||
const TimelineChild = require("./TimelineChild")
|
||||
const {isLatin} = require("../utils/islatin")
|
||||
require("../testimports")(collectors, TimelineChild, TimelineBaseMethods)
|
||||
|
||||
const rssDescriptionTemplate = compile(`
|
||||
|
|
@ -138,6 +139,13 @@ class TimelineEntry extends TimelineBaseMethods {
|
|||
else return caption.split("\n")[0].split(". ")[0]
|
||||
}
|
||||
|
||||
captionIsLatin() {
|
||||
// the caption introduction is likely to be more meaningful for analysis than the full caption.
|
||||
const introduction = this.getCaptionIntroduction()
|
||||
if (typeof introduction !== "string") return true
|
||||
return isLatin(introduction)
|
||||
}
|
||||
|
||||
/**
|
||||
* Alt text is not available for N2, the caption or a placeholder string will be returned instead.
|
||||
* @override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue