From 2be9ea60d7f171ee3375258b774191f4cf911752 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Thu, 23 Feb 2023 01:28:29 +0900 Subject: Handle requests to both ICANN and OpenNIC hosts --- xhtml.cr | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'xhtml.cr') diff --git a/xhtml.cr b/xhtml.cr index 7e21309..4749af1 100644 --- a/xhtml.cr +++ b/xhtml.cr @@ -16,6 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with hybring. If not, see . +require "uri" require "xml" CSS = " @@ -35,8 +36,11 @@ CSS = " " class Page - def initialize(static_url : String, api_url : String) + def initialize(static_dir : String, static_url : String, api_url : String) + Dir.mkdir_p static_dir + @static_file = Path[static_dir] / "index.xhtml" @static_url = static_url + @static_host = URI.parse(static_url).host @api_url = api_url end @@ -87,7 +91,9 @@ class Page errors.fetch("opennic", nil), params.fetch("opennic", nil) input xml, "icann", "ICANN URL", "e.g. https://example.net", errors.fetch("icann", nil), params.fetch("icann", nil) - xml.element "span" + xml.element "span" do + xml.element "input", type: "hidden", name: "host", value: @static_host + end xml.element "input", type: "submit", value: "Let me in!" xml.element "br" end @@ -172,4 +178,8 @@ class Page end end end + + def write(members) + File.write @static_file, self.build members + end end -- cgit 1.4.1