feat: formated code
This commit is contained in:
parent
641909aa31
commit
5e7629a055
13 changed files with 262 additions and 224 deletions
|
@ -3,9 +3,12 @@
|
|||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="assets/icons/favicon.ico" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Minibin</title>
|
||||
</head>
|
||||
|
|
|
@ -4,7 +4,7 @@ import styles from "./CustomSelect.module.css";
|
|||
const CustomSelect = ({ options, onSelect }) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [selectedOption, setSelectedOption] = useState(
|
||||
options.length > 0 ? options[0] : null
|
||||
options.length > 0 ? options[0] : null,
|
||||
);
|
||||
|
||||
const toggleDropdown = () => {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
width: 8rem;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
.selected__option {
|
||||
padding: 8px;
|
||||
}
|
||||
|
|
|
@ -49,29 +49,34 @@ const Editor = () => {
|
|||
if (response.ok) {
|
||||
const isURL = URL_REGEX.test(text);
|
||||
if (isURL) {
|
||||
navigator.clipboard.writeText(`${CLIENT_BASE_URL}/r/${data.id}`).then(function () {
|
||||
alert("Short URL copied to clipboard!");
|
||||
}, function (err) {
|
||||
try {
|
||||
var successful = document.execCommand('copy');
|
||||
navigator.clipboard.writeText(`${CLIENT_BASE_URL}/r/${data.id}`).then(
|
||||
function () {
|
||||
alert("Short URL copied to clipboard!");
|
||||
} catch (err) {
|
||||
console.log('Oops, unable to copy');
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
navigator.clipboard.writeText(`${CLIENT_BASE_URL}/r/${data.id}`).then(function () {
|
||||
navigator.clipboard.writeText(`${CLIENT_BASE_URL}/${data.id}`);
|
||||
alert("URL copied to clipboard!");
|
||||
}, function (err) {
|
||||
try {
|
||||
var successful = document.execCommand('copy');
|
||||
},
|
||||
function (err) {
|
||||
try {
|
||||
var successful = document.execCommand("copy");
|
||||
alert("Short URL copied to clipboard!");
|
||||
} catch (err) {
|
||||
console.log("Oops, unable to copy");
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
navigator.clipboard.writeText(`${CLIENT_BASE_URL}/r/${data.id}`).then(
|
||||
function () {
|
||||
navigator.clipboard.writeText(`${CLIENT_BASE_URL}/${data.id}`);
|
||||
alert("URL copied to clipboard!");
|
||||
} catch (err) {
|
||||
console.log('Oops, unable to copy');
|
||||
}
|
||||
});
|
||||
},
|
||||
function (err) {
|
||||
try {
|
||||
var successful = document.execCommand("copy");
|
||||
alert("URL copied to clipboard!");
|
||||
} catch (err) {
|
||||
console.log("Oops, unable to copy");
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
navigate(`/${data.id}`);
|
||||
} else {
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
|
||||
.btn__save {
|
||||
bottom: 2rem;
|
||||
right: 2rem;
|
||||
|
|
|
@ -7,7 +7,11 @@ import CustomSelect from "../CustomSelect/CustomSelect";
|
|||
const Header = ({ isSelectVisible, onLanguageChange }) => {
|
||||
return (
|
||||
<div className={styles.header}>
|
||||
<Link to="/"><h1><span className={styles.header__mini}>mini</span>bin</h1></Link>
|
||||
<Link to="/">
|
||||
<h1>
|
||||
<span className={styles.header__mini}>mini</span>bin
|
||||
</h1>
|
||||
</Link>
|
||||
{isSelectVisible && (
|
||||
<CustomSelect
|
||||
options={SUPPORTED_LANGUAGES}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
color: inherit;
|
||||
}
|
||||
|
||||
.header__mini{
|
||||
.header__mini {
|
||||
color: var(--color-yellow);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
|||
.header {
|
||||
margin: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
|
||||
.header h1 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
|
|
@ -8,116 +8,117 @@
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #ebdbb2; /* fg1 / fg */
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::-moz-selection,
|
||||
pre[class*="language-"] ::-moz-selection,
|
||||
code[class*="language-"]::-moz-selection,
|
||||
code[class*="language-"] ::-moz-selection {
|
||||
color: #fbf1c7; /* fg0 */
|
||||
background: #7c6f64; /* bg4 */
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection,
|
||||
pre[class*="language-"] ::selection,
|
||||
code[class*="language-"]::selection,
|
||||
code[class*="language-"] ::selection {
|
||||
color: #fbf1c7; /* fg0 */
|
||||
background: #7c6f64; /* bg4 */
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.cdata {
|
||||
color: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.delimiter,
|
||||
.token.boolean,
|
||||
.token.keyword,
|
||||
.token.selector,
|
||||
.token.important,
|
||||
.token.atrule {
|
||||
color: #fb4934; /* red2 */
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.punctuation,
|
||||
.token.attr-name {
|
||||
color: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.tag,
|
||||
.token.tag .punctuation,
|
||||
.token.doctype,
|
||||
.token.builtin {
|
||||
color: #fabd2f; /* yellow2 */
|
||||
}
|
||||
|
||||
.token.entity,
|
||||
.token.number,
|
||||
.token.symbol {
|
||||
color: #d3869b; /* purple2 */
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.constant,
|
||||
.token.variable {
|
||||
color: #fb4934; /* red2 */
|
||||
}
|
||||
|
||||
.token.string,
|
||||
.token.char {
|
||||
color: #b8bb26; /* green2 */
|
||||
}
|
||||
|
||||
.token.attr-value,
|
||||
.token.attr-value .punctuation {
|
||||
color: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.url {
|
||||
color: #b8bb26; /* green2 */
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.token.function {
|
||||
color: #fabd2f; /* yellow2 */
|
||||
}
|
||||
|
||||
.token.regex {
|
||||
background: #b8bb26; /* green2 */
|
||||
}
|
||||
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.inserted {
|
||||
background: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.deleted {
|
||||
background: #fb4934; /* red2 */
|
||||
}
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #ebdbb2; /* fg1 / fg */
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::-moz-selection,
|
||||
pre[class*="language-"] ::-moz-selection,
|
||||
code[class*="language-"]::-moz-selection,
|
||||
code[class*="language-"] ::-moz-selection {
|
||||
color: #fbf1c7; /* fg0 */
|
||||
background: #7c6f64; /* bg4 */
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection,
|
||||
pre[class*="language-"] ::selection,
|
||||
code[class*="language-"]::selection,
|
||||
code[class*="language-"] ::selection {
|
||||
color: #fbf1c7; /* fg0 */
|
||||
background: #7c6f64; /* bg4 */
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.cdata {
|
||||
color: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.delimiter,
|
||||
.token.boolean,
|
||||
.token.keyword,
|
||||
.token.selector,
|
||||
.token.important,
|
||||
.token.atrule {
|
||||
color: #fb4934; /* red2 */
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.punctuation,
|
||||
.token.attr-name {
|
||||
color: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.tag,
|
||||
.token.tag .punctuation,
|
||||
.token.doctype,
|
||||
.token.builtin {
|
||||
color: #fabd2f; /* yellow2 */
|
||||
}
|
||||
|
||||
.token.entity,
|
||||
.token.number,
|
||||
.token.symbol {
|
||||
color: #d3869b; /* purple2 */
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.constant,
|
||||
.token.variable {
|
||||
color: #fb4934; /* red2 */
|
||||
}
|
||||
|
||||
.token.string,
|
||||
.token.char {
|
||||
color: #b8bb26; /* green2 */
|
||||
}
|
||||
|
||||
.token.attr-value,
|
||||
.token.attr-value .punctuation {
|
||||
color: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.url {
|
||||
color: #b8bb26; /* green2 */
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.token.function {
|
||||
color: #fabd2f; /* yellow2 */
|
||||
}
|
||||
|
||||
.token.regex {
|
||||
background: #b8bb26; /* green2 */
|
||||
}
|
||||
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.inserted {
|
||||
background: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.deleted {
|
||||
background: #fb4934; /* red2 */
|
||||
}
|
||||
|
||||
|
|
|
@ -9,5 +9,5 @@ ReactDOM.createRoot(document.getElementById("root")).render(
|
|||
<Router>
|
||||
<App />
|
||||
</Router>
|
||||
</React.StrictMode>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
|
|
|
@ -1,70 +1,94 @@
|
|||
export const CLIENT_BASE_URL = import.meta.env.VITE_CLIENT_BASE_URL;
|
||||
export const SERVER_BASE_URL = import.meta.env.VITE_SERVER_BASE_URL;
|
||||
export const URL_REGEX = /^(https?:\/\/)?([\w.-]+\.[a-z]{2,})(\/?[^\s]*)?$/;
|
||||
export const SUPPORTED_LANGUAGES = [{
|
||||
value: "none",
|
||||
label: "Plain Text",
|
||||
}, {
|
||||
value: "c",
|
||||
label: "C",
|
||||
}, {
|
||||
value: "cpp",
|
||||
label: "C++",
|
||||
}, {
|
||||
value: "css",
|
||||
label: "CSS",
|
||||
}, {
|
||||
value: "git",
|
||||
label: "Git",
|
||||
}, {
|
||||
value: "go",
|
||||
label: "Golang",
|
||||
}, {
|
||||
value: "html",
|
||||
label: "HTML",
|
||||
}, {
|
||||
value: "java",
|
||||
label: "Java",
|
||||
}, {
|
||||
value: "js",
|
||||
label: "JavaScript",
|
||||
}, {
|
||||
value: "json",
|
||||
label: "JSON",
|
||||
}, {
|
||||
value: "jsx",
|
||||
label: "JSX",
|
||||
}, {
|
||||
value: "kotlin",
|
||||
label: "Kotlin",
|
||||
}, {
|
||||
value: "lua",
|
||||
label: "Lua",
|
||||
}, {
|
||||
value: "md",
|
||||
label: "Markdown",
|
||||
}, {
|
||||
value: "py",
|
||||
label: "Python",
|
||||
}, {
|
||||
value: "rust",
|
||||
label: "Rust",
|
||||
}, {
|
||||
value: "sh",
|
||||
label: "Shell",
|
||||
}, {
|
||||
value: "sql",
|
||||
label: "SQL",
|
||||
}, {
|
||||
value: "ts",
|
||||
label: "TypeScript",
|
||||
}, {
|
||||
value: "tsx",
|
||||
label: "TSX",
|
||||
}, {
|
||||
value: "url",
|
||||
label: "URL",
|
||||
}, {
|
||||
value: "xml",
|
||||
label: "XML",
|
||||
}];
|
||||
export const SUPPORTED_LANGUAGES = [
|
||||
{
|
||||
value: "none",
|
||||
label: "Plain Text",
|
||||
},
|
||||
{
|
||||
value: "c",
|
||||
label: "C",
|
||||
},
|
||||
{
|
||||
value: "cpp",
|
||||
label: "C++",
|
||||
},
|
||||
{
|
||||
value: "css",
|
||||
label: "CSS",
|
||||
},
|
||||
{
|
||||
value: "git",
|
||||
label: "Git",
|
||||
},
|
||||
{
|
||||
value: "go",
|
||||
label: "Golang",
|
||||
},
|
||||
{
|
||||
value: "html",
|
||||
label: "HTML",
|
||||
},
|
||||
{
|
||||
value: "java",
|
||||
label: "Java",
|
||||
},
|
||||
{
|
||||
value: "js",
|
||||
label: "JavaScript",
|
||||
},
|
||||
{
|
||||
value: "json",
|
||||
label: "JSON",
|
||||
},
|
||||
{
|
||||
value: "jsx",
|
||||
label: "JSX",
|
||||
},
|
||||
{
|
||||
value: "kotlin",
|
||||
label: "Kotlin",
|
||||
},
|
||||
{
|
||||
value: "lua",
|
||||
label: "Lua",
|
||||
},
|
||||
{
|
||||
value: "md",
|
||||
label: "Markdown",
|
||||
},
|
||||
{
|
||||
value: "py",
|
||||
label: "Python",
|
||||
},
|
||||
{
|
||||
value: "rust",
|
||||
label: "Rust",
|
||||
},
|
||||
{
|
||||
value: "sh",
|
||||
label: "Shell",
|
||||
},
|
||||
{
|
||||
value: "sql",
|
||||
label: "SQL",
|
||||
},
|
||||
{
|
||||
value: "ts",
|
||||
label: "TypeScript",
|
||||
},
|
||||
{
|
||||
value: "tsx",
|
||||
label: "TSX",
|
||||
},
|
||||
{
|
||||
value: "url",
|
||||
label: "URL",
|
||||
},
|
||||
{
|
||||
value: "xml",
|
||||
label: "XML",
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
:root {
|
||||
--color-dark: #282828;
|
||||
--color-light: #ebdbb2;
|
||||
--color-yellow: #fabd2f;
|
||||
}
|
||||
--color-dark: #282828;
|
||||
--color-light: #ebdbb2;
|
||||
--color-yellow: #fabd2f;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,6 @@ export default defineConfig({
|
|||
}),
|
||||
],
|
||||
build: {
|
||||
outDir: '../server/dist'
|
||||
}
|
||||
outDir: "../server/dist",
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"embed"
|
||||
"flag"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
"database/sql"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
|
@ -35,9 +36,9 @@ var (
|
|||
|
||||
func RegisterHandlers(e *echo.Echo) {
|
||||
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
||||
Skipper: nil,
|
||||
Root: "dist",
|
||||
Index: "index.html",
|
||||
Skipper: nil,
|
||||
Root: "dist",
|
||||
Index: "index.html",
|
||||
HTML5: true,
|
||||
Filesystem: http.FS(dist),
|
||||
}))
|
||||
|
@ -119,4 +120,4 @@ func generateShortID() string {
|
|||
id[i] = shortIDCharset[rand.Intn(len(shortIDCharset))]
|
||||
}
|
||||
return string(id)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue