🏡 index : old_projects/url_shortener.git

author yaqubroli <walchuk2018@icloud.com> 2022-12-23 14:28:06.0 -08:00:00
committer yaqubroli <walchuk2018@icloud.com> 2022-12-23 14:28:06.0 -08:00:00
commit
1b71ec337951ee1acde91eaaf1e0610f4ff89edb [patch]
tree
2bca396311c4a07579462798a6f7c4defced76d3
parent
805ff8cb1d1ba77e9e722fd8d792657bf74afdba
download
1b71ec337951ee1acde91eaaf1e0610f4ff89edb.tar.gz

Finished code. It's a spaghetti ball now.



Diff

 .gitignore                 |  2 ++
 html/404.html              | 18 ++++++++++++++++++
 html/paste.html            | 16 +++++++++++++---
 html/url.html              | 16 +++++++++++++---
 src/templating.rs          |  1 +
 html/static/style.css      | 15 +++++++++++++++
 target/debug/url_shortener |  0 
 7 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/.gitignore b/.gitignore
index 09b9ce2..38c9419 100644
--- a/.gitignore
+++ a/.gitignore
@@ -1,3 +1,5 @@
target/
.vscode/
.vscode
target
config.toml
diff --git a/html/404.html b/html/404.html
new file mode 100644
index 0000000..9de2294 100644
--- /dev/null
+++ a/html/404.html
@@ -1,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/static/style.css">
<title>7800.io: URL Shortener</title> 
</head>
<body>
    <h1>URL Shortener</h1>
    <main>
        <div id="ui">
            <p>Your entry was not found.</p>
            <div class="url">
                <span class="domain">{domain}</span>/{shortened}
            </div>
        </div>
    </main>
</body>
</html>
diff --git a/html/paste.html b/html/paste.html
index df023f9..2b7943a 100644
--- a/html/paste.html
+++ a/html/paste.html
@@ -1,12 +1,18 @@
<!DOCTYPE html>
<html>
<head>
    <title>Paste</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="static/style.css" />
<link rel="stylesheet" href="/static/style.css">
<title>7800.io: Pastebin</title> 
</head>
<body>
    <h1>Paste</h1>
    <p>Your paste is accessible at {{domain}}/{{shortened}}</p>
    <h1>URL Shortener</h1>
    <main>
        <div id="ui">
            <p>Text pasted successfully</p>
            <div class="url">
                <span class="domain">{domain}</span>/{shortened}
            </div>
        </div>
    </main>
</body>
</html>
diff --git a/html/url.html b/html/url.html
index 8e26b47..d96933e 100644
--- a/html/url.html
+++ a/html/url.html
@@ -1,12 +1,18 @@
<!DOCTYPE html>
<html>
<head>
    <title>URL shortened</title>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="static/style.css" />
<link rel="stylesheet" href="/static/style.css">
<title>7800.io: URL Shortener</title> 
</head>
<body>
    <h1>URL shortened successfully</h1>
    <p>Your url is accessible at {domain}/{shortened}</p>
    <h1>URL Shortener</h1>
    <main>
        <div id="ui">
            <p>URL shortened successfully</p>
            <div class="url">
                <span class="domain">{domain}</span>/{shortened}
            </div>
        </div>
    </main>
</body>
</html>
diff --git a/src/templating.rs b/src/templating.rs
index 96610bd..1eb9988 100644
--- a/src/templating.rs
+++ a/src/templating.rs
@@ -73,6 +73,7 @@
}

pub async fn get_necessary_value(key: String, key_value: u8, app_data: web::Data<AppData>, schema: &mut TemplateSchema) -> String {
    println!("Evaluating {}:{}", key, key_value);
    // create a vector of (ContentType, i64) tuples
    match key.as_str() {
        "content" => 
diff --git a/html/static/style.css b/html/static/style.css
index 5665cf2..d40f32b 100644
--- a/html/static/style.css
+++ a/html/static/style.css
@@ -70,7 +70,6 @@
    border-radius: 1em;
}

/* make .text, which is an input text field, use the same font as the rest of the website. make it a black box with a thick white outline */
.text {
    display: block;
    font-family: monospace;
@@ -79,6 +78,7 @@
    border: 2px dashed white;
    padding: 0.5em 1em;
    margin: 1em 0;
    width: 100%;
}

/* make .button a black button with thick white outline that uses the same font as the rest of the website */
@@ -98,4 +98,17 @@
textarea {
    width: 20em;
    height: 10em;
}

.url {
    font-family: monospace !important;
    color: white !important;
    display: block;
    /* make normal case */
    text-transform: none !important;
    margin-bottom: 1em;
}

.domain {
    color: lightgray !important;
}
diff --git a/target/debug/url_shortener b/target/debug/url_shortener
index 93b43235902d088f703d90c27b6673e0f2da9704..c1c9c587c16583c26f4bb0fcb8d5b4e4df78b5f8 100755
Binary files a/target/debug/url_shortener and a/target/debug/url_shortener differ