mirror of https://gitlab.com/bashrc2/epicyon
Support hypercore protocol
parent
1fc769b217
commit
4608678cae
|
@ -138,6 +138,7 @@ def addWebLinks(content: str) -> str:
|
|||
w.startswith('i2p://') or \
|
||||
w.startswith('gemini://') or \
|
||||
w.startswith('gopher://') or \
|
||||
w.startswith('hyper://') or \
|
||||
w.startswith('dat://'):
|
||||
if w.endswith('.') or w.endswith(';'):
|
||||
w = w[:-1]
|
||||
|
@ -151,12 +152,15 @@ def addWebLinks(content: str) -> str:
|
|||
markup += '<span class="invisible">i2p://</span>'
|
||||
elif w.startswith('dat://'):
|
||||
markup += '<span class="invisible">dat://</span>'
|
||||
elif w.startswith('hyper://'):
|
||||
markup += '<span class="invisible">hyper://</span>'
|
||||
elif w.startswith('gemini://'):
|
||||
markup += '<span class="invisible">gemini://</span>'
|
||||
elif w.startswith('gopher://'):
|
||||
markup += '<span class="invisible">gopher://</span>'
|
||||
linkText = w.replace('https://', '').replace('http://', '')
|
||||
linkText = linkText.replace('dat://', '').replace('i2p://', '')
|
||||
linkText = linkText.replace('hyper://', '')
|
||||
linkText = linkText.replace('gemini://', '')
|
||||
linkText = linkText.replace('gopher://', '')
|
||||
# prevent links from becoming too long
|
||||
|
@ -415,6 +419,10 @@ def removeLongWords(content: str, maxWordLength: int,
|
|||
continue
|
||||
elif 'dat:' in wordStr:
|
||||
continue
|
||||
elif 'hyper:' in wordStr:
|
||||
continue
|
||||
elif 'briar:' in wordStr:
|
||||
continue
|
||||
if '<' in wordStr:
|
||||
replaceWord = wordStr.split('<', 1)[0]
|
||||
content = content.replace(wordStr, replaceWord)
|
||||
|
@ -540,6 +548,7 @@ def getMentionsFromHtml(htmlText: str,
|
|||
actorStr = mentionStr.split('"')[0]
|
||||
if actorStr.startswith('http') or \
|
||||
actorStr.startswith('i2p') or \
|
||||
actorStr.startswith('hyper') or \
|
||||
actorStr.startswith('dat:'):
|
||||
if actorStr not in mentions:
|
||||
mentions.append(actorStr)
|
||||
|
|
|
@ -171,6 +171,9 @@ parser.add_argument("--http", type=str2bool, nargs='?',
|
|||
parser.add_argument("--dat", type=str2bool, nargs='?',
|
||||
const=True, default=False,
|
||||
help="Use dat protocol only")
|
||||
parser.add_argument("--hyper", type=str2bool, nargs='?',
|
||||
const=True, default=False,
|
||||
help="Use hypercore protocol only")
|
||||
parser.add_argument("--i2p", type=str2bool, nargs='?',
|
||||
const=True, default=False,
|
||||
help="Use i2p protocol only")
|
||||
|
@ -977,6 +980,8 @@ if args.ocap:
|
|||
ocapAlways = args.ocap
|
||||
if args.dat:
|
||||
httpPrefix = 'dat'
|
||||
if args.hyper:
|
||||
httpPrefix = 'hyper'
|
||||
if args.i2p:
|
||||
httpPrefix = 'i2p'
|
||||
|
||||
|
@ -990,6 +995,7 @@ if args.actor:
|
|||
args.actor = args.actor.replace('https://', '')
|
||||
args.actor = args.actor.replace('http://', '')
|
||||
args.actor = args.actor.replace('dat://', '')
|
||||
args.actor = args.actor.replace('hyper://', '')
|
||||
args.actor = args.actor.replace('i2p://', '')
|
||||
args.actor = args.actor.replace('/@', '/users/')
|
||||
if '/users/' not in args.actor and \
|
||||
|
|
|
@ -461,8 +461,8 @@ def noOfFollowRequests(baseDir: str,
|
|||
lines = f.readlines()
|
||||
if followType != "onion":
|
||||
return len(lines)
|
||||
for l in lines:
|
||||
if '.onion' in l:
|
||||
for fileLine in lines:
|
||||
if '.onion' in fileLine:
|
||||
ctr += 1
|
||||
return ctr
|
||||
|
||||
|
|
1
inbox.py
1
inbox.py
|
@ -1361,6 +1361,7 @@ def receiveAnnounce(recentPostsCache: {},
|
|||
objectDomain = objectDomain.replace('http://', '')
|
||||
objectDomain = objectDomain.replace('i2p://', '')
|
||||
objectDomain = objectDomain.replace('dat://', '')
|
||||
objectDomain = objectDomain.replace('hyper://', '')
|
||||
if '/' in objectDomain:
|
||||
objectDomain = objectDomain.split('/')[0]
|
||||
if isBlockedDomain(baseDir, objectDomain):
|
||||
|
|
15
utils.py
15
utils.py
|
@ -230,22 +230,23 @@ def getDomainFromActor(actor: str) -> (str, int):
|
|||
if '/profile/' in actor:
|
||||
domain = actor.split('/profile/')[0].replace('https://', '')
|
||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
||||
domain = domain.replace('dat://', '')
|
||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||
else:
|
||||
if '/channel/' in actor:
|
||||
domain = actor.split('/channel/')[0].replace('https://', '')
|
||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
||||
domain = domain.replace('dat://', '')
|
||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||
else:
|
||||
if '/users/' not in actor:
|
||||
domain = actor.replace('https://', '').replace('http://', '')
|
||||
domain = domain.replace('i2p://', '').replace('dat://', '')
|
||||
domain = domain.replace('i2p://', '')
|
||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||
if '/' in actor:
|
||||
domain = domain.split('/')[0]
|
||||
else:
|
||||
domain = actor.split('/users/')[0].replace('https://', '')
|
||||
domain = domain.replace('http://', '').replace('i2p://', '')
|
||||
domain = domain.replace('dat://', '')
|
||||
domain = domain.replace('dat://', '').replace('hyper://', '')
|
||||
if ':' in domain:
|
||||
portStr = domain.split(':')[1]
|
||||
if not portStr.isdigit():
|
||||
|
@ -481,10 +482,10 @@ def deletePost(baseDir: str, httpPrefix: str,
|
|||
lines = f.readlines()
|
||||
if lines:
|
||||
newlines = ''
|
||||
for l in lines:
|
||||
if postId in l:
|
||||
for fileLine in lines:
|
||||
if postId in fileLine:
|
||||
continue
|
||||
newlines += l
|
||||
newlines += fileLine
|
||||
if not newlines.strip():
|
||||
# if there are no lines then remove the
|
||||
# hashtag file
|
||||
|
|
|
@ -27,7 +27,8 @@ def parseHandle(handle: str) -> (str, str):
|
|||
if '.' not in handle:
|
||||
return None, None
|
||||
handleStr = handle.replace('https://', '').replace('http://', '')
|
||||
handleStr = handleStr.replace('dat://', '').replace('i2p://', '')
|
||||
handleStr = handleStr.replace('dat://', '').replace('hyper://', '')
|
||||
handleStr = handleStr.replace('i2p://', '')
|
||||
if '/@' in handle:
|
||||
domain, nickname = handleStr.split('/@')
|
||||
else:
|
||||
|
|
|
@ -92,6 +92,7 @@ def getBlogAddress(actorJson: {}) -> str:
|
|||
if not (propertyValue['value'].startswith('https://') or
|
||||
propertyValue['value'].startswith('http://') or
|
||||
propertyValue['value'].startswith('dat://') or
|
||||
propertyValue['value'].startswith('hyper://') or
|
||||
propertyValue['value'].startswith('i2p://')):
|
||||
continue
|
||||
if '.' not in propertyValue['value']:
|
||||
|
@ -127,6 +128,7 @@ def setBlogAddress(actorJson: {}, blogAddress: str) -> None:
|
|||
if not (blogAddress.startswith('https://') or
|
||||
blogAddress.startswith('http://') or
|
||||
blogAddress.startswith('dat://') or
|
||||
blogAddress.startswith('hyper://') or
|
||||
blogAddress.startswith('i2p://')):
|
||||
return
|
||||
if '.' not in blogAddress:
|
||||
|
@ -2764,7 +2766,8 @@ def addEmbeddedAudio(translate: {}, content: str) -> str:
|
|||
continue
|
||||
|
||||
if not (w.startswith('http') or w.startswith('dat:') or
|
||||
w.startswith('i2p:') or '/' in w):
|
||||
w.startswith('hyper:') or w.startswith('i2p:') or
|
||||
'/' in w):
|
||||
continue
|
||||
url = w
|
||||
content += '<center><audio controls>'
|
||||
|
@ -2809,7 +2812,8 @@ def addEmbeddedVideo(translate: {}, content: str,
|
|||
if not w.endswith(extension):
|
||||
continue
|
||||
if not (w.startswith('http') or w.startswith('dat:') or
|
||||
w.startswith('i2p:') or '/' in w):
|
||||
w.startswith('hyper:') or w.startswith('i2p:') or
|
||||
'/' in w):
|
||||
continue
|
||||
url = w
|
||||
content += \
|
||||
|
@ -3945,6 +3949,7 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int,
|
|||
postJsonObject['object']['inReplyTo']
|
||||
postDomain = postDomain.replace('https://', '')
|
||||
postDomain = postDomain.replace('http://', '')
|
||||
postDomain = postDomain.replace('hyper://', '')
|
||||
postDomain = postDomain.replace('dat://', '')
|
||||
postDomain = postDomain.replace('i2p://', '')
|
||||
if '/' in postDomain:
|
||||
|
@ -4099,7 +4104,7 @@ def individualPostAsHtml(recentPostsCache: {}, maxRecentPosts: int,
|
|||
postHtml = galleryStr
|
||||
|
||||
if not showPublicOnly and storeToCache and \
|
||||
boxName != 'tlmedia'and boxName != 'tlbookmarks':
|
||||
boxName != 'tlmedia' and boxName != 'tlbookmarks':
|
||||
saveIndividualPostAsHtmlToCache(baseDir, nickname, domain,
|
||||
postJsonObject, postHtml)
|
||||
updateRecentPostsCache(recentPostsCache, maxRecentPosts,
|
||||
|
|
Loading…
Reference in New Issue