summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormms <git@sapka.me>2024-12-27 00:16:14 +0100
committermms <git@sapka.me>2024-12-27 00:16:14 +0100
commitd3316d0b042ffa550ff56ed4e691c80003dd1414 (patch)
treededf93e497bb3c95b5f952a79b13dc89d3670fcf
parent9ff71af752746fd4d61e7b5a1f025b1943f60dea (diff)
feat(new): server mode
-rw-r--r--assets/webbuttons_31/classic-html.pngbin0 -> 13412 bytes
-rw-r--r--new/Gemfile8
-rw-r--r--new/Gemfile.lock37
-rwxr-xr-xnew/bin/server.rb37
-rw-r--r--new/lib/crys.rb4
-rw-r--r--new/lib/crys/code_processor.rb0
-rw-r--r--new/lib/crys/default_data.rb4
-rw-r--r--new/lib/crys/file_watcher.rb0
-rw-r--r--new/lib/crys/image_processor.rb10
-rw-r--r--new/lib/crys/listing.rb0
-rw-r--r--new/lib/crys/new_file.rb0
-rw-r--r--new/lib/crys/page_from_erb.rb0
-rw-r--r--new/lib/crys/page_from_org.rb0
-rw-r--r--new/lib/crys/renderer.rb32
-rw-r--r--new/lib/crys/resource_from_css.rb0
-rw-r--r--new/lib/crys/server.rb21
-rw-r--r--new/output/.gitkeep0
-rw-r--r--new/splash/.gitignore1
-rwxr-xr-xnew/splash/bin/server.rb10
-rw-r--r--new/splash/lib/splash.rb10
-rw-r--r--new/splash/lib/splash/server.rb7
-rw-r--r--new/splash/output/.gitkeep0
-rw-r--r--new/splash/pages/index.rb29
-rw-r--r--new/splash/theme/index.erb7
24 files changed, 217 insertions, 0 deletions
diff --git a/assets/webbuttons_31/classic-html.png b/assets/webbuttons_31/classic-html.png
new file mode 100644
index 0000000..a50115a
--- /dev/null
+++ b/assets/webbuttons_31/classic-html.png
Binary files differ
diff --git a/new/Gemfile b/new/Gemfile
new file mode 100644
index 0000000..547b868
--- /dev/null
+++ b/new/Gemfile
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+source "https://rubygems.org"
+
+gem "erb"
+gem "rspec"
+gem "rss"
+gem "webrick"
diff --git a/new/Gemfile.lock b/new/Gemfile.lock
new file mode 100644
index 0000000..d610cfd
--- /dev/null
+++ b/new/Gemfile.lock
@@ -0,0 +1,37 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ cgi (0.4.1)
+ diff-lcs (1.5.1)
+ erb (4.0.4)
+ cgi (>= 0.3.3)
+ rexml (3.4.0)
+ rspec (3.13.0)
+ rspec-core (~> 3.13.0)
+ rspec-expectations (~> 3.13.0)
+ rspec-mocks (~> 3.13.0)
+ rspec-core (3.13.2)
+ rspec-support (~> 3.13.0)
+ rspec-expectations (3.13.3)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.13.0)
+ rspec-mocks (3.13.2)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.13.0)
+ rspec-support (3.13.2)
+ rss (0.3.1)
+ rexml
+ webrick (1.9.1)
+
+PLATFORMS
+ ruby
+ x86_64-freebsd-14
+
+DEPENDENCIES
+ erb
+ rspec
+ rss
+ webrick
+
+BUNDLED WITH
+ 2.5.16
diff --git a/new/bin/server.rb b/new/bin/server.rb
new file mode 100755
index 0000000..61f7c22
--- /dev/null
+++ b/new/bin/server.rb
@@ -0,0 +1,37 @@
+require_relative "../lib/crys"
+
+module Crys
+ class ServerRunner
+ SPLASH = [
+ <<-HEREDOC
+ ▄████▄ ██▀███ ▓██ ██▓ ██████ ██████ ██▓▄▄▄█████▓▓█████
+▒██▀ ▀█ ▓██ ▒ ██▒ ▒██ ██▒▒██ ▒ ▒██ ▒ ▓██▒▓ ██▒ ▓▒▓█ ▀
+▒▓█ ▄ ▓██ ░▄█ ▒ ▒██ ██░░ ▓██▄ ░ ▓██▄ ▒██▒▒ ▓██░ ▒░▒███
+▒▓▓▄ ▄██▒▒██▀▀█▄ ░ ▐██▓░ ▒ ██▒ ▒ ██▒░██░░ ▓██▓ ░ ▒▓█ ▄
+▒ ▓███▀ ░░██▓ ▒██▒ ░ ██▒▓░▒██████▒▒▒██████▒▒░██░ ▒██▒ ░ ░▒████▒
+░ ░▒ ▒ ░░ ▒▓ ░▒▓░ ██▒▒▒ ▒ ▒▓▒ ▒ ░▒ ▒▓▒ ▒ ░░▓ ▒ ░░ ░░ ▒░ ░
+ ░ ▒ ░▒ ░ ▒░ ▓██ ░▒░ ░ ░▒ ░ ░░ ░▒ ░ ░ ▒ ░ ░ ░ ░ ░
+░ ░░ ░ ▒ ▒ ░░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░
+░ ░ ░ ░ ░ ░ ░ ░ ░ ░
+░ ░ ░
+HEREDOC
+ ]
+
+ def initialize(server_class:, root: )
+ @root = File.expand_path root
+ @server = server_class.new(root: root)
+ end
+
+ def serve
+ puts ""
+ puts SPLASH.sample
+ puts "Serving from: " + root
+ puts ""
+ server.start
+ end
+
+ private
+
+ attr_reader :root, :server
+ end
+end
diff --git a/new/lib/crys.rb b/new/lib/crys.rb
new file mode 100644
index 0000000..333fcfb
--- /dev/null
+++ b/new/lib/crys.rb
@@ -0,0 +1,4 @@
+require_relative "crys/server.rb"
+
+module Crys
+end
diff --git a/new/lib/crys/code_processor.rb b/new/lib/crys/code_processor.rb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/new/lib/crys/code_processor.rb
diff --git a/new/lib/crys/default_data.rb b/new/lib/crys/default_data.rb
new file mode 100644
index 0000000..8333669
--- /dev/null
+++ b/new/lib/crys/default_data.rb
@@ -0,0 +1,4 @@
+module Crys
+ module DefaultData
+ end
+end
diff --git a/new/lib/crys/file_watcher.rb b/new/lib/crys/file_watcher.rb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/new/lib/crys/file_watcher.rb
diff --git a/new/lib/crys/image_processor.rb b/new/lib/crys/image_processor.rb
new file mode 100644
index 0000000..1a33d04
--- /dev/null
+++ b/new/lib/crys/image_processor.rb
@@ -0,0 +1,10 @@
+module Crys
+ class ImageProcessor
+ def initialize(path:, width:, height:, format:)
+ end
+
+ def path
+
+ end
+ end
+end
diff --git a/new/lib/crys/listing.rb b/new/lib/crys/listing.rb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/new/lib/crys/listing.rb
diff --git a/new/lib/crys/new_file.rb b/new/lib/crys/new_file.rb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/new/lib/crys/new_file.rb
diff --git a/new/lib/crys/page_from_erb.rb b/new/lib/crys/page_from_erb.rb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/new/lib/crys/page_from_erb.rb
diff --git a/new/lib/crys/page_from_org.rb b/new/lib/crys/page_from_org.rb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/new/lib/crys/page_from_org.rb
diff --git a/new/lib/crys/renderer.rb b/new/lib/crys/renderer.rb
new file mode 100644
index 0000000..c490330
--- /dev/null
+++ b/new/lib/crys/renderer.rb
@@ -0,0 +1,32 @@
+require 'erb'
+require 'pry'
+
+module Crys
+ module Splash
+ class Theme
+ PARENT_DIR = File.expand_path(".", Dir.pwd)
+
+ def render
+ template = ERB.new(File.read(PARENT_DIR + "/theme/" + self.class::PAGE))
+ template.result(local_binding)
+ end
+
+ def body
+ self.class::BODY.result(local_binding)
+ end
+
+ private
+
+ attr_accessor :template, :data
+
+ def local_binding
+ local_binding = binding.clone
+ self.class::DATA.each do |k, v|
+ local_binding.local_variable_set(k,v)
+ end
+ local_binding
+
+ end
+ end
+ end
+end
diff --git a/new/lib/crys/resource_from_css.rb b/new/lib/crys/resource_from_css.rb
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/new/lib/crys/resource_from_css.rb
diff --git a/new/lib/crys/server.rb b/new/lib/crys/server.rb
new file mode 100644
index 0000000..aa0c19c
--- /dev/null
+++ b/new/lib/crys/server.rb
@@ -0,0 +1,21 @@
+require 'webrick'
+module Crys
+ class Server
+ def initialize(root:)
+ @root = root
+ end
+
+ def start
+ server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => root
+ trap 'INT' do server.shutdown end
+
+ server.start
+ end
+
+ private
+
+ attr_reader :root
+
+ end
+end
+
diff --git a/new/output/.gitkeep b/new/output/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/new/output/.gitkeep
diff --git a/new/splash/.gitignore b/new/splash/.gitignore
new file mode 100644
index 0000000..5a7d1dd
--- /dev/null
+++ b/new/splash/.gitignore
@@ -0,0 +1 @@
+**/output/*.html
diff --git a/new/splash/bin/server.rb b/new/splash/bin/server.rb
new file mode 100755
index 0000000..d932b53
--- /dev/null
+++ b/new/splash/bin/server.rb
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+require_relative "../lib/splash.rb"
+require_relative "../../bin/server.rb"
+
+server_class = Crys::Splash::Server
+
+root = File.dirname(File.dirname(__FILE__)) + "/output"
+Crys::ServerRunner.new(root: root, server_class: server_class).serve
+
diff --git a/new/splash/lib/splash.rb b/new/splash/lib/splash.rb
new file mode 100644
index 0000000..ce51e17
--- /dev/null
+++ b/new/splash/lib/splash.rb
@@ -0,0 +1,10 @@
+require_relative "../../lib/crys.rb"
+require_relative "splash/server"
+
+module Crys
+ module Splash
+ end
+end
+
+
+
diff --git a/new/splash/lib/splash/server.rb b/new/splash/lib/splash/server.rb
new file mode 100644
index 0000000..5c2a473
--- /dev/null
+++ b/new/splash/lib/splash/server.rb
@@ -0,0 +1,7 @@
+module Crys
+ module Splash
+ class Server < Crys::Server
+
+ end
+ end
+end
diff --git a/new/splash/output/.gitkeep b/new/splash/output/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/new/splash/output/.gitkeep
diff --git a/new/splash/pages/index.rb b/new/splash/pages/index.rb
new file mode 100644
index 0000000..b9772d8
--- /dev/null
+++ b/new/splash/pages/index.rb
@@ -0,0 +1,29 @@
+require_relative "../lib/theme.rb"
+
+module Crys
+ module Splash
+ class IndexPage < Theme
+ BODY = ERB.new <<-EOF
+ <h1><%= title %></h1>
+ <%= name %>
+ EOF
+
+ DATA = {
+ title: "A page",
+ name: "A name"
+ }
+
+ PAGE = "index.erb"
+
+ # filename
+ # other embbeds
+ # from .erb file
+ # from .org file
+
+
+
+ end
+ end
+end
+
+p Crys::Splash::IndexPage.new.render
diff --git a/new/splash/theme/index.erb b/new/splash/theme/index.erb
new file mode 100644
index 0000000..ed1dda8
--- /dev/null
+++ b/new/splash/theme/index.erb
@@ -0,0 +1,7 @@
+<html>
+<title> <%= title %>
+<head>
+<%= body %>
+
+</head>
+</html>