Skip to content

Commit

Permalink
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fi…
Browse files Browse the repository at this point in the history
…x-community-post-list-styling
  • Loading branch information
kommunarr committed Jan 5, 2024
2 parents 99148fc + e7b2b24 commit ae27760
Show file tree
Hide file tree
Showing 222 changed files with 13,253 additions and 4,090 deletions.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,18 @@ body:
- Flathub
- .pacman
- Portable
- .rpm
- .rpm
- .zip
- .apk (Android, FreeTubeCordova Unofficial)
- AUR (Unofficial)
- Chocolatey (Unofficial)
- Homebrew (Unofficial)
- MPR (Unofficial)
- Nix (Unofficial)
- PortableApps (Unofficial)
- Scoop (Unofficial)
- Snapcraft (Unofficial)
- WAPT (Unofficial)
- winget (Unofficial)
- other
validations:
Expand Down
4 changes: 2 additions & 2 deletions .github/issue-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
- '(visual bug)'

'B: Unofficial Download':
- '(AUR \(Unofficial\)|Chocolatey \(Unofficial\)|\.apk \(Android, FreeTubeCordova Unofficial\)|PortableApps \(Unofficial\)|winget \(Unofficial\)|Scoop \(Unofficial\)|Snapcraft \(Unofficial\)|MPR \(Unofficial\)|Nix \(Unofficial\))'
- '(AUR \(Unofficial\)|Chocolatey \(Unofficial\)|\.apk \(Android, FreeTubeCordova Unofficial\)|Homebrew \(Unofficial\)|PortableApps \(Unofficial\)|WAPT \(Unofficial\)|winget \(Unofficial\)|Scoop \(Unofficial\)|Snapcraft \(Unofficial\)|MPR \(Unofficial\)|Nix \(Unofficial\))'

'B: keyboard control':
- '(keyboard control not working)'
- '(keyboard control not working)'

'B: text/string':
- '(text/string issue)'
Expand Down
21 changes: 5 additions & 16 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
'PR: waiting for review':
- '*'
- '.babelrc'
- '.editorconfig'
- '.eslintignore'
- '.eslintrc.js'
- '.gitignore'
- '.prettierrc'
- '.whitesource'
- '.github/**/*'
- '.vscode/**/*'
- '_icons/**/*'
- '_scripts/**/*'
- 'src/**/*'
- 'static/**/*'
- changed-files:
- any-glob-to-any-file: '**'

'PR: dependencies':
- 'yarn.lock'
- 'package.json'
- any:
- changed-files:
- any-glob-to-any-file: ['yarn.lock', 'package.json']
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
Expand All @@ -64,7 +64,7 @@ jobs:

