diff --git a/Gemfile b/Gemfile
index cdfa9c5..dc575af 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,7 @@
source "https://rubygems.org"
gem "twenty-cli", path: "./twenty-cli"
gem "twenty-backend", path: "./twenty-backend"
+gem "twenty-frontend", path: "./twenty-frontend"
##
# FIXME: Host these gems on RubyGems.org
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..548a1d0
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,15 @@
+Copyright (C) 2023 by 0x1eef <0x1eef@protonmail.com>
+
+Permission to use, copy, modify, and/or distribute this
+software for any purpose with or without fee is hereby
+granted.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS
+ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+OF THIS SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f549b5d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,23 @@
+## About
+
+...
+
+## Usage
+
+ Usage: twenty COMMAND [OPTIONS]
+
+ Commands:
+ up Start the twenty web server.
+ down Stop the twenty web server.
+ connect Connect a project to twenty.
+ disconnect Disconnect a project from twenty.
+
+## Install
+
+ gem install twenty
+
+## License
+
+[BSD Zero Clause](https://choosealicense.com/licenses/0bsd/).
+
+See [LICENSE](./LICENSE)
diff --git a/twenty-cli/bin/twenty b/twenty-cli/bin/twenty
index 78b3885..aeb99f2 100755
--- a/twenty-cli/bin/twenty
+++ b/twenty-cli/bin/twenty
@@ -11,9 +11,17 @@ when "up"
when "down"
wait spawn("down", *ARGV[1..])
exit $?.exitstatus
+when "connect"
+ wait spawn("connect", *ARGV[1..])
+ exit $?.exitstatus
+when "disconnect"
+ wait spawn("disconnect", *ARGV[1..])
+ exit $?.exitstatus
else
warn "Usage: twenty COMMAND [OPTIONS]\n\n" \
"Commands:\n" \
" up Start the twenty web server.\n" \
" down Stop the twenty web server.\n" \
+ " connect Connect a project to twenty.\n" \
+ " disconnect Disconnect a project from twenty.\n"
end
diff --git a/twenty-cli/lib/twenty/cli.rb b/twenty-cli/lib/twenty/cli.rb
index 5759e37..288747e 100644
--- a/twenty-cli/lib/twenty/cli.rb
+++ b/twenty-cli/lib/twenty/cli.rb
@@ -1,3 +1,5 @@
module Twenty
+ require "twenty/backend"
+ require "twenty/frontend"
require_relative "command"
end
diff --git a/twenty-cli/lib/twenty/command/up.rb b/twenty-cli/lib/twenty/command/up.rb
index 4f0c8e9..d9fb699 100644
--- a/twenty-cli/lib/twenty/command/up.rb
+++ b/twenty-cli/lib/twenty/command/up.rb
@@ -10,6 +10,16 @@ class Twenty::Command::Up < Twenty::Command
private
def run_command
- warn "[twenty] up..."
+ server = WEBrick::HTTPServer.new(server_options)
+ trap(:SIGINT) { server.shutdown }
+ server.start
+ end
+
+ def server_options
+ {
+ DocumentRoot: Twenty.build,
+ BindAddress: "127.0.0.1",
+ Port: 7778
+ }
end
end
diff --git a/twenty-frontend/.gitignore b/twenty-frontend/.gitignore
new file mode 100644
index 0000000..15b8e0b
--- /dev/null
+++ b/twenty-frontend/.gitignore
@@ -0,0 +1,3 @@
+build/
+tmp/
+crash.log
diff --git a/twenty-frontend/Gemfile b/twenty-frontend/Gemfile
new file mode 100644
index 0000000..8b76a2a
--- /dev/null
+++ b/twenty-frontend/Gemfile
@@ -0,0 +1,5 @@
+# frozen_string_literal: true
+
+source 'https://rubygems.org'
+
+gem 'nanoc', '~> 4.12'
diff --git a/twenty-frontend/MANIFEST b/twenty-frontend/MANIFEST
new file mode 100644
index 0000000..17b7e44
--- /dev/null
+++ b/twenty-frontend/MANIFEST
@@ -0,0 +1,2 @@
+build/index.html
+build/stylesheet.css
diff --git a/twenty-frontend/Rules b/twenty-frontend/Rules
new file mode 100644
index 0000000..79b2631
--- /dev/null
+++ b/twenty-frontend/Rules
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+
+compile("/layouts/*") { write(nil) }
+compile '/**/*.html' do
+ layout '/default.*'
+
+ if item.identifier =~ '**/index.*'
+ write item.identifier.to_s
+ else
+ write item.identifier.without_ext + '/index.html'
+ end
+end
+
+# This is an example rule that matches Markdown (.md) files, and filters them
+# using the :kramdown filter. It is commented out by default, because kramdown
+# is not bundled with Nanoc or Ruby.
+#
+#compile '/**/*.md' do
+# filter :kramdown
+# layout '/default.*'
+#
+# if item.identifier =~ '**/index.*'
+# write item.identifier.without_ext + '.html'
+# else
+# write item.identifier.without_ext + '/index.html'
+# end
+#end
+
+passthrough "/**/*"
+layout '/**/*', :erb
diff --git a/twenty-frontend/lib/twenty/frontend.rb b/twenty-frontend/lib/twenty/frontend.rb
new file mode 100644
index 0000000..433fe5f
--- /dev/null
+++ b/twenty-frontend/lib/twenty/frontend.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+module Twenty
+ def self.build
+ File.expand_path File.join(__dir__, "..", "..", "build")
+ end
+end
diff --git a/twenty-frontend/nanoc.yaml b/twenty-frontend/nanoc.yaml
new file mode 100644
index 0000000..5b1f308
--- /dev/null
+++ b/twenty-frontend/nanoc.yaml
@@ -0,0 +1,16 @@
+# A list of file extensions that Nanoc will consider to be textual rather than
+# binary. If an item with an extension not in this list is found, the file
+# will be considered as binary.
+text_extensions: [ 'adoc', 'asciidoc', 'atom', 'coffee', 'css', 'erb', 'haml', 'handlebars', 'hb', 'htm', 'html', 'js', 'less', 'markdown', 'md', 'ms', 'mustache', 'php', 'rb', 'rdoc', 'sass', 'scss', 'slim', 'tex', 'txt', 'xhtml', 'xml' ]
+
+prune:
+ auto_prune: true
+
+lib_dirs: ['nanoc/lib']
+output_dir: build/
+
+data_sources:
+ - type: filesystem
+ encoding: utf-8
+ content_dir: src/
+ layouts_dir: src/layouts
diff --git a/twenty-frontend/src/index.html b/twenty-frontend/src/index.html
new file mode 100644
index 0000000..82bfda9
--- /dev/null
+++ b/twenty-frontend/src/index.html
@@ -0,0 +1,14 @@
+---
+title: Home
+---
+
+
You’ve just created a new Nanoc site. The page you are looking at right now is the home page for your site. To get started, consider replacing this default homepage with your own customized homepage. Some pointers on how to do so:
+ +Change this page’s content by editing the “index.html” file in the “content” directory. This is the actual page content, and therefore doesn’t include the header, sidebar or style information (those are part of the layout).
Change the layout, which is the “default.html” file in the “layouts” directory, and create something unique (and hopefully less bland).
If you need any help with customizing your Nanoc web site, be sure to check out the documentation (see sidebar), and be sure to subscribe to the discussion group (also see sidebar). Enjoy!
diff --git a/twenty-frontend/src/layouts/default.html b/twenty-frontend/src/layouts/default.html new file mode 100644 index 0000000..a9f6bb5 --- /dev/null +++ b/twenty-frontend/src/layouts/default.html @@ -0,0 +1,29 @@ + + + + +