Initial commit

This commit is contained in:
Shuanglei Tao
2016-10-31 22:13:57 +08:00
commit 0eee73cf65
6 changed files with 225 additions and 0 deletions

1
dark.css Normal file
View File

@@ -0,0 +1 @@
.dark{color:#ccc}.dark,.dark pre{background-color:#000}.dark pre{padding:0;border:none}.dark pre code{color:#00bcd4}.dark h1 a,.dark h2 a,.dark h3 a,.dark h4 a,.dark h5 a{color:#ccc}.dark code,.dark strong{color:#fff}.dark code{font-weight:100}.dark table{color:#ccc}.dark table td,.dark table th{border-color:#444}.dark table tbody td:first-child{color:#fff}.dark .form-group label{color:#ccc;border-color:rgba(95,95,95,.78)}.dark .form-group.form-textarea label:after{background-color:#000}.dark .form-control{color:#ccc;border-color:rgba(95,95,95,.78)}.dark .form-control:focus{border-color:#ccc;color:#ccc}.dark textarea.form-control{color:#ccc}.dark .card{border-color:rgba(95,95,95,.78)}.dark .card .card-header{background-color:transparent;color:#ccc;border-bottom:1px solid rgba(95,95,95,.78)}.dark .btn.btn-ghost.btn-default{border-color:#ababab;color:#ababab}.dark .btn.btn-ghost.btn-default:focus,.dark .btn.btn-ghost.btn-default:hover{border-color:#9c9c9c;color:#9c9c9c;z-index:1}.dark .btn.btn-ghost.btn-default:focus,.dark .btn.btn-ghost.btn-default:hover{border-color:#e0e0e0;color:#e0e0e0}.dark .btn.btn-ghost.btn-primary:focus,.dark .btn.btn-ghost.btn-primary:hover{border-color:#64b5f6;color:#64b5f6}.dark .btn.btn-ghost.btn-success:focus,.dark .btn.btn-ghost.btn-success:hover{border-color:#81c784;color:#81c784}.dark .btn.btn-ghost.btn-info:focus,.dark .btn.btn-ghost.btn-info:hover{border-color:#4dd0e1;color:#4dd0e1}.dark .btn.btn-ghost.btn-error:focus,.dark .btn.btn-ghost.btn-error:hover{border-color:#e57373;color:#e57373}.dark .btn.btn-ghost.btn-warning:focus,.dark .btn.btn-ghost.btn-warning:hover{border-color:#ffb74d;color:#ffb74d}.dark .avatarholder,.dark .placeholder{background-color:transparent;border-color:#333}.dark .menu .menu-item{color:#ccc;border-color:rgba(95,95,95,.78)}.dark .menu .menu-item.active,.dark .menu .menu-item:hover{color:#fff;border-color:#ccc}

1
hack.css Normal file

File diff suppressed because one or more lines are too long

92
index.html Normal file
View File

@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ttyd - Share your terminal over the web</title>
<link rel="stylesheet" href="./prism.css">
<link rel="stylesheet" href="./hack.css">
<link rel="stylesheet" href="./dark.css">
</head>
<body class="hack dark">
<a href="https://github.com/tsl0922/ttyd" class="github-corner" aria-label="View source on Github"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#fff; color:#151513; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<div class="main container">
<h1>ttyd - Share your terminal over the web</h1>
<p>ttyd is a simple command-line tool for sharing terminal over the web, inspired by <a href="https://github.com/yudai/gotty">GoTTY</a>.</p>
<p><img src="./screenshot.gif" alt="screenshot" style="max-width:100%;" /></p>
<h1>Features</h1>
<ul>
<li>Build on <a href="https://libwebsockets.org">libwebsockets</a> with C for speed</li>
<li>Full terminal emulation based on <a href="https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm">hterm</a></li>
<li>SSL support based on <a href="https://www.openssl.org">OpenSSL</a></li>
<li>Run any custom command with options</li>
<li>Basic authentication support</li>
<li>Cross platform: macOS, Linux, <a href="https://openwrt.org">OpenWrt</a>/<a href="https://www.lede-project.org">LEDE</a></li>
</ul>
<h1>Installation</h1>
<h2>Install on macOS</h2>
<p>Install with <a href="http://brew.sh">homebrew</a>:</p>
<div class="highlight highlight-source-shell">
<pre><code class="language-bash">brew install ttyd</code></pre>
</div>
<h2>Install on Linux</h2>
<p>Ubuntu 16.04 as example:</p>
<pre><code class="language-bash">sudo apt-get install cmake g++ pkg-config git vim-common libwebsockets-dev libjson-c-dev libssl-dev
git clone https://github.com/tsl0922/ttyd.git
cd ttyd && mkdir build && cd build
cmake ..
make && make install</code></pre>
<blockquote>
<strong>NOTE:</strong> You may need to compile libwebsockets from source for ubuntu versions old than 16.04, since they have outdated <code>libwebsockets-dev</code> package (<a href="https://github.com/tsl0922/ttyd/issues/6">Issue #6</a>).
</blockquote>
<h2>Install on OpenWrt/LEDE</h2>
<div class="highlight highlight-source-shell">
<pre><code class="language-bash">opkg install ttyd</code></pre>
</div>
<blockquote>
<strong>NOTE:</strong> This may only works for <a href="https://www.lede-project.org">LEDE</a> snapshots currently, if the install command fails, compile it yourself.
</blockquote>
<h1>Usage</h1>
<pre><code>ttyd is a tool for sharing terminal over the web
USAGE:
ttyd [options] <command> [<arguments...>]
VERSION:
1.1.0
OPTIONS:
--port, -p Port to listen (default: 7681)
--interface, -i Network interface to bind
--credential, -c Credential for Basic Authentication (format: username:password)
--uid, -u User id to run with
--gid, -g Group id to run with
--signal, -s Signal to send to the command when exit it (default: SIGHUP)
--reconnect, -r Time to reconnect for the client in seconds (default: 10)
--readonly, -R Do not allow clients to write to the TTY
--client-option, -t Send option to client (format: key=value), repeat to add more options
--check-origin, -O Do not allow websocket connection from different origin
--once, -o Accept only one client and exit on disconnection
--ssl, -S Enable ssl
--ssl-cert, -C Ssl certificate file path
--ssl-key, -K Ssl key file path
--ssl-ca, -A Ssl ca file path
--debug, -d Set log level (0-9, default: 7)
--version, -v Print the version and exit
--help, -h Print this text and exit</code></pre>
<p>ttyd starts web server at port <code>7681</code> by default, the <code>command</code> will be started with <code>arguments</code> as options. For example, run:</p>
<pre><code class="language-bash">ttyd bash</code></pre>
<p>Then open <a href="http://localhost:7681">http://localhost:7681</a>, now you can see and control the <code>bash</code> console on your web broswer!</p>
<blockquote>
<strong>TIP:</strong> You may replace <code>bash</code> with <code>login</code> to get a login prompt first.
</blockquote>
<h1>Credits</h1>
<ul>
<li><a href="https://github.com/yudai/gotty">GoTTY</a>: ttyd is a port of GoTTY to <code>C</code> language.</li>
<li><a href="https://chromium.googlesource.com/apps/libapps/+/HEAD/hterm">hterm</a>: ttyd uses hterm to run a terminal emulator on the web.</li>
</ul>
</div>
<script src="./prism.js" async></script>
</body>
</html>

128
prism.css Normal file
View File

@@ -0,0 +1,128 @@
/* http://prismjs.com/download.html?themes=prism-solarizedlight&languages=bash */
/*
Solarized Color Schemes originally by Ethan Schoonover
http://ethanschoonover.com/solarized
Ported for PrismJS by Hector Matos
Website: https://krakendev.io
Twitter Handle: https://twitter.com/allonsykraken)
*/
code[class*="language-"],
pre[class*="language-"] {
color: #657b83; /* base00 */
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
background: #073642; /* base02 */
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
background: #073642; /* base02 */
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
border-radius: 0.3em;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background-color: #fdf6e3; /* base3 */
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: #93a1a1; /* base1 */
}
.token.punctuation {
color: #586e75; /* base01 */
}
.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #268bd2; /* blue */
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.url,
.token.inserted {
color: #2aa198; /* cyan */
}
.token.entity {
color: #657b83; /* base00 */
background: #eee8d5; /* base2 */
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #859900; /* green */
}
.token.function {
color: #b58900; /* yellow */
}
.token.regex,
.token.important,
.token.variable {
color: #cb4b16; /* orange */
}
.token.important,
.token.bold {
font-weight: bold;
}
.token.italic {
font-style: italic;
}
.token.entity {
cursor: help;
}

3
prism.js Normal file

File diff suppressed because one or more lines are too long

BIN
screenshot.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB