Initial Commit

main
silverwizard 2 years ago
commit bc846e39d4
  1. 1
      .gitignore
  2. 211
      Cargo.lock
  3. 10
      Cargo.toml
  4. 24
      index.md
  5. 28
      src/index.rs
  6. 43
      src/main.rs
  7. 475
      src/style.rs

1
.gitignore vendored

@ -0,0 +1 @@
/target

211
Cargo.lock generated

@ -0,0 +1,211 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "block-buffer"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e"
dependencies = [
"generic-array",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cpufeatures"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320"
dependencies = [
"libc",
]
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "digest"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "generic-array"
version = "0.14.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "libc"
version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
name = "proc-macro2"
version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rust-embed"
version = "6.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "283ffe2f866869428c92e0d61c2f35dfb4355293cdfdc48f49e895c15f1333d1"
dependencies = [
"rust-embed-impl",
"rust-embed-utils",
"walkdir",
]
[[package]]
name = "rust-embed-impl"
version = "6.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31ab23d42d71fb9be1b643fe6765d292c5e14d46912d13f3ae2815ca048ea04d"
dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
"syn",
"walkdir",
]
[[package]]
name = "rust-embed-utils"
version = "7.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1669d81dfabd1b5f8e2856b8bbe146c6192b0ba22162edc738ac0a5de18f054"
dependencies = [
"sha2",
"walkdir",
]
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "sha2"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
name = "staticwebserver"
version = "0.1.0"
dependencies = [
"rust-embed",
]
[[package]]
name = "syn"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "typenum"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "unicode-ident"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "walkdir"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
dependencies = [
"same-file",
"winapi",
"winapi-util",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

@ -0,0 +1,10 @@
[package]
name = "staticwebserver"
version = "0.1.0"
authors = ["silverwizard"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rust-embed="6.4.2"

@ -0,0 +1,24 @@
# Obscuritus
Hello!
I hope you're not looking for anything too cool here - as this is mostly my musing regarding RPGs, Sysadminning, or homegames. The more I end up doing, the happier I'll be - at some point I'll do more of this.
If you're looking for old issues of the [Obscuritus](RPGs/Obscuritus_Mag.html) magazine I printed for my ancient Dresden Files game - I still have them, at that link.
If you're looking for things I've made for print:
I've currently got nothing to put out - hopefully will change
If you're interested - my [h-card](https://indieweb.org/h-card) is:
<p class="h-card">
<img class="u-photo" src="/Images/Photo.gif" align="left" height="50" width="50" />
<br />
<a rel="me" class="u-url">http://obscuritus.ca</a>
<br />
<a class="h-card" href="http://www.obscuritus.ca" />
<a rel="me" class="u-email">silverwizard@obscuritus.ca</a>
<br />
<a rel="me" class="u-impp">xmpp:silverwizard@obscuritus.ca</a>
<br />
<a rel="me" class="u-url">http://convenient.email/profile/silverwizard?tab=profile</a>
</p>

@ -0,0 +1,28 @@
#![no_main]
pub static INDEX: &str = "
<link rel=\"stylesheet\" href=\"style.css\">
<h1>Obscuritus</h1>
<p>Hello!</p>
<p>I hope you're not looking for anything too cool here - as this is mostly my musing regarding RPGs, Sysadminning, or homegames. The more I end up doing, the happier I'll be - at some point I'll do more of this.</p>
<p>If you're looking for old issues of the <a href=\"RPGs/Obscuritus_Mag.html\">Obscuritus</a> magazine I printed for my ancient Dresden Files game - I still have them, at that link.</p>
<p>If you're looking for things I've made for print:
I've currently got nothing to put out - hopefully will change</p>
<p>If you're interested - my <a href=\"https://indieweb.org/h-card\">h-card</a> is:</p>
<p class=\"h-card\">
<img class=\"u-photo\" src=\"https://www.obscuritus.ca/Images/Photo.gif\" align=\"left\" height=\"50\" width=\"50\" />
<br />
<a rel=\"me\" class=\"u-url\">http://www.obscuritus.ca</a>
<br />
<a class=\"h-card\" href=\"http://www.obscuritus.ca\" />
<a rel=\"me\" class=\"u-email\">silverwizard@obscuritus.ca</a>
<br />
<a rel=\"me\" class=\"u-impp\"xmpp:silverwizard@obscuritus.ca</a>
<br />
<a rel=\"me\" class=\"u-url\">http://convenient.email/profile/silverwizard?tab=profile</a>
</p>";

@ -0,0 +1,43 @@
use std::{
io::{prelude::*, BufReader},
net::{TcpListener, TcpStream},
str,
};
#[path = "./index.rs"]
mod index;
#[path = "./style.rs"]
mod style;
fn main() {
let listener = TcpListener::bind("0.0.0.0:7878").unwrap();
for stream in listener.incoming() {
let stream = stream.unwrap();
handle_connection(stream);
}
}
fn handle_connection(mut stream: TcpStream) {
let buf_reader = BufReader::new(&mut stream);
let request_line = buf_reader.lines().next().unwrap().unwrap();
let mut content = "<html><head><strong>Error 404</strong><br /></head><body><img src=\"https://http.cat/404\"></img><br /><p>Not Found</p></body></html>";
let mut status_line = "HTTP/1.1 404 NOT FOUND";
if request_line == "GET / HTTP/1.1" {
status_line = "HTTP/1.1 200 OK";
content = "<html><head>Sean's Got A Webserver</head><body><p>EVERYBODY RUN</p></body></html>";
}else if request_line == "GET /index.html HTTP/1.1" {
status_line = "HTTP/1.1 200 OK";
content = index::INDEX;
}else if request_line == "GET /style.css HTTP/1.1" {
status_line = "HTTP/1.1 200 OK";
content = style::STYLE;
}
let status_line = "HTTP/1.1 200 OK";
let length = content.len();
let response = format!(
"{}\r\nContent-Length: {}\r\n\r\n{}"
, status_line, length, content);
stream.write_all(response.as_bytes());
}

@ -0,0 +1,475 @@
#![no_main]
pub static STYLE: &str = "@font-face {
font-family: 'journal';
src: url('Gravity.ttf');
}
* { transition: all 0.5s ease;}
html,body {
min-height:100%;
width:100%;
margin:0;
}
body {
background-color:#ddd;
color:#000;
font-family:sans-serif;
margin:0;
padding:0;
}
a {
color:#369;
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
.header {
background-image: -moz-linear-gradient(top, #ffffff, #000000);
background-image: -o-linear-gradient(top, #ffffff, #000000);
background-image: -webkit-linear-gradient(top, #ffffff, #000000);
background-image: linear-gradient(top, #ffffff, #000000);
background-color:#ccc;
border:0;
text-align:center;
margin-left:auto;
margin-right:auto;
line-height:.75em;
padding:.5em;
}
.header a {
border:0;
color:#111;
text-decoration:none;
}
.headerTitle {
border:0;
font-size:1.5em;
font-weight:700;
margin:0 0 0 .5em;
padding:.25em;
}
.headerTitle a {
border:0;
text-decoration:none;
color:#444;
}
.headerTitle a:hover {
border:0;
text-decoration:underline;
}
.headerSubtitle {
margin-left:1em;
font-size:.5em;
font-style:italic;
text-align:right;
text-shadow:0 0 0 #fff;
}
code {
background-color:#ddd;
border:0;
padding:0;
font-size:1.15em;
}
pre {
background-color:#ddd;
font-family:monospace;
max-height:26em;
overflow-y:auto;
border:1px #ccc dotted;
margin:0 .11em 0 1em;
padding:.2em;
}
blockquote {
font-family:monospace;
text-align:justify;
margin:.2em;
margin-left:3em;
margin-right:3em;
padding:.2em .75em;
font-size:1.2em;
}
blockquote blockquote {
border:0;
text-align:right;
text-decoration:underline;
font-size:1em;
}
table {
border-color:#aaa;
border-style:solid;
border-width:1px;
}
td {
vertical-align:middle;
border-color:transparent;
border-style:solid;
border-width:1px;
}
.topOfPage a {
background-color:#ddd;
font-size:2em;
position:fixed;
top:50%;
right:1em;
border-radius:.25em;
border:1px solid #ccc;
opacity:0.6;
margin:0 auto;
padding:.2em;
}
.topOfPage a:hover {
transition:all .5s ease;
text-decoration:none;
opacity:1;
background-color:#aaa;
color:#f0f0f0;
border:1px solid #ddd;
}
#top {
border-bottom:1px solid #ccc;
}
#menu {
background-image: linear-gradient(right, #f0f0f0, #000000);
float: left;
border:0;
border-radius: 10px;
overflow:hidden;
text-align:center;
max-width:15%;
margin:0 auto;
border:solid 1px #ccc;
}
#menu a {
display:inline;
text-decoration:none;
padding:0 .5em;
}
#menu ul {
list-style-type:none;
list-style-image:none;
background-color:#ddd;
margin:0;
padding:.3em;
}
#menu li {
display:inline;
line-height:1.2em;
white-space:nowrap;
}
#menu ul li a {
background-color:transparent;
padding:.1em 1ex;
}
#menu ul li a:hover {
color:#111;
text-decoration:none;
text-shadow:2px 2px 4px #999;
}
#menu a.thisPage {
font-weight:700;
color:#444;
font-size:1em;
}
#main {
color:#111;
background-color:#f0f0f0;
font-family:serif;
font-size:.85em;
text-align:justify;
margin-left:auto;
margin-right:auto;
width:65%;
max-width:65%;
border:solid 1px #ccc;
padding:1em 2em;
margin-bottom: 8em; /*footer height*/
}
li {list-style-type: square;}
#main ul li {
padding:.2em 1em;
}
#main ul ul ul {
list-style-type:none;
}
h1 {
text-align:center;
font-size:2em;
color:#444;
border-bottom:1px solid #aaa;
text-shadow:2px 2px 4px #999;
margin:0px .5em 0px 0ex;
}
h2 {
font-size:1.7em;
color:#444;
border-bottom:1px dotted #aaa;
margin:1em 1em 0px 0ex;
}
h3 {
font-size:1.45em;
color:#444;
margin:.9em .2em .2ex 0px;
}
h4 {
font-size:1.2em;
color:#444;
margin:.8em .3em .2ex 0px;
}
.center {
background-image: -moz-linear-gradient(top, #ffffff, #000000);
background-image: -o-linear-gradient(top, #ffffff, #000000);
background-image: -webkit-linear-gradient(top, #ffffff, #000000);
background-image: linear-gradient(top, #ffffff, #000000);
margin-left:auto;
margin-right:auto;
width:70%;
text-align:center;
}
.left {
float:left;
margin:0;
padding:0;
}
.right {
float:right;
margin:0;
padding:0;
}
#footer {
color:#999999;
border-radius: 28px;
background-image: -moz-linear-gradient(top, #000000, transparent);
background-image: -o-linear-gradient(top, #000000, transparent);
background-image: -webkit-linear-gradient(top, #000000, transparent);
background-image: linear-gradient(top, #000000, transparent);
background-clip: padding-box;
height:3em;
background-color:#ddd;
font-size:.8em;
text-align:center;
position:fixed;
bottom:0px;
right:0px;
z-index:1;
margin:0 auto;
padding:.2em;
width:100%;
opacity:0.91;
}
#footer:hover {
opacity:1;
}
#footer img {
margin-left:.2em;
margin-right:.2em;
vertical-align:middle;
}
#footer .left {
text-align:left;
float:left;
clear:left;
}
#footer .right {
text-align:right;
}
abbr,acronym {
border-bottom:1px dotted #333;
cursor:help;
}
img,table,td,blockquote,code,pre,textarea,input,iframe,object,embed,video {
max-width:100%;
}
hr {
color:#aaa;
background-color:#aaa;
height:1px;
border:0;
margin-top:0;
margin-bottom:1.5em;
}
code,pre,samp {
white-space:pre-wrap;
}
#extrait {
margin-top:1em;
font-family:sans-serif;
font-size:12px;
column-count:2;
-moz-column-count:2;
column-gap:30px;
-moz-column-gap:30px;
}
#extrait h1 {
color:#444;
border-bottom:0;
text-shadow:0 0 0 #fff;
font-size:14px;
text-align:center;
}
#extrait h2 {font-size:11px;}
#extrait h3 {font-size:10px;}
*,textarea,table,td,th,code,pre,samp {
word-wrap:break-word;
hyphens:auto;
}
p img, p a img {
overflow: hidden;
padding: 10px;
margin-left:auto;
margin-right:auto;
display:block;
}
p a img:hover {
box-shadow: 2px 2px 6px #999;
text-shadow:2px 2px 6px #999;
}
#ad {
position:absolute;
width:350px;
top:10%;
right:-370px;
border:1px solid #ccc;
padding: 20px;
background-color:#ccc;
word-wrap:break-word;
hyphens:auto;
}
#ad:hover {
right:0px;
}
#imagewall img{
clear:both;
}
form {text-align:center;}
input {text-align:center;}
.ca-menu{
clear:both;
padding:0;
text-shadow: 2px 2px 2px rgba(0,0,0,0.5);
word-wrap:break-word;
hyphens:auto;
margin-left:auto;
margin-right:auto;
text-align:center;
}
.ca-menu li{
width: 140px;
height: 100px;
position: relative;
display: inline-block;
}
.ca-menu li:last-child{
margin-right: 0px;
margin-left: 0px;
}
.ca-menu li a{
text-align: left;
width: 100%;
height: 100%;
position: relative;
display: block;
color: #444;
}
.ca-icon{
font-family: monospace;
font-size: 6em;
color: #aaa;
position: absolute;
width: 100%;
left: 0px;
text-align: center;
opacity:1;
}
.ca-main{
font-family: sans;
font-size: 0;
position: absolute;
width: 140px;
text-align: center;
opacity:0;
top:10px;
}
.ca-desc{
font-family: sans;
font-size: 0;
position: absolute;
width: 140px;
text-align: center;
opacity:0;
top:35px;
}
.ca-menu li:hover .ca-icon{
font-size:0;
opacity:0;
}
.ca-menu li:hover .ca-main{
font-size: 1.4em;
opacity: 1;
text-shadow: 0px 0px 0px rgba(0,0,0,0);
}
.ca-menu li:hover .ca-desc{
font-size: 0.9em;
opacity: 1;
text-shadow: 0px 0px 0px rgba(0,0,0,0);
}";
Loading…
Cancel
Save