From 5ef2c3d18d2fa0c74aac74aa3b2a1ff0ca905b60 Mon Sep 17 00:00:00 2001 From: sriramsv Date: Fri, 26 Aug 2022 14:41:04 -0700 Subject: [PATCH 1/6] Add Public IP Search Function --- community/public-ip-search.lua | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 community/public-ip-search.lua diff --git a/community/public-ip-search.lua b/community/public-ip-search.lua new file mode 100644 index 0000000..eaa4250 --- /dev/null +++ b/community/public-ip-search.lua @@ -0,0 +1,37 @@ +-- name = "Public IP Search" +-- description = "Shows your public IP" +-- data_source = "ipify.org" +-- type = "search" +-- author = "Sriram SV" +-- version = "1.0" + +local md_color = require "md_colors" +local blue = md_colors.blue_500 +local red = md_colors.red_500 + +local ip = "" +function on_search(input) + if input:lower():find(string.lower("ip")) then + debug:toast(input) + get_ip() + end +end + +function on_click() + system:copy_to_clipboard(ip) +end + +function get_ip() + http:get("https://api.ipify.org") +end + +function on_network_result(result,code) + if code >= 200 and code < 300 then + ip = result + search:show({result},{blue}) + else + search:show({"Server Error"},{red}) + end +end + + From dcb687c38c40154b549dc17c4668859af97b0cce Mon Sep 17 00:00:00 2001 From: sriramsv Date: Fri, 26 Aug 2022 14:44:12 -0700 Subject: [PATCH 2/6] Remove debug lines --- community/public-ip-search.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/community/public-ip-search.lua b/community/public-ip-search.lua index eaa4250..e4207a9 100644 --- a/community/public-ip-search.lua +++ b/community/public-ip-search.lua @@ -12,7 +12,6 @@ local red = md_colors.red_500 local ip = "" function on_search(input) if input:lower():find(string.lower("ip")) then - debug:toast(input) get_ip() end end From a5aae9185b2257cb1b0f2759defaa9d0761e49d4 Mon Sep 17 00:00:00 2001 From: sriramsv Date: Fri, 26 Aug 2022 19:15:49 -0700 Subject: [PATCH 3/6] QR code and share menu search scripts --- self/qr-code.lua | 34 ++++++++++++++++++++++++++++++++++ self/share-menu.lua | 29 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 self/qr-code.lua create mode 100644 self/share-menu.lua diff --git a/self/qr-code.lua b/self/qr-code.lua new file mode 100644 index 0000000..e59f4de --- /dev/null +++ b/self/qr-code.lua @@ -0,0 +1,34 @@ +-- name = "QR Code" +-- description = "Turn any text or url into QR code" +-- data_source = "https://api.qrserver.com/v1/" +-- type = "search" +-- author = "Sriram SV" +-- version = "1.0" + + +qr_code_url = "https://api.qrserver.com/v1" +text_from = "" +text_to = "" + +local md_color = require "md_colors" + +-- constants +local blue = md_colors.blue_500 + + +function on_search(input) + text_to = "" + text_from = input + search:show({input},{blue}) +end + +function on_click() + if text_to == "" then + get_qr_code(text_from) + end +end + +function get_qr_code(text) + url = qr_code_url.."/create-qr-code/?size=150x150&data="..text + system:open_browser(url) +end \ No newline at end of file diff --git a/self/share-menu.lua b/self/share-menu.lua new file mode 100644 index 0000000..28762f1 --- /dev/null +++ b/self/share-menu.lua @@ -0,0 +1,29 @@ +-- name = "Share Text" +-- description = "Share text with other apps" +-- data_source = "internal" +-- type = "search" +-- author = "Sriram SV" +-- version = "1.0" + + +local md_color = require "md_colors" + +-- constants +local blue = md_colors.blue_500 +local red = md_colors.red_500 + +-- variables +text_from = "" +text_to="" +function on_search(input) + text_from = input + text_to = "" + search:show({"Share \""..input.."\""}, {blue}) +end + +function on_click() + if text_to == "" then + system:share_text(text_from) + end +end + From dd7a8b46fa1276235b7b634aeceb1405e4fa584a Mon Sep 17 00:00:00 2001 From: sriramsv Date: Fri, 26 Aug 2022 22:26:15 -0700 Subject: [PATCH 4/6] Fix Regex pattern and name change --- community/public-ip-search.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/community/public-ip-search.lua b/community/public-ip-search.lua index e4207a9..5c57821 100644 --- a/community/public-ip-search.lua +++ b/community/public-ip-search.lua @@ -1,5 +1,5 @@ --- name = "Public IP Search" --- description = "Shows your public IP" +-- name = "Public IP" +-- description = "Shows your public IP in the search bar" -- data_source = "ipify.org" -- type = "search" -- author = "Sriram SV" @@ -11,7 +11,7 @@ local red = md_colors.red_500 local ip = "" function on_search(input) - if input:lower():find(string.lower("ip")) then + if input:lower():find(string.lower("^ip$")) then get_ip() end end From e6973abdae83f4987a5560036bf6239a2384e6b0 Mon Sep 17 00:00:00 2001 From: sriramsv Date: Fri, 26 Aug 2022 22:27:22 -0700 Subject: [PATCH 5/6] Move scripts to community folder --- community/qr-code.lua | 34 ++++++++++++++++++++++++++++++++++ community/share-menu.lua | 29 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 community/qr-code.lua create mode 100644 community/share-menu.lua diff --git a/community/qr-code.lua b/community/qr-code.lua new file mode 100644 index 0000000..e59f4de --- /dev/null +++ b/community/qr-code.lua @@ -0,0 +1,34 @@ +-- name = "QR Code" +-- description = "Turn any text or url into QR code" +-- data_source = "https://api.qrserver.com/v1/" +-- type = "search" +-- author = "Sriram SV" +-- version = "1.0" + + +qr_code_url = "https://api.qrserver.com/v1" +text_from = "" +text_to = "" + +local md_color = require "md_colors" + +-- constants +local blue = md_colors.blue_500 + + +function on_search(input) + text_to = "" + text_from = input + search:show({input},{blue}) +end + +function on_click() + if text_to == "" then + get_qr_code(text_from) + end +end + +function get_qr_code(text) + url = qr_code_url.."/create-qr-code/?size=150x150&data="..text + system:open_browser(url) +end \ No newline at end of file diff --git a/community/share-menu.lua b/community/share-menu.lua new file mode 100644 index 0000000..28762f1 --- /dev/null +++ b/community/share-menu.lua @@ -0,0 +1,29 @@ +-- name = "Share Text" +-- description = "Share text with other apps" +-- data_source = "internal" +-- type = "search" +-- author = "Sriram SV" +-- version = "1.0" + + +local md_color = require "md_colors" + +-- constants +local blue = md_colors.blue_500 +local red = md_colors.red_500 + +-- variables +text_from = "" +text_to="" +function on_search(input) + text_from = input + text_to = "" + search:show({"Share \""..input.."\""}, {blue}) +end + +function on_click() + if text_to == "" then + system:share_text(text_from) + end +end + From 5f48b99bb89dcdcf03247d6241339196da505932 Mon Sep 17 00:00:00 2001 From: sriramsv Date: Fri, 26 Aug 2022 22:38:13 -0700 Subject: [PATCH 6/6] Remove self folder --- self/qr-code.lua | 34 ---------------------------------- self/share-menu.lua | 29 ----------------------------- 2 files changed, 63 deletions(-) delete mode 100644 self/qr-code.lua delete mode 100644 self/share-menu.lua diff --git a/self/qr-code.lua b/self/qr-code.lua deleted file mode 100644 index e59f4de..0000000 --- a/self/qr-code.lua +++ /dev/null @@ -1,34 +0,0 @@ --- name = "QR Code" --- description = "Turn any text or url into QR code" --- data_source = "https://api.qrserver.com/v1/" --- type = "search" --- author = "Sriram SV" --- version = "1.0" - - -qr_code_url = "https://api.qrserver.com/v1" -text_from = "" -text_to = "" - -local md_color = require "md_colors" - --- constants -local blue = md_colors.blue_500 - - -function on_search(input) - text_to = "" - text_from = input - search:show({input},{blue}) -end - -function on_click() - if text_to == "" then - get_qr_code(text_from) - end -end - -function get_qr_code(text) - url = qr_code_url.."/create-qr-code/?size=150x150&data="..text - system:open_browser(url) -end \ No newline at end of file diff --git a/self/share-menu.lua b/self/share-menu.lua deleted file mode 100644 index 28762f1..0000000 --- a/self/share-menu.lua +++ /dev/null @@ -1,29 +0,0 @@ --- name = "Share Text" --- description = "Share text with other apps" --- data_source = "internal" --- type = "search" --- author = "Sriram SV" --- version = "1.0" - - -local md_color = require "md_colors" - --- constants -local blue = md_colors.blue_500 -local red = md_colors.red_500 - --- variables -text_from = "" -text_to="" -function on_search(input) - text_from = input - text_to = "" - search:show({"Share \""..input.."\""}, {blue}) -end - -function on_click() - if text_to == "" then - system:share_text(text_from) - end -end -