Compare commits

...

4 commits

Author SHA1 Message Date
zoe
f77033ef8a remove snippets 2022-01-30 14:21:45 +01:00
zoe
d0317aca7e remove snippets 2022-01-30 14:20:22 +01:00
zoe
c686002dc1 cleanup whitespace in new room requests 2022-01-30 14:18:50 +01:00
zoe
cdf392a232 copy url button 2022-01-30 12:47:53 +01:00
7 changed files with 31 additions and 19 deletions

View file

@ -1 +0,0 @@
<p>Sorry! This room is already full. Maybe try another one?</p>

View file

@ -23,7 +23,7 @@ struct Args {
// Port number for server
#[clap(short, long, default_value_t = 8000)]
port: u16,
#[clap(short, long, default_value = "localhost")]
#[clap(short, long, default_value = "http://127.0.0.1:8000")]
base_url: String,
}
@ -39,6 +39,8 @@ fn rocket() -> _ {
#[get("/?<roomname>")]
async fn index(mut roomname: String) -> Template {
// remove whitespace from roomname
roomname = roomname.split_whitespace().collect();
// generate roomname if there is none yet
if roomname.chars().count() == 0 {
roomname = names::get_random_name().await;
@ -70,7 +72,7 @@ async fn index(mut roomname: String) -> Template {
}
}
#[get("/room?<roomname>&<token>")]
async fn room(roomname: &str, token: usize) -> String{
#[get("/room?<roomname>&<token>&<player1>")]
async fn room(roomname: &str, token: usize, player1: bool) -> String{
"hey gamer".to_string()
}

View file

@ -8,10 +8,12 @@ pub struct Room {
impl Room {
pub fn new() -> Room {
let random: usize = thread_rng().gen();
// generate room token
let tok: usize = thread_rng().gen();
// flip coin to see who starts
Room {
full: false,
token: random,
token: tok,
}
}
}

View file

@ -2,8 +2,6 @@ use std::collections::HashMap;
use rocket_dyn_templates::Template;
use clap::Parser;
lazy_static! {
static ref ARGS: Args = Args::parse();
}
@ -11,7 +9,7 @@ lazy_static! {
#[derive(Parser, Debug)]
#[clap(about, version, author)]
struct Args {
#[clap(short, long, default_value = "localhost")]
#[clap(short, long, default_value = "http://127.0.0.1:8000")]
base_url: String,
}
@ -21,13 +19,13 @@ pub fn get_back_to_home(roomname: &str) -> Template {
pub fn join_new_room(roomname: &str, token: usize) -> Template {
let message = format!("your room is \"{}\"! copy your link and send it to a friend to let them join", roomname);
let link_url = link_url_from(roomname, token);
let link_url = link_url_from(roomname, token, true);
join_template_from(&message, "let me in!", &link_url, "url_button", roomname)
}
pub fn join_room(roomname: &str, token: usize) -> Template {
let message = format!("your room is \"{}\"! someone is already waiting in this room!", roomname);
let link_url = link_url_from(roomname, token);
let link_url = link_url_from(roomname, token, false);
join_template_from(&message, "let me in!", &link_url, "hidden", roomname)
}
@ -42,6 +40,6 @@ fn join_template_from(message: &str, link: &str, link_url: &str, hide_url_button
Template::render("join", context)
}
fn link_url_from(roomname: &str, token: usize) -> String{
format!("./room?roomname={}&token={}", roomname, token)
fn link_url_from(roomname: &str, token: usize, player1: bool) -> String{
format!("./room?roomname={}&token={}&player1={}", roomname, token, player1)
}

View file

@ -2,8 +2,10 @@ function copyURI(evt) {
evt.preventDefault();
navigator.clipboard.writeText(evt.target.getAttribute('href')).then(() => {
/* clipboard successfully set */
document.getElementById("urlForCopy").innerHTML = "copied";
}, () => {
/* clipboard write failed */
document.getElementById("urlForCopy").innerHTML = "failed to copy :\(";
});
}

View file

@ -7,6 +7,11 @@
--accent1: #accce4;
}
* {
margin: 0;
padding: 0;
}
body,
html {
color: var(--text);
@ -19,8 +24,10 @@ html {
justify-content: center;
width: 100%;
height: 100%;
size: 100%;
margin: 0;
padding: 0;
scrollbar-color: var(--accent1);
}
::selection {
@ -45,12 +52,12 @@ footer {
overflow: visible;
left: 0;
display: flex;
height: 10%;
bottom: 0;
width: 100%;
font-size: 3em;
font-size: 16pt;
justify-content: center;
align-items: center;
height: 10%;
}
.contentdiv {
@ -58,8 +65,9 @@ footer {
flex-direction: column;
align-items: center;
align-self: center;
height: 90%;
min-height: 90%;
justify-content: center;
width: 100%;
}
button,
@ -68,8 +76,8 @@ a,
p {
line-height: 1.84em;
border-radius: 0.48em;
font-size: 32pt;
margin: 0.5em;
font-size: 24pt;
margin-top: 0.5em;
text-align: center;
font-family: "Sen", sans-serif;
line-break: anywhere;
@ -79,10 +87,10 @@ a,
button,
input {
outline: none;
padding: 2%;
background-color: var(--background);
color: var(--text);
border: 0.12em solid var(--text);
width: 90%;
}
input {

View file

@ -16,6 +16,7 @@
<div class="contentdiv">
<p>{{message}}</p><br />
<a
title="copy to clipboard"
onclick="copyURI(event)"
id="urlForCopy"
class="{{hide_url_button}}"