Add twenty-frontend/
This commit is contained in:
parent
8b1643dc30
commit
b23d7fbe4d
16 changed files with 281 additions and 1 deletions
1
Gemfile
1
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
|
||||
|
|
15
LICENSE
Normal file
15
LICENSE
Normal file
|
@ -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.
|
23
README.md
Normal file
23
README.md
Normal file
|
@ -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/).
|
||||
<br>
|
||||
See [LICENSE](./LICENSE)
|
|
@ -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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
module Twenty
|
||||
require "twenty/backend"
|
||||
require "twenty/frontend"
|
||||
require_relative "command"
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
3
twenty-frontend/.gitignore
vendored
Normal file
3
twenty-frontend/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
build/
|
||||
tmp/
|
||||
crash.log
|
5
twenty-frontend/Gemfile
Normal file
5
twenty-frontend/Gemfile
Normal file
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'nanoc', '~> 4.12'
|
2
twenty-frontend/MANIFEST
Normal file
2
twenty-frontend/MANIFEST
Normal file
|
@ -0,0 +1,2 @@
|
|||
build/index.html
|
||||
build/stylesheet.css
|
30
twenty-frontend/Rules
Normal file
30
twenty-frontend/Rules
Normal file
|
@ -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
|
7
twenty-frontend/lib/twenty/frontend.rb
Normal file
7
twenty-frontend/lib/twenty/frontend.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Twenty
|
||||
def self.build
|
||||
File.expand_path File.join(__dir__, "..", "..", "build")
|
||||
end
|
||||
end
|
16
twenty-frontend/nanoc.yaml
Normal file
16
twenty-frontend/nanoc.yaml
Normal file
|
@ -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
|
14
twenty-frontend/src/index.html
Normal file
14
twenty-frontend/src/index.html
Normal file
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
title: Home
|
||||
---
|
||||
|
||||
<h1>A Brand New Nanoc Site</h1>
|
||||
|
||||
<p>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:</p>
|
||||
|
||||
<ul>
|
||||
<li><p><strong>Change this page’s content</strong> 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).</p></li>
|
||||
<li><p><strong>Change the layout</strong>, which is the “default.html” file in the “layouts” directory, and create something unique (and hopefully less bland).</p></li>
|
||||
</ul>
|
||||
|
||||
<p>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!</p>
|
29
twenty-frontend/src/layouts/default.html
Normal file
29
twenty-frontend/src/layouts/default.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>A Brand New Nanoc Site - <%= @item[:title] %></title>
|
||||
<link rel="stylesheet" href="/stylesheet.css">
|
||||
|
||||
<!-- you don't need to keep this, but it's cool for stats! -->
|
||||
<meta name="generator" content="Nanoc <%= Nanoc::VERSION %>">
|
||||
</head>
|
||||
<body>
|
||||
<div id="main">
|
||||
<%= yield %>
|
||||
</div>
|
||||
<div id="sidebar">
|
||||
<h2>Documentation</h2>
|
||||
<ul>
|
||||
<li><a href="https://nanoc.ws/doc/">Documentation</a></li>
|
||||
<li><a href="https://nanoc.ws/doc/tutorial/">Tutorial</a></li>
|
||||
</ul>
|
||||
<h2>Community</h2>
|
||||
<ul>
|
||||
<li><a href="http://groups.google.com/group/nanoc/">Discussion group</a></li>
|
||||
<li><a href="https://gitter.im/nanoc/nanoc">Gitter channel</a></li>
|
||||
<li><a href="https://nanoc.ws/contributing/">Contributing</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
101
twenty-frontend/src/stylesheet.css
Normal file
101
twenty-frontend/src/stylesheet.css
Normal file
|
@ -0,0 +1,101 @@
|
|||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
font-family: Georgia, Palatino, serif;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:link,
|
||||
a:visited {
|
||||
color: #f30;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #f90;
|
||||
}
|
||||
|
||||
#main {
|
||||
position: absolute;
|
||||
|
||||
top: 40px;
|
||||
left: 280px;
|
||||
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#main h1 {
|
||||
font-size: 40px;
|
||||
font-weight: normal;
|
||||
|
||||
line-height: 40px;
|
||||
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
|
||||
#main p {
|
||||
margin: 20px 0;
|
||||
|
||||
font-size: 15px;
|
||||
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
#main ul, #main ol {
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
#main li {
|
||||
font-size: 15px;
|
||||
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
#main ul li {
|
||||
list-style-type: square;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
position: absolute;
|
||||
|
||||
top: 40px;
|
||||
left: 20px;
|
||||
width: 200px;
|
||||
|
||||
padding: 20px 20px 0 0;
|
||||
|
||||
border-right: 1px solid #ccc;
|
||||
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#sidebar h2 {
|
||||
text-transform: uppercase;
|
||||
|
||||
font-size: 13px;
|
||||
|
||||
color: #333;
|
||||
|
||||
letter-spacing: 1px;
|
||||
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
#sidebar ul {
|
||||
list-style-type: none;
|
||||
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
#sidebar li {
|
||||
font-size: 14px;
|
||||
|
||||
line-height: 20px;
|
||||
}
|
14
twenty-frontend/twenty-frontend.gemspec
Normal file
14
twenty-frontend/twenty-frontend.gemspec
Normal file
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Gem::Specification.new do |gem|
|
||||
gem.name = "twenty-frontend"
|
||||
gem.authors = ["0x1eef"]
|
||||
gem.email = ["0x1eef@protonmail.com"]
|
||||
gem.homepage = "https://github.com/0x1eef/twenty#readme"
|
||||
gem.version = "0.1.0"
|
||||
gem.licenses = ["0BSD"]
|
||||
gem.files = File.binread("./MANIFEST").each_line.map(&:chomp)
|
||||
gem.require_paths = ["lib"]
|
||||
gem.summary = "twenty: frontend"
|
||||
gem.description = gem.summary
|
||||
end
|
Loading…
Reference in a new issue