-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
75 changed files
with
1,802 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*/*-lock.json | ||
*/node_modules | ||
*.sqlite | ||
*.lock | ||
*target | ||
*.db | ||
**.DS_Store | ||
*.DS_Store | ||
/scpt/*.jpeg | ||
/scpt/*.png | ||
config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!DOCTYPE HTML> | ||
<html style="width: 100%; height: 100%"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<!-- Optional: apply a font --> | ||
<!-- | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Michroma&family=Montserrat:wght@600&display=swap" rel="stylesheet"> | ||
--> | ||
<!-- Optional: set some favicons --> | ||
<link rel="shortcut icon" href="43ef81525e6853dc.ico" type="image/x-icon"> | ||
<link rel="icon" type="image/png" sizes="96x96" href="images/favicon-96x96.png"> | ||
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png"> | ||
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png"> | ||
|
||
<!-- Optional: set a title for your page --> | ||
<title>Pixel Streaming</title> | ||
<script defer src="player.js"></script></head> | ||
|
||
<!-- The Pixel Streaming player fills 100% of its parent element but body has a 0px height unless filled with content. As such, we explicitly force the body to be 100% of the viewport height --> | ||
<body style="width: 100vw; height: 100vh; min-height: -webkit-fill-available; font-family: 'Montserrat'; margin: 0px"> | ||
|
||
<style> | ||
button#settingsBtn { | ||
display:none; | ||
} | ||
button#statsBtn { | ||
display:none; | ||
} | ||
button#fullscreen-btn { | ||
display:none; | ||
} | ||
div#connection{ | ||
display:none; | ||
} | ||
.comment { | ||
text-align: right; | ||
padding: 10px; | ||
} | ||
a{ | ||
text-decoration: none; | ||
color: #ccc; | ||
} | ||
</style> | ||
<div class="comment"> | ||
<a href="https://bsky.app/profile/yui.syui.ai/feed/cmd">/comment</a> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
services: | ||
|
||
restreamer: | ||
image: datarhei/restreamer | ||
#image: datarhei/restreamer:cuda-latest | ||
ports: | ||
- 8080:8080 | ||
- 1935:1935 | ||
- 6000:6000/udp | ||
restart: always | ||
volumes: | ||
- ./data/config:/core/config | ||
- ./data/data:/core/data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "rust-bbs" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
actix-web = "4.0" | ||
url = "2.3.1" | ||
rusqlite = { version = "0.28", features = ["bundled"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
askama = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM syui/aios | ||
|
||
WORKDIR /app | ||
COPY ./src ./src | ||
COPY ./templates ./templates | ||
COPY ./Cargo.toml ./Cargo.toml | ||
RUN cargo build --release | ||
CMD ["/app/target/release/rust-bbs"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
web: | ||
build: . | ||
ports: | ||
- 8080:8080 | ||
volumes: | ||
- ./sqlite.db:/app/sqlite.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
use askama::Template; | ||
use serde::{Deserialize, Serialize}; | ||
use rusqlite::{Connection, Result as SqliteResult}; | ||
use actix_web::{web, App, HttpServer, HttpResponse, Responder, HttpRequest, Error}; | ||
use actix_web::error::{ErrorInternalServerError}; | ||
|
||
use std::fmt; | ||
impl fmt::Display for Post { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "@{} {}", self.handle.as_deref().unwrap_or("anonymous"), self.content) | ||
} | ||
} | ||
|
||
#[derive(Deserialize, Default)] | ||
struct QueryParams { | ||
handle: Option<String>, | ||
} | ||
#[derive(Serialize, Deserialize)] | ||
struct Post { | ||
id: i32, | ||
handle: Option<String>, | ||
content: String, | ||
} | ||
|
||
#[derive(Template)] | ||
#[template(path = "index.html")] | ||
struct IndexTemplate { | ||
posts: Vec<Post>, | ||
} | ||
|
||
#[derive(Template)] | ||
#[template(path = "post.html")] | ||
struct PostTemplate {} | ||
|
||
fn init_db() -> SqliteResult<()> { | ||
let conn = Connection::open("sqlite.db")?; | ||
conn.execute( | ||
"CREATE TABLE IF NOT EXISTS posts ( | ||
id INTEGER PRIMARY KEY, | ||
handle TEXT NOT NULL, | ||
content TEXT NOT NULL | ||
)", | ||
[], | ||
)?; | ||
Ok(()) | ||
} | ||
|
||
async fn index() -> impl Responder { | ||
let conn = Connection::open("sqlite.db").unwrap(); | ||
let mut stmt = conn.prepare("SELECT id, handle, content FROM posts ORDER BY id DESC").unwrap(); | ||
let posts = stmt.query_map([], |row| { | ||
Ok(Post { | ||
id: row.get(0)?, | ||
handle: row.get(1)?, | ||
content: row.get(2)?, | ||
}) | ||
}).unwrap().filter_map(Result::ok).collect::<Vec<Post>>(); | ||
|
||
let template = IndexTemplate { posts }; | ||
HttpResponse::Ok().body(template.render().unwrap()) | ||
} | ||
|
||
async fn post_form() -> impl Responder { | ||
let template = PostTemplate {}; | ||
HttpResponse::Ok().body(template.render().unwrap()) | ||
} | ||
|
||
#[derive(Deserialize)] | ||
struct FormData { | ||
handle: String, | ||
content: String, | ||
} | ||
|
||
async fn submit_post( | ||
req: HttpRequest, | ||
form: web::Form<FormData> | ||
) -> Result<impl Responder, Error> { | ||
let query = web::Query::<QueryParams>::from_query(req.query_string()) | ||
.unwrap_or_else(|_| web::Query(QueryParams { handle: None })); | ||
//let handle = query.handle.clone().filter(|h| !h.is_empty()); | ||
//println!("Debug: Extracted handle: {:?}", handle); | ||
let handle = if !form.handle.is_empty() { | ||
form.handle.clone() | ||
} else { | ||
query.handle.clone().unwrap_or_default() | ||
}; | ||
|
||
println!("Debug: Using handle: {:?}", handle); | ||
|
||
let conn = Connection::open("sqlite.db") | ||
.map_err(|_| ErrorInternalServerError("Database connection failed"))?; | ||
let result = conn.execute( | ||
"INSERT INTO posts (handle, content) VALUES (?1, ?2)", | ||
&[&form.handle, &form.content], | ||
); | ||
match result { | ||
Ok(_) => { | ||
let redirect_url = if !handle.is_empty() { | ||
format!("/?handle={}", handle) | ||
} else { | ||
"/".to_string() | ||
}; | ||
Ok(HttpResponse::SeeOther() | ||
.append_header(("Location", | ||
redirect_url)) | ||
.finish()) | ||
}, | ||
|
||
//Ok(_) => Ok(web::Redirect::to("/" + "?handle=" + handle).see_other()), | ||
Err(_) => Err(ErrorInternalServerError("Failed to insert post")), | ||
} | ||
} | ||
|
||
#[actix_web::main] | ||
async fn main() -> std::io::Result<()> { | ||
init_db().unwrap(); | ||
|
||
HttpServer::new(|| { | ||
App::new() | ||
.route("/", web::get().to(index)) | ||
.route("/post", web::get().to(post_form)) | ||
.route("/submit", web::post().to(submit_post)) | ||
}) | ||
.bind("0.0.0.0:8080")? | ||
.run() | ||
.await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Simple BBS</title> | ||
</head> | ||
<body> | ||
<div class="post-form" id="post-form"> | ||
<form action="/submit" method="post"> | ||
<input type="hidden" name="handle" id="handleInput"> | ||
<textarea name="content" required></textarea> | ||
<input type="submit" value="Post"> | ||
</form> | ||
</div> | ||
<div class="post-list"> | ||
<ul> | ||
{% for post in posts %} | ||
<li><span class="user-post">{{ post }}</span></li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
</body> | ||
|
||
<script> | ||
function getHandleFromUrl() { | ||
const urlParams = new URLSearchParams(window.location.search); | ||
return urlParams.get('handle'); | ||
} | ||
window.onload = function() { | ||
const handle = getHandleFromUrl(); | ||
if (handle) { | ||
document.getElementById('handleInput').value = handle; | ||
} else { | ||
document.getElementById('handleInput').value = "anonymous"; | ||
var post = document.getElementById('post-form'); | ||
post.style.display = 'none'; | ||
} | ||
}; | ||
</script> | ||
|
||
<style> | ||
ul { | ||
overflow-y: scroll; | ||
white-space: normal; | ||
word-break: break-word; | ||
} | ||
li { | ||
width: 100%; | ||
list-style: none; | ||
padding: 10px 0px; | ||
border-bottom: 1px solid #ccc; | ||
} | ||
textarea { | ||
width: 100%; | ||
border-radius: 5px; | ||
resize: none; | ||
border-bottom: 3px solid #2060df; | ||
box-sizing: border-box; | ||
} | ||
input[type="submit"] { | ||
border-radius: 5px; | ||
width: 100%; | ||
color: #fff; | ||
background: #2060df; | ||
border: none; | ||
padding: 10px; | ||
font-size 20px; | ||
} | ||
ul { | ||
border-radius: 5px; | ||
padding: 0px; | ||
margin: 0 auto; | ||
border: 1px solid #ccc; | ||
} | ||
span.user-post { | ||
padding: 0px 10px; | ||
} | ||
</style> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>New Post</title> | ||
</head> | ||
<body> | ||
<h1>New Post</h1> | ||
<form action="/submit" method="post"> | ||
<textarea name="content" required></textarea> | ||
<br> | ||
<input type="submit" value="Post"> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules | ||
.DS_Store | ||
dist | ||
*.local | ||
.vite-inspect | ||
.remote-assets | ||
components.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# for pnpm | ||
shamefully-hoist=true | ||
auto-install-peers=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Welcome to [Slidev](https://github.com/slidevjs/slidev)! | ||
|
||
To start the slide show: | ||
|
||
- `npm install` | ||
- `npm run dev` | ||
- visit <http://localhost:3030> | ||
|
||
Edit the [slides.md](./slides.md) to see the changes. | ||
|
||
Learn more about Slidev at the [documentation](https://sli.dev/). | ||
|
||
```sh | ||
$ slidev build --base /slide | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
const props = defineProps({ | ||
count: { | ||
default: 0, | ||
}, | ||
}) | ||
const counter = ref(props.count) | ||
</script> | ||
|
||
<template> | ||
<div flex="~" w="min" border="~ main rounded-md"> | ||
<button | ||
border="r main" | ||
p="2" | ||
font="mono" | ||
outline="!none" | ||
hover:bg="gray-400 opacity-20" | ||
@click="counter -= 1" | ||
> | ||
- | ||
</button> | ||
<span m="auto" p="2">{{ counter }}</span> | ||
<button | ||
border="l main" | ||
p="2" | ||
font="mono" | ||
outline="!none" | ||
hover:bg="gray-400 opacity-20" | ||
@click="counter += 1" | ||
> | ||
+ | ||
</button> | ||
</div> | ||
</template> |
Oops, something went wrong.