Add files via upload
This commit is contained in:
parent
8f8de61251
commit
6eaa4a32b2
8 changed files with 244 additions and 2 deletions
1
CNAME
Normal file
1
CNAME
Normal file
|
@ -0,0 +1 @@
|
||||||
|
mayaspace.nodemixaholic.com
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Samuel Lord
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -1,2 +1,2 @@
|
||||||
# mayaspace-prod
|
# mayaspace
|
||||||
Mayaspace Production Copy
|
A decentralized social network. Kinda a mix of Mastodon and 4chan technology-wise because it's a pseudominous decentralized platform with tweet-like posts, with no algorithm. TLDR: A decentralized, (slightly) more secure Guest Book.
|
||||||
|
|
35
index.html
Normal file
35
index.html
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head><title>Maya Space</title></head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
|
||||||
|
<script>
|
||||||
|
</script>
|
||||||
|
<body id="body">
|
||||||
|
<img class="logo" src="maya.jpg">
|
||||||
|
<h1>MayaSpace (WIP)</h1><hr><br>
|
||||||
|
<div class="container">
|
||||||
|
<label for="uname"><b>Username</b></label>
|
||||||
|
<input type="text" placeholder="Enter Username" name="uname" id="uname" required>
|
||||||
|
|
||||||
|
<label for="psw"><b>Password</b></label>
|
||||||
|
<input type="password" placeholder="Enter Password" name="password" id="password" required>
|
||||||
|
|
||||||
|
<button type="submit" onclick="login()">Login/Sign Up</button>
|
||||||
|
</div>
|
||||||
|
<a href="rules.html" style="text-align: right;"><p>Rules for this instance.</p></a>
|
||||||
|
<br>
|
||||||
|
<h2>About Maya</h2>
|
||||||
|
<p>Maya is the cat of the Lord family as of 2020. Before her came Dixie, who (unfortunately) died not too long before we adopted Maya.</p>
|
||||||
|
<h3>Why did you create MayaSpace?</h3>
|
||||||
|
<p>I thought it was a good pun, and decided to make it real. (Thanks Mom and Dad for the pun!)</p>
|
||||||
|
<h3>What is MayaSpace?</h3>
|
||||||
|
<p>MayaSpace is a decentralized social media site where you can post posts, however it was originally a meme site. Everyone is treated equally, since there are no comments and likes, and everyone gets on the front page as soon as they post as well.</p>
|
||||||
|
<h3>Do you love Maya?</h3>
|
||||||
|
<p>Yes. Yes I do.</p>
|
||||||
|
<hr>
|
||||||
|
<p>Copyright Samuel Lord. Licensed under the <a target="_blank" href="https://github.com/nodemixaholic/mayaspace/blob/master/LICENSE">MIT license.</a></p>
|
||||||
|
<script src="xss/xss.js"></script>
|
||||||
|
<script src="index.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
115
index.js
Normal file
115
index.js
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
let gun = Gun(['http://nodemixaholic.com:8069/gun', 'https://gun-manhattan.herokuapp.com/gun']);
|
||||||
|
let usrname;
|
||||||
|
|
||||||
|
function showMainPage() {
|
||||||
|
body.innerHTML = `<img class="logo" src="maya.jpg">
|
||||||
|
<h1>MayaSpace</h1><hr><br>
|
||||||
|
<div class="container" id="poster">
|
||||||
|
<input type="text" placeholder="Type a post here..." name="post" id="post" required>
|
||||||
|
<button onclick="post()">Post</button>
|
||||||
|
</div>
|
||||||
|
<div class="container" id="postContainer">
|
||||||
|
<hr>
|
||||||
|
Copyright Samuel Lord. All rights reserved.
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
let postContainer = document.getElementById("postContainer");
|
||||||
|
const coredb = gun.get(`mayaspace`);
|
||||||
|
const postsDB = coredb.get('posts');
|
||||||
|
// Use on() to continuously listen for changes
|
||||||
|
postsDB.on((data) => {
|
||||||
|
addPost(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sha256HexPromise(data) {
|
||||||
|
const msgUint8 = new TextEncoder().encode(data); // encode as (utf-8) Uint8Array
|
||||||
|
const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8); // hash the message
|
||||||
|
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
|
||||||
|
const hashHex = hashArray
|
||||||
|
.map((b) => b.toString(16).padStart(2, "0"))
|
||||||
|
.join(""); // convert bytes to hex string
|
||||||
|
return hashHex;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
async function sha256HexPromise(data) {
|
||||||
|
const msgUint8 = new TextEncoder().encode(data); // encode as (utf-8) Uint8Array
|
||||||
|
const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8); // hash the message
|
||||||
|
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
|
||||||
|
const hashHex = hashArray
|
||||||
|
.map((b) => b.toString(16).padStart(2, "0"))
|
||||||
|
.join(""); // convert bytes to hex string
|
||||||
|
return hashHex;
|
||||||
|
}
|
||||||
|
|
||||||
|
function login() {
|
||||||
|
let password = document.getElementById("password").value;
|
||||||
|
const coredb = gun.get(`mayaspace`);
|
||||||
|
// Perform the SHA-256 hashing asynchronously
|
||||||
|
sha256HexPromise(password)
|
||||||
|
.then(function (encryptedPassword) {
|
||||||
|
usrname = `${document.getElementById("uname").value}@${window.location.hostname}`;
|
||||||
|
return encryptedPassword;
|
||||||
|
})
|
||||||
|
.then(function (encryptedPassword) {
|
||||||
|
// Access the user reference and check the stored password
|
||||||
|
let userRef = coredb.get('users').get(usrname);
|
||||||
|
let storedPassword = coredb.get('users').get(usrname).get("passwd");
|
||||||
|
|
||||||
|
storedPassword.once((storedData) => {
|
||||||
|
if (storedData === undefined || storedData === null || storedData === "") {
|
||||||
|
storedPassword.put(`${encryptedPassword}`);
|
||||||
|
showMainPage();
|
||||||
|
console.log("registering and logging in....");
|
||||||
|
} else if (storedData === encryptedPassword) {
|
||||||
|
showMainPage();
|
||||||
|
console.log("welcome back!");
|
||||||
|
} else {
|
||||||
|
alert("Incorrect Password");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.error('Error in sha256HexPromise:', error);
|
||||||
|
// Handle the error appropriately
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function trimStringToChars(inputString, maxLength) {
|
||||||
|
if (inputString.length > maxLength + 1) {
|
||||||
|
return inputString.substring(0, maxLength) + '...';
|
||||||
|
} else {
|
||||||
|
return inputString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addPost(data) {
|
||||||
|
let postContainer = document.getElementById("postContainer");
|
||||||
|
|
||||||
|
let postElement = document.createElement('div');
|
||||||
|
postElement.textContent = filterXSS(trimStringToChars(data, 1000));
|
||||||
|
postContainer.appendChild(postElement);
|
||||||
|
postContainer.appendChild(document.createElement('br'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function post() {
|
||||||
|
let post = `${filterXSS(document.getElementById("post").value)}`;
|
||||||
|
let postData = `[${usrname}]: ${post}`;
|
||||||
|
const coredb = gun.get(`mayaspace`);
|
||||||
|
const postsDB = coredb.get('posts');
|
||||||
|
if (post.length < 1001) {
|
||||||
|
postsDB.put(postData);
|
||||||
|
} else {
|
||||||
|
alert("max post length is 1000 chars!")
|
||||||
|
}
|
||||||
|
console.log("USER: " + usrname);
|
||||||
|
}
|
||||||
|
|
||||||
|
function logout() {
|
||||||
|
document.location.href = "index.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("loaded");
|
BIN
maya.jpg
Normal file
BIN
maya.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
26
rules.html
Normal file
26
rules.html
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Mayaspace Rules</title>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>RULES FOR THIS INSTANCE</h1>
|
||||||
|
<div id="rules">
|
||||||
|
<p>1. No being a jerk.</p>
|
||||||
|
<p>2. Don't hack the website.</p>
|
||||||
|
<p>3. No spamming.</p>
|
||||||
|
<p>4. No posting content that's illegal in the state of Texas.</p>
|
||||||
|
<p>5. No posting content that's <i>majorly</i> offensive. (NSFL [Not Safe For Life], etc.)</p>
|
||||||
|
<p>6. No posting <b>severly graphic content.</b>
|
||||||
|
<p>7. No posting copyrighted content. (Basically, no piracy)</p>
|
||||||
|
<p>8. No posting links to copyrighted content. (Again, no piracy)</p>
|
||||||
|
<p>9. The rules may change at any time.</p>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<a href="index.html">Back to main page</a>
|
||||||
|
<hr>
|
||||||
|
<p>Copyright Samuel Lord. Licensed under the <a target="_blank" href="https://github.com/nodemixaholic/mayaspace/blob/master/LICENSE">MIT license.</a></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
44
style.css
Normal file
44
style.css
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', 'sans-serif';
|
||||||
|
}
|
||||||
|
h1,h2,h3,h4,h5,h6 {
|
||||||
|
font-family: cursive;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 1.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
width: 25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
border-radius: 55%;
|
||||||
|
float: left;
|
||||||
|
width: 15vw;
|
||||||
|
min-width: 80px;
|
||||||
|
max-width:200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 500px) {
|
||||||
|
h1 { font-size: 5rem; }
|
||||||
|
h2 { font-size: 4rem; }
|
||||||
|
h3 { font-size: 3rem; }
|
||||||
|
p { font-size: 3rem !important; }
|
||||||
|
input,button {
|
||||||
|
font-size: 2rem;
|
||||||
|
width: 25%;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue