Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
16 KB
Referenced Files
None
Subscribers
None
diff --git a/README.md b/README.md
index a1dabba359..f2951a8ccd 100644
--- a/README.md
+++ b/README.md
@@ -1,51 +1,51 @@
# Pleroma-FE
> Highly-customizable frontend designed for Pleroma.
-![screenshot](./image-1.png)
+![screenshot](./public/static/PWA/tablet_landscape.png)
[![Pipeline Status](https://ci.pleroma.com/api/badges/2/status.svg)](https://ci.pleroma.com/repos/2) [![Coverage](https://sonarqube.pleroma.dev/api/project_badges/measure?project=Pleroma-FE&metric=coverage&token=sqb_f8a5ec836caede0e2c6c62a9bfe66e62a89e2b01)](https://sonarqube.pleroma.dev/dashboard?id=Pleroma-FE) [![Maintainability Rating](https://sonarqube.pleroma.dev/api/project_badges/measure?project=Pleroma-FE&metric=software_quality_maintainability_rating&token=sqb_f8a5ec836caede0e2c6c62a9bfe66e62a89e2b01)](https://sonarqube.pleroma.dev/dashboard?id=Pleroma-FE) [![Reliability Rating](https://sonarqube.pleroma.dev/api/project_badges/measure?project=Pleroma-FE&metric=software_quality_reliability_rating&token=sqb_f8a5ec836caede0e2c6c62a9bfe66e62a89e2b01)](https://sonarqube.pleroma.dev/dashboard?id=Pleroma-FE) [![Security Rating](https://sonarqube.pleroma.dev/api/project_badges/measure?project=Pleroma-FE&metric=software_quality_security_rating&token=sqb_f8a5ec836caede0e2c6c62a9bfe66e62a89e2b01)](https://sonarqube.pleroma.dev/dashboard?id=Pleroma-FE) <a href="https://translate.pleroma.social/engage/pleroma/"><img src="https://translate.pleroma.social/widget/pleroma/pleroma-fe/svg-badge.svg" alt="Translation status"></a>
# For Translators
To translate Pleroma-FE, use our weblate server: https://translate.pleroma.social/. If you need to add your language it should be added as a json file in [src/i18n/](https://git.pleroma.social/pleroma/pleroma-fe/src/src/i18n/) folder and added in a list within [src/i18n/languages.js](https://git.pleroma.social/pleroma/pleroma-fe/src/src/i18n/languages.js).
Pleroma-FE will set your language by your browser locale, but you can change language in settings.
# For instance admins
You don't need to build Pleroma-FE yourself. Those using the Pleroma backend will be able to use it out of the box. Information of customizing PleromaFE settings/defaults is in our [guide](https://docs-develop.pleroma.social/frontend/CONFIGURATION/) and in case you want to build your own custom version there's [another](https://docs-develop.pleroma.social/frontend/HACKING/)
# Build Setup
``` bash
# install dependencies
npm install -g yarn
yarn
# serve with hot reload at localhost:8080
yarn dev
# build for production with minification
yarn build
# run unit tests
yarn unit
```
# For Contributors:
You can make local build proxy requests to specific instance with an environment variable `VITE_PROXY_TARGET`, generally it is a good idea to also set port for that specific proxy, if you intend on testing multiple instances, i.e.:
```bash
yarn && PORT=8080 VITE_PROXY_TARGET=https://coolinstance.tld yarn dev
```
You can create file `/config/local.json` (see [example](https://git.pleroma.social/pleroma/pleroma-fe/src/config/local.example.json)) to enable some convenience dev options:
* `staticConfigPreference`: makes FE's `/static/config.json` take preference of BE-served `/api/pleroma/frontend_configurations`. Only works in dev mode.
FE Build process also leaves current commit hash in global variable `___pleromafe_commit_hash` so that you can easily see which pleroma-fe commit instance is running, also helps pinpointing which commit was used when FE was bundled into BE.
# Configuration
Set configuration settings in AdminFE, additionally you can edit config.json. For more details see [documentation](https://docs-develop.pleroma.social/frontend/CONFIGURATION/).
diff --git a/build/hosted_plugin.js b/build/hosted_plugin.js
new file mode 100644
index 0000000000..fc20e4f533
--- /dev/null
+++ b/build/hosted_plugin.js
@@ -0,0 +1,23 @@
+export const hostedModePlugin = () => {
+ return {
+ name: 'hosted-mode-plugin',
+ transformIndexHtml(html) {
+ if (process.env.PLEROMAFE_HOSTED_MODE) {
+ const replacement = [
+ '<title>PleromaFE</title>',
+ '<link rel="manifest" href="/static/PWA/manifest.json">',
+ '<meta name="theme-color" content="#1e2734">',
+ '<link rel="apple-touch-icon" href="/static/PWA/192_bg.png">',
+ '<link rel="icon" href="/static/PWA/192.png">',
+ ].map((x) => ' ' + x)
+
+ return html.replace(
+ '<!--server-generated-meta-->',
+ replacement.join('\n'),
+ )
+ } else {
+ return html
+ }
+ },
+ }
+}
diff --git a/image-1.png b/image-1.png
deleted file mode 100644
index 602cbb2631..0000000000
Binary files a/image-1.png and /dev/null differ
diff --git a/image.png b/image.png
deleted file mode 100644
index c1004c7c82..0000000000
Binary files a/image.png and /dev/null differ
diff --git a/public/static/PWA/192.png b/public/static/PWA/192.png
new file mode 100644
index 0000000000..a29c9bf978
Binary files /dev/null and b/public/static/PWA/192.png differ
diff --git a/public/static/PWA/192_bg.png b/public/static/PWA/192_bg.png
new file mode 100644
index 0000000000..a58cdec5bd
Binary files /dev/null and b/public/static/PWA/192_bg.png differ
diff --git a/public/static/PWA/512.png b/public/static/PWA/512.png
new file mode 100644
index 0000000000..d3203a5bc6
Binary files /dev/null and b/public/static/PWA/512.png differ
diff --git a/public/static/PWA/512_bg.png b/public/static/PWA/512_bg.png
new file mode 100644
index 0000000000..d92f8e67b0
Binary files /dev/null and b/public/static/PWA/512_bg.png differ
diff --git a/public/static/PWA/logo.png b/public/static/PWA/logo.png
new file mode 100644
index 0000000000..284a597069
Binary files /dev/null and b/public/static/PWA/logo.png differ
diff --git a/public/static/PWA/logo_bg.png b/public/static/PWA/logo_bg.png
new file mode 100644
index 0000000000..dfdf920e18
Binary files /dev/null and b/public/static/PWA/logo_bg.png differ
diff --git a/public/static/PWA/manifest.json b/public/static/PWA/manifest.json
new file mode 100644
index 0000000000..ceea2a114f
--- /dev/null
+++ b/public/static/PWA/manifest.json
@@ -0,0 +1,69 @@
+{
+ "name": "PleromaFE",
+ "short_name": "PleromaFE",
+ "description": "Pleroma/Akkoma client",
+ "start_url": "/",
+ "scope": "/",
+ "id": ".",
+ "display": "standalone",
+ "orientation": "any",
+ "theme_color": "#1e2734",
+ "background_color": "#121a24",
+ "icons": [
+ {
+ "src": "/static/PWA/512.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "monochrome"
+ },
+ {
+ "src": "/static/PWA/512_bg.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "maskable"
+ },
+ {
+ "src": "/static/PWA/512_bg.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "any"
+ },
+ {
+ "src": "/static/PWA/192.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "monochrome"
+ },
+ {
+ "src": "/static/PWA/192_bg.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "maskable"
+ },
+ {
+ "src": "/static/PWA/192_bg.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "any"
+ }
+ ],
+ "screenshots": [
+ {
+ "src": "/static/PWA/mobile.png",
+ "sizes": "1082x2426",
+ "type": "image/png",
+ "label": "Timeline view (Mobile)",
+ "form_factor": "narrow"
+ },
+ {
+ "src": "/static/PWA/tablet_landscape.png",
+ "sizes": "2752x2064",
+ "type": "image/png",
+ "label": "Timeline view (Desktop)",
+ "form_factor": "wide"
+ }
+ ],
+ "prefer_related_applications": false,
+ "categories": ["social networking"],
+ "display_override": ["window-controls-overlay", "standalone"]
+}
diff --git a/public/static/PWA/mobile.png b/public/static/PWA/mobile.png
new file mode 100644
index 0000000000..3e521ee061
Binary files /dev/null and b/public/static/PWA/mobile.png differ
diff --git a/public/static/PWA/tablet_landscape.png b/public/static/PWA/tablet_landscape.png
new file mode 100644
index 0000000000..92661bdda8
Binary files /dev/null and b/public/static/PWA/tablet_landscape.png differ
diff --git a/vite.config.js b/vite.config.js
index 1336edea35..84e561b747 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -1,259 +1,261 @@
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { playwright } from '@vitest/browser-playwright'
import { defineConfig } from 'vite'
import biomePlugin from 'vite-plugin-biome'
import stylelint from 'vite-plugin-stylelint'
import vueDevTools from 'vite-plugin-vue-devtools'
import { configDefaults } from 'vitest/config'
import { getCommitHash } from './build/commit_hash.js'
import copyPlugin from './build/copy_plugin.js'
import emojisPlugin from './build/emojis_plugin.js'
+import { hostedModePlugin } from './build/hosted_plugin.js'
import { buildSwPlugin, swMessagesPlugin } from './build/sw_plugin.js'
const localConfigPath = '<projectRoot>/config/local.json'
const normalizeTarget = (target) => {
if (!target || typeof target !== 'string') return target
return target.endsWith('/') ? target.replace(/\/$/, '') : target
}
const getLocalDevSettings = async () => {
const envTarget = normalizeTarget(process.env.VITE_PROXY_TARGET)
const envOrigin = normalizeTarget(process.env.VITE_PROXY_ORIGIN)
try {
const settings = (await import('./config/local.json')).default
settings.target = normalizeTarget(settings.target)
settings.origin = normalizeTarget(settings.origin)
if (envTarget) settings.target = envTarget
if (envOrigin) settings.origin = envOrigin
console.info(`Using local dev server settings (${localConfigPath}):`)
console.info(JSON.stringify(settings, null, 2))
return settings
} catch (e) {
if (!envTarget && !envOrigin) {
console.info(
`Local dev server settings not found (${localConfigPath}), using default`,
e,
)
return {}
}
const settings = { target: envTarget, origin: envOrigin }
console.info(
'Using dev server settings from VITE_PROXY_TARGET/VITE_PROXY_ORIGIN:',
)
console.info(JSON.stringify(settings, null, 2))
return settings
}
}
const projectRoot = dirname(fileURLToPath(import.meta.url))
const getTransformSWSettings = (settings) => {
if ('transformSW' in settings) {
return settings.transformSW
} else {
console.info(
'`transformSW` is not present in your local settings.\n' +
'This option controls whether the service worker should be bundled and transformed into iife (immediately-invoked function expression) during development.\n' +
'If set to false, the service worker will be served as-is, as an ES Module.\n' +
'Some browsers (e.g. Firefox) does not support ESM service workers.\n' +
'To avoid surprises, it is defaulted to true, but this can be slow.\n' +
'If you are using a browser that supports ESM service workers, you can set this option to false.\n' +
`No matter your choice, you can set the transformSW option in ${localConfigPath} in to disable this message.`,
)
return true
}
}
export default defineConfig(async ({ mode, command }) => {
const settings = await getLocalDevSettings()
const target = settings.target || 'http://localhost:4000/'
const origin = settings.origin || target
const targetSW = target.replace(/^http/, 'ws')
const transformSW = getTransformSWSettings(settings)
const proxy = {
'/api': {
target,
changeOrigin: true,
cookieDomainRewrite: 'localhost',
ws: true,
rewriteWsOrigin: true,
},
'/auth': {
// Mastodon password reset lives here
target,
changeOrigin: true,
cookieDomainRewrite: 'localhost',
ws: true,
},
'/nodeinfo': {
target,
changeOrigin: true,
cookieDomainRewrite: 'localhost',
},
'/instance': {
target,
changeOrigin: true,
cookieDomainRewrite: 'localhost',
},
'/oauth': {
target,
changeOrigin: true,
cookieDomainRewrite: 'localhost',
},
'/socket': {
target: targetSW,
changeOrigin: true,
cookieDomainRewrite: 'localhost',
rewriteWsOrigin: true,
ws: true,
headers: {
Origin: origin,
},
},
}
const swSrc = 'src/sw.js'
const swDest = 'sw-pleroma.js'
const alias = {
src: '/src',
test: '/test',
components: '/src/components',
...(mode === 'test' ? { vue: 'vue/dist/vue.esm-bundler.js' } : {}),
}
return {
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement(tag) {
if (tag === 'pinch-zoom') {
return true
}
if (tag.startsWith('cropper-')) {
return true
}
return false
},
},
},
}),
vueDevTools(),
vueJsx(),
+ hostedModePlugin(),
buildSwPlugin({ swSrc, swDest }),
swMessagesPlugin(),
emojisPlugin(),
copyPlugin({
inUrl: '/static/ruffle',
inFs: resolve(projectRoot, 'node_modules/@ruffle-rs/ruffle'),
}),
biomePlugin({
mode: 'check',
}),
stylelint({
lintInWorker: true,
lintOnStart: true,
cacheLocation: resolve(
projectRoot,
'node_modules/.cache/stylelintcache',
),
}),
],
css: {
devSourcemap: true,
},
resolve: {
alias,
},
define: {
'process.env': JSON.stringify({
NODE_ENV:
mode === 'test'
? 'testing'
: command === 'serve'
? 'development'
: 'production',
HAS_MODULE_SERVICE_WORKER: command === 'serve' && !transformSW,
}),
COMMIT_HASH: JSON.stringify(
command === 'serve' ? 'DEV' : getCommitHash(),
),
HOSTED_MODE: process.env.PLEROMAFE_HOSTED_MODE,
DEV_OVERRIDES: JSON.stringify(command === 'serve' ? settings : undefined),
__VUE_OPTIONS_API__: true,
__VUE_PROD_DEVTOOLS__: false,
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false,
},
// devtools: { enabled: true },
build: {
sourcemap: true,
rolldownOptions: {
input: {
main: 'index.html',
},
output: {
entryFileNames(chunkInfo) {
const id = chunkInfo.facadeModuleId
if (id.endsWith(swSrc)) {
return swDest
} else {
return 'static/js/[name].[hash].js'
}
},
chunkFileNames(chunkInfo) {
if (chunkInfo.facadeModuleId) {
if (
chunkInfo.facadeModuleId.includes(
'node_modules/@kazvmoe-infra/unicode-emoji-json/annotations/',
)
) {
return 'static/js/emoji-annotations/[name].[hash].js'
} else if (chunkInfo.facadeModuleId.includes('src/i18n/')) {
return 'static/js/i18n/[name].[hash].js'
}
}
return 'static/js/[name].[hash].js'
},
assetFileNames(assetInfo) {
const name = assetInfo.names?.[0] || ''
if (/\.(png|jpe?g|gif|svg)(\?.*)?$/.test(name)) {
return 'static/img/[name].[hash][extname]'
} else if (/\.css$/.test(name)) {
return 'static/css/[name].[hash][extname]'
} else {
return 'static/misc/[name].[hash][extname]'
}
},
},
},
},
server: {
...(mode === 'test' ? {} : { proxy }),
port: Number(process.env.PORT) || 8080,
},
preview: {
proxy,
},
test: {
globals: true,
exclude: [...configDefaults.exclude, 'test/e2e-playwright/**'],
coverage: {
provider: 'v8',
all: true,
reporter: ['text-summary', ['lcov', { subdir: './src' }]],
exclude: ['**/*.style.js', 'public/**', '**/*.scss'],
},
browser: {
enabled: true,
headless: false,
provider: playwright(),
// https://github.com/mswjs/msw/issues/2757
instances: [{ browser: 'chromium' }],
},
},
}
})

File Metadata

Mime Type
text/x-diff
Expires
Wed, Nov 18, 4:14 PM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1840580
Default Alt Text
(16 KB)

Event Timeline