generated from cms/tibi-docs
Initial commit
This commit is contained in:
30
frontend/.htaccess
Normal file
30
frontend/.htaccess
Normal file
@@ -0,0 +1,30 @@
|
||||
AddType application/javascript .mjs
|
||||
|
||||
#DirectoryIndex index.html spa.html
|
||||
DirectoryIndex noindex
|
||||
|
||||
<ifModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
RewriteRule ^/?api/(.*)$ http://tibi-server:8080/api/v1/_/demo/$1 [P,QSA,L]
|
||||
|
||||
# set in vhost or global in apache
|
||||
#SSLProxyEngine On
|
||||
#SSLProxyVerify none
|
||||
#SSLProxyCheckPeerCN off
|
||||
#SSLProxyCheckPeerName off
|
||||
#SSLProxyCheckPeerExpire off
|
||||
|
||||
# Set the Host header for requests to sentry
|
||||
RequestHeader set Host sentry.basehosts.de env=proxy-sentry
|
||||
RequestHeader unset Authorization env=proxy-sentry
|
||||
# need to update project id
|
||||
RewriteRule ^/?_s(.*)$ https://sentry.basehosts.de/api/__PROJECT_ID__/envelope/$1 [P,L,E=proxy-sentry:1]
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^/?(.*)$ http://tibi-server:8080/api/v1/_/demo/ssr?token=owshwerNwoa&url=/$1 [P,QSA,L]
|
||||
#RewriteRule (.*) /spa.html [QSA,L]
|
||||
|
||||
</ifModule>
|
||||
23
frontend/spa.html
Normal file
23
frontend/spa.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>TibiCMS</title>
|
||||
<base href="/" />
|
||||
<link rel="stylesheet" href="/dist/index.css?t=__TIMESTAMP__" />
|
||||
|
||||
<!--HEAD-->
|
||||
|
||||
<!--PRELOAD-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="appContainer"><!--HTML--></div>
|
||||
<script type="module" src="/dist/index.mjs?t=__TIMESTAMP__"></script>
|
||||
<script nomodule src="/dist/index.es5.js?t=__TIMESTAMP__"></script>
|
||||
</body>
|
||||
|
||||
<!--SSR.ERROR-->
|
||||
<!--SSR.COMMENT-->
|
||||
</html>
|
||||
22
frontend/src/components/App.svelte
Normal file
22
frontend/src/components/App.svelte
Normal file
@@ -0,0 +1,22 @@
|
||||
<script lang="ts">
|
||||
import { location } from "../store"
|
||||
|
||||
export let url = ""
|
||||
|
||||
if (url) {
|
||||
// ssr
|
||||
let l = url.split("?")
|
||||
$location = {
|
||||
path: l[0],
|
||||
search: l.length > 1 ? l[1] : "",
|
||||
hash: "",
|
||||
categoryPath: l[0].replace(/\/[^_\/]+_[^\/]+$/, ""),
|
||||
push: false,
|
||||
pop: false,
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window !== "undefined") console.log("App initialized")
|
||||
</script>
|
||||
|
||||
<h1>Hello World</h1>
|
||||
12
frontend/src/config.ts
Normal file
12
frontend/src/config.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as sentry from "./sentry"
|
||||
import configClient from "../../api/hooks/config-client"
|
||||
|
||||
export const apiBaseURL = "/api/"
|
||||
export const release = configClient.release
|
||||
console.log("Release: ", release)
|
||||
|
||||
export const sentryDSN = "https://5063f9b5564d0fdece4e47a8e2e63672@sentry.basehosts.de/3"
|
||||
export const sentryTracingOrigins = ["localhost", "project-domain.tld", /^\//]
|
||||
export const sentryEnvironment: string = "local"
|
||||
// need to execute early for fetch wrapping
|
||||
// sentry.init(sentryDSN, sentryTracingOrigins, sentryEnvironment, release)
|
||||
86
frontend/src/index.ts
Normal file
86
frontend/src/index.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import App from "./components/App.svelte"
|
||||
import { location } from "./store"
|
||||
|
||||
const publishLocation = (_p?: string) => {
|
||||
let _s: string
|
||||
let _h: string
|
||||
if (_p) {
|
||||
const parts = _p.split("#")
|
||||
_p = parts.shift()
|
||||
_h = parts.join()
|
||||
if (_h) _h = "#" + _h
|
||||
|
||||
const parts2 = _p.split("?")
|
||||
_p = parts2.shift()
|
||||
_s = parts2.join()
|
||||
if (_s) _s = "?" + _s
|
||||
}
|
||||
|
||||
const newLocation = {
|
||||
path:
|
||||
_p || (typeof window !== "undefined" && window.location?.pathname),
|
||||
search: _p
|
||||
? _s
|
||||
: typeof window !== "undefined" && window.location?.search,
|
||||
hash: _p ? _h : typeof window !== "undefined" && window.location?.hash,
|
||||
push: !!_p,
|
||||
pop: !_p,
|
||||
categoryPath: "",
|
||||
}
|
||||
newLocation.categoryPath = newLocation.path.replace(/\/[^_\/]+_[^\/]+$/, "")
|
||||
location.set(newLocation)
|
||||
}
|
||||
|
||||
if (typeof history !== "undefined") {
|
||||
if (typeof Proxy !== "undefined") {
|
||||
// modern browser
|
||||
const historyApply = (target, thisArg, argumentsList) => {
|
||||
publishLocation(
|
||||
argumentsList && argumentsList.length >= 2 && argumentsList[2]
|
||||
)
|
||||
Reflect.apply(target, thisArg, argumentsList)
|
||||
}
|
||||
|
||||
history.pushState = new Proxy(history.pushState, {
|
||||
apply: historyApply,
|
||||
})
|
||||
|
||||
history.replaceState = new Proxy(history.replaceState, {
|
||||
apply: historyApply,
|
||||
})
|
||||
} else {
|
||||
// ie11
|
||||
const pushStateFn = history.pushState
|
||||
const replaceStateFn = history.replaceState
|
||||
|
||||
history.pushState = function (data: any, title: string, url?: string) {
|
||||
publishLocation(url)
|
||||
return pushStateFn.apply(history, arguments)
|
||||
}
|
||||
history.replaceState = function (
|
||||
data: any,
|
||||
title: string,
|
||||
url?: string
|
||||
) {
|
||||
publishLocation(url)
|
||||
return replaceStateFn.apply(history, arguments)
|
||||
}
|
||||
}
|
||||
} // else ssr -> no history handling
|
||||
|
||||
typeof window !== "undefined" &&
|
||||
window.addEventListener("popstate", (event) => {
|
||||
publishLocation()
|
||||
})
|
||||
|
||||
let appContainer = document?.getElementById("appContainer")
|
||||
|
||||
const hydrate = true //import.meta?.env?.MODE !== "development"
|
||||
console.log("Features: ", { hydrate })
|
||||
const app = new App({
|
||||
target: appContainer,
|
||||
props: {},
|
||||
hydrate,
|
||||
})
|
||||
|
||||
export default app
|
||||
42
frontend/src/sentry.ts
Normal file
42
frontend/src/sentry.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import * as Sentry from "@sentry/svelte"
|
||||
|
||||
let initialized = false
|
||||
|
||||
export const init = (dsn: string, tracingOrigins: (string | RegExp)[], environment: string, release: string) => {
|
||||
if (typeof window !== "undefined") {
|
||||
Sentry.init({
|
||||
dsn: dsn,
|
||||
tunnel: "/_s",
|
||||
integrations: [
|
||||
new Sentry.BrowserTracing({
|
||||
tracingOrigins: tracingOrigins,
|
||||
traceFetch: false,
|
||||
traceXHR: false,
|
||||
}),
|
||||
new Sentry.Replay({
|
||||
maskAllText: false,
|
||||
maskAllInputs: false,
|
||||
blockAllMedia: false,
|
||||
networkDetailAllowUrls: [/\/api\//],
|
||||
}),
|
||||
],
|
||||
environment: environment,
|
||||
tracesSampleRate: 1.0,
|
||||
debug: false,
|
||||
release: release,
|
||||
replaysSessionSampleRate: 1.0,
|
||||
replaysOnErrorSampleRate: 1.0,
|
||||
})
|
||||
console.log("Sentry initialized")
|
||||
initialized = true
|
||||
}
|
||||
}
|
||||
|
||||
export const currentTransaction = () => Sentry.getCurrentHub().getScope().getTransaction()
|
||||
|
||||
export const setUser = (user: Sentry.User) => {
|
||||
if (typeof window !== "undefined" && initialized) {
|
||||
user.ip_address = "{{auto}}"
|
||||
Sentry.setUser(user)
|
||||
}
|
||||
}
|
||||
3
frontend/src/ssr.ts
Normal file
3
frontend/src/ssr.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import App from "./components/App.svelte"
|
||||
|
||||
export default App
|
||||
11
frontend/src/store.ts
Normal file
11
frontend/src/store.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { writable } from "svelte/store"
|
||||
|
||||
const initLoc = {
|
||||
path: (typeof window !== "undefined" && window.location?.pathname) || "/",
|
||||
search: (typeof window !== "undefined" && window.location?.search) || "",
|
||||
hash: (typeof window !== "undefined" && window.location?.hash) || "",
|
||||
push: false,
|
||||
pop: false,
|
||||
categoryPath: "",
|
||||
}
|
||||
export const location = writable(initLoc)
|
||||
Reference in New Issue
Block a user