mirror of https://gitlab.com/bashrc2/epicyon
Removing long words from feed titles
parent
ade3c0560b
commit
cb49d90bb9
|
@ -639,7 +639,7 @@ def removeLongWords(content: str, maxWordLength: int,
|
||||||
wordStr[:maxWordLength])
|
wordStr[:maxWordLength])
|
||||||
if content.startswith('<p>'):
|
if content.startswith('<p>'):
|
||||||
if not content.endswith('</p>'):
|
if not content.endswith('</p>'):
|
||||||
content = content.strip()+'</p>'
|
content = content.strip() + '</p>'
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ from utils import removeHtml
|
||||||
from blocking import isBlockedDomain
|
from blocking import isBlockedDomain
|
||||||
from blocking import isBlockedHashtag
|
from blocking import isBlockedHashtag
|
||||||
from filters import isFiltered
|
from filters import isFiltered
|
||||||
from content import removeLongWords
|
|
||||||
|
|
||||||
|
|
||||||
def rss2Header(httpPrefix: str,
|
def rss2Header(httpPrefix: str,
|
||||||
|
@ -90,10 +89,6 @@ def addNewswireDictEntry(baseDir: str, domain: str,
|
||||||
tags=[], maxTags=32) -> None:
|
tags=[], maxTags=32) -> None:
|
||||||
"""Update the newswire dictionary
|
"""Update the newswire dictionary
|
||||||
"""
|
"""
|
||||||
# remove any long words from the title, which can
|
|
||||||
# cause column overflows
|
|
||||||
title = removeLongWords(title, 30, [])
|
|
||||||
|
|
||||||
allText = removeHtml(title + ' ' + description)
|
allText = removeHtml(title + ' ' + description)
|
||||||
|
|
||||||
# check that none of the text is filtered against
|
# check that none of the text is filtered against
|
||||||
|
|
9
tests.py
9
tests.py
|
@ -1674,6 +1674,15 @@ def testWebLinks():
|
||||||
resultText = removeLongWords(exampleText, 40, [])
|
resultText = removeLongWords(exampleText, 40, [])
|
||||||
assert resultText == exampleText
|
assert resultText == exampleText
|
||||||
|
|
||||||
|
exampleText = \
|
||||||
|
'some.incredibly.long.and.annoying.word.which.should.be.removed: ' + \
|
||||||
|
'The remaining text'
|
||||||
|
resultText = removeLongWords(exampleText, 40, [])
|
||||||
|
print('resultText: ' + resultText)
|
||||||
|
assert resultText == \
|
||||||
|
'some.incredibly.long.and.annoying.word.w\n' + \
|
||||||
|
'hich.should.be.removed: The remaining text'
|
||||||
|
|
||||||
exampleText = \
|
exampleText = \
|
||||||
'<p>Tox address is 88AB9DED6F9FBEF43E105FB72060A2D89F9B93C74' + \
|
'<p>Tox address is 88AB9DED6F9FBEF43E105FB72060A2D89F9B93C74' + \
|
||||||
'4E8C45AB3C5E42C361C837155AFCFD9D448</p>'
|
'4E8C45AB3C5E42C361C837155AFCFD9D448</p>'
|
||||||
|
|
|
@ -5707,9 +5707,10 @@ def htmlNewswire(newswire: {}, nickname: str, moderator: bool,
|
||||||
totalVotesStr = \
|
totalVotesStr = \
|
||||||
votesIndicator(totalVotes, positiveVoting)
|
votesIndicator(totalVotes, positiveVoting)
|
||||||
|
|
||||||
|
title = removeLongWords(item[0], 30, []).replace('\n', '<br>')
|
||||||
htmlStr += '<p class="newswireItemVotedOn">' + \
|
htmlStr += '<p class="newswireItemVotedOn">' + \
|
||||||
'<a href="' + item[1] + '">' + \
|
'<a href="' + item[1] + '">' + \
|
||||||
'<span class="newswireItemVotedOn">' + item[0] + \
|
'<span class="newswireItemVotedOn">' + title + \
|
||||||
'</span></a>' + totalVotesStr
|
'</span></a>' + totalVotesStr
|
||||||
if moderator:
|
if moderator:
|
||||||
htmlStr += \
|
htmlStr += \
|
||||||
|
@ -5732,10 +5733,11 @@ def htmlNewswire(newswire: {}, nickname: str, moderator: bool,
|
||||||
totalVotesStr = \
|
totalVotesStr = \
|
||||||
votesIndicator(totalVotes, positiveVoting)
|
votesIndicator(totalVotes, positiveVoting)
|
||||||
|
|
||||||
|
title = removeLongWords(item[0], 30, []).replace('\n', '<br>')
|
||||||
if moderator and moderatedItem:
|
if moderator and moderatedItem:
|
||||||
htmlStr += '<p class="newswireItemModerated">' + \
|
htmlStr += '<p class="newswireItemModerated">' + \
|
||||||
'<a href="' + item[1] + '">' + \
|
'<a href="' + item[1] + '">' + \
|
||||||
item[0] + '</a>' + totalVotesStr
|
title + '</a>' + totalVotesStr
|
||||||
htmlStr += ' ' + dateShown
|
htmlStr += ' ' + dateShown
|
||||||
htmlStr += '<a href="/users/' + nickname + \
|
htmlStr += '<a href="/users/' + nickname + \
|
||||||
'/newswirevote=' + dateStrLink + '" ' + \
|
'/newswirevote=' + dateStrLink + '" ' + \
|
||||||
|
@ -5746,7 +5748,7 @@ def htmlNewswire(newswire: {}, nickname: str, moderator: bool,
|
||||||
else:
|
else:
|
||||||
htmlStr += '<p class="newswireItem">' + \
|
htmlStr += '<p class="newswireItem">' + \
|
||||||
'<a href="' + item[1] + '">' + \
|
'<a href="' + item[1] + '">' + \
|
||||||
item[0] + '</a>' + \
|
title + '</a>' + \
|
||||||
totalVotesStr
|
totalVotesStr
|
||||||
htmlStr += ' <span class="newswireDate">'
|
htmlStr += ' <span class="newswireDate">'
|
||||||
htmlStr += dateShown + '</span></p>\n'
|
htmlStr += dateShown + '</span></p>\n'
|
||||||
|
|
Loading…
Reference in New Issue