Skip to content

feat: opt. white-label #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Dockerfile
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we not doing for non-docker deployment?
should it be just .env variable

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or in main.js

Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ ENV PORT=$PORT
# Expose the application port
EXPOSE $PORT

# Set the command to run the application
# Make entrypoint script executable
RUN chmod +x ./entrypoint.sh

ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["node", "main"]
7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Automatically set PUBLIC_WHITE_LABEL based on WHITE_LABEL
export PUBLIC_WHITE_LABEL="${WHITE_LABEL}"

# Start the application
exec "$@"
32 changes: 32 additions & 0 deletions seeds/site_data.js
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better way would be do to do it in src/lib/server/db/seedSiteData.js

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import seedSiteData from "../src/lib/server/db/seedSiteData.js";
import { config } from "dotenv";
config(); // Load .env variables
const isWhiteLabeled = process.env.WHITE_LABEL === 'true';

/**
* @param { import("knex").Knex } knex
Expand All @@ -12,6 +15,35 @@ export async function seed(knex) {
if (Object.prototype.hasOwnProperty.call(seedSiteData, key)) {
let value = seedSiteData[key];
let data_type = typeof value;

// Remove attribution from metaTags for initial db seeding (if white-labeled)
if (key === "metaTags" && data_type === "object" && Array.isArray(value) && isWhiteLabeled) {
value.forEach(item => {
if (item.key === "twitter:site" || item.key === "twitter:creator") {
item.value = "kener";
}
});
}

// Remove Documentation & Github nav links from initial db seeding (if white-labeled)
if (key === "nav" && data_type === "object" && Array.isArray(value) && isWhiteLabeled) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should keep github and documentation as it will help people after they do 1 click deploy

value = value.filter(item => item.name !== "Documentation" && item.name !== "Github");
}

// Remove GA tracking ID/key from initial db seeding (if white-labeled)
if (key === "analytics" && data_type === "object" && Array.isArray(value) && isWhiteLabeled) {
const gaObject = value.find(item => item.type === 'GA');
if (gaObject) {
gaObject.id = "";
}
}

// Remove 'Created by' text on initial db seeding (if white-labeled)
if (key === "footerHTML" && isWhiteLabeled) {
// value = value.replace(/<span data-white-label>.*?<\/span>/s, ""); // Remove <span data-white-label>...</span>
value = "";
}

if (data_type === "object") {
value = JSON.stringify(value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/db/seedSiteData.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const seedSiteData = {
subtitle: "Let your users know what's going on."
},
footerHTML:
'<p class="text-center">\nMade using \n<a href="https://github.com/rajnandan1/kener" target="_blank" rel="noreferrer" class="font-medium underline underline-offset-4">\n Kener\n</a>\nan open source status page system built with Svelte and TailwindCSS.<br/>\nCreated with ❤️ by <a href="https://rajnandan.com" target="_blank" rel="noreferrer" class="font-medium underline underline-offset-4">Raj Nandan Sharma</a>.\n</p>\n',
'<p class="text-center">\nMade using \n<a href="https://github.com/rajnandan1/kener" target="_blank" rel="noreferrer" class="font-medium underline underline-offset-4">\n Kener\n</a>\nan open source status page system built with Svelte and TailwindCSS.<span data-white-label><br/>\nCreated with ❤️ by <a href="https://rajnandan.com" target="_blank" rel="noreferrer" class="font-medium underline underline-offset-4">Raj Nandan Sharma</a>.\n</span></p>\n',
i18n: {
defaultLocale: "en",
locales: [{ code: "en", name: "English", selected: true, disabled: false }]
Expand Down
143 changes: 75 additions & 68 deletions src/routes/(manage)/manage/(app)/+layout.svelte
Copy link
Owner

@rajnandan1 rajnandan1 Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing {env} in everyfile we can do it in src/routes/(docs)/+layout.server.js

then you can use variable like data.isWhiteLabeled

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import "../../../../kener.css";
import "../../../../manage.css";
import { base } from "$app/paths";
import { env } from '$env/dynamic/public';
import * as DropdownMenu from "$lib/components/ui/dropdown-menu";
import Sun from "lucide-svelte/icons/sun";
import Moon from "lucide-svelte/icons/moon";
Expand All @@ -13,6 +14,8 @@
import { Play, User } from "lucide-svelte";
import { setMode, mode, ModeWatcher } from "mode-watcher";

const isWhiteLabeled = env.PUBLIC_WHITE_LABEL === 'true';

let thisYear = new Date().getFullYear();
function toggleMode() {
if ($mode === "light") {
Expand Down Expand Up @@ -74,18 +77,20 @@
<div class=" flex w-full justify-between rounded-lg border bg-card px-5 py-4">
<div class="mt-2 flex gap-x-1.5">
<img src="{base}/logo.png" alt="Kener" class="inline h-6 w-6" />
<h1 class="font-semibold">Manage Kener</h1>
<h1 class="font-semibold">Manage <a class="hover:border-b hover:border-dotted hover:border-b-foreground/50" href="https://github.com/rajnandan1/kener" target="_blank">Kener</a></h1>
</div>
<div class="flex">
<Button
variant="ghost"
size="icon"
target="_blank"
href="https://github.com/rajnandan1/kener"
class="flex"
>
<Github class="h-4 w-4 " />
</Button>
{#if !isWhiteLabeled}
<Button
variant="ghost"
size="icon"
target="_blank"
href="https://github.com/rajnandan1/kener"
class="flex"
>
<Github class="h-4 w-4 " />
</Button>
{/if}
<Button on:click={toggleMode} variant="ghost" size="icon" class="flex">
<Sun
class="h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"
Expand Down Expand Up @@ -151,68 +156,70 @@
</main>

<!-- ========== FOOTER ========== -->
<footer class="mx-auto mt-8 w-full max-w-2xl px-4 sm:px-6 lg:px-8">
<div class="border-t py-6 dark:border-neutral-700">
<div class="flex flex-wrap items-center justify-between gap-2">
<div>
<p class="text-xs text-muted-foreground">
Kener.ing by <a
class="text-xs font-semibold text-muted-foreground hover:underline"
href="https://www.rajnandan.com">Raj Nandan Sharma</a
>
</p>
</div>
<!-- End Col -->
{#if !isWhiteLabeled}
<footer class="mx-auto mt-8 w-full max-w-2xl px-4 sm:px-6 lg:px-8">
<div class="border-t py-6 dark:border-neutral-700">
<div class="flex flex-wrap items-center justify-between gap-2">
<div>
<p class="text-xs text-muted-foreground">
Kener.ing by <a
class="text-xs font-semibold text-muted-foreground hover:underline"
href="https://www.rajnandan.com">Raj Nandan Sharma</a
>
</p>
</div>
<!-- End Col -->

<!-- List -->
<ul class="flex flex-wrap items-center">
<li
class="before:size-[3px] relative inline-block pe-4 text-xs before:absolute before:end-1.5 before:top-1/2 before:-translate-y-1/2 before:rounded-full before:bg-gray-400 last:pe-0 last-of-type:before:hidden dark:text-neutral-500 dark:before:bg-neutral-600"
>
<a
target="_blank"
class="text-xs font-medium text-muted-foreground hover:underline hover:decoration-1 focus:decoration-1 focus:outline-none"
href="https://github.com/sponsors/rajnandan1"
<!-- List -->
<ul class="flex flex-wrap items-center">
<li
class="before:size-[3px] relative inline-block pe-4 text-xs before:absolute before:end-1.5 before:top-1/2 before:-translate-y-1/2 before:rounded-full before:bg-gray-400 last:pe-0 last-of-type:before:hidden dark:text-neutral-500 dark:before:bg-neutral-600"
>
Donate
</a>
</li>
<li
class="before:size-[3px] relative inline-block pe-4 text-xs before:absolute before:end-1.5 before:top-1/2 before:-translate-y-1/2 before:rounded-full before:bg-gray-400 last:pe-0 last-of-type:before:hidden dark:text-neutral-500 dark:before:bg-neutral-600"
>
<a
target="_blank"
class="text-xs font-medium text-muted-foreground hover:underline hover:decoration-1 focus:decoration-1 focus:outline-none"
href="https://twitter.com/_rajnandan_"
<a
target="_blank"
class="text-xs font-medium text-muted-foreground hover:underline hover:decoration-1 focus:decoration-1 focus:outline-none"
href="https://github.com/sponsors/rajnandan1"
>
Donate
</a>
</li>
<li
class="before:size-[3px] relative inline-block pe-4 text-xs before:absolute before:end-1.5 before:top-1/2 before:-translate-y-1/2 before:rounded-full before:bg-gray-400 last:pe-0 last-of-type:before:hidden dark:text-neutral-500 dark:before:bg-neutral-600"
>
Contact
</a>
</li>
<li
class="before:size-[3px] relative inline-block pe-4 text-xs before:absolute before:end-1.5 before:top-1/2 before:-translate-y-1/2 before:rounded-full before:bg-gray-400 last:pe-0 last-of-type:before:hidden dark:text-neutral-500 dark:before:bg-neutral-600"
>
<a
target="_blank"
class="text-xs font-medium text-muted-foreground hover:underline hover:decoration-1 focus:decoration-1 focus:outline-none"
href="https://discord.gg/uSTpnuK9XR"
<a
target="_blank"
class="text-xs font-medium text-muted-foreground hover:underline hover:decoration-1 focus:decoration-1 focus:outline-none"
href="https://twitter.com/_rajnandan_"
>
Contact
</a>
</li>
<li
class="before:size-[3px] relative inline-block pe-4 text-xs before:absolute before:end-1.5 before:top-1/2 before:-translate-y-1/2 before:rounded-full before:bg-gray-400 last:pe-0 last-of-type:before:hidden dark:text-neutral-500 dark:before:bg-neutral-600"
>
Discord
</a>
</li>
<li
class="before:size-[3px] relative inline-block pe-4 text-xs before:absolute before:end-1.5 before:top-1/2 before:-translate-y-1/2 before:rounded-full before:bg-gray-400 last:pe-0 last-of-type:before:hidden dark:text-neutral-500 dark:before:bg-neutral-600"
>
<a
target="_blank"
class="text-xs font-medium text-muted-foreground hover:underline hover:decoration-1 focus:decoration-1 focus:outline-none"
href="https://github.com/rajnandan1/kener"
<a
target="_blank"
class="text-xs font-medium text-muted-foreground hover:underline hover:decoration-1 focus:decoration-1 focus:outline-none"
href="https://discord.gg/uSTpnuK9XR"
>
Discord
</a>
</li>
<li
class="before:size-[3px] relative inline-block pe-4 text-xs before:absolute before:end-1.5 before:top-1/2 before:-translate-y-1/2 before:rounded-full before:bg-gray-400 last:pe-0 last-of-type:before:hidden dark:text-neutral-500 dark:before:bg-neutral-600"
>
Github
</a>
</li>
</ul>
<!-- End List -->
<a
target="_blank"
class="text-xs font-medium text-muted-foreground hover:underline hover:decoration-1 focus:decoration-1 focus:outline-none"
href="https://github.com/rajnandan1/kener"
>
Github
</a>
</li>
</ul>
<!-- End List -->
</div>
</div>
</div>
</footer>
</footer>
{/if}
<!-- ========== END FOOTER ========== -->
11 changes: 7 additions & 4 deletions src/routes/(manage)/manage/(app)/app/alerts/+page.svelte
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should keep the documentation urls for easy access to what this page is about

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import { onMount } from "svelte";
import { Button } from "$lib/components/ui/button";
import { ExternalLink } from "lucide-svelte";

import { env } from '$env/dynamic/public';
const isWhiteLabeled = env.PUBLIC_WHITE_LABEL === 'true';
export let data;
</script>

<div class="min-h-[70vh]">
<div class="flex justify-end">
<Button variant="outline" href="https://kener.ing/docs/alerts" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{#if !isWhiteLabeled}
<Button variant="outline" href="https://kener.ing/docs/alerts" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{/if}
</div>
<AlertsInfo {data} />
</div>
11 changes: 7 additions & 4 deletions src/routes/(manage)/manage/(app)/app/api-keys/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import { onMount } from "svelte";
import { Button } from "$lib/components/ui/button";
import { ExternalLink } from "lucide-svelte";

import { env } from '$env/dynamic/public';
const isWhiteLabeled = env.PUBLIC_WHITE_LABEL === 'true';
export let data;
</script>

<div class="min-h-[70vh]">
<div class="flex justify-end">
<Button variant="outline" href="https://kener.ing/docs/apikeys" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{#if !isWhiteLabeled}
<Button variant="outline" href="https://kener.ing/docs/apikeys" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{/if}
</div>
<APIKeys />
</div>
11 changes: 7 additions & 4 deletions src/routes/(manage)/manage/(app)/app/home/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import { onMount } from "svelte";
import { Button } from "$lib/components/ui/button";
import { ExternalLink } from "lucide-svelte";

import { env } from '$env/dynamic/public';
const isWhiteLabeled = env.PUBLIC_WHITE_LABEL === 'true';
export let data;
</script>

<div class="min-h-[70vh]">
<div class="flex justify-end">
<Button variant="outline" href="https://kener.ing/docs/home-page" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{#if !isWhiteLabeled}
<Button variant="outline" href="https://kener.ing/docs/home-page" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{/if}
</div>
<HomePage {data} />
</div>
18 changes: 11 additions & 7 deletions src/routes/(manage)/manage/(app)/app/incidents/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
Trash
} from "lucide-svelte";
import * as Select from "$lib/components/ui/select";
import { env } from '$env/dynamic/public';
export let data;
const isWhiteLabeled = env.PUBLIC_WHITE_LABEL === 'true';
let status = "OPEN";
let loadingData = false;
let editMonitorsModal = false;
Expand Down Expand Up @@ -373,13 +375,15 @@

<div class="min-h-[70vh]">
<div class="flex justify-end">
<Button
variant="outline"
href="https://kener.ing/docs/incident-management"
class=" text-sm"
>
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{#if !isWhiteLabeled}
<Button
variant="outline"
href="https://kener.ing/docs/incident-management"
class=" text-sm"
>
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{/if}
</div>
<div class="mt-4 flex justify-end">
<div class="flex w-40">
Expand Down
11 changes: 7 additions & 4 deletions src/routes/(manage)/manage/(app)/app/monitors/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import { onMount } from "svelte";
import { Button } from "$lib/components/ui/button";
import { ExternalLink } from "lucide-svelte";

import { env } from '$env/dynamic/public';
const isWhiteLabeled = env.PUBLIC_WHITE_LABEL === 'true';
export let data;
</script>

<div class="min-h-[70vh]">
<div class="flex justify-end">
<Button variant="outline" href="https://kener.ing/docs/monitors" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{#if !isWhiteLabeled}
<Button variant="outline" href="https://kener.ing/docs/monitors" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{/if}
</div>
<MonitorsAdd
monitorSort={data.siteData?.monitorSort}
Expand Down
11 changes: 7 additions & 4 deletions src/routes/(manage)/manage/(app)/app/seo/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import { onMount } from "svelte";
import { Button } from "$lib/components/ui/button";
import { ExternalLink } from "lucide-svelte";

import { env } from '$env/dynamic/public';
const isWhiteLabeled = env.PUBLIC_WHITE_LABEL === 'true';
export let data;
</script>

<div class="min-h-[70vh]">
<div class="flex justify-end">
<Button variant="outline" href="https://kener.ing/docs/seo" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{#if !isWhiteLabeled}
<Button variant="outline" href="https://kener.ing/docs/seo" class=" text-sm">
Documentation <ExternalLink size="12" class="ml-1" />
</Button>
{/if}
</div>
<SeoInfo {data} />
</div>
Loading