diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..5452531 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +mayaspace.nodemixaholic.com \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2a526a3 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 7d61d23..4dff22b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# mayaspace-prod -Mayaspace Production Copy +# mayaspace +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. diff --git a/index.html b/index.html new file mode 100644 index 0000000..0ff3302 --- /dev/null +++ b/index.html @@ -0,0 +1,35 @@ + + + Maya Space + + + + + +

MayaSpace (WIP)



+
+ + + + + + + +
+

Rules for this instance.

+
+

About Maya

+

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.

+

Why did you create MayaSpace?

+

I thought it was a good pun, and decided to make it real. (Thanks Mom and Dad for the pun!)

+

What is MayaSpace?

+

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.

+

Do you love Maya?

+

Yes. Yes I do.

+
+

Copyright Samuel Lord. Licensed under the MIT license.

+ + + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..cc2367f --- /dev/null +++ b/index.js @@ -0,0 +1,115 @@ +let gun = Gun(['http://nodemixaholic.com:8069/gun', 'https://gun-manhattan.herokuapp.com/gun']); +let usrname; + +function showMainPage() { + body.innerHTML = ` +

MayaSpace



+
+ + +
+
+
+ Copyright Samuel Lord. All rights reserved. +
+ `; + + 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"); diff --git a/maya.jpg b/maya.jpg new file mode 100644 index 0000000..9162371 Binary files /dev/null and b/maya.jpg differ diff --git a/rules.html b/rules.html new file mode 100644 index 0000000..5305123 --- /dev/null +++ b/rules.html @@ -0,0 +1,26 @@ + + + +Mayaspace Rules + + + + +

RULES FOR THIS INSTANCE

+
+

1. No being a jerk.

+

2. Don't hack the website.

+

3. No spamming.

+

4. No posting content that's illegal in the state of Texas.

+

5. No posting content that's majorly offensive. (NSFL [Not Safe For Life], etc.)

+

6. No posting severly graphic content. +

7. No posting copyrighted content. (Basically, no piracy)

+

8. No posting links to copyrighted content. (Again, no piracy)

+

9. The rules may change at any time.

+
+
+ Back to main page +
+

Copyright Samuel Lord. Licensed under the MIT license.

+ + diff --git a/style.css b/style.css new file mode 100644 index 0000000..b9580bd --- /dev/null +++ b/style.css @@ -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%; + } +}