- name: Set Version Number Variable
id: versionNumber
uses: actions/github-script@v6
uses: actions/github-script@v7
env:
IS_DEV: ${{ contains(github.ref, 'development') }}
IS_RC: ${{ contains(github.ref, 'RC') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -45,7 +45,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -58,6 +58,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
rm freetube-${{ steps.sub.outputs.result }}-linux-portable-x64.zip
rm freetube-${{ steps.sub.outputs.result }}-linux-portable-arm64.zip
- name: Commit Files
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
# Optional but recommended
# Defaults to "Apply automatic changes"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v3.2
- uses: github/issue-labeler@v3.3
with:
configuration-path: .github/issue-labeler.yml
enable-versioned-regex: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
steps:
- uses: actions/labeler@v4
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/pr-labeler.yml
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: "yarn"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue is stale because it has been open 28 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
stale-pr-message: 'This PR is stale because it has been open 28 days with no activity. Remove stale label or comment or this will be closed in 14 days.'
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Please follow these guidelines before sending your pull request and making contr
* Please test your code. Make sure new features work as well as existing core features such as watching videos or loading subscriptions. New features need to work with both the Local API as well as the Invidious API
* Please make sure your code does not violate any standards set by our linter. It's up to you to make fixes whenever necessary. You can run `npm run lint` to check locally and `npm run lint-fix` to automatically fix smaller issues.
* Please limit the amount of Node Modules that you introduce into the project. Only include them when **absolutely necessary** for your code to work (Ex: Using nedb for databases) or if a module provides similar functionality to what you are trying to achieve (Ex: Using autolinker to create links to outside URLs instead of writing the functionality myself).
* Please try to stay involved with the community and maintain your code. We are only two developers working on FreeTube in our spare time. We do not have time to work on everything, and it would be nice if you can maintain your code when necessary.
* Please try to stay involved with the community and maintain your code. We are only a handful of developers working on FreeTube in our spare time. We do not have time to work on everything, and it would be nice if you can maintain your code when necessary.

# Setting up Your Environment

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ These builds are maintained by the community. While they should be safe, downloa

* FreeTubeCordova (FreeTube port for Android and PWA): [Download](https://github.com/MarmadileManteater/FreeTubeCordova/releases) and [Source Code](https://github.com/MarmadileManteater/FreeTubeCordova)

* Homebrew Formulae (Mac only): [Download](https://formulae.brew.sh/cask/freetube)

* makedeb Package Repository (MPR): [Download](https://mpr.makedeb.org/packages/freetube-bin)

* Nix Packages: [Download](https://search.nixos.org/packages?query=freetube)
Expand All @@ -99,6 +101,8 @@ These builds are maintained by the community. While they should be safe, downloa

* Snap: [Download](https://snapcraft.io/freetube) and [Source Code](https://git.launchpad.net/freetube)

* WAPT: [Download](https://wapt.tranquil.it/store/tis-freetube)

* Windows Package Manager (winget): [Usage](https://docs.microsoft.com/en-us/windows/package-manager/winget/)

## Contributing
Expand Down
110 changes: 72 additions & 38 deletions _scripts/ProcessLocalesPlugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { existsSync, readFileSync } = require('fs')
const { existsSync, readFileSync, statSync } = require('fs')
const { brotliCompress, constants } = require('zlib')
const { promisify } = require('util')
const { load: loadYaml } = require('js-yaml')
Expand All @@ -8,6 +8,7 @@ const brotliCompressAsync = promisify(brotliCompress)
class ProcessLocalesPlugin {
constructor(options = {}) {
this.compress = !!options.compress
this.isIncrementalBuild = false

if (typeof options.inputDir !== 'string') {
throw new Error('ProcessLocalesPlugin: no input directory `inputDir` specified.')
Expand All @@ -21,10 +22,11 @@ class ProcessLocalesPlugin {
}
this.outputDir = options.outputDir

this.locales = []
this.locales = {}
this.localeNames = []
this.activeLocales = []

this.cache = []
this.cache = {}

this.loadLocales()
}
Expand All @@ -37,66 +39,98 @@ class ProcessLocalesPlugin {

compilation.hooks.additionalAssets.tapPromise('process-locales-plugin', async (_assets) => {

// While running in the webpack dev server, this hook gets called for every incrememental build.
// While running in the webpack dev server, this hook gets called for every incremental build.
// For incremental builds we can return the already processed versions, which saves time
// and makes webpack treat them as cached
if (IS_DEV_SERVER && this.cache.length > 0) {
for (const { filename, source } of this.cache) {
compilation.emitAsset(filename, source, { minimized: true })
}
const promises = []
// Prevents `loadLocales` called twice on first time (e.g. release build)
if (this.isIncrementalBuild) {
this.loadLocales(true)
} else {
const promises = []
this.isIncrementalBuild = true
}

for (const { locale, data } of this.locales) {
promises.push(new Promise(async (resolve) => {
if (Object.prototype.hasOwnProperty.call(data, 'Locale Name')) {
delete data['Locale Name']
}
Object.values(this.locales).forEach((localeEntry) => {
const { locale, data, mtimeMs } = localeEntry

this.removeEmptyValues(data)
promises.push(new Promise(async (resolve) => {
if (IS_DEV_SERVER) {
const cacheEntry = this.cache[locale]

let filename = `${this.outputDir}/${locale}.json`
let output = JSON.stringify(data)
if (cacheEntry != null) {
const { filename, source, mtimeMs: cachedMtimeMs } = cacheEntry

if (this.compress) {
filename += '.br'
output = await this.compressLocale(output)
if (cachedMtimeMs === mtimeMs) {
compilation.emitAsset(filename, source, { minimized: true })
resolve()
return
}
}
}

let source = new RawSource(output)
if (Object.prototype.hasOwnProperty.call(data, 'Locale Name')) {
delete data['Locale Name']
}

if (IS_DEV_SERVER) {
source = new CachedSource(source)
this.cache.push({ filename, source })
}
this.removeEmptyValues(data)

compilation.emitAsset(filename, source, { minimized: true })
let filename = `${this.outputDir}/${locale}.json`
let output = JSON.stringify(data)

resolve()
}))
}
if (this.compress) {
filename += '.br'
output = await this.compressLocale(output)
}

let source = new RawSource(output)

if (IS_DEV_SERVER) {
source = new CachedSource(source)
this.cache[locale] = { filename, source, mtimeMs }
}

await Promise.all(promises)
compilation.emitAsset(filename, source, { minimized: true })

resolve()
}))

if (IS_DEV_SERVER) {
// we don't need the unmodified sources anymore, as we use the cache `this.cache`
// so we can clear this to free some memory
delete this.locales
delete localeEntry.data
}
}
})

await Promise.all(promises)
})
})
}

loadLocales() {
const activeLocales = JSON.parse(readFileSync(`${this.inputDir}/activeLocales.json`))
loadLocales(loadModifiedFilesOnly = false) {
if (this.activeLocales.length === 0) {
this.activeLocales = JSON.parse(readFileSync(`${this.inputDir}/activeLocales.json`))
}

for (const locale of activeLocales) {
const contents = readFileSync(`${this.inputDir}/${locale}.yaml`, 'utf-8')
for (const locale of this.activeLocales) {
const filePath = `${this.inputDir}/${locale}.yaml`
// Cannot use `mtime` since values never equal
const mtimeMsFromStats = statSync(filePath).mtimeMs
if (loadModifiedFilesOnly) {
// Skip reading files where mtime (modified time) same as last read
// (stored in mtime)
const existingMtime = this.locales[locale]?.mtimeMs
if (existingMtime != null && existingMtime === mtimeMsFromStats) {
continue
}
}
const contents = readFileSync(filePath, 'utf-8')
const data = loadYaml(contents)
this.locales[locale] = { locale, data, mtimeMs: mtimeMsFromStats }

this.localeNames.push(data['Locale Name'] ?? locale)
this.locales.push({ locale, data })
const localeName = data['Locale Name'] ?? locale
if (!loadModifiedFilesOnly) {
this.localeNames.push(localeName)
}
}
}

Expand Down
Loading

0 comments on commit ae27760

Please sign in to comment.