1
0
mirror of https://github.com/flarum/core.git synced 2025-08-13 20:04:24 +02:00

Compare commits

..

31 Commits

Author SHA1 Message Date
Daniël Klabbers
e478ea08d3 prettier is prettier 2022-06-30 08:59:34 +02:00
StyleCI Bot
24864e82dc Apply fixes from StyleCI 2022-06-29 13:37:42 +00:00
Daniël Klabbers
856bb8a0da reduced required query amount 2022-06-29 15:37:03 +02:00
Daniël Klabbers
f034fdd9f2 wip 2022-06-28 08:53:09 +02:00
flarum-bot
bbf90e42ff Bundled output for commit 0859bb13a5
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-06-21 15:36:15 +00:00
Daniël Klabbers
0859bb13a5 feature: adds advanced link handling in core (#3455)
* feature: adds advanced link handling in core

This PR adds rel and target to textformatter so that these can be easily extended and rendered into the source.

Without using the Extender the default values `ngc nofollow` are provided as a backward compatible way.

The new extender allows conditional overrides, a proof of concept extension is available at https://github.com/luceos/flarum-ext-dofollow; I will probably migrate this into the Blomstra namespace soon.

* Apply fixes from StyleCI

* fix typehints

* fix: mixed typehint is php 8+

Co-authored-by: StyleCI Bot <bot@styleci.io>
2022-06-21 17:32:23 +02:00
flarum-bot
62be3e01be Bundled output for commit 613523c9b4
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-06-20 15:57:13 +00:00
Sami Mazouz
613523c9b4 fix(tags): tag selection modal shown when no tags can be selected (#3448) 2022-06-20 16:53:11 +01:00
flarum-bot
3e56bd3dc6 Bundled output for commit 293e8ab8b6
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-06-20 12:06:42 +00:00
David Wheatley
293e8ab8b6 feat: support custom reusable setting components for buildSettingComponent (#3494) 2022-06-20 13:01:29 +01:00
David Wheatley
824fb2feff chore: enable and set up prettier for flarum/tags (#3496) 2022-06-20 13:00:01 +01:00
flarum-bot
4923253fbf Bundled output for commit 36c296d787
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-06-20 03:17:23 +00:00
David Wheatley
36c296d787 fix(a11y: DiscussionListItem): controls dropdown not visible when tabbed into (#3450) 2022-06-20 03:52:54 +01:00
David Wheatley
9fc2e5e2c0 fix(extension typings): remove some accessibility modifiers from Component (#3437) 2022-06-20 03:52:25 +01:00
David Wheatley
cb47a9c92e feat(translator): add locale getter (#3451) 2022-06-20 03:51:26 +01:00
Martin Hasoň
5dedec12f9 feat: return error code for failed CLI-based installs (#3452) 2022-06-20 03:50:38 +01:00
flarum-bot
5e81592e18 Bundled output for commit 74bcab866c
Includes transpiled JS/TS.

[skip ci]
2022-06-19 22:54:28 +00:00
Sami Mazouz
74bcab866c fix(suspend): suspension modal shows after suspension is over (#3449) 2022-06-19 23:51:29 +01:00
David Wheatley
1d949a3170 feat: split frontend asset generation into separate steps for more extensibility (#3446) 2022-06-19 22:58:05 +01:00
flarum-bot
79e0f44324 Bundled output for commit 976a03c9e5
Includes transpiled JS/TS.

[skip ci]
2022-06-19 21:30:47 +00:00
Sami Mazouz
976a03c9e5 fix: post mention notification errors with _no content_ subjects (#3493)
Co-authored-by: David Wheatley <hi@davwheat.dev>
2022-06-19 22:27:39 +01:00
SychO9
49ab6630d4 chore: run yarn-audit-fix 2022-06-19 20:16:55 +01:00
Sami Mazouz
27fb011bf5 chore: with yarn workspaces we only need a single yarn.lock (#3464)
* chore: yarn workspaces means we only need a single `yarn.lock`
* fix: add a `cache_dependency_path` workflow input
* fix: re-introduce `env.cache_dependency_path`
2022-06-19 19:01:21 +01:00
Sami Mazouz
6466427061 chore: move reusable workflows to monorepo (#3490) 2022-06-19 11:14:21 +01:00
flawedworld
818035f385 feat: split preloaded JSON payload and frontend boot into separate <script> tags (#3461) 2022-06-13 16:11:00 +01:00
flarum-bot
4748f31d93 Bundled output for commit e049e9d7ae
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-06-09 09:14:05 +00:00
Ian Morland
e049e9d7ae chore: add priorities to AdminNav (#3453) 2022-06-09 10:07:50 +01:00
Rafael Horvat
776f9bf132 feat: add automatic created/updated timestamps for various tables (#3435)
Adds timestamps for various tables:

- groups
- group_user
- group_permission
- tags
- discussion_tag
- post_mentions_post
- post_mentions_user
2022-06-07 20:35:27 +01:00
Daniël Klabbers
f882ff9bb5 update constant for 1.3.1 2022-06-07 14:34:51 +02:00
Daniël Klabbers
535052e3dc v1.3.1 release changelog 2022-06-07 10:53:23 +02:00
Sami Mazouz
c2ba3bb7d5 fix(subscriptions): reply notifications not working (#3445)
* chore: subscriptions backend test infrastructure

* test: reply notification

* fix: fix reply notifications not working
2022-06-03 21:06:30 +02:00
151 changed files with 3899 additions and 63486 deletions

112
.github/workflows/REUSABLE_backend.yml vendored Normal file
View File

@@ -0,0 +1,112 @@
name: Flarum Backend Jobs
on:
workflow_call:
inputs:
enable_backend_testing:
description: "Enable Backend Testing?"
type: boolean
default: true
required: false
backend_directory:
description: The directory of the project where backend code is located. This should contain a `composer.json` file, and is generally the root directory of the repo.
type: string
required: false
default: '.'
php_versions:
description: Versions of PHP to test with. Should be array of strings encoded as JSON array
type: string
required: false
default: '["7.4", "8.0", "8.1"]'
db_versions:
description: Versions of databases to test with. Should be array of strings encoded as JSON array
type: string
required: false
default: '["mysql:5.7", "mariadb"]'
php_ini_values:
description: PHP ini values
type: string
required: false
default: error_reporting=E_ALL
env:
COMPOSER_ROOT_VERSION: dev-main
FLARUM_TEST_TMP_DIR_LOCAL: tests/integration/tmp
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: ${{ fromJSON(inputs.php_versions) }}
service: ${{ fromJSON(inputs.db_versions) }}
prefix: ['', flarum_]
include:
- service: 'mysql:5.7'
db: MySQL
- service: mariadb
db: MariaDB
- prefix: flarum_
prefixStr: (prefix)
exclude:
- php: 8.0
service: 'mysql:5.7'
prefix: flarum_
- php: 8.0
service: mariadb
prefix: flarum_
services:
mysql:
image: ${{ matrix.service }}
ports:
- 13306:3306
name: 'PHP ${{ matrix.php }} / ${{ matrix.db }} ${{ matrix.prefixStr }}'
if: inputs.enable_backend_testing
steps:
- uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
tools: phpunit, composer:v2
ini-values: ${{ inputs.php_ini_values }}
# The authentication alter is necessary because newer mysql versions use the `caching_sha2_password` driver,
# which isn't supported prior to PHP7.4
# When we drop support for PHP7.3, we should remove this from the setup.
- name: Create MySQL Database
run: |
sudo systemctl start mysql
mysql -uroot -proot -e 'CREATE DATABASE flarum_test;' --port 13306
mysql -uroot -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" --port 13306
- name: Install Composer dependencies
run: composer install
working-directory: ${{ inputs.backend_directory }}
- name: Setup Composer tests
run: composer test:setup
working-directory: ${{ inputs.backend_directory }}
env:
DB_PORT: 13306
DB_PASSWORD: root
DB_PREFIX: ${{ matrix.prefix }}
- name: Run Composer tests
run: composer test
working-directory: ${{ inputs.backend_directory }}
env:
COMPOSER_PROCESS_TIMEOUT: 600

220
.github/workflows/REUSABLE_frontend.yml vendored Normal file
View File

@@ -0,0 +1,220 @@
name: Flarum Frontend Jobs
on:
workflow_call:
inputs:
enable_bundlewatch:
description: "Enable Bundlewatch?"
type: boolean
default: false
required: false
enable_prettier:
description: "Enable Prettier?"
type: boolean
default: true
required: false
enable_typescript:
description: "Enable TypeScript?"
type: boolean
default: true
required: false
backend_directory:
description: The directory of the project where backend code is located. This should contain a `composer.json` file, and is generally the root directory of the repo.
type: string
required: false
default: '.'
frontend_directory:
description: The directory of the project where frontend code is located. This should contain a `package.json` file.
type: string
required: false
default: './js'
main_git_branch:
description: The main git branch to use for the workflow.
type: string
required: false
default: main
node_version:
description: The node version to use for the workflow.
type: number
required: false
default: 16
js_package_manager:
description: "Enable TypeScript?"
type: string
default: yarn
required: false
cache_dependency_path:
description: "The path to the cache dependency file."
type: string
required: false
secrets:
bundlewatch_github_token:
description: The GitHub token to use for Bundlewatch.
required: false
env:
COMPOSER_ROOT_VERSION: dev-main
ci_script: ${{ inputs.js_package_manager == 'yarn' && 'yarn install --immutable' || 'npm ci' }}
cache_dependency_path: ${{ inputs.cache_dependency_path || format(inputs.js_package_manager == 'yarn' && '{0}/yarn.lock' || '{0}/package-lock.json', inputs.frontend_directory) }}
jobs:
bundlewatch:
name: Bundlewatch
runs-on: ubuntu-latest
if: inputs.enable_bundlewatch
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node_version }}
cache: ${{ inputs.js_package_manager }}
cache-dependency-path: ${{ env.cache_dependency_path }}
- name: Build production assets
uses: flarum/action-build@2
with:
github_token: ${{ secrets.github_token }}
build_script: build
package_manager: ${{ inputs.js_package_manager }}
js_path: ${{ inputs.frontend_directory }}
do_not_commit: true
- name: Check bundle size change
run: node_modules/.bin/bundlewatch --config .bundlewatch.config.json
working-directory: ${{ inputs.frontend_directory }}
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.bundlewatch_github_token }}
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
prettier:
name: Prettier
runs-on: ubuntu-latest
if: inputs.enable_prettier
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node_version }}
cache: ${{ inputs.js_package_manager }}
cache-dependency-path: ${{ env.cache_dependency_path }}
- name: Install JS dependencies
run: ${{ env.ci_script }}
working-directory: ${{ inputs.frontend_directory }}
- name: Check JS formatting
run: ${{ inputs.js_package_manager }} run format-check
working-directory: ${{ inputs.frontend_directory }}
typecheck:
name: Typecheck
runs-on: ubuntu-latest
if: inputs.enable_typescript
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node_version }}
cache: ${{ inputs.js_package_manager }}
cache-dependency-path: ${{ env.cache_dependency_path }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: curl, dom, gd, json, mbstring, openssl, pdo_mysql, tokenizer, zip
tools: composer:v2
# Needed since tsconfig draws typings from vendor folder.
- name: Install Composer dependencies
run: composer install
working-directory: ${{ inputs.backend_directory }}
- name: Install JS dependencies
run: ${{ env.ci_script }}
working-directory: ${{ inputs.frontend_directory }}
- name: Typecheck
run: ${{ inputs.js_package_manager }} run check-typings
working-directory: ${{ inputs.frontend_directory }}
type-coverage:
name: Type Coverage
runs-on: ubuntu-latest
if: inputs.enable_typescript
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node_version }}
cache: ${{ inputs.js_package_manager }}
cache-dependency-path: ${{ env.cache_dependency_path }}
- name: Install JS dependencies
run: ${{ env.ci_script }}
working-directory: ${{ inputs.frontend_directory }}
- name: Check type coverage
run: ${{ inputs.js_package_manager }} run check-typings-coverage
working-directory: ${{ inputs.frontend_directory }}
build:
name: Build
runs-on: ubuntu-latest
if: "always() && !contains(needs.*.result, 'failed') && !contains(needs.*.result, 'cancelled')"
needs: [bundlewatch, prettier, typecheck, type-coverage]
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: ${{ inputs.node_version }}
cache: ${{ inputs.js_package_manager }}
cache-dependency-path: ${{ env.cache_dependency_path }}
# Our action will install npm/yarn, cd into `${{ inputs.frontend_directory }}`, build dist JS and typings,
# then commit and upload any changes iff we are on the main branch and have just pushed.
- name: Build production JS
if: inputs.enable_typescript
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: ${{ inputs.js_package_manager }}
typings_script: build-typings
js_path: ${{ inputs.frontend_directory }}
do_not_commit: ${{ github.ref != format('refs/heads/{0}', inputs.main_git_branch) || github.event_name != 'push' }}
# Our action will install npm/yarn, cd into `${{ inputs.frontend_directory }}`, build dist JS and typings,
# then commit and upload any changes iff we are on the main branch and have just pushed.
- name: Build production JS
if: "! inputs.enable_typescript"
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: ${{ inputs.js_package_manager }}
js_path: ${{ inputs.frontend_directory }}
do_not_commit: ${{ github.ref != format('refs/heads/{0}', inputs.main_git_branch) || github.event_name != 'push' }}

View File

@@ -2,13 +2,9 @@ name: Akismet PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true

View File

@@ -2,13 +2,9 @@ name: Akismet JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/akismet/js
backend_directory: ./extensions/akismet
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Approval PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Approval JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/approval/js
backend_directory: ./extensions/approval
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Core PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true

View File

@@ -2,13 +2,9 @@ name: Core JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: true
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./framework/core/js
backend_directory: ./framework/core
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Embed PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Embed JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/embed/js
backend_directory: ./extensions/embed
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Emoji PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Emoji JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/emoji/js
backend_directory: ./extensions/emoji
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Flags PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true

View File

@@ -2,13 +2,9 @@ name: Flags JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/flags/js
backend_directory: ./extensions/flags
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Likes PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Likes JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/likes/js
backend_directory: ./extensions/likes
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Lock PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Lock JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/lock/js
backend_directory: ./extensions/lock
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Markdown PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Markdown JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/markdown/js
backend_directory: ./extensions/markdown
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Mentions PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true

View File

@@ -2,13 +2,9 @@ name: Mentions JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/mentions/js
backend_directory: ./extensions/mentions
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Nicknames PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true

View File

@@ -2,13 +2,9 @@ name: Nicknames JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/nicknames/js
backend_directory: ./extensions/nicknames
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Package Manager PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true

View File

@@ -2,13 +2,9 @@ name: Package Manager JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/package-manager/js
backend_directory: ./extensions/package-manager
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Pusher PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Pusher JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/pusher/js
backend_directory: ./extensions/pusher
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Statistics PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true

View File

@@ -2,13 +2,9 @@ name: Statistics JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/statistics/js
backend_directory: ./extensions/statistics
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Sticky PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Sticky JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/sticky/js
backend_directory: ./extensions/sticky
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Subscriptions PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Subscriptions JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/subscriptions/js
backend_directory: ./extensions/subscriptions
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Suspend PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: false

View File

@@ -2,13 +2,9 @@ name: Suspend JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: true
@@ -17,6 +13,7 @@ jobs:
frontend_directory: ./extensions/suspend/js
backend_directory: ./extensions/suspend
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:

View File

@@ -2,13 +2,9 @@ name: Tags PHP
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_backend.yml@main
uses: ./.github/workflows/REUSABLE_backend.yml
with:
enable_backend_testing: true

View File

@@ -2,21 +2,18 @@ name: Tags JS
on: [workflow_dispatch, push, pull_request]
# The reusable workflow definitions will be moved to the `flarum/framework` repo soon.
# This will break your current script.
# When this happens, run `flarum-cli audit infra --fix` to update your infrastructure.
jobs:
run:
uses: flarum/.github/.github/workflows/REUSABLE_frontend.yml@main
uses: ./.github/workflows/REUSABLE_frontend.yml
with:
enable_bundlewatch: false
enable_prettier: false
enable_prettier: true
enable_typescript: true
frontend_directory: ./extensions/tags/js
backend_directory: ./extensions/tags
js_package_manager: yarn
cache_dependency_path: ./yarn.lock
main_git_branch: main
secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}

View File

@@ -1,5 +1,19 @@
# Changelog
## [1.3.1](https://github.com/flarum/framework/compare/v1.3.0...v1.3.1)
### Changed
- UserCard now has ItemList for easier extending (https://github.com/flarum/framework/pull/3436)
### Fixed
- Button to go directly to all results page is hidden while API request for search hasn't completed (https://github.com/flarum/framework/pull/3431)
- Setting extender does not register modifications beyond first fluent call (https://github.com/flarum/framework/pull/3439)
- Link to font awesome icons list no longer works (https://github.com/flarum/framework/commit/df1bdd2ad84e992414c0e1e7be576558b4b0fe29)
- Mentions: mentions with deleted authors not showing (https://github.com/flarum/framework/pull/3432)
- Nicknames: regex validation isn't functional (https://github.com/flarum/framework/pull/3430)
- Subscriptions: reply notifications not working (https://github.com/flarum/framework/pull/3445)
- Suspend: not providing suspension reason breaks mail (https://github.com/flarum/framework/pull/3433)
<!-- One-time commit-based diff due to monorepo rework. Diffing against the 1.2.1 tag doesn't work due to unrelated histories. -->
## [1.3.0](https://github.com/flarum/framework/compare/33d939cb012716ed6309ea02236737ad4f25a75b...v1.3.0)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -7,14 +7,12 @@
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Likes;
use Flarum\Api\Controller;
use Flarum\Api\Serializer\BasicUserSerializer;
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Extend;
use Flarum\Likes\Event\PostWasLiked;
use Flarum\Likes\Event\PostWasUnliked;
use Flarum\Likes\Listener;
use Flarum\Likes\Notification\PostLikedBlueprint;
use Flarum\Post\Event\Deleted;
use Flarum\Post\Event\Saving;
use Flarum\Post\Post;
@@ -29,34 +27,54 @@ return [
->js(__DIR__.'/js/dist/admin.js'),
(new Extend\Model(Post::class))
->belongsToMany('likes', User::class, 'post_likes', 'post_id', 'user_id'),
->belongsToMany('likes', User::class, 'post_likes', 'post_id', 'user_id')
->relationship('recentLikes', Model\RecentLikesRelationship::class),
new Extend\Locales(__DIR__.'/locale'),
(new Extend\Notification())
->type(PostLikedBlueprint::class, PostSerializer::class, ['alert']),
->type(Notification\PostLikedBlueprint::class, PostSerializer::class, ['alert']),
(new Extend\ApiSerializer(PostSerializer::class))
->relationship('recentLikes', Api\RecentLikesRelationship::class)
->attributes(function (PostSerializer $serializer, $model, $attributes) {
$actor = $serializer->getActor();
$model->loadCount('likes');
$attributes['likesCount'] = $model->likes_count;
$attributes['likedByActor'] = $actor && $model->likes()->where('id', $actor->id)->exists();
return $attributes;
})
->hasMany('likes', BasicUserSerializer::class)
->attribute('canLike', function (PostSerializer $serializer, $model) {
return (bool) $serializer->getActor()->can('like', $model);
return $serializer->getActor()->can('like', $model);
}),
(new Extend\ApiController(Controller\ShowDiscussionController::class))
->addInclude('posts.likes'),
->addOptionalInclude('posts.likes')
->addInclude('posts.recentLikes')
->load('posts.recentLikes'),
(new Extend\ApiController(Controller\ListPostsController::class))
->addInclude('likes'),
->addOptionalInclude('likes')
->addInclude('recentLikes')
->load('posts.recentLikes'),
(new Extend\ApiController(Controller\ShowPostController::class))
->addInclude('likes'),
->addOptionalInclude('likes')
->addInclude('recentLikes')
->load('posts.recentLikes'),
(new Extend\ApiController(Controller\CreatePostController::class))
->addInclude('likes'),
->addOptionalInclude('likes')
->addInclude('recentLikes')
->load('posts.recentLikes'),
(new Extend\ApiController(Controller\UpdatePostController::class))
->addInclude('likes'),
->addOptionalInclude('likes')
->addInclude('recentLikes')
->load('posts.recentLikes'),
(new Extend\Event())
->listen(PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class)
->listen(PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class)
->listen(Event\PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class)
->listen(Event\PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class)
->listen(Deleted::class, [Listener\SaveLikesToDatabase::class, 'whenPostIsDeleted'])
->listen(Saving::class, [Listener\SaveLikesToDatabase::class, 'whenPostIsSaving']),
];

120
extensions/likes/js/dist/admin.js generated vendored
View File

@@ -1,2 +1,120 @@
(()=>{var e={n:r=>{var o=r&&r.__esModule?()=>r.default:()=>r;return e.d(o,{a:o}),o},d:(r,o)=>{for(var t in o)e.o(o,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:o[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};(()=>{"use strict";e.r(r);const o=flarum.core.compat["admin/app"];var t=e.n(o);t().initializers.add("flarum-likes",(function(){t().extensionData.for("flarum-likes").registerPermission({icon:"far fa-thumbs-up",label:t().translator.trans("flarum-likes.admin.permissions.like_posts_label"),permission:"discussion.likePosts"},"reply")}))})(),module.exports=r})();
/******/ (() => { // webpackBootstrap
/******/ // runtime can't be in strict mode because a global variable is assign and maybe created.
/******/ var __webpack_modules__ = ({
/***/ "./src/admin/index.js":
/*!****************************!*\
!*** ./src/admin/index.js ***!
\****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var flarum_admin_app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/admin/app */ "flarum/admin/app");
/* harmony import */ var flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_admin_app__WEBPACK_IMPORTED_MODULE_0__);
flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('flarum-likes', function () {
flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().extensionData["for"]('flarum-likes').registerPermission({
icon: 'far fa-thumbs-up',
label: flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('flarum-likes.admin.permissions.like_posts_label'),
permission: 'discussion.likePosts'
}, 'reply');
});
/***/ }),
/***/ "flarum/admin/app":
/*!**************************************************!*\
!*** external "flarum.core.compat['admin/app']" ***!
\**************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['admin/app'];
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
(() => {
"use strict";
/*!******************!*\
!*** ./admin.js ***!
\******************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _src_admin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/admin */ "./src/admin/index.js");
})();
module.exports = __webpack_exports__;
/******/ })()
;
//# sourceMappingURL=admin.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"admin.js","mappings":"MACA,IAAIA,EAAsB,CCA1BA,EAAyBC,IACxB,IAAIC,EAASD,GAAUA,EAAOE,WAC7B,IAAOF,EAAiB,QACxB,IAAM,EAEP,OADAD,EAAoBI,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,GCLRF,EAAwB,CAACM,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXP,EAAoBS,EAAEF,EAAYC,KAASR,EAAoBS,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3ER,EAAwB,CAACc,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFf,EAAyBM,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,M,+BCLvD,MAAM,EAA+BC,OAAOC,KAAKC,OAAO,a,aCExDC,IAAAA,aAAAA,IAAqB,gBAAgB,WACnCA,IAAAA,cAAAA,IAAsB,gBAAgBC,mBACpC,CACEC,KAAM,mBACNC,MAAOH,IAAAA,WAAAA,MAAqB,mDAC5BI,WAAY,wBAEd,a","sources":["webpack://@flarum/likes/webpack/bootstrap","webpack://@flarum/likes/webpack/runtime/compat get default export","webpack://@flarum/likes/webpack/runtime/define property getters","webpack://@flarum/likes/webpack/runtime/hasOwnProperty shorthand","webpack://@flarum/likes/webpack/runtime/make namespace object","webpack://@flarum/likes/external root \"flarum.core.compat['admin/app']\"","webpack://@flarum/likes/./src/admin/index.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = flarum.core.compat['admin/app'];","import app from 'flarum/admin/app';\n\napp.initializers.add('flarum-likes', () => {\n app.extensionData.for('flarum-likes').registerPermission(\n {\n icon: 'far fa-thumbs-up',\n label: app.translator.trans('flarum-likes.admin.permissions.like_posts_label'),\n permission: 'discussion.likePosts',\n },\n 'reply'\n );\n});\n"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","flarum","core","compat","app","registerPermission","icon","label","permission"],"sourceRoot":""}
{"version":3,"file":"admin.js","mappings":";;;;;;;;;;;;;;AAAA;AAEAA,wEAAA,CAAqB,cAArB,EAAqC,YAAM;AACzCA,EAAAA,4EAAA,CAAsB,cAAtB,EAAsCI,kBAAtC,CACE;AACEC,IAAAA,IAAI,EAAE,kBADR;AAEEC,IAAAA,KAAK,EAAEN,wEAAA,CAAqB,iDAArB,CAFT;AAGES,IAAAA,UAAU,EAAE;AAHd,GADF,EAME,OANF;AAQD,CATD;;;;;;;;;;;ACFA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D","sources":["webpack://@flarum/likes/./src/admin/index.js","webpack://@flarum/likes/external root \"flarum.core.compat['admin/app']\"","webpack://@flarum/likes/webpack/bootstrap","webpack://@flarum/likes/webpack/runtime/compat get default export","webpack://@flarum/likes/webpack/runtime/define property getters","webpack://@flarum/likes/webpack/runtime/hasOwnProperty shorthand","webpack://@flarum/likes/webpack/runtime/make namespace object","webpack://@flarum/likes/./admin.js"],"sourcesContent":["import app from 'flarum/admin/app';\n\napp.initializers.add('flarum-likes', () => {\n app.extensionData.for('flarum-likes').registerPermission(\n {\n icon: 'far fa-thumbs-up',\n label: app.translator.trans('flarum-likes.admin.permissions.like_posts_label'),\n permission: 'discussion.likePosts',\n },\n 'reply'\n );\n});\n","module.exports = flarum.core.compat['admin/app'];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './src/admin';\n"],"names":["app","initializers","add","extensionData","registerPermission","icon","label","translator","trans","permission"],"sourceRoot":""}

622
extensions/likes/js/dist/forum.js generated vendored
View File

@@ -1,2 +1,622 @@
(()=>{var t={n:o=>{var n=o&&o.__esModule?()=>o.default:()=>o;return t.d(n,{a:n}),n},d:(o,n)=>{for(var e in n)t.o(n,e)&&!t.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:n[e]})},o:(t,o)=>Object.prototype.hasOwnProperty.call(t,o),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};(()=>{"use strict";t.r(o);const n=flarum.core.compat["common/extend"],e=flarum.core.compat["forum/app"];var r=t.n(e);const s=flarum.core.compat["common/models/Post"];var a=t.n(s);const i=flarum.core.compat["common/Model"];var c=t.n(i);const u=flarum.core.compat["forum/components/NotificationGrid"];var l=t.n(u);const f=flarum.core.compat["common/components/Button"];var p=t.n(f);const d=flarum.core.compat["forum/components/CommentPost"];var k=t.n(d);const h=flarum.core.compat["common/components/Link"];var v=t.n(h);const y=flarum.core.compat["common/helpers/punctuateSeries"];var _=t.n(y);const b=flarum.core.compat["common/helpers/username"];var g=t.n(b);const P=flarum.core.compat["common/helpers/icon"];var L=t.n(P);function M(t,o){return M=Object.setPrototypeOf||function(t,o){return t.__proto__=o,t},M(t,o)}function x(t,o){t.prototype=Object.create(o.prototype),t.prototype.constructor=t,M(t,o)}const j=flarum.core.compat["common/components/Modal"];var O=t.n(j);const N=flarum.core.compat["common/helpers/avatar"];var S=t.n(N),B=function(t){function o(){return t.apply(this,arguments)||this}x(o,t);var n=o.prototype;return n.className=function(){return"PostLikesModal Modal--small"},n.title=function(){return r().translator.trans("flarum-likes.forum.post_likes.title")},n.content=function(){return m("div",{className:"Modal-body"},m("ul",{className:"PostLikesModal-list"},this.attrs.post.likes().map((function(t){return m("li",null,m(v(),{href:r().route.user(t)},S()(t)," ",g()(t)))}))))},o}(O());const T=flarum.core.compat["forum/components/Notification"];var w=t.n(T);const C=flarum.core.compat["common/utils/string"];var I=function(t){function o(){return t.apply(this,arguments)||this}x(o,t);var n=o.prototype;return n.icon=function(){return"far fa-thumbs-up"},n.href=function(){return r().route.post(this.attrs.notification.subject())},n.content=function(){var t=this.attrs.notification.fromUser();return r().translator.trans("flarum-likes.forum.notifications.post_liked_text",{user:t,count:1})},n.excerpt=function(){return(0,C.truncate)(this.attrs.notification.subject().contentPlain(),200)},o}(w());r().initializers.add("flarum-likes",(function(){r().notificationComponents.postLiked=I,a().prototype.canLike=c().attribute("canLike"),a().prototype.likes=c().hasMany("likes"),(0,n.extend)(k().prototype,"actionItems",(function(t){var o=this.attrs.post;if(!o.isHidden()&&o.canLike()){var n=o.likes(),e=r().session.user&&n&&n.some((function(t){return t===r().session.user}));t.add("like",p().component({className:"Button Button--link",onclick:function(){e=!e,o.save({isLiked:e});var t=o.data.relationships.likes.data;t.some((function(o,n){if(o.id===r().session.user.id())return t.splice(n,1),!0})),e&&t.unshift({type:"users",id:r().session.user.id()})}},r().translator.trans(e?"flarum-likes.forum.post.unlike_link":"flarum-likes.forum.post.like_link")))}})),(0,n.extend)(k().prototype,"footerItems",(function(t){var o=this.attrs.post,n=o.likes();if(n&&n.length){var e=n.length>4,s=n.sort((function(t){return t===r().session.user?-1:1})).slice(0,e?3:4).map((function(t){return m(v(),{href:r().route.user(t)},t===r().session.user?r().translator.trans("flarum-likes.forum.post.you_text"):g()(t))}));if(e){var a=n.length-s.length;s.push(m("a",{href:"#",onclick:function(t){t.preventDefault(),r().modal.show(B,{post:o})}},r().translator.trans("flarum-likes.forum.post.others_link",{count:a})))}t.add("liked",m("div",{className:"Post-likedBy"},L()("far fa-thumbs-up"),r().translator.trans("flarum-likes.forum.post.liked_by"+(n[0]===r().session.user?"_self":"")+"_text",{count:s.length,users:_()(s)})))}})),(0,n.extend)(l().prototype,"notificationTypes",(function(t){t.add("postLiked",{name:"postLiked",icon:"far fa-thumbs-up",label:r().translator.trans("flarum-likes.forum.settings.notify_post_liked_label")})}))}))})(),module.exports=o})();
/******/ (() => { // webpackBootstrap
/******/ // runtime can't be in strict mode because a global variable is assign and maybe created.
/******/ var __webpack_modules__ = ({
/***/ "./src/forum/addLikeAction.js":
/*!************************************!*\
!*** ./src/forum/addLikeAction.js ***!
\************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/common/extend */ "flarum/common/extend");
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var flarum_common_components_Button__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/common/components/Button */ "flarum/common/components/Button");
/* harmony import */ var flarum_common_components_Button__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_common_components_Button__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/forum/components/CommentPost */ "flarum/forum/components/CommentPost");
/* harmony import */ var flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_3__);
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
(0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__.extend)((flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_3___default().prototype), 'actionItems', function (items) {
var post = this.attrs.post;
if (post.isHidden() || !post.canLike()) return;
var likes = post.likes();
var isLiked = (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user) && likes && likes.some(function (user) {
return user === (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user);
});
items.add('like', flarum_common_components_Button__WEBPACK_IMPORTED_MODULE_2___default().component({
className: 'Button Button--link',
onclick: function onclick() {
isLiked = !isLiked;
post.save({
isLiked: isLiked
}); // We've saved the fact that we do or don't like the post, but in order
// to provide instantaneous feedback to the user, we'll need to add or
// remove the like from the relationship data manually.
var data = post.data.relationships.likes.data;
data.some(function (like, i) {
if (like.id === flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user.id()) {
data.splice(i, 1);
return true;
}
});
if (isLiked) {
data.unshift({
type: 'users',
id: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user.id()
});
}
}
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans(isLiked ? 'flarum-likes.forum.post.unlike_link' : 'flarum-likes.forum.post.like_link')));
});
}
/***/ }),
/***/ "./src/forum/addLikesList.js":
/*!***********************************!*\
!*** ./src/forum/addLikesList.js ***!
\***********************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/common/extend */ "flarum/common/extend");
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/forum/components/CommentPost */ "flarum/forum/components/CommentPost");
/* harmony import */ var flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/common/components/Link */ "flarum/common/components/Link");
/* harmony import */ var flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var flarum_common_helpers_punctuateSeries__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! flarum/common/helpers/punctuateSeries */ "flarum/common/helpers/punctuateSeries");
/* harmony import */ var flarum_common_helpers_punctuateSeries__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_punctuateSeries__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! flarum/common/helpers/username */ "flarum/common/helpers/username");
/* harmony import */ var flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var flarum_common_helpers_icon__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! flarum/common/helpers/icon */ "flarum/common/helpers/icon");
/* harmony import */ var flarum_common_helpers_icon__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_icon__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _components_PostLikesModal__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components/PostLikesModal */ "./src/forum/components/PostLikesModal.js");
/* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
(0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__.extend)((flarum_forum_components_CommentPost__WEBPACK_IMPORTED_MODULE_2___default().prototype), 'footerItems', function (items) {
var post = this.attrs.post;
var likes = post.recentLikes();
var count = post.likesCount();
if (likes && likes.length) {
// the limit is dynamic through the backend, we only load those we need
var limit = likes.length; // overLimit indicates there are more likes than the ones we render (and load)
var overLimit = count > likes.length; // Construct a list of names of users who have liked this post. Make sure the
// current user is first in the list, and cap a maximum of 4 items.
var names = likes.filter(function (a) {
return a !== (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user);
}).slice(0, limit).map(function (user) {
return m((flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default()), {
href: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().route.user(user)
}, user === (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user) ? flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post.you_text') : flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5___default()(user));
});
if (post.likedByActor()) {
names.unshift(m((flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default()), {
href: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().route.user((flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user))
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post.you_text')));
} // If there are more users that we've run out of room to display, add a "x
// others" name to the end of the list. Clicking on it will display a modal
// with a full list of names.
if (overLimit) {
names.push(m("a", {
href: "#",
onclick: function onclick(e) {
e.preventDefault();
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().modal.show(_components_PostLikesModal__WEBPACK_IMPORTED_MODULE_7__["default"], {
post: post
});
}
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post.others_link', {
count: count - likes.length
})));
}
items.add('liked', m("div", {
className: "Post-likedBy"
}, flarum_common_helpers_icon__WEBPACK_IMPORTED_MODULE_6___default()('far fa-thumbs-up'), flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post.liked_by' + (likes[0] === (flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().session.user) ? '_self' : '') + '_text', {
count: names.length,
users: flarum_common_helpers_punctuateSeries__WEBPACK_IMPORTED_MODULE_4___default()(names)
})));
}
});
}
/***/ }),
/***/ "./src/forum/components/PostLikedNotification.js":
/*!*******************************************************!*\
!*** ./src/forum/components/PostLikedNotification.js ***!
\*******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ PostLikedNotification)
/* harmony export */ });
/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "../../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js");
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var flarum_forum_components_Notification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/forum/components/Notification */ "flarum/forum/components/Notification");
/* harmony import */ var flarum_forum_components_Notification__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_components_Notification__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var flarum_common_utils_string__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/common/utils/string */ "flarum/common/utils/string");
/* harmony import */ var flarum_common_utils_string__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_common_utils_string__WEBPACK_IMPORTED_MODULE_3__);
var PostLikedNotification = /*#__PURE__*/function (_Notification) {
(0,_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(PostLikedNotification, _Notification);
function PostLikedNotification() {
return _Notification.apply(this, arguments) || this;
}
var _proto = PostLikedNotification.prototype;
_proto.icon = function icon() {
return 'far fa-thumbs-up';
};
_proto.href = function href() {
return flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().route.post(this.attrs.notification.subject());
};
_proto.content = function content() {
var notification = this.attrs.notification;
var user = notification.fromUser();
return flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.notifications.post_liked_text', {
user: user,
count: 1
});
};
_proto.excerpt = function excerpt() {
return (0,flarum_common_utils_string__WEBPACK_IMPORTED_MODULE_3__.truncate)(this.attrs.notification.subject().contentPlain(), 200);
};
return PostLikedNotification;
}((flarum_forum_components_Notification__WEBPACK_IMPORTED_MODULE_2___default()));
/***/ }),
/***/ "./src/forum/components/PostLikesModal.js":
/*!************************************************!*\
!*** ./src/forum/components/PostLikesModal.js ***!
\************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ PostLikesModal)
/* harmony export */ });
/* harmony import */ var _babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/esm/inheritsLoose */ "../../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js");
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var flarum_common_components_Modal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/common/components/Modal */ "flarum/common/components/Modal");
/* harmony import */ var flarum_common_components_Modal__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_common_components_Modal__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/common/components/Link */ "flarum/common/components/Link");
/* harmony import */ var flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var flarum_common_helpers_avatar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! flarum/common/helpers/avatar */ "flarum/common/helpers/avatar");
/* harmony import */ var flarum_common_helpers_avatar__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_avatar__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! flarum/common/helpers/username */ "flarum/common/helpers/username");
/* harmony import */ var flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5__);
var PostLikesModal = /*#__PURE__*/function (_Modal) {
(0,_babel_runtime_helpers_esm_inheritsLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(PostLikesModal, _Modal);
function PostLikesModal() {
return _Modal.apply(this, arguments) || this;
}
var _proto = PostLikesModal.prototype;
_proto.className = function className() {
return 'PostLikesModal Modal--small';
};
_proto.title = function title() {
return flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.post_likes.title');
};
_proto.content = function content() {
return m("div", {
className: "Modal-body"
}, m("ul", {
className: "PostLikesModal-list"
}, this.attrs.post.likes().map(function (user) {
return m("li", null, m((flarum_common_components_Link__WEBPACK_IMPORTED_MODULE_3___default()), {
href: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().route.user(user)
}, flarum_common_helpers_avatar__WEBPACK_IMPORTED_MODULE_4___default()(user), " ", flarum_common_helpers_username__WEBPACK_IMPORTED_MODULE_5___default()(user)));
})));
};
return PostLikesModal;
}((flarum_common_components_Modal__WEBPACK_IMPORTED_MODULE_2___default()));
/***/ }),
/***/ "./src/forum/index.js":
/*!****************************!*\
!*** ./src/forum/index.js ***!
\****************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! flarum/common/extend */ "flarum/common/extend");
/* harmony import */ var flarum_common_extend__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flarum/forum/app */ "flarum/forum/app");
/* harmony import */ var flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flarum/common/models/Post */ "flarum/common/models/Post");
/* harmony import */ var flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var flarum_common_Model__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! flarum/common/Model */ "flarum/common/Model");
/* harmony import */ var flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(flarum_common_Model__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var flarum_forum_components_NotificationGrid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! flarum/forum/components/NotificationGrid */ "flarum/forum/components/NotificationGrid");
/* harmony import */ var flarum_forum_components_NotificationGrid__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(flarum_forum_components_NotificationGrid__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _addLikeAction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./addLikeAction */ "./src/forum/addLikeAction.js");
/* harmony import */ var _addLikesList__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./addLikesList */ "./src/forum/addLikesList.js");
/* harmony import */ var _components_PostLikedNotification__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./components/PostLikedNotification */ "./src/forum/components/PostLikedNotification.js");
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().initializers.add('flarum-likes', function () {
(flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().notificationComponents.postLiked) = _components_PostLikedNotification__WEBPACK_IMPORTED_MODULE_7__["default"];
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.canLike) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().attribute('canLike');
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.likes) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().hasMany('likes');
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.likesCount) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().attribute('likesCount');
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.recentLikes) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().hasMany('recentLikes');
(flarum_common_models_Post__WEBPACK_IMPORTED_MODULE_2___default().prototype.likedByActor) = flarum_common_Model__WEBPACK_IMPORTED_MODULE_3___default().attribute('likedByActor');
(0,_addLikeAction__WEBPACK_IMPORTED_MODULE_5__["default"])();
(0,_addLikesList__WEBPACK_IMPORTED_MODULE_6__["default"])();
(0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_0__.extend)((flarum_forum_components_NotificationGrid__WEBPACK_IMPORTED_MODULE_4___default().prototype), 'notificationTypes', function (items) {
items.add('postLiked', {
name: 'postLiked',
icon: 'far fa-thumbs-up',
label: flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('flarum-likes.forum.settings.notify_post_liked_label')
});
});
});
/***/ }),
/***/ "flarum/common/Model":
/*!*****************************************************!*\
!*** external "flarum.core.compat['common/Model']" ***!
\*****************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/Model'];
/***/ }),
/***/ "flarum/common/components/Button":
/*!*****************************************************************!*\
!*** external "flarum.core.compat['common/components/Button']" ***!
\*****************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/components/Button'];
/***/ }),
/***/ "flarum/common/components/Link":
/*!***************************************************************!*\
!*** external "flarum.core.compat['common/components/Link']" ***!
\***************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/components/Link'];
/***/ }),
/***/ "flarum/common/components/Modal":
/*!****************************************************************!*\
!*** external "flarum.core.compat['common/components/Modal']" ***!
\****************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/components/Modal'];
/***/ }),
/***/ "flarum/common/extend":
/*!******************************************************!*\
!*** external "flarum.core.compat['common/extend']" ***!
\******************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/extend'];
/***/ }),
/***/ "flarum/common/helpers/avatar":
/*!**************************************************************!*\
!*** external "flarum.core.compat['common/helpers/avatar']" ***!
\**************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/helpers/avatar'];
/***/ }),
/***/ "flarum/common/helpers/icon":
/*!************************************************************!*\
!*** external "flarum.core.compat['common/helpers/icon']" ***!
\************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/helpers/icon'];
/***/ }),
/***/ "flarum/common/helpers/punctuateSeries":
/*!***********************************************************************!*\
!*** external "flarum.core.compat['common/helpers/punctuateSeries']" ***!
\***********************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/helpers/punctuateSeries'];
/***/ }),
/***/ "flarum/common/helpers/username":
/*!****************************************************************!*\
!*** external "flarum.core.compat['common/helpers/username']" ***!
\****************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/helpers/username'];
/***/ }),
/***/ "flarum/common/models/Post":
/*!***********************************************************!*\
!*** external "flarum.core.compat['common/models/Post']" ***!
\***********************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/models/Post'];
/***/ }),
/***/ "flarum/common/utils/string":
/*!************************************************************!*\
!*** external "flarum.core.compat['common/utils/string']" ***!
\************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['common/utils/string'];
/***/ }),
/***/ "flarum/forum/app":
/*!**************************************************!*\
!*** external "flarum.core.compat['forum/app']" ***!
\**************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['forum/app'];
/***/ }),
/***/ "flarum/forum/components/CommentPost":
/*!*********************************************************************!*\
!*** external "flarum.core.compat['forum/components/CommentPost']" ***!
\*********************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['forum/components/CommentPost'];
/***/ }),
/***/ "flarum/forum/components/Notification":
/*!**********************************************************************!*\
!*** external "flarum.core.compat['forum/components/Notification']" ***!
\**********************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['forum/components/Notification'];
/***/ }),
/***/ "flarum/forum/components/NotificationGrid":
/*!**************************************************************************!*\
!*** external "flarum.core.compat['forum/components/NotificationGrid']" ***!
\**************************************************************************/
/***/ ((module) => {
"use strict";
module.exports = flarum.core.compat['forum/components/NotificationGrid'];
/***/ }),
/***/ "../../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js":
/*!*************************************************************************!*\
!*** ../../../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js ***!
\*************************************************************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ _inheritsLoose)
/* harmony export */ });
/* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setPrototypeOf.js */ "../../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js");
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
(0,_setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__["default"])(subClass, superClass);
}
/***/ }),
/***/ "../../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js":
/*!**************************************************************************!*\
!*** ../../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js ***!
\**************************************************************************/
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (/* binding */ _setPrototypeOf)
/* harmony export */ });
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
(() => {
"use strict";
/*!******************!*\
!*** ./forum.js ***!
\******************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _src_forum__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./src/forum */ "./src/forum/index.js");
})();
module.exports = __webpack_exports__;
/******/ })()
;
//# sourceMappingURL=forum.js.map

