Skip to content
Merged
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
2 changes: 1 addition & 1 deletion ganesh/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POSTGRES_PASSWORD="postgres"
POSTGRES_DB="postgres"

# AUTH
NEXTAUTH_SECRET="secret"
AUTH_SECRET="secret"

# DEEPL
DEEPL_API_KEY="secret"
Expand Down
1 change: 1 addition & 0 deletions ganesh/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ WORKDIR /app

# Copy only necessary files from the builder stage
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
Expand Down
5 changes: 2 additions & 3 deletions ganesh/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.8"

services:
app:
build: .
Expand All @@ -8,8 +6,9 @@ services:
- "3000:3000"
environment:
DATABASE_URL: ${DATABASE_URL_PRODUCTION}
NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}
NODE_ENV: production
AUTH_SECRET: ${AUTH_SECRET}
AUTH_URL: http://localhost:3000/
depends_on:
- postgres
networks:
Expand Down
14 changes: 13 additions & 1 deletion ganesh/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@ const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
port: '',
pathname: '**'
},
{
protocol: 'https',
hostname: 'github.com',
port: '',
pathname: '**'
},
{
protocol: 'https',
hostname: 'raw.githubusercontent.com',
port: '',
pathname: '**'
}
]
],
}
};

Expand Down
9 changes: 8 additions & 1 deletion ganesh/src/app/[locale]/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ export default function AboutPage() {
<div className="text-2xl font-mono font-bold pb-4 flex items-center gap-5">
{t("ctf_title")}
<a href="https://ctf-br.org/" target="_blank">
<img className="w-8" src='/images/pages/aboutus_ctfbr_256x256.gif' alt='CTF.br Website Logo' />
<Image
className="w-8"
src="/images/pages/aboutus_ctfbr_256x256.gif"
alt="CTF.br Website Logo"
width={32}
height={32}
unoptimized
/>
</a>
</div>
<div dangerouslySetInnerHTML={{ __html: t.raw('ctf') }} />
Expand Down
2 changes: 1 addition & 1 deletion ganesh/src/app/[locale]/admin/dashboard/authors/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Pagination from '@/components/admin/pagination';
import Table from '@/components/admin/authors/table';
import { Suspense, use } from 'react';
import { Suspense } from 'react';
import { fetchAuthorsPages } from '@/services/data';

import type { Metadata } from 'next';
Expand Down
1 change: 0 additions & 1 deletion ganesh/src/app/[locale]/content/activity/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { fetchPostById } from '@/services/data';
import { notFound } from 'next/navigation';

import type { Metadata } from 'next';
import Terminal from '@/components/cards/terminal';
import Preview from '@/components/preview/preview';
import Container from '@/components/container';
export const metadata: Metadata = {
Expand Down
1 change: 0 additions & 1 deletion ganesh/src/app/[locale]/content/article/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { fetchPostById } from '@/services/data';
import { notFound } from 'next/navigation';

import type { Metadata } from 'next';
import Terminal from '@/components/cards/terminal';
import Preview from '@/components/preview/preview';
import Container from '@/components/container';
export const metadata: Metadata = {
Expand Down
2 changes: 1 addition & 1 deletion ganesh/src/app/[locale]/content/article/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fetchPosts, fetchPostsPages } from "@/services/data";
import { Post, postTypes } from "@/models/post";
import { Post } from "@/models/post";
import ClientArticlesComponent from "@/components/client/articles";

interface PageProps {
Expand Down
1 change: 0 additions & 1 deletion ganesh/src/app/[locale]/content/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ interface ContentPageProps {
}

export default async function ContentPage({
searchParams
}: ContentPageProps) {

const [activities, articles, tips, videos]: [Post[], Post[], Post[], Video[]] = await Promise.all([
Expand Down
1 change: 0 additions & 1 deletion ganesh/src/app/[locale]/content/tip/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { fetchPostById } from '@/services/data';
import { notFound } from 'next/navigation';

import type { Metadata } from 'next';
import Terminal from '@/components/cards/terminal';
import Preview from '@/components/preview/preview';
import Container from '@/components/container';
export const metadata: Metadata = {
Expand Down
2 changes: 1 addition & 1 deletion ganesh/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default async function RootLayout({
}) {

const { locale } = await params;
if (!routing.locales.includes(locale as any)) {
if (!routing.locales.includes(locale as 'br' | 'en')) {
notFound();
}

Expand Down
1 change: 0 additions & 1 deletion ganesh/src/app/[locale]/news/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { fetchPostById } from '@/services/data';
import { notFound } from 'next/navigation';

import type { Metadata } from 'next';
import Terminal from '@/components/cards/terminal';
import Preview from '@/components/preview/preview';
import Container from '@/components/container';
export const metadata: Metadata = {
Expand Down
3 changes: 0 additions & 3 deletions ganesh/src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import EncryptButton from "@/components/button/encrypt-button";
import Terminal from "@/components/cards/terminal";
import ClientHomeComponent from "@/components/client/home";
import { Sponsor } from "@/models/sponsor";
import { fetchSponsors } from "@/services/data";
import Image from "next/image";

export default async function Page() {
const sponsors: Sponsor[] = await fetchSponsors();
Expand Down
1 change: 0 additions & 1 deletion ganesh/src/auth.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { PrismaAdapter } from '@auth/prisma-adapter';
import type { NextAuthConfig } from 'next-auth';
import { prisma } from '@/services/prisma';

Expand Down
2 changes: 1 addition & 1 deletion ganesh/src/components/admin/posts/edit-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useActionState } from '@/lib/utils';
import { PostForm, PostTxtContent, postTypes } from '@/models/post';
import { State, updatePost } from '@/services/post';
import { Author } from '@/models/author';
import { Suspense, useState } from 'react';
import { useState } from 'react';
import Preview from '@/components/preview/preview';
import { Tabs, TabsContent, TabsList, TabsTrigger } from './tabs';
import TxtInput from './txt-input';
Expand Down
2 changes: 0 additions & 2 deletions ganesh/src/components/admin/posts/txt-input.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { State } from "@/services/post";

export default function TxtInput({
label,
name,
Expand Down
9 changes: 8 additions & 1 deletion ganesh/src/components/admin/sponsors/card.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { Sponsor } from "@/models/sponsor";
import { DeleteSponsor, UpdateSponsor } from "./buttons";
import Image from "next/image";

export default function Card({ id, name, logo, link, description, description_en }: Sponsor) {
return (
<>
<div className="relative flex items-center justify-center text-white text-3xl rounded-md text-mono w-48 h-48 bg-adminBackground border-[2px] border-background hover:bg-adminForeground hover:border-white">
<img src={logo} alt={name} className="w-2/3 h-full object-cover" />
<Image
className="w-2/3 h-full object-cover"
src={logo}
alt={name}
width={100}
height={100}
/>
<UpdateSponsor
id={id}
name={name}
Expand Down
1 change: 0 additions & 1 deletion ganesh/src/components/admin/video/buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { createVideo, deleteVideo, State, updateVideo } from '@/services/video';
import { useState } from 'react';
import ErrorMessages from '../posts/error-messages';
import { PencilIcon, PlusIcon, TrashIcon } from '@heroicons/react/24/outline';
import { VideoForm } from '@/models/video';

export const CreateVideo = () => {
const [isModalOpen, setIsModalOpen] = useState(false);
Expand Down
4 changes: 1 addition & 3 deletions ganesh/src/components/button/encrypt-button.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"use client";

import { useRef, useState } from "react";
import { LockClosedIcon } from "@heroicons/react/24/outline";
import { InformationCircleIcon } from "@heroicons/react/16/solid";
import { MagnifyingGlassIcon } from "@heroicons/react/16/solid";
import { motion } from "framer-motion";
import Link from "next/link";
Expand All @@ -16,7 +14,7 @@ interface EncryptButtonProps {
targetText: string;
}

export default function EncryptButton({ onClick, targetText }: EncryptButtonProps) {
export default function EncryptButton({ targetText }: EncryptButtonProps) {
const intervalRef = useRef<NodeJS.Timeout | null>(null);

const [text, setText] = useState(targetText);
Expand Down
1 change: 0 additions & 1 deletion ganesh/src/components/cards/news.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Image from "next/image";
import Terminal from "./terminal";
import Link from "next/link";
import { ArrowRightCircleIcon } from "@heroicons/react/24/outline";
import { useLocale } from "next-intl";
Expand Down
2 changes: 1 addition & 1 deletion ganesh/src/components/cards/terminal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode } from 'react';
import React from 'react';


export default function Terminal({ children }:
Expand Down
6 changes: 3 additions & 3 deletions ganesh/src/components/client/contents.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
"use client";

import { Post } from "@/models/post";
import { useLocale, useTranslations } from "next-intl";
import { useTranslations } from "next-intl";
import Container from "../container";
import Link from "next/link";
import { ArrowRightCircleIcon } from "@heroicons/react/24/outline";
import Slider from "../slider/slider";
import { Video } from "@/models/video";

interface ContentsProps {
activities: Post[];
articles: Post[];
tips: Post[];
videos: any;
videos: Video[];
}

export default function Contents({ activities, articles, tips }: ContentsProps) {
const t = useTranslations('Navbar');
const locale = useLocale();
return (
<div className="flex flex-col gap-12 items-center pt-32 pb-12">
<Container>
Expand Down
8 changes: 7 additions & 1 deletion ganesh/src/components/client/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ export default function ClientHomeComponent({ sponsors }: HomeProps) {
<div className="flex flex-col md:flex-row justify-center items-center">
{sponsors.map((sponsor) => (
<div key={sponsor.id} className="flex flex-col gap-2">
<img src={sponsor.logo} alt={sponsor.name} className="w-64 object-cover" />
<Image
className="w-64 object-cover"
alt={sponsor.name}
src={sponsor.logo}
width={200}
height={200}
/>
<p className="text-gray-500">{sponsor.description}</p>
</div>
))}
Expand Down
6 changes: 4 additions & 2 deletions ganesh/src/components/matrix.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

'use client';

import React from "react";
Expand All @@ -6,10 +8,10 @@ import { useEffect } from "react";
import clsx from "clsx";

const renderMatrix = (ref: React.RefObject<HTMLCanvasElement>, color: string | undefined) => {
let canvas = ref.current;
const canvas = ref.current;

if (!canvas) return;
let context = canvas.getContext("2d");
const context = canvas.getContext("2d");

if (!context) return;

Expand Down
8 changes: 1 addition & 7 deletions ganesh/src/components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import Link from "next/link";
import { usePathname, useRouter } from 'next/navigation';
import { usePathname } from 'next/navigation';
import Image from 'next/image';
import clsx from 'clsx';
import { useState } from "react";
Expand Down Expand Up @@ -54,12 +54,6 @@ export default function Navbar() {
const t = useTranslations('Navbar');
const locale = useLocale();

const router = useRouter();
const changeLanguage = (lang: string) => {
// This will navigate to the new locale while preserving the current path.
router.push(`/${lang}${pathname}`);
};

return (
<>
{!pathname.includes("/admin") && (
Expand Down
2 changes: 2 additions & 0 deletions ganesh/src/i18n/request.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { getRequestConfig } from 'next-intl/server';
import { routing } from './routing';

Expand Down
1 change: 0 additions & 1 deletion ganesh/src/i18n/routing.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { defineRouting } from 'next-intl/routing';
import { createNavigation } from 'next-intl/navigation';

export const routing = defineRouting({
// A list of all locales that are supported
Expand Down
6 changes: 4 additions & 2 deletions ganesh/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import NextAuth from 'next-auth';
import { authConfig } from '@/auth.config';
import createIntlMiddleware from 'next-intl/middleware';
import { routing } from './i18n/routing';
import { NextRequest, NextResponse } from 'next/server';
import { NextResponse } from 'next/server';

// Create middleware functions for each feature.
const { auth } = NextAuth(authConfig)
Expand Down Expand Up @@ -35,7 +37,7 @@ export default auth(async function middleware(request: any) {
export const config = {
matcher: [
// For auth: ignore api routes, Next.js internals and static assets
'/((?!api|_next/static|_next/image|favicon.ico|.*\\.png$).*)',
'/((?!api|_next/static|_next/image|.*\\.png$).*)',
// For internationalized paths
'/',
'/(en|br)/:path*',
Expand Down
1 change: 1 addition & 0 deletions ganesh/src/services/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function authenticate(
email: formData.get('email') as string,
password: formData.get('password') as string,
redirectTo: '/br/admin/dashboard',
callbackUrl: '/br/admin/dashboard'
});
} catch (error) {
if (error instanceof AuthError) {
Expand Down
Loading
Loading