add some forumoji
This commit is contained in:
36
lib/babycode-emoji.lua
Normal file
36
lib/babycode-emoji.lua
Normal file
@ -0,0 +1,36 @@
|
||||
local emoji_template = " <img class=emoji src=\"/emoji/$.png\" alt=\"$\" title=\"$\"> "
|
||||
|
||||
return {
|
||||
["angry"] = emoji_template:gsub("%$", "angry"),
|
||||
|
||||
["("] = emoji_template:gsub("%$", "frown"),
|
||||
|
||||
["D"] = emoji_template:gsub("%$", "grin"),
|
||||
|
||||
["imp"] = emoji_template:gsub("%$", "imp"),
|
||||
|
||||
["angryimp"] = emoji_template:gsub("%$", "impangry"),
|
||||
["impangry"] = emoji_template:gsub("%$", "impangry"),
|
||||
|
||||
["|"] = emoji_template:gsub("%$", "neutral"),
|
||||
|
||||
[")"] = emoji_template:gsub("%$", "smile"),
|
||||
|
||||
[","] = emoji_template:gsub("%$", "sob"),
|
||||
["T"] = emoji_template:gsub("%$", "sob"),
|
||||
["cry"] = emoji_template:gsub("%$", "sob"),
|
||||
["sob"] = emoji_template:gsub("%$", "sob"),
|
||||
|
||||
["o"] = emoji_template:gsub("%$", "surprised"),
|
||||
["O"] = emoji_template:gsub("%$", "surprised"),
|
||||
|
||||
["hmm"] = emoji_template:gsub("%$", "think"),
|
||||
["think"] = emoji_template:gsub("%$", "think"),
|
||||
["thinking"] = emoji_template:gsub("%$", "think"),
|
||||
|
||||
["P"] = emoji_template:gsub("%$", "tongue"),
|
||||
["p"] = emoji_template:gsub("%$", "tongue"),
|
||||
|
||||
[";"] = emoji_template:gsub("%$", "wink"),
|
||||
["wink"] = emoji_template:gsub("%$", "wink"),
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
local babycode = {}
|
||||
|
||||
local string_trim = require("lapis.util").trim
|
||||
local emoji = require("lib.babycode-emoji")
|
||||
|
||||
local function s_split(s, delimiter, max_matches, trim, allow_empty)
|
||||
local result = {}
|
||||
@ -121,6 +122,14 @@ function babycode.to_html(s, escape_html)
|
||||
|
||||
-- these can be nested, so replace open and closed separately
|
||||
text = text:gsub("%[(/?)quote%]", "<%1blockquote>")
|
||||
|
||||
text = text:gsub(":(.-):", function(code)
|
||||
if emoji[code] then
|
||||
return emoji[code]
|
||||
else
|
||||
return code
|
||||
end
|
||||
end)
|
||||
|
||||
-- replace loose links
|
||||
text = text:gsub("(https?://[%w-_%.%?%.:/%+=&~%@#%%]+[%w-/])", function(url)
|
||||
|
Reference in New Issue
Block a user