Added cashtags and fixed regex error
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import std/[algorithm, unicode, re, strutils, strformat, options, nre]
|
import std/[algorithm, unicode, re, strutils, strformat, options]
|
||||||
import jsony
|
import jsony
|
||||||
import utils, slices
|
import utils, slices
|
||||||
import ../types/user as userType
|
import ../types/user as userType
|
||||||
@@ -8,7 +8,7 @@ let
|
|||||||
unRegex = re.re"(^|[^A-z0-9-_./?])@([A-z0-9_]{1,15})"
|
unRegex = re.re"(^|[^A-z0-9-_./?])@([A-z0-9_]{1,15})"
|
||||||
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
||||||
|
|
||||||
htRegex = nre.re"""(*U)(^|[^\w-_.?])([##$])([\w_]*+)(?!</a>|">|#)"""
|
htRegex = re.re"(^|[^a-zA-Z0-9_-_.?])([##$])([a-zA-Z0-9_]+)"
|
||||||
htReplace = "$1<a href=\"/search?f=tweets&q=%23$3\">$2$3</a>"
|
htReplace = "$1<a href=\"/search?f=tweets&q=%23$3\">$2$3</a>"
|
||||||
|
|
||||||
proc expandUserEntities(user: var User; raw: RawUser) =
|
proc expandUserEntities(user: var User; raw: RawUser) =
|
||||||
@@ -29,7 +29,7 @@ proc expandUserEntities(user: var User; raw: RawUser) =
|
|||||||
|
|
||||||
user.bio = orig.replacedWith(replacements, 0 .. orig.len)
|
user.bio = orig.replacedWith(replacements, 0 .. orig.len)
|
||||||
.replacef(unRegex, unReplace)
|
.replacef(unRegex, unReplace)
|
||||||
.replace(htRegex, htReplace)
|
.replacef(htRegex, htReplace)
|
||||||
|
|
||||||
proc getBanner(user: RawUser): string =
|
proc getBanner(user: RawUser): string =
|
||||||
if user.profileBannerUrl.len > 0:
|
if user.profileBannerUrl.len > 0:
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ let
|
|||||||
unRegex = re"(^|[^A-z0-9-_./?])@([A-z0-9_]{1,15})"
|
unRegex = re"(^|[^A-z0-9-_./?])@([A-z0-9_]{1,15})"
|
||||||
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
unReplace = "$1<a href=\"/$2\">@$2</a>"
|
||||||
|
|
||||||
htRegex = re"(^|[^\w-_./?])([#$]|#)([\w_]+)"
|
htRegex = re"(^|[^a-zA-Z0-9_-_.?])([#$]|#)([a-zA-Z0-9_]+)"
|
||||||
htReplace = "$1<a href=\"/search?f=tweets&q=%23$3\">$2$3</a>"
|
htReplace = "$1<a href=\"/search?f=tweets&q=%23$3\">$2$3</a>"
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ const
|
|||||||
"media", "images", "twimg", "videos",
|
"media", "images", "twimg", "videos",
|
||||||
"native_video", "consumer_video", "spaces",
|
"native_video", "consumer_video", "spaces",
|
||||||
"links", "news", "quote", "mentions",
|
"links", "news", "quote", "mentions",
|
||||||
"replies", "retweets", "nativeretweets"
|
"replies", "retweets", "nativeretweets", "cashtags"
|
||||||
]
|
]
|
||||||
|
|
||||||
emptyQuery* = "include:nativeretweets"
|
emptyQuery* = "include:nativeretweets"
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ const toggles = {
|
|||||||
"links": "Links",
|
"links": "Links",
|
||||||
"images": "Images",
|
"images": "Images",
|
||||||
"quote": "Quotes",
|
"quote": "Quotes",
|
||||||
"spaces": "Spaces"
|
"spaces": "Spaces",
|
||||||
|
"cashtags": "Cashtags"
|
||||||
}.toOrderedTable
|
}.toOrderedTable
|
||||||
|
|
||||||
proc renderSearch*(): VNode =
|
proc renderSearch*(): VNode =
|
||||||
|
|||||||
Reference in New Issue
Block a user