diff --git a/.github/workflows/golang-test-lint.yml b/.github/workflows/golang-test-lint.yml index 2576c347..a87e7f14 100644 --- a/.github/workflows/golang-test-lint.yml +++ b/.github/workflows/golang-test-lint.yml @@ -20,8 +20,8 @@ jobs: uses: actions/setup-go@v3 with: go-version: '1.21' - - name: Dummy JS File - run: touch bskyweb/static/js/blah.js + - name: Dummy Static Files + run: touch bskyweb/static/js/blah.js && touch bskyweb/static/media/blah.txt - name: Check run: cd bskyweb/ && make check - name: Build (binary) @@ -37,7 +37,7 @@ jobs: uses: actions/setup-go@v3 with: go-version: '1.21' - - name: Dummy JS File - run: touch bskyweb/static/js/blah.js + - name: Dummy Static Files + run: touch bskyweb/static/js/blah.js && touch bskyweb/static/media/blah.txt - name: Lint run: cd bskyweb/ && make lint diff --git a/Dockerfile.embedr b/Dockerfile.embedr index c7025165..63f06098 100644 --- a/Dockerfile.embedr +++ b/Dockerfile.embedr @@ -40,6 +40,7 @@ RUN find ./bskyweb/embedr-static && find ./bskyweb/embedr-templates && find ./bs # hack around issue with empty directory and go:embed RUN touch bskyweb/static/js/empty.txt +RUN touch bskyweb/static/media/empty.txt # # Generate the embedr Go binary. diff --git a/assets/kawaii.png b/assets/kawaii.png new file mode 100644 index 00000000..79cab8e5 Binary files /dev/null and b/assets/kawaii.png differ diff --git a/assets/kawaii_smol.png b/assets/kawaii_smol.png new file mode 100644 index 00000000..4bed5620 Binary files /dev/null and b/assets/kawaii_smol.png differ diff --git a/bskyweb/.gitignore b/bskyweb/.gitignore index fad122a2..05b3ad7a 100644 --- a/bskyweb/.gitignore +++ b/bskyweb/.gitignore @@ -10,6 +10,8 @@ static/js/*.js static/js/*.map static/js/*.js.LICENSE.txt static/js/empty.txt +static/media/*.png +static/media/empty.txt templates/scripts.html templates/*-embed.html static/embed/*.html diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go index 54580d64..e1b00964 100644 --- a/bskyweb/cmd/bskyweb/server.go +++ b/bskyweb/cmd/bskyweb/server.go @@ -158,7 +158,7 @@ func serve(cctx *cli.Context) error { // Cache javascript and images files for 1 week, which works because // they're always versioned (e.g. /static/js/main.64c14927.js) - if strings.HasPrefix(path, "/static/js/") || strings.HasPrefix(path, "/static/images/") { + if strings.HasPrefix(path, "/static/js/") || strings.HasPrefix(path, "/static/images/") || strings.HasPrefix(path, "/static/media/") { maxAge = 7 * (60 * 60 * 24) // 1 week } diff --git a/bskyweb/static/media/.gitkeep b/bskyweb/static/media/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/package.json b/package.json index acb9007b..874a55c1 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "web": "expo start --web", "use-build-number": "./scripts/useBuildNumberEnv.sh", "use-build-number-with-bump": "./scripts/useBuildNumberEnvWithBump.sh", - "build-web": "expo export:web && node ./scripts/post-web-build.js && cp -v ./web-build/static/js/*.* ./bskyweb/static/js/", + "build-web": "expo export:web && node ./scripts/post-web-build.js && cp -v ./web-build/static/js/*.* ./bskyweb/static/js/ && cp -v ./web-build/static/media/*.png ./bskyweb/static/media/", "build-all": "yarn intl:build && yarn use-build-number-with-bump eas build --platform all", "build-ios": "yarn use-build-number-with-bump eas build -p ios", "build-android": "yarn use-build-number-with-bump eas build -p android", diff --git a/src/state/persisted/index.ts b/src/state/persisted/index.ts index f57172d2..5fe0f9bd 100644 --- a/src/state/persisted/index.ts +++ b/src/state/persisted/index.ts @@ -1,11 +1,11 @@ import EventEmitter from 'eventemitter3' -import {logger} from '#/logger' -import {defaults, Schema} from '#/state/persisted/schema' -import {migrate} from '#/state/persisted/legacy' -import * as store from '#/state/persisted/store' -import BroadcastChannel from '#/lib/broadcast' -export type {Schema, PersistedAccount} from '#/state/persisted/schema' +import BroadcastChannel from '#/lib/broadcast' +import {logger} from '#/logger' +import {migrate} from '#/state/persisted/legacy' +import {defaults, Schema} from '#/state/persisted/schema' +import * as store from '#/state/persisted/store' +export type {PersistedAccount, Schema} from '#/state/persisted/schema' export {defaults} from '#/state/persisted/schema' const broadcast = new BroadcastChannel('BSKY_BROADCAST_CHANNEL') diff --git a/src/state/persisted/schema.ts b/src/state/persisted/schema.ts index 43f08e12..77a79b78 100644 --- a/src/state/persisted/schema.ts +++ b/src/state/persisted/schema.ts @@ -80,6 +80,7 @@ export const schema = z.object({ pdsAddressHistory: z.array(z.string()).optional(), disableHaptics: z.boolean().optional(), disableAutoplay: z.boolean().optional(), + kawaii: z.boolean().optional(), }) export type Schema = z.infer @@ -117,4 +118,5 @@ export const defaults: Schema = { pdsAddressHistory: [], disableHaptics: false, disableAutoplay: prefersReducedMotion, + kawaii: false, } diff --git a/src/state/preferences/index.tsx b/src/state/preferences/index.tsx index 82035851..5bca3545 100644 --- a/src/state/preferences/index.tsx +++ b/src/state/preferences/index.tsx @@ -7,6 +7,7 @@ import {Provider as DisableHapticsProvider} from './disable-haptics' import {Provider as ExternalEmbedsProvider} from './external-embeds-prefs' import {Provider as HiddenPostsProvider} from './hidden-posts' import {Provider as InAppBrowserProvider} from './in-app-browser' +import {Provider as KawaiiProvider} from './kawaii' import {Provider as LanguagesProvider} from './languages' export { @@ -32,7 +33,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) { - {children} + + {children} + diff --git a/src/state/preferences/kawaii.tsx b/src/state/preferences/kawaii.tsx new file mode 100644 index 00000000..4aa95ef8 --- /dev/null +++ b/src/state/preferences/kawaii.tsx @@ -0,0 +1,50 @@ +import React from 'react' + +import {isWeb} from '#/platform/detection' +import * as persisted from '#/state/persisted' + +type StateContext = persisted.Schema['kawaii'] + +const stateContext = React.createContext( + persisted.defaults.kawaii, +) + +export function Provider({children}: React.PropsWithChildren<{}>) { + const [state, setState] = React.useState(persisted.get('kawaii')) + + const setStateWrapped = React.useCallback( + (kawaii: persisted.Schema['kawaii']) => { + setState(kawaii) + persisted.write('kawaii', kawaii) + }, + [setState], + ) + + React.useEffect(() => { + return persisted.onUpdate(() => { + setState(persisted.get('kawaii')) + }) + }, [setStateWrapped]) + + React.useEffect(() => { + // dumb and stupid but it's web only so just refresh the page if you want to change it + + if (isWeb) { + const kawaii = new URLSearchParams(window.location.search).get('kawaii') + switch (kawaii) { + case 'true': + setStateWrapped(true) + break + case 'false': + setStateWrapped(false) + break + } + } + }, [setStateWrapped]) + + return {children} +} + +export function useKawaiiMode() { + return React.useContext(stateContext) +} diff --git a/src/view/com/auth/SplashScreen.web.tsx b/src/view/com/auth/SplashScreen.web.tsx index f905e1e8..6df4e439 100644 --- a/src/view/com/auth/SplashScreen.web.tsx +++ b/src/view/com/auth/SplashScreen.web.tsx @@ -4,6 +4,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {useKawaiiMode} from '#/state/preferences/kawaii' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' import {Logo} from '#/view/icons/Logo' import {Logotype} from '#/view/icons/Logotype' @@ -28,6 +29,8 @@ export const SplashScreen = ({ const t = useTheme() const {isTabletOrMobile: isMobileWeb} = useWebMediaQueries() + const kawaii = useKawaiiMode() + return ( <> {onDismiss && ( @@ -66,11 +69,13 @@ export const SplashScreen = ({ ]}> - + - - - + {!kawaii && ( + + + + )} {hasSession && ( - + - + 100 + ? require('../../../assets/kawaii.png') + : require('../../../assets/kawaii_smol.png') + } + accessibilityLabel="Bluesky" + accessibilityHint="" + accessibilityIgnoresInvertColors + style={[{height: size, aspectRatio: 1.4}]} + /> + ) + } + return ( { const {isAtHome, isAtSearch, isAtFeeds, isAtNotifications, isAtMyProfile} = useNavigationTabState() const {hasSession, currentAccount} = useSession() + const kawaii = useKawaiiMode() // events // = @@ -262,6 +264,17 @@ let DrawerContent = ({}: {}): React.ReactNode => { href="https://bsky.social/about/support/privacy-policy" text={_(msg`Privacy Policy`)} /> + {kawaii && ( + + Logo by{' '} + + + )} diff --git a/src/view/shell/desktop/RightNav.tsx b/src/view/shell/desktop/RightNav.tsx index c1f49872..f0cd4f59 100644 --- a/src/view/shell/desktop/RightNav.tsx +++ b/src/view/shell/desktop/RightNav.tsx @@ -1,22 +1,26 @@ import React from 'react' import {StyleSheet, View} from 'react-native' -import {usePalette} from 'lib/hooks/usePalette' -import {DesktopSearch} from './Search' -import {DesktopFeeds} from './Feeds' -import {Text} from 'view/com/util/text/Text' -import {TextLink} from 'view/com/util/Link' -import {FEEDBACK_FORM_URL, HELP_DESK_URL} from 'lib/constants' -import {s} from 'lib/styles' -import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' -import {useLingui} from '@lingui/react' import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {useKawaiiMode} from '#/state/preferences/kawaii' import {useSession} from '#/state/session' +import {FEEDBACK_FORM_URL, HELP_DESK_URL} from 'lib/constants' +import {usePalette} from 'lib/hooks/usePalette' +import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' +import {s} from 'lib/styles' +import {TextLink} from 'view/com/util/Link' +import {Text} from 'view/com/util/text/Text' +import {DesktopFeeds} from './Feeds' +import {DesktopSearch} from './Search' export function DesktopRightNav({routeName}: {routeName: string}) { const pal = usePalette('default') const {_} = useLingui() const {hasSession, currentAccount} = useSession() + const kawaii = useKawaiiMode() + const {isTablet} = useWebMediaQueries() if (isTablet) { return null @@ -90,6 +94,17 @@ export function DesktopRightNav({routeName}: {routeName: string}) { text={_(msg`Help`)} /> + {kawaii && ( + + Logo by{' '} + + + )}