File diff suppressed because one or more lines are too long

View File

@@ -11,17 +11,20 @@ import PostLikesModal from './components/PostLikesModal';
export default function () {
extend(CommentPost.prototype, 'footerItems', function (items) {
const post = this.attrs.post;
const likes = post.likes();
const likes = post.recentLikes();
const count = post.likesCount();
if (likes && likes.length) {
const limit = 4;
const overLimit = likes.length > limit;
// the limit is dynamic through the backend, we only load those we need
const limit = likes.length;
// overLimit indicates there are more likes than the ones we render (and load)
const overLimit = count > likes.length;
// Construct a list of names of users who have liked this post. Make sure the
// current user is first in the list, and cap a maximum of 4 items.
const names = likes
.sort((a) => (a === app.session.user ? -1 : 1))
.slice(0, overLimit ? limit - 1 : limit)
.filter((a) => a !== app.session.user)
.slice(0, limit)
.map((user) => {
return (
<Link href={app.route.user(user)}>
@@ -30,12 +33,14 @@ export default function () {
);
});
if (post.likedByActor()) {
names.unshift(<Link href={app.route.user(app.session.user)}>{app.translator.trans('flarum-likes.forum.post.you_text')}</Link>);
}
// If there are more users that we've run out of room to display, add a "x
// others" name to the end of the list. Clicking on it will display a modal
// with a full list of names.
if (overLimit) {
const count = likes.length - names.length;
names.push(
<a
href="#"
@@ -44,7 +49,7 @@ export default function () {
app.modal.show(PostLikesModal, { post });
}}
>
{app.translator.trans('flarum-likes.forum.post.others_link', { count })}
{app.translator.trans('flarum-likes.forum.post.others_link', { count: count - likes.length })}
</a>
);
}

View File

@@ -14,6 +14,10 @@ app.initializers.add('flarum-likes', () => {
Post.prototype.canLike = Model.attribute('canLike');
Post.prototype.likes = Model.hasMany('likes');
Post.prototype.likesCount = Model.attribute('likesCount');
Post.prototype.recentLikes = Model.hasMany('recentLikes');
Post.prototype.likedByActor = Model.attribute('likedByActor');
addLikeAction();
addLikesList();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Likes\Api;
use Flarum\Api\Serializer\BasicUserSerializer;
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Post\Post;
use Tobscure\JsonApi\Collection;
use Tobscure\JsonApi\Relationship;
class RecentLikesRelationship
{
private BasicUserSerializer $serializer;
public function __construct(BasicUserSerializer $serializer)
{
$this->serializer = $serializer;
}
public function __invoke(PostSerializer $serializer, Post $post): Relationship
{
return new Relationship(new Collection(
$post->recentLikes,
$this->serializer
));
}
}

View File

@@ -0,0 +1,28 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Likes\Model;
use Flarum\Post\Post;
use Flarum\User\User;
class RecentLikesRelationship
{
public function __invoke(Post $post)
{
return $post->belongsToMany(
User::class,
'post_likes',
'post_id',
'user_id'
)
->limit(3)
->orderBy('post_likes.created_at');
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -23,6 +23,6 @@ export default class PostMentionedNotification extends Notification {
}
excerpt() {
return truncate(this.attrs.notification.subject().contentPlain(), 200);
return truncate(this.attrs.notification.subject().contentPlain() || '', 200);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
return [
'up' => function (Builder $schema) {
$schema->table('post_mentions_post', function (Blueprint $table) {
$table->timestamp('created_at')->nullable();
});
// do this manually because dbal doesn't recognize timestamp columns
$connection = $schema->getConnection();
$prefix = $connection->getTablePrefix();
$connection->statement("ALTER TABLE `${prefix}post_mentions_post` MODIFY created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP");
},
'down' => function (Builder $schema) {
$schema->table('post_mentions_post', function (Blueprint $table) {
$table->dropColumn('created_at');
});
}
];

View File

@@ -0,0 +1,30 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
return [
'up' => function (Builder $schema) {
$schema->table('post_mentions_user', function (Blueprint $table) {
$table->timestamp('created_at')->nullable();
});
// do this manually because dbal doesn't recognize timestamp columns
$connection = $schema->getConnection();
$prefix = $connection->getTablePrefix();
$connection->statement("ALTER TABLE `${prefix}post_mentions_user` MODIFY created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP");
},
'down' => function (Builder $schema) {
$schema->table('post_mentions_user', function (Blueprint $table) {
$table->dropColumn('created_at');
});
}
];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -51,7 +51,7 @@
"prettier": true,
"typescript": false,
"bundlewatch": false,
"backendTesting": false,
"backendTesting": true,
"editorConfig": true,
"styleci": true
}
@@ -64,5 +64,28 @@
}
],
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"autoload-dev": {
"psr-4": {
"Flarum\\Subscriptions\\Tests\\": "tests/"
}
},
"scripts": {
"test": [
"@test:unit",
"@test:integration"
],
"test:unit": "phpunit -c tests/phpunit.unit.xml",
"test:integration": "phpunit -c tests/phpunit.integration.xml",
"test:setup": "@php tests/integration/setup.php"
},
"scripts-descriptions": {
"test": "Runs all tests.",
"test:unit": "Runs all unit tests.",
"test:integration": "Runs all integration tests.",
"test:setup": "Sets up a database for use with integration tests. Execute this only once."
},
"require-dev": {
"flarum/testing": "^1.0.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -49,7 +49,7 @@ class SendReplyNotification implements ShouldQueue
$notify = $discussion->readers()
->where('users.id', '!=', $post->user_id)
->where('discussion_user.subscription', 'follow')
->where('discussion_user.last_read_post_number', $this->lastPostNumber)
->where('discussion_user.last_read_post_number', $this->lastPostNumber - 1)
->get();
$notifications->sync(

View File

View File

@@ -0,0 +1,142 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Subscriptions\tests\integration\api\discussions;
use Carbon\Carbon;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
class ReplyNotificationTest extends TestCase
{
use RetrievesAuthorizedUsers;
protected function setUp(): void
{
parent::setUp();
$this->extension('flarum-subscriptions');
$this->prepareDatabase([
'users' => [
$this->normalUser(),
],
'discussions' => [
['id' => 1, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 1, 'comment_count' => 1, 'last_post_number' => 1, 'last_post_id' => 1],
['id' => 2, 'title' => __CLASS__, 'created_at' => Carbon::now(), 'last_posted_at' => Carbon::now(), 'user_id' => 1, 'first_post_id' => 2, 'comment_count' => 1, 'last_post_number' => 1, 'last_post_id' => 2],
],
'posts' => [
['id' => 1, 'discussion_id' => 1, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 1],
['id' => 2, 'discussion_id' => 2, 'created_at' => Carbon::createFromDate(1975, 5, 21)->toDateTimeString(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>foo bar</p></t>', 'number' => 1],
],
'discussion_user' => [
['discussion_id' => 1, 'user_id' => 1, 'last_read_post_number' => 1, 'subscription' => 'follow'],
['discussion_id' => 2, 'user_id' => 1, 'last_read_post_number' => 1, 'subscription' => 'follow'],
]
]);
}
/** @test */
public function replying_to_a_discussion_with_comment_post_as_last_post_sends_reply_notification()
{
$this->app();
/** @var User $mainUser */
$mainUser = User::query()->find(1);
$this->assertEquals(0, $this->getUnreadNotificationCount($mainUser));
$this->send(
$this->request('POST', '/api/posts', [
'authenticatedAs' => 2,
'json' => [
'data' => [
'attributes' => [
'content' => 'reply with predetermined content for automated testing - too-obscure',
],
'relationships' => [
'discussion' => ['data' => ['id' => 1]],
],
],
],
])
);
$this->assertEquals(1, $this->getUnreadNotificationCount($mainUser));
}
/** @test */
public function replying_to_a_discussion_with_event_post_as_last_post_sends_reply_notification()
{
$this->app();
/** @var User $mainUser */
$mainUser = User::query()->find(1);
// Rename the discussion to trigger an event post.
$this->send(
$this->request('POST', '/api/discussions/2', [
'authenticatedAs' => 1,
'json' => [
'data' => [
'attributes' => [
'title' => 'ACME',
],
],
],
])
);
// Mark as read
$this->send(
$this->request('POST', '/api/discussions/2', [
'authenticatedAs' => 1,
'json' => [
'data' => [
'attributes' => [
'lastReadPostNumber' => 2,
],
],
],
])
);
$this->assertEquals(0, $this->getUnreadNotificationCount($mainUser));
$this->send(
$this->request('POST', '/api/posts', [
'authenticatedAs' => 2,
'json' => [
'data' => [
'attributes' => [
'content' => 'reply with predetermined content for automated testing - too-obscure',
],
'relationships' => [
'discussion' => ['data' => ['id' => 2]],
],
],
],
])
);
$this->assertEquals(1, $this->getUnreadNotificationCount($mainUser));
}
/** @todo change after core no longer statically caches unread notification in the User class */
protected function getUnreadNotificationCount(User $user)
{
return $user->notifications()
->where('type', 'newPost')
->whereNull('read_at')
->where('is_deleted', false)
->whereSubjectVisibleTo($user)
->count();
}
}

View File

@@ -0,0 +1,16 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Flarum\Testing\integration\Setup\SetupScript;
require __DIR__.'/../../vendor/autoload.php';
$setup = new SetupScript();
$setup->run();

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Flarum Integration Tests">
<directory suffix="Test.php">./integration</directory>
<exclude>./integration/tmp</exclude>
</testsuite>
</testsuites>
</phpunit>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">../src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Flarum Unit Tests">
<directory suffix="Test.php">./unit</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -7,11 +7,12 @@ export default function () {
if (app.session.user) {
const message = app.session.user.suspendMessage();
const until = app.session.user.suspendedUntil();
const isSuspended = message && until && new Date() < until;
const alreadyDisplayed = localStorage.getItem(localStorageKey()) === until?.getTime().toString();
if (message && !alreadyDisplayed) {
if (isSuspended && !alreadyDisplayed) {
app.modal.show(SuspensionInfoModal, { message, until });
} else if (!until && localStorage.getItem(localStorageKey())) {
} else if (localStorage.getItem(localStorageKey())) {
localStorage.removeItem(localStorageKey());
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
import type Tag from "../common/models/Tag";
import type TagListState from "../forum/states/TagListState";
import type Tag from '../common/models/Tag';
import type TagListState from '../forum/states/TagListState';
declare module 'flarum/forum/routes' {
export interface ForumRoutes {

View File

@@ -1,2 +1,2 @@
import Tag from "../models/Tag";
import Tag from '../models/Tag';
export default function sortTags(tags: Tag[]): Tag[];

View File

@@ -1,4 +1,4 @@
import type Tag from "../../common/models/Tag";
import type Tag from '../../common/models/Tag';
export default class TagListState {
loadedIncludes: Set<unknown>;
load(includes?: string[]): Promise<Tag[]>;

2
extensions/tags/js/dist/admin.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
extensions/tags/js/dist/forum.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,6 +2,7 @@
"private": true,
"name": "@flarum/tags",
"version": "0.0.0",
"prettier": "@flarum/prettier-config",
"dependencies": {
"sortablejs": "^1.14.0"
},
@@ -13,14 +14,17 @@
"build-typings": "yarn run clean-typings && ([ -e src/@types ] && cp -r src/@types dist-typings/@types || true) && tsc && yarn run post-build-typings",
"post-build-typings": "find dist-typings -type f -name '*.d.ts' -print0 | xargs -0 sed -i 's,../src/@types,@types,g'",
"check-typings": "tsc --noEmit --emitDeclarationOnly false",
"check-typings-coverage": "typescript-coverage-report"
"check-typings-coverage": "typescript-coverage-report",
"format": "prettier --write src",
"format-check": "prettier --check src"
},
"devDependencies": {
"flarum-webpack-config": "^2.0.0",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1",
"flarum-tsconfig": "^1.0.2",
"flarum-webpack-config": "^2.0.0",
"prettier": "^2.7.1",
"typescript": "^4.5.4",
"typescript-coverage-report": "^0.6.1"
"typescript-coverage-report": "^0.6.1",
"webpack": "^5.65.0",
"webpack-cli": "^4.9.1"
}
}

View File

@@ -1,5 +1,5 @@
import type Tag from "../common/models/Tag";
import type TagListState from "../forum/states/TagListState";
import type Tag from '../common/models/Tag';
import type TagListState from '../forum/states/TagListState';
declare module 'flarum/forum/routes' {
export interface ForumRoutes {

View File

@@ -2,26 +2,30 @@ import { extend } from 'flarum/common/extend';
import PermissionGrid from 'flarum/admin/components/PermissionGrid';
import SettingDropdown from 'flarum/admin/components/SettingDropdown';
export default function() {
extend(PermissionGrid.prototype, 'startItems', items => {
items.add('allowTagChange', {
icon: 'fas fa-tag',
label: app.translator.trans('flarum-tags.admin.permissions.allow_edit_tags_label'),
setting: () => {
const minutes = parseInt(app.data.settings.allow_tag_change, 10);
export default function () {
extend(PermissionGrid.prototype, 'startItems', (items) => {
items.add(
'allowTagChange',
{
icon: 'fas fa-tag',
label: app.translator.trans('flarum-tags.admin.permissions.allow_edit_tags_label'),
setting: () => {
const minutes = parseInt(app.data.settings.allow_tag_change, 10);
return SettingDropdown.component({
defaultLabel: minutes
? app.translator.trans('core.admin.permissions_controls.allow_some_minutes_button', {count: minutes})
: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button'),
key: 'allow_tag_change',
options: [
{value: '-1', label: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button')},
{value: '10', label: app.translator.trans('core.admin.permissions_controls.allow_ten_minutes_button')},
{value: 'reply', label: app.translator.trans('core.admin.permissions_controls.allow_until_reply_button')}
]
});
}
}, 90);
return SettingDropdown.component({
defaultLabel: minutes
? app.translator.trans('core.admin.permissions_controls.allow_some_minutes_button', { count: minutes })
: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button'),
key: 'allow_tag_change',
options: [
{ value: '-1', label: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button') },
{ value: '10', label: app.translator.trans('core.admin.permissions_controls.allow_ten_minutes_button') },
{ value: 'reply', label: app.translator.trans('core.admin.permissions_controls.allow_until_reply_button') },
],
});
},
},
90
);
});
}

View File

@@ -1,14 +1,22 @@
export default function () {
app.extensionData
.for('flarum-tags')
.registerPermission({
icon: 'fas fa-tag',
label: app.translator.trans('flarum-tags.admin.permissions.tag_discussions_label'),
permission: 'discussion.tag',
}, 'moderate', 95)
.registerPermission({
icon: 'fas fa-tags',
label: app.translator.trans('flarum-tags.admin.permissions.bypass_tag_counts_label'),
permission: 'bypassTagCounts',
}, 'start', 89);
.registerPermission(
{
icon: 'fas fa-tag',
label: app.translator.trans('flarum-tags.admin.permissions.tag_discussions_label'),
permission: 'discussion.tag',
},
'moderate',
95
)
.registerPermission(
{
icon: 'fas fa-tags',
label: app.translator.trans('flarum-tags.admin.permissions.bypass_tag_counts_label'),
permission: 'bypassTagCounts',
},
'start',
89
);
}

View File

@@ -1,11 +1,11 @@
import { extend } from 'flarum/common/extend';
import BasicsPage from 'flarum/admin/components/BasicsPage';
export default function() {
extend(BasicsPage.prototype, 'homePageItems', items => {
export default function () {
extend(BasicsPage.prototype, 'homePageItems', (items) => {
items.add('tags', {
path: '/tags',
label: app.translator.trans('flarum-tags.admin.basics.tags_label')
label: app.translator.trans('flarum-tags.admin.basics.tags_label'),
});
});
}

View File

@@ -11,10 +11,10 @@ import tagIcon from '../common/helpers/tagIcon';
import sortTags from '../common/utils/sortTags';
import Tag from '../common/models/Tag';
export default function() {
export default function () {
extend(PermissionGrid.prototype, 'oninit', function () {
this.loading = true;
})
});
extend(PermissionGrid.prototype, 'oncreate', function () {
app.store.find<Tag[]>('tags', {}).then(() => {
@@ -30,7 +30,7 @@ export default function() {
}
return original(vnode);
})
});
override(app, 'getRequiredPermissions', (original, permission) => {
const tagPrefix = permission.match(/^tag\d+\./);
@@ -40,45 +40,60 @@ export default function() {
const required = original(globalPermission);
return required.map(required => tagPrefix[0] + required);
return required.map((required) => tagPrefix[0] + required);
}
return original(permission);
});
extend(PermissionGrid.prototype, 'scopeItems', items => {
extend(PermissionGrid.prototype, 'scopeItems', (items) => {
sortTags(app.store.all('tags'))
.filter(tag => tag.isRestricted())
.forEach(tag => items.add('tag' + tag.id(), {
label: tagLabel(tag),
onremove: () => tag.save({isRestricted: false}),
render: item => {
if ('setting' in item) return '';
.filter((tag) => tag.isRestricted())
.forEach((tag) =>
items.add('tag' + tag.id(), {
label: tagLabel(tag),
onremove: () => tag.save({ isRestricted: false }),
render: (item) => {
if ('setting' in item) return '';
if (item.permission === 'viewForum'
|| item.permission === 'startDiscussion'
|| (item.permission && item.permission.indexOf('discussion.') === 0 && item.tagScoped !== false)
|| item.tagScoped) {
return PermissionDropdown.component({
permission: 'tag' + tag.id() + '.' + item.permission,
allowGuest: item.allowGuest
});
}
if (
item.permission === 'viewForum' ||
item.permission === 'startDiscussion' ||
(item.permission && item.permission.indexOf('discussion.') === 0 && item.tagScoped !== false) ||
item.tagScoped
) {
return PermissionDropdown.component({
permission: 'tag' + tag.id() + '.' + item.permission,
allowGuest: item.allowGuest,
});
}
return '';
}
}));
return '';
},
})
);
});
extend(PermissionGrid.prototype, 'scopeControlItems', items => {
const tags = sortTags(app.store.all<Tag>('tags').filter(tag => !tag.isRestricted()));
extend(PermissionGrid.prototype, 'scopeControlItems', (items) => {
const tags = sortTags(app.store.all<Tag>('tags').filter((tag) => !tag.isRestricted()));
if (tags.length) {
items.add('tag', <Dropdown className='Dropdown--restrictByTag' buttonClassName='Button Button--text' label={app.translator.trans('flarum-tags.admin.permissions.restrict_by_tag_heading')} icon='fas fa-plus' caretIcon={null}>
{tags.map(tag => <Button icon={true} onclick={() => tag.save({ isRestricted: true })}>
{[tagIcon(tag, { className: 'Button-icon' }), ' ', tag.name()]}
</Button>)}
</Dropdown>);
items.add(
'tag',
<Dropdown
className="Dropdown--restrictByTag"
buttonClassName="Button Button--text"
label={app.translator.trans('flarum-tags.admin.permissions.restrict_by_tag_heading')}
icon="fas fa-plus"
caretIcon={null}
>
{tags.map((tag) => (
<Button icon={true} onclick={() => tag.save({ isRestricted: true })}>
{[tagIcon(tag, { className: 'Button-icon' }), ' ', tag.name()]}
</Button>
))}
</Dropdown>
);
}
});
}

View File

@@ -59,9 +59,7 @@ export default class EditTagModal extends Modal<EditTagModalAttrs> {
content() {
return (
<div className="Modal-body">
<div className="Form">
{this.fields().toArray()}
</div>
<div className="Form">{this.fields().toArray()}</div>
</div>
);
}
@@ -69,59 +67,97 @@ export default class EditTagModal extends Modal<EditTagModalAttrs> {
fields() {
const items = new ItemList();
items.add('name', <div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.name_label')}</label>
<input className="FormControl" placeholder={app.translator.trans('flarum-tags.admin.edit_tag.name_placeholder')} value={this.name()} oninput={(e: InputEvent) => {
const target = e.target as HTMLInputElement;
this.name(target.value);
this.slug(slug(target.value));
}} />
</div>, 50);
items.add(
'name',
<div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.name_label')}</label>
<input
className="FormControl"
placeholder={app.translator.trans('flarum-tags.admin.edit_tag.name_placeholder')}
value={this.name()}
oninput={(e: InputEvent) => {
const target = e.target as HTMLInputElement;
this.name(target.value);
this.slug(slug(target.value));
}}
/>
</div>,
50
);
items.add('slug', <div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.slug_label')}</label>
<input className="FormControl" bidi={this.slug} />
</div>, 40);
items.add(
'slug',
<div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.slug_label')}</label>
<input className="FormControl" bidi={this.slug} />
</div>,
40
);
items.add('description', <div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.description_label')}</label>
<textarea className="FormControl" bidi={this.description} />
</div>, 30);
items.add(
'description',
<div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.description_label')}</label>
<textarea className="FormControl" bidi={this.description} />
</div>,
30
);
items.add('color', <div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.color_label')}</label>
<ColorPreviewInput className="FormControl" placeholder="#aaaaaa" bidi={this.color} />
</div>, 20);
items.add(
'color',
<div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.color_label')}</label>
<ColorPreviewInput className="FormControl" placeholder="#aaaaaa" bidi={this.color} />
</div>,
20
);
items.add('icon', <div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.icon_label')}</label>
<div className="helpText">
{app.translator.trans('flarum-tags.admin.edit_tag.icon_text', { a: <a href="https://fontawesome.com/icons?m=free" tabindex="-1" /> })}
</div>
<input className="FormControl" placeholder="fas fa-bolt" bidi={this.icon} />
</div>, 10);
items.add(
'icon',
<div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.edit_tag.icon_label')}</label>
<div className="helpText">
{app.translator.trans('flarum-tags.admin.edit_tag.icon_text', { a: <a href="https://fontawesome.com/icons?m=free" tabindex="-1" /> })}
</div>
<input className="FormControl" placeholder="fas fa-bolt" bidi={this.icon} />
</div>,
10
);
items.add('hidden', <div className="Form-group">
<div>
<label className="checkbox">
<input type="checkbox" bidi={this.isHidden} />
{app.translator.trans('flarum-tags.admin.edit_tag.hide_label')}
</label>
</div>
</div>, 10);
items.add(
'hidden',
<div className="Form-group">
<div>
<label className="checkbox">
<input type="checkbox" bidi={this.isHidden} />
{app.translator.trans('flarum-tags.admin.edit_tag.hide_label')}
</label>
</div>
</div>,
10
);
items.add('submit', <div className="Form-group">
{Button.component({
type: 'submit',
className: 'Button Button--primary EditTagModal-save',
loading: this.loading,
}, app.translator.trans('flarum-tags.admin.edit_tag.submit_button'))}
{this.tag.exists ? (
<button type="button" className="Button EditTagModal-delete" onclick={this.delete.bind(this)}>
{app.translator.trans('flarum-tags.admin.edit_tag.delete_tag_button')}
</button>
) : ''}
</div>, -10);
items.add(
'submit',
<div className="Form-group">
{Button.component(
{
type: 'submit',
className: 'Button Button--primary EditTagModal-save',
loading: this.loading,
},
app.translator.trans('flarum-tags.admin.edit_tag.submit_button')
)}
{this.tag.exists ? (
<button type="button" className="Button EditTagModal-delete" onclick={this.delete.bind(this)}>
{app.translator.trans('flarum-tags.admin.edit_tag.delete_tag_button')}
</button>
) : (
''
)}
</div>,
-10
);
return items;
}
@@ -147,20 +183,22 @@ export default class EditTagModal extends Modal<EditTagModalAttrs> {
// This is done for better error visibility on smaller screen heights.
this.tag.save(this.submitData()).then(
() => this.hide(),
() => this.loading = false
() => (this.loading = false)
);
}
delete() {
if (confirm(extractText(app.translator.trans('flarum-tags.admin.edit_tag.delete_tag_confirmation')))) {
const children = app.store.all<Tag>('tags').filter(tag => tag.parent() === this.tag);
const children = app.store.all<Tag>('tags').filter((tag) => tag.parent() === this.tag);
this.tag.delete().then(() => {
children.forEach(tag => tag.pushData({
attributes: { isChild: false },
// @deprecated. Temporary hack for type safety, remove before v1.3.
relationships: { parent: null as any as [] }
}));
children.forEach((tag) =>
tag.pushData({
attributes: { isChild: false },
// @deprecated. Temporary hack for type safety, remove before v1.3.
relationships: { parent: null as any as [] },
})
);
m.redraw();
});

View File

@@ -1,5 +1,6 @@
import sortable from 'sortablejs';
import app from 'flarum/admin/app';
import ExtensionPage from 'flarum/admin/components/ExtensionPage';
import Button from 'flarum/common/components/Button';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
@@ -18,16 +19,18 @@ function tagItem(tag) {
{Button.component({
className: 'Button Button--link',
icon: 'fas fa-pencil-alt',
onclick: () => app.modal.show(EditTagModal, { model: tag })
onclick: () => app.modal.show(EditTagModal, { model: tag }),
})}
</div>
{!tag.isChild() && tag.position() !== null ? (
<ol className="TagListItem-children TagList">
{sortTags(app.store.all('tags'))
.filter(child => child.parent() === tag)
.filter((child) => child.parent() === tag)
.map(tagItem)}
</ol>
) : ''}
) : (
''
)}
</li>
);
}
@@ -62,81 +65,78 @@ export default class TagsPage extends ExtensionPage {
const minSecondaryTags = this.setting('flarum-tags.min_secondary_tags', 0);
const maxSecondaryTags = this.setting('flarum-tags.max_secondary_tags', 0);
const tags = sortTags(app.store.all('tags').filter(tag => !tag.parent()));
const tags = sortTags(app.store.all('tags').filter((tag) => !tag.parent()));
return (
<div className="TagsContent">
<div className="TagsContent-list">
<div className="container" key={this.forcedRefreshKey} oncreate={this.onListOnCreate.bind(this)}><div className="SettingsGroups">
<div className="TagGroup">
<label>{app.translator.trans('flarum-tags.admin.tags.primary_heading')}</label>
<ol className="TagList TagList--primary">
{tags
.filter(tag => tag.position() !== null && !tag.isChild())
.map(tagItem)}
</ol>
{Button.component(
{
className: 'Button TagList-button',
icon: 'fas fa-plus',
onclick: () => app.modal.show(EditTagModal, { primary: true }),
},
app.translator.trans('flarum-tags.admin.tags.create_primary_tag_button')
)}
</div>
<div className="container" key={this.forcedRefreshKey} oncreate={this.onListOnCreate.bind(this)}>
<div className="SettingsGroups">
<div className="TagGroup">
<label>{app.translator.trans('flarum-tags.admin.tags.primary_heading')}</label>
<ol className="TagList TagList--primary">{tags.filter((tag) => tag.position() !== null && !tag.isChild()).map(tagItem)}</ol>
{Button.component(
{
className: 'Button TagList-button',
icon: 'fas fa-plus',
onclick: () => app.modal.show(EditTagModal, { primary: true }),
},
app.translator.trans('flarum-tags.admin.tags.create_primary_tag_button')
)}
</div>
<div className="TagGroup TagGroup--secondary">
<label>{app.translator.trans('flarum-tags.admin.tags.secondary_heading')}</label>
<ul className="TagList">
{tags
.filter(tag => tag.position() === null)
.sort((a, b) => a.name().localeCompare(b.name()))
.map(tagItem)}
</ul>
{Button.component(
{
className: 'Button TagList-button',
icon: 'fas fa-plus',
onclick: () => app.modal.show(EditTagModal, { primary: false }),
},
app.translator.trans('flarum-tags.admin.tags.create_secondary_tag_button')
)}
</div>
<div className="Form">
<label>{app.translator.trans('flarum-tags.admin.tags.settings_heading')}</label>
<div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.tag_settings.required_primary_heading')}</label>
<div className="helpText">{app.translator.trans('flarum-tags.admin.tag_settings.required_primary_text')}</div>
<div className="TagSettings-rangeInput">
<input
className="FormControl"
type="number"
min="0"
value={minPrimaryTags()}
oninput={withAttr('value', this.setMinTags.bind(this, minPrimaryTags, maxPrimaryTags))}
/>
{app.translator.trans('flarum-tags.admin.tag_settings.range_separator_text')}
<input className="FormControl" type="number" min={minPrimaryTags()} bidi={maxPrimaryTags} />
</div>
<div className="TagGroup TagGroup--secondary">
<label>{app.translator.trans('flarum-tags.admin.tags.secondary_heading')}</label>
<ul className="TagList">
{tags
.filter((tag) => tag.position() === null)
.sort((a, b) => a.name().localeCompare(b.name()))
.map(tagItem)}
</ul>
{Button.component(
{
className: 'Button TagList-button',
icon: 'fas fa-plus',
onclick: () => app.modal.show(EditTagModal, { primary: false }),
},
app.translator.trans('flarum-tags.admin.tags.create_secondary_tag_button')
)}
</div>
<div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.tag_settings.required_secondary_heading')}</label>
<div className="helpText">{app.translator.trans('flarum-tags.admin.tag_settings.required_secondary_text')}</div>
<div className="TagSettings-rangeInput">
<input
className="FormControl"
type="number"
min="0"
value={minSecondaryTags()}
oninput={withAttr('value', this.setMinTags.bind(this, minSecondaryTags, maxSecondaryTags))}
/>
{app.translator.trans('flarum-tags.admin.tag_settings.range_separator_text')}
<input className="FormControl" type="number" min={minSecondaryTags()} bidi={maxSecondaryTags} />
<div className="Form">
<label>{app.translator.trans('flarum-tags.admin.tags.settings_heading')}</label>
<div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.tag_settings.required_primary_heading')}</label>
<div className="helpText">{app.translator.trans('flarum-tags.admin.tag_settings.required_primary_text')}</div>
<div className="TagSettings-rangeInput">
<input
className="FormControl"
type="number"
min="0"
value={minPrimaryTags()}
oninput={withAttr('value', this.setMinTags.bind(this, minPrimaryTags, maxPrimaryTags))}
/>
{app.translator.trans('flarum-tags.admin.tag_settings.range_separator_text')}
<input className="FormControl" type="number" min={minPrimaryTags()} bidi={maxPrimaryTags} />
</div>
</div>
<div className="Form-group">
<label>{app.translator.trans('flarum-tags.admin.tag_settings.required_secondary_heading')}</label>
<div className="helpText">{app.translator.trans('flarum-tags.admin.tag_settings.required_secondary_text')}</div>
<div className="TagSettings-rangeInput">
<input
className="FormControl"
type="number"
min="0"
value={minSecondaryTags()}
oninput={withAttr('value', this.setMinTags.bind(this, minSecondaryTags, maxSecondaryTags))}
/>
{app.translator.trans('flarum-tags.admin.tag_settings.range_separator_text')}
<input className="FormControl" type="number" min={minSecondaryTags()} bidi={maxSecondaryTags} />
</div>
</div>
<div className="Form-group">{this.submitButton()}</div>
</div>
<div className="Form-group">{this.submitButton()}</div>
</div>
</div>
<div className="TagsContent-footer">
<p>{app.translator.trans('flarum-tags.admin.tags.about_tags_text')}</p>
</div>
@@ -147,19 +147,21 @@ export default class TagsPage extends ExtensionPage {
}
onListOnCreate(vnode) {
this.$('.TagList').get().map(e => {
sortable.create(e, {
group: 'tags',
delay: 50,
delayOnTouchOnly: true,
touchStartThreshold: 5,
animation: 150,
swapThreshold: 0.65,
dragClass: 'sortable-dragging',
ghostClass: 'sortable-placeholder',
onSort: (e) => this.onSortUpdate(e)
})
});
this.$('.TagList')
.get()
.map((e) => {
sortable.create(e, {
group: 'tags',
delay: 50,
delayOnTouchOnly: true,
touchStartThreshold: 5,
animation: 150,
swapThreshold: 0.65,
dragClass: 'sortable-dragging',
ghostClass: 'sortable-placeholder',
onSort: (e) => this.onSortUpdate(e),
});
});
}
setMinTags(minTags, maxTags, value) {
@@ -175,9 +177,9 @@ export default class TagsPage extends ExtensionPage {
app.store.getById('tags', e.item.getAttribute('data-id')).pushData({
attributes: {
position: null,
isChild: false
isChild: false,
},
relationships: { parent: null }
relationships: { parent: null },
});
}
@@ -187,12 +189,15 @@ export default class TagsPage extends ExtensionPage {
.map(function () {
return {
id: $(this).data('id'),
children: $(this).find('li')
children: $(this)
.find('li')
.map(function () {
return $(this).data('id');
}).get()
})
.get(),
};
}).get();
})
.get();
// Now that we have an accurate representation of the order which the
// primary tags are in, we will update the tag attributes in our local
@@ -202,18 +207,18 @@ export default class TagsPage extends ExtensionPage {
parent.pushData({
attributes: {
position: i,
isChild: false
isChild: false,
},
relationships: { parent: null }
relationships: { parent: null },
});
tag.children.forEach((child, j) => {
app.store.getById('tags', child).pushData({
attributes: {
position: j,
isChild: true
isChild: true,
},
relationships: { parent }
relationships: { parent },
});
});
});
@@ -221,7 +226,7 @@ export default class TagsPage extends ExtensionPage {
app.request({
url: app.forum.attribute('apiUrl') + '/tags/order',
method: 'POST',
body: { order }
body: { order },
});
this.forcedRefreshKey++;

View File

@@ -6,7 +6,7 @@ import addTagsHomePageOption from './addTagsHomePageOption';
import addTagChangePermission from './addTagChangePermission';
import TagsPage from './components/TagsPage';
app.initializers.add('flarum-tags', app => {
app.initializers.add('flarum-tags', (app) => {
app.store.models.tags = Tag;
app.extensionData.for('flarum-tags').registerPage(TagsPage);
@@ -17,7 +17,6 @@ app.initializers.add('flarum-tags', app => {
addTagChangePermission();
});
// Expose compat API
import tagsCompat from './compat';
import { compat } from '@flarum/core/admin';

View File

@@ -9,5 +9,5 @@ export default {
'tags/models/Tag': Tag,
'tags/helpers/tagsLabel': tagsLabel,
'tags/helpers/tagIcon': tagIcon,
'tags/helpers/tagLabel': tagLabel
'tags/helpers/tagLabel': tagLabel,
};

View File

@@ -4,11 +4,7 @@ export default function tagIcon(tag, attrs = {}, settings = {}) {
const hasIcon = tag && tag.icon();
const { useColor = true } = settings;
attrs.className = classList([
attrs.className,
'icon',
hasIcon ? tag.icon() : 'TagIcon'
]);
attrs.className = classList([attrs.className, 'icon', hasIcon ? tag.icon() : 'TagIcon']);
if (tag && useColor) {
attrs.style = attrs.style || {};
@@ -21,5 +17,5 @@ export default function tagIcon(tag, attrs = {}, settings = {}) {
attrs.className += ' untagged';
}
return hasIcon ? <i {...attrs}/> : <span {...attrs}/>;
return hasIcon ? <i {...attrs} /> : <span {...attrs} />;
}

View File

@@ -18,7 +18,7 @@ export default function tagLabel(tag, attrs = {}) {
if (link) {
attrs.title = tag.description() || '';
attrs.href = app.route('tag', {tags: tag.slug()});
attrs.href = app.route('tag', { tags: tag.slug() });
}
if (tag.isChild()) {
@@ -28,11 +28,11 @@ export default function tagLabel(tag, attrs = {}) {
attrs.className += ' untagged';
}
return (
m((link ? Link : 'span'), attrs,
<span className="TagLabel-text">
{tag && tag.icon() && tagIcon(tag, {}, {useColor: false})} {tagText}
</span>
)
return m(
link ? Link : 'span',
attrs,
<span className="TagLabel-text">
{tag && tag.icon() && tagIcon(tag, {}, { useColor: false })} {tagText}
</span>
);
}

Some files were not shown because too many files have changed in this diff Show More