fix
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
*.sqlite
|
||||
*.lock
|
||||
*target
|
||||
*.db
|
||||
|
@ -1,40 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="referrer" content="origin-when-cross-origin">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.purple.min.css">
|
||||
<title>atproto OAuth Web Service Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<hgroup>
|
||||
{% if g.user %}
|
||||
{% endif %}
|
||||
</hgroup>
|
||||
<nav>
|
||||
<ul>
|
||||
{% if g.user %}
|
||||
<li><a href="{{ url_for('bsky_post') }}">Create Post</a>
|
||||
<li><a href="{{ url_for('oauth_refresh') }}">Refresh Token</a>
|
||||
<li><a href="{{ url_for('oauth_logout') }}">Logout</a>
|
||||
{% else %}
|
||||
<li><a href="{{ url_for('oauth_login') }}">Login</a>
|
||||
{% endif %}
|
||||
<!--
|
||||
<li><a href="https://github.com/bluesky-social/cookbook">Code</a>
|
||||
-->
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<section class="content">
|
||||
{% for message in get_flashed_messages() %}
|
||||
<article>{{ message }}</article>
|
||||
{% endfor %}
|
||||
{% block content %}{% endblock %}
|
||||
</section>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
@ -1,15 +0,0 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
{% if g.user %}
|
||||
<div class="livestream">
|
||||
<iframe id="livestream" title="stream" width="100%" height="700px" src="https://live.syui.ai/b9ec42d4-8a4d-4343-99fc-1bd1cdbc5a6f.html"> </iframe>
|
||||
</div>
|
||||
@<span class="user-handle">{{ g.user['handle'] }}</span>
|
||||
<div class="livechat">
|
||||
<iframe id="livechat" title="bskychat" width="100%" height="500" src="https://bbs.syui.ai/?handle={{ session['user_handle'] }}"> </iframe>
|
||||
</div>
|
||||
<style> /* .livechat { position: absolute; top: 0px; right:0px; } */ </style>
|
||||
{% else %}
|
||||
<p>Login to get started!</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
@ -1,67 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Simple BBS</title>
|
||||
</head>
|
||||
<body>
|
||||
<ul>
|
||||
{% for post in posts %}
|
||||
<li><span class="user-post">{{ post }}</span></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<form action="/submit" method="post">
|
||||
<input type="hidden" name="handle" id="handleInput">
|
||||
<textarea name="content" required></textarea>
|
||||
<input type="submit" value="Post">
|
||||
</form>
|
||||
</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";
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
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 #2e7b96;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
input[type="submit"] {
|
||||
border-radius: 5px;
|
||||
width: 100%;
|
||||
color: #fff;
|
||||
background: #bb1a1a;
|
||||
border: none;
|
||||
padding: 10px;
|
||||
}
|
||||
ul {
|
||||
border-radius: 5px;
|
||||
padding: 0px;
|
||||
margin: 0 auto;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
span.user-post {
|
||||
padding: 0px 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
</html>
|
@ -4,4 +4,4 @@ WORKDIR /app
|
||||
COPY . .
|
||||
RUN pacman -Syu rye --noconfirm
|
||||
RUN rye sync
|
||||
#CMD ["rye", "run", "flask", "run"]
|
||||
|
3
github/python-oauth-web-app/app_add.py
Normal file
@ -0,0 +1,3 @@
|
||||
@app.route("/about")
|
||||
def aboutpage():
|
||||
return render_template("about.html")
|
@ -7,4 +7,4 @@ services:
|
||||
- "5000:5000"
|
||||
volumes:
|
||||
- ./demo.sqlite:/app/demo.sqlite
|
||||
command: rye run flask run
|
||||
command: rye run flask run --host=0.0.0.0
|
18
github/python-oauth-web-app/templates/about.html
Normal file
@ -0,0 +1,18 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<h2>about</h2>
|
||||
<p>This service allows you to comment on live broadcasts using your atproto account.</p>
|
||||
<hr/>
|
||||
<p>このサービスはlive配信にatprotoアカウントを使ってコメントができます。</p>
|
||||
|
||||
<h2>system</h2>
|
||||
<p>Display posts to BBS using atproto oauth.</p>
|
||||
<p>This service is generated using <a href="https://github.com/bluesky-social/cookbook">bluesky/cookbook</a>.</p>
|
||||
<p>Authentication information will be deleted periodically.</p>
|
||||
<hr/>
|
||||
<p>atproto oauthを使用してbbsへの書き込みを許可します。</p>
|
||||
<p>このサービスは<a href="https://github.com/bluesky-social/cookbook">bluesky/cookbook</a>を使用して生成されています。</p>
|
||||
<p>認証情報は定期的に削除されます。</p>
|
||||
|
||||
{% endblock %}
|
106
github/python-oauth-web-app/templates/base.html
Normal file
@ -0,0 +1,106 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="referrer" content="origin-when-cross-origin">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.blue.min.css">
|
||||
<title>o.syui.ai | oauth service atproto</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<hgroup>
|
||||
{% if g.user %}
|
||||
{% endif %}
|
||||
</hgroup>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="/"><button class="secondary">o</button></a></li>
|
||||
<li>live/video</li>
|
||||
</ul>
|
||||
<ul>
|
||||
{% if g.user %}
|
||||
<li><a href="{{ url_for('bsky_post') }}">post</a>
|
||||
<li><a href="{{ url_for('oauth_refresh') }}">refresh</a>
|
||||
<li><a href="{{ url_for('oauth_logout') }}"><button class="secondary">logout</button></a>
|
||||
{% else %}
|
||||
<li><a href="/about">about</a></li>
|
||||
<!--
|
||||
<button><a href="{{ url_for('oauth_login') }}">@</a>
|
||||
-->
|
||||
{% endif %}
|
||||
<!--
|
||||
<li><a href="https://github.com/bluesky-social/cookbook">Code</a>
|
||||
-->
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
<section class="content">
|
||||
{% for message in get_flashed_messages() %}
|
||||
<article>{{ message }}</article>
|
||||
{% endfor %}
|
||||
{% block content %}{% endblock %}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<style>
|
||||
button a {
|
||||
color: #fff;
|
||||
}
|
||||
iframe#livechat {
|
||||
width: 100%;
|
||||
height: 700px;
|
||||
}
|
||||
iframe#livestream {
|
||||
width: 100%;
|
||||
height: 700px;
|
||||
}
|
||||
button.oauth-login {
|
||||
width: 100%;
|
||||
}
|
||||
footer {
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.container-1 {
|
||||
display: flex;
|
||||
.right-container {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
align-self: flex-start;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
padding-left:10px;
|
||||
.content:first-of-type {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.left-container {
|
||||
width: 80%;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 959px) {
|
||||
.left-container {
|
||||
width: 100%;
|
||||
}
|
||||
iframe#livestream {
|
||||
width: 100%;
|
||||
min-height:300px;
|
||||
height:100%;
|
||||
}
|
||||
.container-1 {
|
||||
display: block;
|
||||
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<footer>©syui</footer>
|
||||
</body>
|
||||
</html>
|
8
github/python-oauth-web-app/templates/bsky_post.html
Normal file
@ -0,0 +1,8 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
<textarea name="post_text" placeholder="What's up?" id="post_text" required></textarea>
|
||||
<input type="submit" value="Poast!">
|
||||
</form>
|
||||
{% endblock %}
|
13
github/python-oauth-web-app/templates/error.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}Error{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>⚠️ Error {{ status_code }} ⚠️</h2>
|
||||
{% if err.description %}
|
||||
<p><code>{{ err.description }}</code></p>
|
||||
{% else %}
|
||||
<p>Something went wrong!</p>
|
||||
{% endif %}
|
||||
<p><a href="/">Start Over</a></p>
|
||||
{% endblock %}
|
25
github/python-oauth-web-app/templates/home.html
Normal file
@ -0,0 +1,25 @@
|
||||
{% extends 'base.html' %}
|
||||
{% block content %}
|
||||
|
||||
<div class="container-1">
|
||||
<div class="left-container">
|
||||
<div class="livestream">
|
||||
<iframe id="livestream" title="stream" src="https://live.syui.ai/b9ec42d4-8a4d-4343-99fc-1bd1cdbc5a6f.html"> </iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div class="right-container">
|
||||
{% if g.user %}
|
||||
<span class="user-handle">@{{ g.user['handle'] }}</span>
|
||||
<div class="livechat">
|
||||
<iframe id="livechat" title="bskychat" src="https://bbs.syui.ai/?handle={{ session['user_handle'] }}"> </iframe>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="livechat">
|
||||
<a href="{{ url_for('oauth_login') }}"><button class="oauth-login">@</button></a>
|
||||
<iframe id="livechat" title="bskychat" src="https://bbs.syui.ai"> </iframe>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
15
github/python-oauth-web-app/templates/login.html
Normal file
@ -0,0 +1,15 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<article>
|
||||
<h3>Login with atproto</h3>
|
||||
<form method="post">
|
||||
<p>Provide your handle or DID to authorize an existing account with PDS.
|
||||
<br>You can also supply a PDS/entryway URL (eg, <code>https://pds.example.com</code>).</p>
|
||||
<fieldset role="group">
|
||||
<input name="username" id="username" placeholder="handle.example.com" style="font-family: monospace,monospace;" required>
|
||||
<input type="submit" value="Login">
|
||||
</fieldset>
|
||||
</form>
|
||||
</article>
|
||||
{% endblock %}
|
@ -1,7 +1,8 @@
|
||||
FROM syui/aios
|
||||
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
COPY ./src ./src
|
||||
COPY ./templates ./templates
|
||||
COPY ./Cargo.toml ./Cargo.toml
|
||||
RUN cargo build --release
|
||||
COPY ./templates /templates
|
||||
CMD ["/app/target/release/rust-bbs"]
|
@ -2,6 +2,6 @@ services:
|
||||
web:
|
||||
build: .
|
||||
ports:
|
||||
- "8782:8782"
|
||||
- 8080:8080
|
||||
volumes:
|
||||
- ./sqlite.db:/app/sqlite.db
|
@ -79,13 +79,13 @@ async fn submit_post(
|
||||
.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() {
|
||||
let handle = if !form.handle.is_empty() {
|
||||
form.handle.clone()
|
||||
} else {
|
||||
} else {
|
||||
query.handle.clone().unwrap_or_default()
|
||||
};
|
||||
};
|
||||
|
||||
println!("Debug: Using handle: {:?}", handle);
|
||||
println!("Debug: Using handle: {:?}", handle);
|
||||
|
||||
let conn = Connection::open("sqlite.db")
|
||||
.map_err(|_| ErrorInternalServerError("Database connection failed"))?;
|
||||
@ -106,7 +106,7 @@ async fn submit_post(
|
||||
.finish())
|
||||
},
|
||||
|
||||
//Ok(_) => Ok(web::Redirect::to("/").see_other()),
|
||||
//Ok(_) => Ok(web::Redirect::to("/" + "?handle=" + handle).see_other()),
|
||||
Err(_) => Err(ErrorInternalServerError("Failed to insert post")),
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.route("/post", web::get().to(post_form))
|
||||
.route("/submit", web::post().to(submit_post))
|
||||
})
|
||||
.bind("0.0.0.0:8782")?
|
||||
.bind("0.0.0.0:8080")?
|
||||
.run()
|
||||
.await
|
||||
}
|
77
github/rust-bbs/templates/index.html
Normal file
@ -0,0 +1,77 @@
|
||||
<!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;
|
||||
}
|
||||
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>
|
Before Width: | Height: | Size: 174 KiB After Width: | Height: | Size: 174 KiB |
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 792 KiB After Width: | Height: | Size: 792 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |