feat: create v2 for module support
All checks were successful
Deploy / deploy (push) Successful in 1m21s
All checks were successful
Deploy / deploy (push) Successful in 1m21s
This commit is contained in:
4
assets/.gitignore
vendored
4
assets/.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
/build
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
@@ -6,9 +7,6 @@
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
|
||||
19
assets/assets.go
Normal file
19
assets/assets.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
//go:embed build/*
|
||||
var ui embed.FS
|
||||
|
||||
func GetUI() fs.FS {
|
||||
dir, err := fs.Sub(ui, "build")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
panic(err)
|
||||
}
|
||||
return dir
|
||||
}
|
||||
38032
assets/package-lock.json
generated
38032
assets/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,20 @@
|
||||
{
|
||||
"name": "paste",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"private": true,
|
||||
"homepage": "https://paste.dn42.us/ui",
|
||||
"dependencies": {
|
||||
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
||||
"bootstrap": "^4.5.2",
|
||||
"bootstrap-4-react": "0.0.59",
|
||||
"crypto-js": "^4.0.0",
|
||||
"react": "^16.9.0",
|
||||
"react-dom": "^16.9.0",
|
||||
"react-highlight": "^0.12.0",
|
||||
"react-markdown": "^4.3.1",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "^3.1.1",
|
||||
"pako": "^2.1.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-highlight": "^0.15.0",
|
||||
"react-markdown": "^9.0.0",
|
||||
"react-router-dom": "^6.17.0",
|
||||
"react-scripts": "^5.0.1",
|
||||
"seedrandom": "^3.0.5"
|
||||
},
|
||||
"scripts": {
|
||||
|
||||
@@ -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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user