From f7275309ad3ec062ebed915a097766daf126813b Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Fri, 21 Jun 2024 00:43:41 +0530 Subject: Basic Home Page Implementation * Moves assets from old website * Basic layout based on old website * Move home page from old website --- src/indrajith-dev-crystal.cr | 21 ++++++++++++++++-- src/views/home.ecr | 23 +++++++++++++++++++ src/views/layout.ecr | 53 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 src/views/home.ecr create mode 100644 src/views/layout.ecr (limited to 'src') diff --git a/src/indrajith-dev-crystal.cr b/src/indrajith-dev-crystal.cr index a7a08b6..28948cf 100644 --- a/src/indrajith-dev-crystal.cr +++ b/src/indrajith-dev-crystal.cr @@ -3,8 +3,25 @@ require "kemal" module Indrajith::Dev::Crystal VERSION = "0.1.0" - get "/" do - "Hello World!" + macro page_renderer(filename) + render "src/views/#{{{filename}}}.ecr", "src/views/layout.ecr" + end + + def self.htmx_request?(context) + context.request.headers.has_key?("HX-Request") || + context.request.headers.has_key?("Hx-Request") || + context.request.headers.has_key?("hx-request") + end + + get "/" do |context| + if htmx_request?(context) + partial_content = render("src/views/home.ecr") + context.response.content_type = "text/html" + context.response.print partial_content + else + context.response.content_type = "text/html" + page_renderer "home" + end end Kemal.run diff --git a/src/views/home.ecr b/src/views/home.ecr new file mode 100644 index 0000000..5d7eb54 --- /dev/null +++ b/src/views/home.ecr @@ -0,0 +1,23 @@ +
+ "Hello Friend!! My name is Indrajith K L." I'm a web developer, hobbyist game developer from India, working as a front-end developer. + This site is where I write about my fun side projects, R&D's, random thoughts, game development etc. Since you are here why don't you read some posts. +
+