modifying...

This commit is contained in:
CatAClock 2025-05-02 15:07:20 -07:00
parent bf738b63d3
commit 0f420b6eb9
14 changed files with 114 additions and 24 deletions

View file

@ -205,6 +205,13 @@ html {
border-width: 1px;
}
.Posting {
border-style: solid;
border-width: 1px;
margin-right: 5%;
}
.MainFooter {
display: flex;
margin-top: 75vh;

1
CSS/post.css Normal file
View file

@ -0,0 +1 @@

0
CSS/setting.css Normal file
View file

21
HTML/post.html Normal file
View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>The Fediverse</title>
<meta name="description" content="Change the fucking channel already!">
<link rel="icon" href="../Icons/favicon.ico" />
<link rel="stylesheet" href="../CSS/post.css">
<script type="module" src="../JS/post.js"></script>
<!-- Dependenci -->
<script language="JavaScript" type="text/javascript" src="https://kjur.github.io/jsrsasign/jsrsasign-latest-all-min.js"></script>
</head>
<body style="margin: 0px; text-align: center;">
<header>
<h1>Post</h1>
<textarea cols="50" rows="25" class="text" placeholder="status here..."></textarea>
<p class="button">POST!</p>
</header>
<p onclick="history.back()"><b>Back</b></p>
</body>
</html>

View file

@ -4,7 +4,7 @@
<title>The Fediverse</title>
<meta name="description" content="Change the fucking channel already!">
<link rel="icon" href="../Icons/favicon.ico" />
<link rel="stylesheet" href="../CSS/setting.css">
<script type="module" src="../JS/setting.js"></script>
<!-- Dependenci -->
<script language="JavaScript" type="text/javascript" src="https://kjur.github.io/jsrsasign/jsrsasign-latest-all-min.js"></script>
@ -17,10 +17,10 @@
<p class="Local">Toggle Local</p>
<p class="Remote">Toggle Remote</p>
<p class="Login Mastodon"><em>Login to Mastodon</em></p>
<input type="text" minlength="6" class="WebInput Mastodon" required />
<input type="text" class="WebInput Mastodon" placeholder="The website your account is on."/>
<p class="Logout Mastodon" style="visibility: hidden;"><em>Logout of Mastodon</em></p>
<p class="Login Bluesky"><em>Login to Bluesky</em></p>
<input type="text" minlength="6" class="WebInput Bluesky" required />
<input type="text" class="WebInput Bluesky" />
<p class="Logout Bluesky" style="visibility: hidden;"><em>Logout of Bluesky</em></p>
<p onclick="history.back()"><b>OK</b></p>
</body>

View file

@ -156,7 +156,7 @@ export async function GainTokens() {
let WellKnown = await GetPDSWellKnown();
// Check to see if something's a miss...
if ((document.location.href.split("state=").length > 1 && document.location.href.split("iss=").length > 1 && document.location.href.split("code=").length > 1) && Cookie.IsCookieReal(Cookie.BlueskyPKCEVeriferCookie)) {
if ((document.location.href.split("state=").length > 1 && document.location.href.split("iss=").length > 1 && document.location.href.split("code=").length > 1) && Cookie.IsCookieReal(Cookie.BlueskyPKCEVeriferCookie) && !(Cookie.IsCookieReal(Cookie.BlueskyAccessTokenCookie))) {
// Create varaibles, be aware of waits because of internet.
let DPoP = await ClientDPoPToken("POST", WellKnown.token_endpoint);
let code = document.location.href.split("code=")[1];

View file

@ -1,6 +1,6 @@
// STRINGS TODO: make sure to seperate stuff that a user will want to input. Ex: MastodonWebsiteName, BlueskyPDS, etc.
// Mastodon
export const MastodonWebsiteName = "https://wetdry.world";
export const MastodonWebsiteName = "mastodon_website";
export const MastodonClientIDName = "mastodon_client_id";
export const MastodonClientSecretName = "mastodon_client_secret";
export const MastodonAccessTokenName = "mastodon_access_token";
@ -22,6 +22,7 @@ export const TumblrWebsiteName = "https://www.tumblr.com";
// COOKIES TODO: person inputted stuff (like MastodonWebsiteName) should be implemented.
// Mastodon
export const MastodonWebsiteCookie = GetCookie(MastodonWebsiteName);
export const MastodonClientIDCookie = GetCookie(MastodonClientIDName);
export const MastodonClientSecretCookie = GetCookie(MastodonClientSecretName);
export const MastodonAccessTokenCookie = GetCookie(MastodonAccessTokenName);

View file

@ -4,6 +4,7 @@ export const Scopes = "read write follow push";
// Gets the public timeline.
export async function GetPublicTimeline(Local = false, Remote = false, Website) {
// Cookies can be found in `setting.js`
let Timeline;
if (Local == true && Remote == true) {
console.error("Don't set both Local and Remote timelines to true.");
@ -24,10 +25,11 @@ export async function GetPublicTimeline(Local = false, Remote = false, Website)
}
// Gets the favorites of a user that you have access to.
export async function GetFavorites(Website) {
export async function GetFavorites() {
let Favorites;
// Check for a token.
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
let Website = Cookie.MastodonWebsiteCookie;
// Get the varaibles that are stored in cookies.
Favorites = await fetch(Website + "/api/v1/favourites", {method: "GET", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}})
.then((response) => response.json());
@ -36,10 +38,11 @@ export async function GetFavorites(Website) {
}
// Gets the bookmarks of a user that you have access to.
export async function GetBookmarks(Website) {
export async function GetBookmarks() {
let Bookmarks;
// Check for a token.
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
let Website = Cookie.MastodonWebsiteCookie;
// Get the varaibles that are stored in cookies.
Bookmarks = await fetch(Website + "/api/v1/bookmarks", {method: "GET", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}})
.then((response) => response.json());
@ -48,10 +51,11 @@ export async function GetBookmarks(Website) {
}
// Gets the notifications of a user that you have access to.
export async function GetNotifications(Website) {
export async function GetNotifications() {
let Notifications;
// Check for a token.
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
let Website = Cookie.MastodonWebsiteCookie;
// Get the varaibles that are stored in cookies and then input it.
Notifications = await fetch(Website + "/api/v1/notifications", {method: "GET", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}})
.then((response) => response.json());
@ -59,6 +63,16 @@ export async function GetNotifications(Website) {
return Notifications;
}
// Make a status
export async function CreateStatus(Text) {
// Check for a token
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
let Website = Cookie.MastodonWebsiteCookie;
return await fetch(Website + "/api/v1/statuses?status=" + Text , {method: "POST", headers: {"Authorization": Cookie.MastodonTokenTypeCookie + " " + Cookie.MastodonAccessTokenCookie}})
.then((response) => response.json());
}
}
// The first step to using the app.
export async function HandleAuthentication(Website) {
// See if the user is smart enough to put https.
@ -69,6 +83,8 @@ export async function HandleAuthentication(Website) {
} else {
Website = "https://" + Website;
}
// Save the website
Cookie.InputCookie(Cookie.MastodonWebsiteName, Website);
// Registering the app.
InstanceData = await fetch(Website + "/api/v1/apps?client_name=Channel Viewer&redirect_uris=" + document.location.href + "&scopes=" + Scopes, {method: "POST"})
.then((response) => response.json());
@ -80,14 +96,16 @@ export async function HandleAuthentication(Website) {
}
// This specific functino goes after HandleAuthentication for when login happens.
export async function GainToken(Website) {
export async function GainToken() {
// check if you both have a code and have a current authentication.
if (document.location.href.split("code=").length > 1 && Cookie.IsCookieReal(Cookie.MastodonClientIDCookie)) {
if (document.location.href.split("code=").length > 1 && Cookie.IsCookieReal(Cookie.MastodonClientIDCookie) && !(Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie))) {
// Get some vars.
let code = document.location.href.split("code=")[1];
let Website = Cookie.MastodonWebsiteCookie;
// Authenticate.
let AuthenticationToken = await fetch(Website + "/oauth/token?client_id=" + Cookie.MastodonClientIDCookie + "&client_secret=" + Cookie.MastodonClientSecretCookie + "&redirect_uri=" + document.location.href + "&grant_type=authorization_code&code=" + code, {method: "POST"})
.then((response) => response.json());
// Cookify These
// Cookify These.
Cookie.InputCookie(Cookie.MastodonAccessTokenName, AuthenticationToken.access_token);
Cookie.InputCookie(Cookie.MastodonTokenTypeName, AuthenticationToken.token_type);
}

View file

@ -0,0 +1 @@
import * as Cookie from "./Cookies.js";

View file

@ -15,6 +15,7 @@ let BrowserHeight = window.innerHeight;
let ArrowsButton = document.getElementsByClassName("Arrow");
let SettingButton = document.getElementsByClassName("Setting")[0];
let MailButton = document.getElementsByClassName("Mail")[0];
let PostingButton = document.getElementsByClassName("Posting")[0];
// Sounds
const ButtonSound = new Audio("Audio/button-305770.mp3");
@ -108,8 +109,13 @@ async function PosterContainerUpdate() {
var LocalTrue = (LocalCookie === "true");
let RemoteCookie = Cookie.GetCookie("Remote");
var RemoteTrue = (RemoteCookie === "true");
let Website = Cookie.MastodonWebsiteCookie;
let Timeline = await MastodonAPI.GetPublicTimeline(LocalTrue, RemoteTrue, Cookie.MastodonWebsiteName);
if (!(Cookie.IsCookieReal(Cookie.MastodonWebsiteCookie))) {
Website = "https://wetdry.world";
}
let Timeline = await MastodonAPI.GetPublicTimeline(LocalTrue, RemoteTrue, Website);
let Content = [];
let Users = [];
for (let i in Timeline) {
@ -128,7 +134,12 @@ SettingButton.onclick = (event) => {
window.location.href = "./HTML/setting.html";
}
// Open the notifs, private message, favorites, bookmarks
// Open the notifs, private message, favorites, ... anything mail related!
MailButton.onclick = (event) => {
window.location.href = "./HTML/mail.html";
}
// Open the posting area
PostingButton.onclick = (event) => {
window.location.href = "./HTML/post.html";
}

View file

@ -5,7 +5,7 @@ import * as Cookie from "./Cookies.js";
// Below is the thing it populates if you login.
async function PopulateFavorites() {
let Favorites = await MastodonAPI.GetFavorites(Cookie.MastodonWebsiteName);
let Favorites = await MastodonAPI.GetFavorites();
let FavoritesArea = document.getElementsByClassName("Favorites")[0];
// Populate the favorites area.
@ -16,7 +16,7 @@ async function PopulateFavorites() {
}
async function PopulateBookmarks() {
let Bookmarks = await MastodonAPI.GetBookmarks(Cookie.MastodonWebsiteName);
let Bookmarks = await MastodonAPI.GetBookmarks();
let BookmarksArea = document.getElementsByClassName("Bookmarks")[0];
// Populate the Bookmarks area.
@ -27,7 +27,7 @@ async function PopulateBookmarks() {
}
async function PopulateNotifications() {
let Notifications = await MastodonAPI.GetNotifications(Cookie.MastodonWebsiteName);
let Notifications = await MastodonAPI.GetNotifications();
let NotificationsArea = document.getElementsByClassName("Notifications")[0];
// Populate the Conversations area.

25
JS/post.js Normal file
View file

@ -0,0 +1,25 @@
import * as MastodonAPI from "./MastodonAPI.js";
import * as BlueskyAPI from "./BlueskyAPI.js";
import * as TumblrAPI from "./TumblrAPI.js";
import * as Cookie from "./Cookies.js";
// Elements.
let PostButton = document.getElementsByClassName("button")[0];
let InputArea = document.getElementsByClassName("text")[0];
// Clicking the beeg POST button.
PostButton.onclick = (event) => {
Post();
}
async function Post() {
let Text = InputArea.value;
// Mastodon posting.
if (Cookie.IsCookieReal(Cookie.MastodonAccessTokenCookie)) {
MastodonAPI.CreateStatus(Text);
}
// Bluesky posting.
if (Cookie.IsCookieReal(Cookie.BlueskyAccessTokenCookie)) {
}
}

View file

@ -14,6 +14,9 @@ let BlueskyLoginButton = document.getElementsByClassName("Login Bluesky")[0];
let BlueskyWebInput = document.getElementsByClassName("WebInput Bluesky")[0];
let BlueskyLogoutButton = document.getElementsByClassName("Logout Bluesky")[0];
// original link
let Origin = location.origin + "/HTML/setting.html"
// Change weather the timelines are public or remote
LocalButton.onclick = (event) => {
// Toggle the cookie
@ -36,8 +39,9 @@ RemoteButton.onclick = (event) => {
// Mastodon buttons
// Login
MastodonLoginButton.onclick = (event) => {
if (MastodonWebInput != "") {
MastodonAPI.HandleAuthentication(Cookie.MastodonWebsiteName);
if (MastodonWebInput.value != "") {
let text = MastodonWebInput.value
MastodonAPI.HandleAuthentication(text);
}
}
@ -47,13 +51,13 @@ MastodonLogoutButton.onclick = (event) => {
Cookie.ExpireCookie(Cookie.MastodonClientSecretName);
Cookie.ExpireCookie(Cookie.MastodonAccessTokenName);
Cookie.ExpireCookie(Cookie.MastodonTokenTypeName);
document.location.href = document.location.href;
document.location.href = Origin;
}
// Bluesky Buttons
// Login
BlueskyLoginButton.onclick = (event) => {
if (BlueskyWebInput != "") {
if (BlueskyWebInput.value != "") {
BlueskyAPI.HandleAuthorization();
}
}
@ -67,7 +71,7 @@ BlueskyLogoutButton.onclick = (event) => {
Cookie.ExpireCookie(Cookie.BlueskyRefreshTokenName);
Cookie.ExpireCookie(Cookie.BlueskyPublicKeyName);
Cookie.ExpireCookie(Cookie.BlueskyPrivateKeyName);
document.location.href = document.location.href;
document.location.href = Origin;
}
// if an access token is found, login.
@ -80,7 +84,7 @@ async function CheckLogin() {
MastodonLogoutButton.setAttribute("style", "");
} else {
// Auto log in
MastodonAPI.GainToken(Cookie.MastodonWebsiteName);
await MastodonAPI.GainToken(Cookie.MastodonWebsiteName);
}
// Check for a bluesky token.
if (Cookie.IsCookieReal(Cookie.BlueskyAccessTokenCookie)) {
@ -90,7 +94,7 @@ async function CheckLogin() {
BlueskyLogoutButton.setAttribute("style", "");
} else {
// Auto log in
BlueskyAPI.GainTokens();
await BlueskyAPI.GainTokens();
}
}

View file

@ -292,6 +292,7 @@
<footer class="MainFooter">
<p class="Setting">Setting</p>
<p class="Time" style="width: 50%">Time</p>
<p class="Posting">Post</p>
<p class="Mail">Mail</p>
</footer>
</section>