+ Restructuring!
1
dist/db/migrations/000001_posts.down.sql
vendored
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS t_posts;
|
||||
12
dist/db/migrations/000001_posts.up.sql
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS `t_posts` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(256) NOT NULL DEFAULT '' COLLATE 'latin1_swedish_ci',
|
||||
`content` MEDIUMTEXT NOT NULL COLLATE 'latin1_swedish_ci',
|
||||
`ts` DATETIME NOT NULL DEFAULT current_timestamp(),
|
||||
`ts_updated` DATETIME NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `name` (`name`) USING BTREE
|
||||
)
|
||||
COLLATE='latin1_swedish_ci'
|
||||
ENGINE=InnoDB
|
||||
;
|
||||
1
dist/db/migrations_sqlite/000001_posts.down.sql
vendored
Normal file
@@ -0,0 +1 @@
|
||||
DROP table t_posts;
|
||||
6
dist/db/migrations_sqlite/000001_posts.up.sql
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS "t_posts" (
|
||||
"id" INTEGER,
|
||||
"name" TEXT,
|
||||
"content" TEXT,
|
||||
PRIMARY KEY("id" AUTOINCREMENT)
|
||||
);
|
||||
BIN
dist/freepad
vendored
Executable file
0
dist/static/css/.keep
vendored
Normal file
3
dist/static/css/main.css
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#post_content {
|
||||
height: calc(100vh - 35rem);
|
||||
}
|
||||
0
dist/static/img/.keep
vendored
Normal file
BIN
dist/static/img/banner_building.png
vendored
Normal file
|
After Width: | Height: | Size: 7.1 KiB |
BIN
dist/static/img/banner_environment.png
vendored
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
dist/static/img/banner_prerequisites.png
vendored
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
BIN
dist/static/img/facebook_cover_photo_1.png
vendored
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
dist/static/img/facebook_cover_photo_2.png
vendored
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
dist/static/img/facebook_profile_image.png
vendored
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
dist/static/img/favicon.png
vendored
Normal file
|
After Width: | Height: | Size: 218 B |
BIN
dist/static/img/gopher.png
vendored
Normal file
|
After Width: | Height: | Size: 186 KiB |
BIN
dist/static/img/instagram_profile_image.png
vendored
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
dist/static/img/linkedin_banner_image_1.png
vendored
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
dist/static/img/linkedin_banner_image_2.png
vendored
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
dist/static/img/linkedin_profile_image.png
vendored
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
dist/static/img/logo.png
vendored
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
dist/static/img/logo_transparent.png
vendored
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
dist/static/img/pinterest_board_photo.png
vendored
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
dist/static/img/pinterest_profile_image.png
vendored
Normal file
|
After Width: | Height: | Size: 780 B |
BIN
dist/static/img/twitter_header_photo_1.png
vendored
Normal file
|
After Width: | Height: | Size: 1021 B |
BIN
dist/static/img/twitter_header_photo_2.png
vendored
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
dist/static/img/twitter_profile_image.png
vendored
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
dist/static/img/youtube_profile_image.png
vendored
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
0
dist/static/js/.keep
vendored
Normal file
82
dist/static/js/main.js
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
function setStatus(text, className ) {
|
||||
// Show loading
|
||||
const statusIndicator = document.getElementById(`status-indicator`);
|
||||
|
||||
if ( !!statusIndicator ) {
|
||||
// Clear all previous status-es
|
||||
for ( let [x, k] of statusIndicator.classList.entries() ) {
|
||||
statusIndicator.classList.remove(k);
|
||||
}
|
||||
|
||||
// Mark as loading
|
||||
statusIndicator.textContent = text;
|
||||
statusIndicator.classList.add(className);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updatePost(postName) {
|
||||
|
||||
const postContentElement = document.getElementById(`post_content`);
|
||||
|
||||
if ( !!postContentElement && !!postContentElement.value ) {
|
||||
const postContent = String(postContentElement.value);
|
||||
if ( !!postContent && postContent.length > 0 ) {
|
||||
|
||||
setStatus(`Loading...`, `has-text-warning`);
|
||||
|
||||
// Generate the form data
|
||||
let formData = new FormData();
|
||||
formData.append('name', postName);
|
||||
formData.append('content', postContent);
|
||||
|
||||
// Send out a fetch request
|
||||
fetch("/api/post", {
|
||||
method: "post",
|
||||
body: formData,
|
||||
})
|
||||
.then( result => {
|
||||
|
||||
if ( result.status < 200 || result.status > 299 ) {
|
||||
if ( result.status == 429) {
|
||||
setStatus(`Too many requests, please wait`, `has-text-danger`);
|
||||
} else {
|
||||
setStatus(`Failed to Save`, `has-text-danger`);
|
||||
}
|
||||
} else {
|
||||
setStatus(`Saved`, `has-text-success`);
|
||||
}
|
||||
|
||||
console.log(result);
|
||||
|
||||
})
|
||||
.catch( error => {
|
||||
console.error(error);
|
||||
alert(error);
|
||||
setStatus(`Failed to Save`, `has-text-danger`);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @location /
|
||||
* @role Searching
|
||||
*/
|
||||
function goToPost() {
|
||||
// Get the post name element
|
||||
const postNameElement = document.getElementById(`postName`);
|
||||
|
||||
// Check if the element exists
|
||||
if ( !!postNameElement ) {
|
||||
// Get the post name string
|
||||
const postName = String(postNameElement.value);
|
||||
// Check if the post name is valid
|
||||
if ( !!postName && postName.length > 0 && postName.length <= 256 ) {
|
||||
// Change the location
|
||||
window.location.href = `/${postName}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
0
dist/static/vendor/.keep
vendored
Normal file
20
dist/templates/inc/footer.html
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{{ define "inc/footer.html"}}
|
||||
|
||||
<footer class="footer">
|
||||
<div class="content has-text-centered">
|
||||
<p>
|
||||
<strong>FreePad</strong> by <a href="https://justkato.me">Kato Twofold</a>.
|
||||
<br>
|
||||
The source code is licensed under the
|
||||
<a href="http://opensource.org/licenses/mit-license.php">MIT</a> License.
|
||||
<br>
|
||||
The project is <b>Free and Open Source</b>, check out our <a href="https://github.com/JustKato/FreePad">Github Repo</a>.
|
||||
<br>
|
||||
Powered by <b>Go</b>phers!
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="/static/js/main.js"></script>
|
||||
|
||||
{{ end }}
|
||||
22
dist/templates/inc/header.html
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{{ define "inc/header.html"}}
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>FreePad - {{.title}}</title>
|
||||
|
||||
<meta name="description" content="Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time." />
|
||||
<meta property="og:description" content="Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time." />
|
||||
<meta property="fb:app_id" content="231493360234820" />
|
||||
<meta property="og:title" content="FreePad.com - #1 paste tool since 2002!" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:site_name" content="FreePad" />
|
||||
<meta property="og:url" content="{{.domain_base}}/" />
|
||||
|
||||
<link rel="icon" type="image/png" href="/static/img/gopher.png"/>
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="https://unpkg.com/bulma-prefers-dark" />
|
||||
<link rel="stylesheet" href="/static/css/main.css">
|
||||
</head>
|
||||
{{ end }}
|
||||
42
dist/templates/pages/index.html
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{{ template "inc/header.html" .}}
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container is-fullhd p-4 mb-6" style="min-height: 50rem; height: calc(100vh - 18rem)">
|
||||
<h1 class="title">FreePad</h1>
|
||||
<h2 class="subtitle">Free and Open source internet notepad</h2>
|
||||
|
||||
<hr class="mb-6">
|
||||
|
||||
<div class="content">
|
||||
<form class="columns px-4 mt-6" onsubmit="goToPost(); return false;">
|
||||
<span class="mt-2 is-size-4" style="font-family: monospace">{{.domain_base}}/</span>
|
||||
<input class="mt-2 input mr-4" type="text" name="postName" id="postName" style="font-family: monospace" placeholder="Something memorable">
|
||||
<button class="mt-2 button" type="submit">Open</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="content my-4">
|
||||
<h3>Why FreePad</h3>
|
||||
<p>Why should you use FreePad and not some other provider?</p>
|
||||
<ol>
|
||||
<li style="list-style-type: none;">Keep it simple 😎</li>
|
||||
<li style="list-style-type: none;">Don't worry about passwords 📔</li>
|
||||
<li style="list-style-type: none;">You can be a mess, it's all temporary 🗑</li>
|
||||
<li style="list-style-type: none;">Quick and Clean 🧼</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="content my-6">
|
||||
<h3>Some Rules</h3>
|
||||
<p>FreePad has an API and you can use it to interact with it, although there are some limitations.</p>
|
||||
<ol>
|
||||
<li>You are going to be rate-limited if you spam too much and put on a cooldown</li>
|
||||
<li>There's only so many pages that can be stored before affecting performance</li>
|
||||
<li>Automatic Shadowbanning</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ template "inc/footer.html" .}}
|
||||
</body>
|
||||
28
dist/templates/pages/page.html
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
{{ template "inc/header.html" .}}
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container is-fullhd p-4 mb-6" style="min-height: 35rem; height: calc(100vh - 18rem)">
|
||||
<h1 class="title">FreePad</h1>
|
||||
<h2 class="subtitle">Reading from <code>{{.domain_base}}/{{.title}}</code></h2>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="content">
|
||||
<div class="block">
|
||||
<a href="/" class="button is-light">Back Home</a>
|
||||
<a href="javascript:updateSelf()" class="button is-primary">Save</a>
|
||||
<p class="mt-3">Status: <code class="has-text-primary" id="status-indicator">Loaded</code></p>
|
||||
</div>
|
||||
<textarea class="input" name="post_content" id="post_content" onchange="updateSelf()">{{.post_content}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function updateSelf() {
|
||||
updatePost({{.title}})
|
||||
}
|
||||
</script>
|
||||
|
||||
{{ template "inc/footer.html" .}}
|
||||
</body>
|
||||