feat: create v2 for module support
All checks were successful
Deploy / deploy (push) Successful in 1m21s

This commit is contained in:
xuu
2023-10-19 17:05:41 -06:00
parent 392341cf38
commit b82a1e954e
33 changed files with 14142 additions and 25714 deletions

View File

@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import './paste/Framework.css';
@@ -20,7 +20,7 @@ class App extends Component {
}
componentDidMount() {
req('https://paste.dn42.us/app-info').get()
req('/app-info').get()
.then((response) => {
if (response.ok) return response.text().catch(()=>"");
else return "Unknown API"; })
@@ -30,20 +30,16 @@ componentDidMount() {
render() {
const {api, name} = this.state;
return (
<BrowserRouter basename={'/ui'}>
<React.Fragment key={1}>
<>
<section className="container-responsive">
<Switch>
<Route path={`/`} component={Paste} />
</Switch>
<Paste />
</section>
<footer>
<span className="left text-muted">{name}</span>
<span className="right text-muted">{api}</span>
</footer>
</React.Fragment>
</BrowserRouter>
</>
);
}
}

View File

@@ -91,7 +91,7 @@ const blength = (o) => {
return utf8length;
};
const PASTE_API = "https://paste.dn42.us/paste"
const PASTE_API = (''+window.location).replace(/ui\/.*$/, 'paste');
const syntaxItems = [
["text", "Plain Text"],
@@ -133,9 +133,7 @@ class Paste extends Component {
constructor(props) {
super(props);
const { location } = props;
const [ hash, key ] = location.hash.substring(2).split("!");
const [ hash, key ] = window.location.hash.substring(2).split("!");
this.state = {
error: "",
@@ -290,8 +288,7 @@ class Paste extends Component {
req(`${PASTE_API}/${hash}`).get().then((res)=> res.ok ? res.text() : "").then(this.decrypt).catch();
}
componentWillReceiveProps(nextProps) {
const { location } = nextProps;
const { hash:nextHash } = location;
const { hash:nextHash } = window.location;
const [ hash='', key='' ] = nextHash.substring(2).split("!");
if (hash === this.state.hash) return;