From d85917bfb2a64a3387900f260ced68de30cf9e2b Mon Sep 17 00:00:00 2001 From: Thomas Miceli <27960254+thomiceli@users.noreply.github.com> Date: Thu, 4 Jan 2024 04:44:56 +0100 Subject: [PATCH] Small fixes (#196) --- Makefile | 6 +++--- internal/ssh/run.go | 2 +- internal/web/server.go | 2 +- package.json | 7 +++---- public/admin.ts | 1 + public/embed.scss | 2 +- postcss.config.js => public/postcss.config.js | 4 +++- public/style.css | 2 +- .../tailwind-embed.config.js | 1 + tailwind.config.js => public/tailwind.config.js | 1 + public/tsconfig.json | 12 ++++++++++++ vite.config.js => public/vite.config.js | 0 templates/base/admin_footer.html | 2 +- templates/pages/admin_config.html | 7 +++++++ templates/pages/all.html | 2 +- templates/pages/likes.html | 2 +- templates/pages/revisions.html | 2 +- templates/pages/search.html | 2 +- .../pagination.html => partials/_pagination.html} | 2 +- tsconfig.json | 9 --------- 20 files changed, 41 insertions(+), 27 deletions(-) rename postcss.config.js => public/postcss.config.js (77%) rename tailwind-embed.config.js => public/tailwind-embed.config.js (95%) rename tailwind.config.js => public/tailwind.config.js (95%) create mode 100644 public/tsconfig.json rename vite.config.js => public/vite.config.js (100%) rename templates/{base/pagination.html => partials/_pagination.html} (99%) delete mode 100644 tsconfig.json diff --git a/Makefile b/Makefile index b6885a4..e0ca23b 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ install: build_frontend: @echo "Building frontend assets..." - npx vite build - @EMBED=1 npx postcss 'public/assets/embed-*.css' -c postcss.config.js --replace # until we can .nest { @tailwind } in Sass + npx vite -c public/vite.config.js build + @EMBED=1 npx postcss 'public/assets/embed-*.css' -c public/postcss.config.js --replace # until we can .nest { @tailwind } in Sass build_backend: @echo "Building Opengist binary..." @@ -33,7 +33,7 @@ build_docker: watch_frontend: @echo "Building frontend assets..." - npx vite dev --port 16157 + npx vite -c public/vite.config.js dev --port 16157 watch_backend: @echo "Building Opengist binary..." diff --git a/internal/ssh/run.go b/internal/ssh/run.go index d5c4e99..e4eaccb 100644 --- a/internal/ssh/run.go +++ b/internal/ssh/run.go @@ -64,7 +64,7 @@ func listen(serverConfig *ssh.ServerConfig) { go func() { sConn, channels, reqs, err := ssh.NewServerConn(nConn, serverConfig) if err != nil { - if !(err != io.EOF && !errors.Is(err, syscall.ECONNRESET)) { + if err != io.EOF && !errors.Is(err, syscall.ECONNRESET) { errorSsh("Failed to handshake", err) } return diff --git a/internal/web/server.go b/internal/web/server.go index 45c9185..994e6c2 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -178,7 +178,7 @@ func NewServer(isDev bool) *Server { return nil }, })) - // e.Use(middleware.Recover()) + e.Use(middleware.Recover()) e.Use(middleware.Secure()) e.Renderer = &Template{ diff --git a/package.json b/package.json index c95660b..ab5078d 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,10 @@ { "name": "opengist", "private": true, - "version": "1.0.0", "scripts": { - "dev": "node_modules/.bin/vite", - "build": "node_modules/.bin/vite build", - "preview": "node_modules/.bin/vite preview" + "dev": "node_modules/.bin/vite -c public/vite.config.js", + "build": "node_modules/.bin/vite -c public/vite.config.js build", + "preview": "node_modules/.bin/vite -c public/vite.config.js preview" }, "devDependencies": { "@codemirror/commands": "^6.2.2", diff --git a/public/admin.ts b/public/admin.ts index 56fa0ea..037803c 100644 --- a/public/admin.ts +++ b/public/admin.ts @@ -8,6 +8,7 @@ document.addEventListener('DOMContentLoaded', () => { }); const setSetting = (key: string, value: string) => { + // @ts-ignore const baseUrl = window.opengist_base_url || ''; const data = new URLSearchParams(); data.append('key', key); diff --git a/public/embed.scss b/public/embed.scss index fc1d354..5ac1941 100644 --- a/public/embed.scss +++ b/public/embed.scss @@ -11,7 +11,7 @@ @tailwind components; @tailwind utilities; -@config "../tailwind-embed.config.js"; +@config "./tailwind-embed.config.js"; .html { -webkit-text-size-adjust: 100%; diff --git a/postcss.config.js b/public/postcss.config.js similarity index 77% rename from postcss.config.js rename to public/postcss.config.js index f9f24f4..1f8e345 100644 --- a/postcss.config.js +++ b/public/postcss.config.js @@ -2,7 +2,9 @@ module.exports = { plugins: { 'postcss-import': {}, 'tailwindcss/nesting': {}, - tailwindcss: {}, + tailwindcss: { + config: "./public/tailwind.config.js", + }, autoprefixer: {}, 'postcss-selector-namespace': {namespace() {return (process.env.EMBED) ? '.opengist-embed' : '';}}, cssnano: {}, diff --git a/public/style.css b/public/style.css index 4763dbe..81fae94 100644 --- a/public/style.css +++ b/public/style.css @@ -2,7 +2,7 @@ @tailwind components; @tailwind utilities; -@config "../tailwind.config.js"; +@config "./tailwind.config.js"; @layer base { ul, ol { diff --git a/tailwind-embed.config.js b/public/tailwind-embed.config.js similarity index 95% rename from tailwind-embed.config.js rename to public/tailwind-embed.config.js index be4c91d..5102e64 100644 --- a/tailwind-embed.config.js +++ b/public/tailwind-embed.config.js @@ -1,5 +1,6 @@ const colors = require('tailwindcss/colors') +/** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./templates/pages/gist_embed.html", diff --git a/tailwind.config.js b/public/tailwind.config.js similarity index 95% rename from tailwind.config.js rename to public/tailwind.config.js index a387490..e7de624 100644 --- a/tailwind.config.js +++ b/public/tailwind.config.js @@ -1,5 +1,6 @@ const colors = require('tailwindcss/colors') +/** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./templates/**/*.html", diff --git a/public/tsconfig.json b/public/tsconfig.json new file mode 100644 index 0000000..854045d --- /dev/null +++ b/public/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "esModuleInterop": true + }, + "files": [ + "main.ts", + "editor.ts", + "admin.ts", + "gist.ts", + "embed.ts", + ], +} diff --git a/vite.config.js b/public/vite.config.js similarity index 100% rename from vite.config.js rename to public/vite.config.js diff --git a/templates/base/admin_footer.html b/templates/base/admin_footer.html index 6ee70df..fa67afe 100644 --- a/templates/base/admin_footer.html +++ b/templates/base/admin_footer.html @@ -5,7 +5,7 @@ {{ define "admin_footer" }} {{ if .urlPage }}