summary refs log tree commit diff homepage
path: root/xhtml.cr
diff options
context:
space:
mode:
Diffstat (limited to 'xhtml.cr')
-rw-r--r--xhtml.cr14
1 files changed, 12 insertions, 2 deletions
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 <https://www.gnu.org/licenses/>.
 
+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