diff --git a/README.zh-CN.md b/README.zh-CN.md new file mode 100644 index 00000000..b19693ef --- /dev/null +++ b/README.zh-CN.md @@ -0,0 +1,33 @@ +# Website + +该网站是使用现代静态网站生成器 [Docusaurus 2](https://v2.docusaurus.io/) 构建的。 + +### 自动安装依赖 + +``` +$ yarn +``` + +### 本地开发 + +``` +$ yarn start +``` + +此命令启动本地开发服务器并打开浏览器窗口。大多数更改都会实时反映,无需重新启动服务器。 + +### 构建 + +``` +$ yarn build +``` + +此命令将静态内容生成到`build`目录中,并且可以使用任何静态内容托管服务提供服务。 + +### 部署 + +``` +$ GIT_USER=<您的 GitHub 用户名> USE_SSH=true yarn deploy +``` + +如果您使用 GitHub Pages 进行托管,此命令是构建网站并将其推送到 `gh-pages` 分支的便捷方法。 diff --git a/blog/2022-08-03-control-refs.md b/blog/2022-08-03-control-refs.md index 563da6a6..43e91489 100644 --- a/blog/2022-08-03-control-refs.md +++ b/blog/2022-08-03-control-refs.md @@ -12,7 +12,7 @@ Flet controls are objects and to access their properties we need to keep referen Consider the following example: -```python {6-8,18,19,21} +```python {6-7,18,19,21} import flet as ft def main(page): @@ -84,7 +84,7 @@ All Flet controls have `ref` property. We could re-write our program to use references: -```python {7-9,21-24} +```python {7-8,21-23} import flet as ft @@ -117,4 +117,4 @@ Now we can clearly see in `page.add()` the structure of the page and all the con Yes, the logic becomes a little bit more verbose as you need to add `.current.` to access ref's control, but it's a matter of personal preference :) -[Give Flet a try](/docs/guides/python/getting-started) and [let us know](https://discord.gg/dzWXP8SHG8) what you think! \ No newline at end of file +[Give Flet a try](/docs/guides/python/getting-started) and [let us know](https://discord.gg/dzWXP8SHG8) what you think! diff --git a/make_lang b/make_lang new file mode 100755 index 00000000..b5002aa3 --- /dev/null +++ b/make_lang @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# coding=utf-8 +# Powered by https://github.com/alan3344/website +# Automatically create translation directory structure, files to be translated, +# and `React Translate/translate()` tags for the project + +lang=$1 +override=$2 +color() { + echo "\033[0;$1m${@:2}\033[0m" +} + +if [[ "$@" =~ "-h" ]] || [[ "$@" =~ "--help" ]]; then + echo Usage: "$(color 33 ./mkdir_lang) <$(color 32 language)> [$(color 31 --override)]" + echo " $(color 32 language) \t$(color 33 Required) The language name." + echo " $(color 31 --override) \t$(color 33 Optional) Override the existing files." + echo " $(color 33 -h --help) \t$(color 33 Optional) Show this help message." + echo + echo "$(color 33 Example): $(color 32 ./mkdir_lang) $(color 31 zh-CN)" + exit 0 +fi + +if [ -z "$lang" ]; then + echo "$(color 31 Error): $(color 33 language) is required." + echo "Try '$(color 32 ./mkdir_lang --help)' for more information." + exit 1 +fi + +if [ "$override" = "--override" ]; then + override="--override" +else + override="" +fi + +mkdir -p i18n/$lang/docusaurus-plugin-content-blog/ +mkdir -p i18n/$lang/docusaurus-plugin-content-docs/ +mkdir -p i18n/$lang/docusaurus-plugin-content-pages/ +mkdir -p i18n/$lang/docusaurus-theme-classic/ +npx docusaurus write-translations --locale $lang $override + +if [ "$override" = "--override" ]; then + override="" +else + override="-n" +fi + +cp -r $override blog/* i18n/$lang/docusaurus-plugin-content-blog/ +cp -r $override docs/* i18n/$lang/docusaurus-plugin-content-docs/ +cp -r $override src/pages/* i18n/$lang/docusaurus-plugin-content-pages/ +cp -r $override src/theme/* i18n/$lang/docusaurus-theme-classic/ diff --git a/src/components/signup-form/index.js b/src/components/signup-form/index.js index 22b53164..a6cb872b 100644 --- a/src/components/signup-form/index.js +++ b/src/components/signup-form/index.js @@ -1,77 +1,118 @@ -import React, { useEffect, useRef, useState } from "react"; -import BrowserOnly from '@docusaurus/BrowserOnly'; -import HCaptcha from "@hcaptcha/react-hcaptcha"; -import styles from './styles.module.css'; +import React, { useEffect, useRef, useState } from 'react' +import BrowserOnly from '@docusaurus/BrowserOnly' +import HCaptcha from '@hcaptcha/react-hcaptcha' +import styles from './styles.module.css' +import Translate, { translate } from '@docusaurus/Translate' export default function SignupForm() { - const [token, setToken] = useState(null); - const [email, setEmail] = useState(""); - const captchaRef = useRef(null); + const [token, setToken] = useState(null) + const [email, setEmail] = useState('') + const captchaRef = useRef(null) - const onSubmit = (event) => { - event.preventDefault(); - captchaRef.current.execute(); - }; + const onSubmit = event => { + event.preventDefault() + captchaRef.current.execute() + } - const onExpire = () => { - console.log("hCaptcha Token Expired"); - }; + const onExpire = () => { + console.log('hCaptcha Token Expired') + } - const onError = (err) => { - console.log(`hCaptcha Error: ${err}`); - }; + const onError = err => { + console.log(`hCaptcha Error: ${err}`) + } - useEffect(async () => { - if (token) { - var data = { - email: email, - captchaToken: token - }; + useEffect(async () => { + if (token) { + var data = { + email: email, + captchaToken: token, + } - // send message - const response = await fetch("/api/email-signup", { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify(data), - }); - const results = await response.json(); - console.log(`Results:`, results); - } - }, [token, email]); + // send message + const response = await fetch('/api/email-signup', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data), + }) + const results = await response.json() + console.log(`Results:`, results) + } + }, [token, email]) - return ( -
- Loading...
}> - {() => { - if (token) { - // signup submitted - return
Thank you! You will receive the confirmation email shortly.
- } else if (window.location.href.endsWith('?signup-confirmed')) { - // signup confirmed - return
🎉Congratulations! You have successfully subscribed to Flet newsletter.
- } else { - // signup form - return
-

Subscribe to Flet newsletter for project updates and tutorials!

- setEmail(evt.target.value)} - /> - - - - } - }} - - - ); + return ( +
+ Loading...
}> + {() => { + if (token) { + // signup submitted + return ( +
+ + Thank you! You will receive the confirmation email shortly. + +
+ ) + } else if (window.location.href.endsWith('?signup-confirmed')) { + // signup confirmed + return ( +
+ + 🎉 + + + Congratulations! You have successfully subscribed to Flet + newsletter. + +
+ ) + } else { + // signup form + return ( +
+

+ + Subscribe to Flet newsletter for project updates and + tutorials! + +

+ setEmail(evt.target.value)} + /> + + + + ) + } + }} + + + ) } diff --git a/src/pages/index.js b/src/pages/index.js index 173890bd..43c28e4f 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,127 +1,268 @@ -import React from 'react'; -import clsx from 'clsx'; -import Layout from '@theme/Layout'; -import Link from '@docusaurus/Link'; -import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; -import useBaseUrl from '@docusaurus/useBaseUrl'; -import styles from './styles.module.css'; -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import React from 'react' +import clsx from 'clsx' +import Layout from '@theme/Layout' +import Link from '@docusaurus/Link' +import useDocusaurusContext from '@docusaurus/useDocusaurusContext' +import useBaseUrl from '@docusaurus/useBaseUrl' +import styles from './styles.module.css' +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' import SignupForm from '@site/src/components/signup-form' -import CodeBlock from '@theme/CodeBlock'; +import CodeBlock from '@theme/CodeBlock' +import Translate, { translate } from '@docusaurus/Translate' const features = [ { - title: <>From idea to app in minutes, + title: ( + <> + + From idea to app in minutes + + + ), imageUrl: 'img/pages/home/feature-bolt.svg', description: ( <> - An internal tool or a dashboard for your team, weekend project, data entry form, kiosk app or high-fidelity prototype - - Flet is an ideal framework to quickly hack a great-looking interactive apps to serve a group of users. + + An internal tool or a dashboard for your team, weekend project, data + entry form, kiosk app or high-fidelity prototype - Flet is an ideal + framework to quickly hack a great-looking interactive apps to serve a + group of users. + ), }, { - title: <>Simple architecture, + title: ( + <> + + Simple architecture + + + ), imageUrl: 'img/pages/home/feature-house.svg', description: ( <> - No more complex architecture with JavaScript frontend, REST API backend, database, cache, etc. - With Flet you just write a monolith stateful app in Python only and get multi-user, realtime Single-Page Application (SPA). + + No more complex architecture with JavaScript frontend, REST API + backend, database, cache, etc. With Flet you just write a monolith + stateful app in Python only and get multi-user, realtime Single-Page + Application (SPA). + ), }, { - title: <>Batteries included, + title: ( + <> + + Batteries included + + + ), imageUrl: 'img/pages/home/feature-battery.svg', description: ( <> - To start developing with Flet, you just need your favorite IDE or text editor. - No SDKs, no thousands of dependencies, no complex tooling - Flet has built-in web server with assets hosting and desktop clients. + + To start developing with Flet, you just need your favorite IDE or text + editor. No SDKs, no thousands of dependencies, no complex tooling - + Flet has built-in web server with assets hosting and desktop clients. + ), }, { - title: <>Powered by Flutter, + title: ( + <> + + Powered by Flutter + + + ), imageUrl: 'img/pages/home/feature-flutter.svg', description: ( <> - Flet UI is built with Flutter, so your app looks professional and can be delivered to any platform. - Flet simplifies Flutter model by combining smaller "widgets" into ready-to-use "controls" with imperative programming model. + + Flet UI is built with + {' '} + Flutter + + , so your app looks professional and can be delivered to any platform. + Flet simplifies Flutter model by combining smaller "widgets" into + ready-to-use "controls" with imperative programming model. + ), }, { - title: <>Speaks your language, + title: ( + <> + + Speaks your language + + + ), imageUrl: 'img/pages/home/feature-language.svg', description: ( <> - Flet is language-agnostic, so anyone on your team could develop Flet apps in their favorite language. Python is already supported, Go, C# and others are coming next. + + Flet is language-agnostic, so anyone on your team could develop Flet + apps in their favorite language. + {' '} + Python{' '} + + is already supported, Go, C# and others are + + + {' '} + + coming next. + + ), }, { - title: <>Deliver to any device, + title: ( + <> + + Deliver to any device + + + ), imageUrl: 'img/pages/home/feature-mobile.svg', description: ( <> - Deploy Flet app as a web app and view it in a browser. Package it as a standalone desktop app for Windows, macOS and Linux. - Install it on mobile as PWA or view via Flet app for iOS and Android. + + Deploy Flet app as a web app and view it in a browser. Package it as a + standalone desktop app for Windows, macOS and Linux. Install it on + mobile as + {' '} + PWA{' '} + + or view via Flet app for iOS and Android. + ), }, -]; +] function Feature({ imageUrl, title, description }) { - const imgUrl = useBaseUrl(imageUrl); + const imgUrl = useBaseUrl(imageUrl) return (
{imgUrl && ( -
+
{title}
)}

{title}

{description}

- ); + ) } function Home() { - const context = useDocusaurusContext(); - const { siteConfig = {} } = context; + const context = useDocusaurusContext() + const { siteConfig = {} } = context return ( + title={translate({ + id: 'indexPage.title.heroTitle', + message: 'The fastest way to build Flutter apps in Python', + description: 'the title heroTitle description', + })} + description={translate({ + id: 'indexPage.title.description', + message: + 'Build internal web apps quickly in the language you already know.', + description: 'the description heroSubTitle description', + })}>
-
+
-
-
+
+
{/*

It's amazing how little code you need to get amazing results!

*/} - +
-
-

{siteConfig.customFields.heroTitle}

-

{siteConfig.customFields.heroSubTitle}

+
+

+ + The fastest way to build Flutter apps in Python + +

+

+ + Flet enables developers to easily build realtime web, mobile + and desktop apps in Python. No frontend experience required. + +

- Get Started + + Get Started +
-
-

Main features

+
+

+ + Main features + +

{features && features.length > 0 && (
-
-
+
+
{features.map((props, idx) => ( ))} @@ -133,7 +274,7 @@ function Home() {
- ); + ) } -export default Home; \ No newline at end of file +export default Home