Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/next/pages/index.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2021 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Layout, Tooltip } from "antd";6import { GetServerSidePropsContext } from "next";7import { join } from "path";8import { getRecentHeadlines } from "@cocalc/database/postgres/news";9import { COLORS } from "@cocalc/util/theme";10import { RecentHeadline } from "@cocalc/util/types/news";11import { CoCalcComFeatures } from "components/landing/cocalc-com-features";12import Content from "components/landing/content";13import Footer from "components/landing/footer";14import Head from "components/landing/head";15import Header from "components/landing/header";16import { NewsBanner } from "components/landing/news-banner";17import Logo from "components/logo";18import { CSS, Paragraph, Title } from "components/misc";19import A from "components/misc/A";20import Videos, { Video } from "components/videos";21import basePath from "lib/base-path";22import { Customize, CustomizeType } from "lib/customize";23import { PublicPath as PublicPathType } from "lib/share/types";24import withCustomize from "lib/with-customize";25import screenshot from "public/cocalc-screenshot-20200128-nq8.png";26import { Tagline } from "components/landing/tagline";2728const TOP_LINK_STYLE: CSS = { marginRight: "20px" } as const;2930interface Props {31customize: CustomizeType;32publicPaths: PublicPathType[];33recentHeadlines: RecentHeadline[] | null;34headlineIndex: number;35}3637export default function Home(props: Props) {38const { customize, recentHeadlines, headlineIndex } = props;39const {40siteName,41siteDescription,42organizationName,43organizationURL,44splashImage,45indexInfo,46onCoCalcCom,47account,48isCommercial,49indexTagline,50} = customize;5152function contentDescription() {53return (54<Paragraph type="secondary">55{onCoCalcCom ? (56<>by Sagemath, Inc.</>57) : (58<>59An instance of <A href="https://cocalc.com">CoCalc</A>60{organizationName && organizationURL ? (61<>62{" "}63hosted by <A href={organizationURL}>{organizationName}</A>64</>65) : undefined}66.67</>68)}69</Paragraph>70);71}7273function topAccountLinks() {74if (!account) return;75return (76<div77style={{78textAlign: "center",79margin: "30px 0 15px 0",80}}81>82<Title level={1} style={{ color: COLORS.GRAY }}>83Signed in as{" "}84<Tooltip title={"View all your account settings"} placement={"right"}>85<a href={join(basePath, "settings")}>86{`${account.first_name} ${account.last_name} ${87account.name ? "(@" + account.name + ")" : ""88}`}89</a>90</Tooltip>91</Title>92<Paragraph style={{ fontSize: "11pt", margin: "15px 0" }}>93{isCommercial && account && !account.is_anonymous && (94<>95<a href={join(basePath, "store")} style={TOP_LINK_STYLE}>96Store97</a>{" "}98<a99href={join(basePath, "settings/purchases")}100style={TOP_LINK_STYLE}101>102Purchases103</a>{" "}104<A href={"/vouchers"} style={TOP_LINK_STYLE}>105Vouchers106</A>{" "}107</>108)}109<a href={join(basePath, "projects")} style={TOP_LINK_STYLE}>110Projects111</a>{" "}112{customize.landingPages && (113<>114<A href="/features/" style={TOP_LINK_STYLE}>115Features116</A>{" "}117<A href="/software" style={TOP_LINK_STYLE}>118Software119</A>{" "}120{isCommercial && (121<>122<A href="/pricing" style={TOP_LINK_STYLE}>123Pricing124</A>{" "}125</>126)}127</>128)}129</Paragraph>130</div>131);132}133134function renderCoCalcComFeatures() {135if (!onCoCalcCom) return;136return <CoCalcComFeatures />;137}138139function logo(): JSX.Element {140return <Logo type="full" style={{ width: "50%" }} />;141}142143function renderNews() {144if (recentHeadlines == null) return;145return (146<NewsBanner147recentHeadlines={recentHeadlines}148headlineIndex={headlineIndex}149/>150);151}152153return (154<Customize value={customize}>155<Head title={siteDescription ?? "Collaborative Calculation"} />156<Layout>157<Header />158<Layout.Content style={{ backgroundColor: "white" }}>159{renderNews()}160{topAccountLinks()}161<Content162style={{ minHeight: "30vh" }}163body={logo()}164title={onCoCalcCom ? "" : siteName}165subtitle={siteDescription}166description={contentDescription()}167image={splashImage ? splashImage : screenshot}168alt={"Screenshot showing CoCalc in action!"}169imageAlternative={170onCoCalcCom ? <Videos videos={YOUTUBE_IDS} /> : indexInfo171}172/>173<Tagline value={indexTagline} style={{ padding: "5px" }} />174{renderCoCalcComFeatures()}175<Footer />176</Layout.Content>177</Layout>178</Customize>179);180}181182export async function getServerSideProps(context: GetServerSidePropsContext) {183// get most recent headlines184const recentHeadlines = await getRecentHeadlines(5);185// we want to not always show the same headlines at the start186const headlineIndex =187recentHeadlines != null188? Math.floor(Date.now() % recentHeadlines.length)189: 0;190191return await withCustomize(192{ context, props: { recentHeadlines, headlineIndex } },193{ name: true },194);195}196197const YOUTUBE_IDS: Readonly<Video[]> = [198{ id: "oDdfmkQ0Hvw", title: "CoCalc Overview" },199{ id: "UfmjYxalyh0", title: "Using AI in CoCalc" },200{ id: "LLtLFtD8qfo", title: "Using JupyterLab in CoCalc" },201{ id: "OMN1af0LUcA", title: "Using OpenWebUI and Ollama On CoCalc" },202{ id: "Owq90O0vLJo", title: "R Studio on CoCalc" },203{ id: "JG6jm6yv_KE", title: "PyTorch with a GPU on CoCalc" },204{205id: "Uwn3ngzXD0Y",206title: "JAX Quickstart on CoCalc using a GPU (or on CPU)",207},208{ id: "NkNx6tx3nu0", title: "Running On-Prem Compute Servers on CoCalc" },209] as const;210211212