File tree Expand file tree Collapse file tree
app/src/main/kotlin/org/vestifeed Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -365,12 +365,15 @@ class StandaloneNewsApi(
365365 )
366366 }
367367
368+ val rawDescription = description ? : " "
369+ val summary = rawDescription.stripHtml().take(400 )
370+
368371 return Pair (
369372 Entry (
370373 contentType = " html" ,
371374 contentSrc = " " ,
372- contentText = description ? : " " ,
373- summary = description ,
375+ contentText = rawDescription ,
376+ summary = summary ,
374377 id = id,
375378 feedId = feedId,
376379 title = title ? : " " ,
@@ -386,10 +389,17 @@ class StandaloneNewsApi(
386389 extOpenGraphImageUrl = " " ,
387390 extOpenGraphImageWidth = 0 ,
388391 extOpenGraphImageHeight = 0 ,
389- ), emptyList()
392+ ), links
390393 )
391394 }
392395
396+ private fun String.stripHtml (): String {
397+ return this
398+ .replace(Regex (" <[^>]*>" ), " " )
399+ .replace(Regex (" \\ s+" ), " " )
400+ .trim()
401+ }
402+
393403 private fun sha256 (string : String ): String {
394404 val digest = MessageDigest .getInstance(" SHA-256" )
395405 val hash = digest.digest(string.toByteArray())
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class LinkQueries(private val conn: SQLiteConnection) {
4646 fun insertForFeed (feedId : String , links : List <Link >) {
4747 conn.prepare(
4848 """
49- INSERT INTO link (
49+ INSERT OR IGNORE INTO link (
5050 feed_id,
5151 href,
5252 rel,
@@ -78,7 +78,7 @@ class LinkQueries(private val conn: SQLiteConnection) {
7878 fun insertForEntry (entryId : String , links : List <Link >) {
7979 conn.prepare(
8080 """
81- INSERT INTO link (
81+ INSERT OR IGNORE INTO link (
8282 entry_id,
8383 href,
8484 rel,
You can’t perform that action at this time.
0 commit comments