Skip to content

Commit

Permalink
complete form
Browse files Browse the repository at this point in the history
  • Loading branch information
arhaanb committed Jun 19, 2021
1 parent 93b5007 commit 245c238
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 510 deletions.
4 changes: 3 additions & 1 deletion api/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const express = require('express')
const fetch = require('node-fetch')
var Airtable = require('airtable')
const Airtable = require('airtable')
const bcrypt = require('bcryptjs')

fs = require('fs')
require('dotenv').config()

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"author": "Arhaan Bahadur",
"dependencies": {
"airtable": "^0.11.0",
"bcryptjs": "^2.4.3",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"node-fetch": "^2.6.1"
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## Functionality

- Enable/Disable links directly through Airtable
- Easily add links to Airtable via a password protected form ([arhn.us/shrtn](https://arhn.us/shrtn))
- Generate random URIs through Airtable
- Nested links (`/shortened/link`)
- Shorten GitHub Repo links -> /gh/${repository}
Expand Down
Empty file removed shrtn/app.js
Empty file.
21 changes: 10 additions & 11 deletions shrtn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shrtn | arhaanb</title>
<link rel="stylesheet" type="text/css" href="https://rsms.me/inter/inter-display.css">
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>

<style>
Expand Down Expand Up @@ -608,16 +609,16 @@ <h1 class="zero title">Shorten</h1>
</p>

<label>Name</label>
<input type="text" id="name" required placeholder="Name" />
<input type="text" autocomplete="off" id="name" required placeholder="Name" />
<br>
<label>Link</label>
<input type="url" id="link" placeholder="https://website.com" required />
<input type="url" autocomplete="off" id="link" placeholder="https://website.com" required />
<br>
<label>Backlink</label>
<input type="text" id="backlink" placeholder="/something" required />
<input type="text" autocomplete="off" id="backlink" placeholder="/something" required />
<br>
<label>Password</label>
<input type="password" id="password" placeholder="Password" required />
<input type="password" autocomplete="off" id="password" placeholder="Password" required />
<br>

<p id="error"></p>
Expand All @@ -631,7 +632,7 @@ <h1 class="zero title">Shorten</h1>
<section id="after" style="display: none;">
<h1 class="zero" style="margin-top: 4em;">Link created succesfully</h1>
<p style="margin-top: 0.5em; font-size: 1.2em;">
You can now visit <a href="#" id="successlink"></a>
You can now visit <a href="#" target="_blank" id="successlink"></a>
</p>
</section>
</div>
Expand All @@ -653,15 +654,13 @@ <h1 class="zero" style="margin-top: 4em;">Link created succesfully</h1>
password
}

fetch('/api/shrtn', {
method: 'POST',
body: JSON.stringify(data)
}).then((res) => {
axios.post('/api/shrtn', data).then((res) => {
if (res.data.error == true) {
document.getElementById('error').innerText = res.data.message
btn.innerText = 'Create Link'
} else {
document.getElementById('successlink').innerText = `arhn.us${res.data.backlink1}`
document.getElementById('successlink').setAttribute('href') = res.data.link
document.getElementById('successlink').innerText = `arhn.us/${res.data.backlink1}`
document.getElementById('successlink').setAttribute('href', res.data.link)
document.getElementById('before').style.display = 'none'
document.getElementById('after').style.display = 'block'
}
Expand Down
262 changes: 0 additions & 262 deletions shrtn/skel.css

This file was deleted.

Loading

0 comments on commit 245c238

Please sign in to comment.