From 80dcbad83744ae0c3691f1bb2a9f4c1bcc355c3a Mon Sep 17 00:00:00 2001 From: LofiSu Date: Sun, 1 Sep 2024 21:27:15 +0800 Subject: [PATCH 1/4] Add new sections HomePageLanguageCard and HomePageCode with Corresponding links . Added some basic configurations --- babel.config.js | 2 +- docusaurus.config.ts | 1 + package.json | 7 +- src/components/HomePageLanguageCard/index.tsx | 79 ++++++++++++++++++ src/components/HomepageCode/index.tsx | 72 ++++++++++++++++ src/pages/index.tsx | 16 +++- static/JavaScript.svg | 1 + static/Rust.svg | 1 + static/cat.svg | 1 + static/golang.svg | 1 + static/home/coding.svg | 82 +++++++++++++++++++ static/java.svg | 1 + static/more.svg | 1 + static/programming.svg | 1 + static/python.svg | 1 + 15 files changed, 263 insertions(+), 4 deletions(-) create mode 100644 src/components/HomePageLanguageCard/index.tsx create mode 100644 src/components/HomepageCode/index.tsx create mode 100644 static/JavaScript.svg create mode 100644 static/Rust.svg create mode 100644 static/cat.svg create mode 100644 static/golang.svg create mode 100644 static/home/coding.svg create mode 100644 static/java.svg create mode 100644 static/more.svg create mode 100644 static/programming.svg create mode 100644 static/python.svg diff --git a/babel.config.js b/babel.config.js index e00595da..bfd75dbd 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,3 @@ module.exports = { - presets: [require.resolve('@docusaurus/core/lib/babel/preset')], + presets: [require.resolve("@docusaurus/core/lib/babel/preset")], }; diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 5ac8ac80..db677871 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -77,6 +77,7 @@ const config: Config = { plugins: [ require.resolve('docusaurus-lunr-search') ], + themeConfig: { metadata: [ {'http-equiv': 'Content-Security-Policy', content: "frame-src 'self' https://ghbtns.com"}, diff --git a/package.json b/package.json index 45c87c26..372823a4 100644 --- a/package.json +++ b/package.json @@ -20,17 +20,22 @@ "@docusaurus/plugin-content-docs": "^3.5.1", "@docusaurus/preset-classic": "3.0.1", "@mdx-js/react": "^3.0.0", + "antd": "^5.20.3", "aos": "^2.3.4", "clsx": "^2.0.0", "docusaurus-lunr-search": "^3.3.1", "prism-react-renderer": "^2.3.0", "react": "^18.0.0", - "react-dom": "^18.0.0" + "react-dom": "^18.0.0", + "react-syntax-highlighter": "^15.5.0" }, "devDependencies": { "@docusaurus/module-type-aliases": "3.0.1", "@docusaurus/tsconfig": "3.0.1", "@docusaurus/types": "3.0.1", + "css-loader": "^7.1.2", + "esbuild-loader": "^4.2.2", + "style-loader": "^4.0.0", "typescript": "~5.2.2" }, "browserslist": { diff --git a/src/components/HomePageLanguageCard/index.tsx b/src/components/HomePageLanguageCard/index.tsx new file mode 100644 index 00000000..39b3050e --- /dev/null +++ b/src/components/HomePageLanguageCard/index.tsx @@ -0,0 +1,79 @@ +import React from "react"; +import { Card } from "antd"; + +export const HomePageLanguageCard = () => ( +
+
+

Quick Start!

+

Choose a language to get started .

+
+ + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#java-serialization"; + }}> + + Java + + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#python"; + }}> + + Python + + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#golang"; + }}> + + Golang + + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#javascript"; + }}> + + JavaScript + + { + window.location.href = "https://fury.apache.org/docs/start/usage/#rust"; + }}> + + Rust + + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#crosslanguage-serialization"; + }}> + + More + + +
+); + +const gridStyle: React.CSSProperties = { + width: "50%", + display: "flex", + alignItems: "center", + justifyContent: "center", + height: "100px", + textAlign: "center", + border: "1px solid #f0f0f0", + borderRadius: "10px", + fontWeight: "bold", + fontSize: "18px", +}; +const imageStyle: React.CSSProperties = { + width: "38px", + height: "38px", + marginRight: "8px", +}; diff --git a/src/components/HomepageCode/index.tsx b/src/components/HomepageCode/index.tsx new file mode 100644 index 00000000..56228acf --- /dev/null +++ b/src/components/HomepageCode/index.tsx @@ -0,0 +1,72 @@ +import React from "react"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { dracula } from "react-syntax-highlighter/dist/esm/styles/prism"; + +export const HomepageCodeDisplay = () => { + const codeString = `import java.util.List; +import java.util.Arrays; +import io.fury.*; + +public class Example { + public static void main(String[] args) { + SomeClass object = new SomeClass(); + // Note that Fury instances should be reused between + // multiple serializations of different objects. + Fury fury = Fury.builder().withLanguage(Language.JAVA) + // Allow to deserialize objects unknown types, + // more flexible but less secure. + // .withSecureMode(false) + .build(); + // Registering types can reduce class name serialization + // overhead but not mandatory. + // If secure mode enabled + //all custom types must be registered. + fury.register(SomeClass.class); + byte[] bytes = fury.serialize(object); + System.out.println(fury.deserialize(bytes)); + } +} + `; + + return ( + <> +
+
+ programming-coding +
+
+ + {codeString} + +
+
+ + ); +}; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 86a82aaa..abe4e9db 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -9,6 +9,8 @@ import styles from "./index.module.css"; import Translate, { translate } from "@docusaurus/Translate"; import AOS from "aos"; import "aos/dist/aos.css"; +import { HomePageLanguageCard } from "../components/HomePageLanguageCard"; +import { HomepageCodeDisplay } from "../components/HomepageCode"; function HomepageHeader() { const { siteConfig } = useDocusaurusContext(); @@ -95,11 +97,21 @@ export default function Home(): JSX.Element { >
-
+
+
+
+ +
+
+
+
+ +
+
- ); + ); } diff --git a/static/JavaScript.svg b/static/JavaScript.svg new file mode 100644 index 00000000..326d4172 --- /dev/null +++ b/static/JavaScript.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/Rust.svg b/static/Rust.svg new file mode 100644 index 00000000..bbcd3dbc --- /dev/null +++ b/static/Rust.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/cat.svg b/static/cat.svg new file mode 100644 index 00000000..431358c1 --- /dev/null +++ b/static/cat.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/golang.svg b/static/golang.svg new file mode 100644 index 00000000..5cf4792b --- /dev/null +++ b/static/golang.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/home/coding.svg b/static/home/coding.svg new file mode 100644 index 00000000..df9b9e32 --- /dev/null +++ b/static/home/coding.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/java.svg b/static/java.svg new file mode 100644 index 00000000..56dbe6e5 --- /dev/null +++ b/static/java.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/more.svg b/static/more.svg new file mode 100644 index 00000000..e99a2260 --- /dev/null +++ b/static/more.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/programming.svg b/static/programming.svg new file mode 100644 index 00000000..2e7d451d --- /dev/null +++ b/static/programming.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/static/python.svg b/static/python.svg new file mode 100644 index 00000000..7c19426b --- /dev/null +++ b/static/python.svg @@ -0,0 +1 @@ + \ No newline at end of file From ebe741106ddaf79be248f1df93517664051110e0 Mon Sep 17 00:00:00 2001 From: LofiSu Date: Mon, 2 Sep 2024 13:18:53 +0800 Subject: [PATCH 2/4] Fix JS icon 404 issue and add copy button to homepage code display --- src/components/HomepageCode/index.tsx | 37 ++++++++++++++++++++++++--- static/JavaScript.svg | 2 +- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/components/HomepageCode/index.tsx b/src/components/HomepageCode/index.tsx index 56228acf..494b9120 100644 --- a/src/components/HomepageCode/index.tsx +++ b/src/components/HomepageCode/index.tsx @@ -1,8 +1,9 @@ -import React from "react"; +import React, { useState } from "react"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { dracula } from "react-syntax-highlighter/dist/esm/styles/prism"; export const HomepageCodeDisplay = () => { + const [copySuccess, setCopySuccess] = useState(""); const codeString = `import java.util.List; import java.util.Arrays; import io.fury.*; @@ -28,6 +29,18 @@ public class Example { } `; + const copyToClipboard = () => { + navigator.clipboard.writeText(codeString).then( + () => { + setCopySuccess("Copied!"); + setTimeout(() => setCopySuccess(""), 2000); // 清除复制成功的提示 + }, + (err) => { + setCopySuccess("Failed to copy!"); + } + ); + }; + return ( <>
+ {/* 复制按钮 */} + \ No newline at end of file + \ No newline at end of file From f797f4b6eefed2245be5cde8b30351fce57a9ed2 Mon Sep 17 00:00:00 2001 From: LofiSu Date: Mon, 2 Sep 2024 13:26:50 +0800 Subject: [PATCH 3/4] Fix JS icon 404 issue and add copy button to homepage code display and added some new like org.apache.fury.* --- docs/start/usage.md | 4 ++-- src/components/HomepageCode/index.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/start/usage.md b/docs/start/usage.md index 6a2a0d76..a2be7491 100644 --- a/docs/start/usage.md +++ b/docs/start/usage.md @@ -9,7 +9,7 @@ sidebar_position: 1 ```java import java.util.List; import java.util.Arrays; -import io.fury.*; +import org.apache.fury.*; public class Example { public static void main(String[] args) { @@ -36,7 +36,7 @@ public class Example { ```java import com.google.common.collect.ImmutableMap; -import io.fury.*; +import org.apache.fury.*; import java.util.Map; diff --git a/src/components/HomepageCode/index.tsx b/src/components/HomepageCode/index.tsx index 494b9120..972dad9d 100644 --- a/src/components/HomepageCode/index.tsx +++ b/src/components/HomepageCode/index.tsx @@ -6,7 +6,7 @@ export const HomepageCodeDisplay = () => { const [copySuccess, setCopySuccess] = useState(""); const codeString = `import java.util.List; import java.util.Arrays; -import io.fury.*; +import org.apache.fury.*; public class Example { public static void main(String[] args) { From c0a05832d4565864d5f9f030977b54406f42b7f2 Mon Sep 17 00:00:00 2001 From: LofiSu Date: Mon, 2 Sep 2024 13:35:36 +0800 Subject: [PATCH 4/4] change name --- src/components/HomePageLanguageCard/index.tsx | 67 ++++++++++++------- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/src/components/HomePageLanguageCard/index.tsx b/src/components/HomePageLanguageCard/index.tsx index 39b3050e..4ba6ede5 100644 --- a/src/components/HomePageLanguageCard/index.tsx +++ b/src/components/HomePageLanguageCard/index.tsx @@ -15,44 +15,63 @@ export const HomePageLanguageCard = () => ( boxShadow: "0 4px 8px rgba(0, 0, 0, 0.1)", }} > - { - window.location.href = - "https://fury.apache.org/docs/start/usage/#java-serialization"; - }}> + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#java-serialization"; + }} + > Java - { - window.location.href = - "https://fury.apache.org/docs/start/usage/#python"; - }}> + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#python"; + }} + > Python - { - window.location.href = - "https://fury.apache.org/docs/start/usage/#golang"; - }}> + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#golang"; + }} + > Golang - { - window.location.href = - "https://fury.apache.org/docs/start/usage/#javascript"; - }}> - + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#javascript"; + }} + > + JavaScript - { - window.location.href = "https://fury.apache.org/docs/start/usage/#rust"; - }}> + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#rust"; + }} + > Rust - { - window.location.href = - "https://fury.apache.org/docs/start/usage/#crosslanguage-serialization"; - }}> + { + window.location.href = + "https://fury.apache.org/docs/start/usage/#crosslanguage-serialization"; + }} + > More