summaryrefslogtreecommitdiffstats
path: root/weblogviewfunctions.lua
diff options
context:
space:
mode:
authorLuke Stuart <lukestu@gmail.com>2011-08-10 15:03:33 +0000
committerTed Trask <ttrask01@yahoo.com>2011-08-10 11:53:30 -0400
commit28804449df1f28067b9eba8475452b5c97b2a1ac (patch)
treeb5e712dbc55b15c0ee1612f8a1a0bccabbf3d9fc /weblogviewfunctions.lua
parent9377ebd8eef7b2e04d475a983369d8f9a903056b (diff)
downloadacf-weblog-28804449df1f28067b9eba8475452b5c97b2a1ac.tar.bz2
acf-weblog-28804449df1f28067b9eba8475452b5c97b2a1ac.tar.xz
Weblog Updates including Squark support and revamped analysis.
Diffstat (limited to 'weblogviewfunctions.lua')
-rw-r--r--weblogviewfunctions.lua52
1 files changed, 52 insertions, 0 deletions
diff --git a/weblogviewfunctions.lua b/weblogviewfunctions.lua
new file mode 100644
index 0000000..b809f23
--- /dev/null
+++ b/weblogviewfunctions.lua
@@ -0,0 +1,52 @@
+require("html")
+require("session")
+
+-- Split a string to an array by delimiter or pattern
+function split(str, pat)
+ if string.find(str, pat) == nil then
+ return str
+ end
+ local t = {}
+ local fpat = "(.-)" .. pat
+ local last_end = 1
+ local s, e, cap = str:find(fpat, 1)
+ while s do
+ if s ~= 1 or cap ~= "" then
+ table.insert(t,cap)
+ end
+ last_end = e+1
+ s, e, cap = str:find(fpat, last_end)
+ end
+ if last_end <= #str then
+ cap = str:sub(last_end)
+ table.insert(t, cap)
+ end
+ return t
+end
+-- Insert a string into another string
+function string.insert(value, insert, place)
+
+ if place == nil then
+ place = string.len(value)+1
+ end
+
+ return string.sub(value, 1,place-1) .. tostring(insert) .. string.sub(value, place, string.len(value))
+
+end
+
+--Highlight occurences of a word in a string
+function string.highlight(txtvalue, searchval, fcolour, bcolour)
+
+ if txtvalue ~=nil and searchval ~= nil then
+ sStart = string.find(string.lower(txtvalue),string.lower(searchval))
+ if sStart ~= nil then
+ sEnd = sStart + string.len(searchval)
+ txtvalue = string.insert(txtvalue,"</font>", sEnd)
+ txtvalue = string.insert(txtvalue,"<font style='color:"..fcolour.."; background-color:"..bcolour..";'>", sStart)
+ end
+ end
+
+ return txtvalue
+
+end
+