Release v1.4.0 #146
|
|
@ -1,4 +1,4 @@
|
|||
APP_NAME=Laravel
|
||||
APP_NAME="Fedi Feed Router"
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ jobs:
|
|||
run: vendor/bin/pint --test
|
||||
|
||||
- name: Static analysis
|
||||
run: vendor/bin/phpstan analyse
|
||||
run: vendor/bin/phpstan analyse --memory-limit=1G
|
||||
|
||||
- name: Tests
|
||||
run: php artisan test --coverage-clover coverage.xml --coverage-text
|
||||
|
|
|
|||
3
.gitignore
vendored
|
|
@ -19,9 +19,10 @@ npm-debug.log
|
|||
yarn-error.log
|
||||
/package-lock.json
|
||||
/auth.json
|
||||
/composer.lock
|
||||
/.idea
|
||||
/coverage-report*
|
||||
/coverage.xml
|
||||
/.php-cs-fixer.dist.php
|
||||
/.php-cs-fixer.cache
|
||||
/.codewhale
|
||||
.aider*
|
||||
|
|
|
|||
38
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [1.4.0] - 2026-08-14
|
||||
|
||||
### Added
|
||||
|
||||
- Add a dark theme (#88)
|
||||
- Add a daily publish cap, so a feed returning a large batch cannot flood a community (#90)
|
||||
- Defaults to unlimited, so existing installs publish exactly as before until someone opts in.
|
||||
- Add an in-app activity log showing what the automation has been doing (#91)
|
||||
- Add a scheduled platform credential health check (#95)
|
||||
- Add a warning for feeds that fetch successfully but return no articles (#116)
|
||||
- Add community existence validation when creating a channel (#114)
|
||||
- Add edit and delete actions to feed and channel cards (#136, #137, #141)
|
||||
- Deleting a channel cascades to its routes, keywords, route articles and publications, so past days in the dashboard charts lose those data points.
|
||||
- Add a Failed tab surfacing publishes that did not go through (#142)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix a failed publish disappearing from the interface instead of returning to the user (#142)
|
||||
- Automatic retry is removed, replaced by a per-row Retry action.
|
||||
- Fix modals being unusable by keyboard (#111)
|
||||
- Fix oversized thumbnails (#138)
|
||||
- Fix renamed Tailwind v4 utilities rendering at a shifted scale (#109)
|
||||
|
||||
### Changed
|
||||
|
||||
- Rework the dashboard with trends and breakdowns over a selectable date range (#83)
|
||||
- Make an article's routing legible on the Articles page, with per-feed colour, grouping and a filter (#113)
|
||||
- Store an article's thumbnail when it is fetched rather than re-fetching the page on every publish (#119)
|
||||
- Replace the stock Laravel branding with the project's own (#121)
|
||||
- Extract business logic from services into Action classes (#144)
|
||||
|
||||
### Removed
|
||||
|
||||
- Remove the unused Inertia, Ziggy and Breeze dependencies, the dead Jenkinsfile, and the Inertia middleware (#140)
|
||||
95
CONTRIBUTING.md
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
# Contributing
|
||||
|
||||
Thanks for your interest in FFR. This is a small self-hosted project, issues and
|
||||
pull requests are both welcome.
|
||||
|
||||
## Reporting issues
|
||||
|
||||
Use [Issues](https://forge.lvl0.xyz/lvl0/fedi-feed-router/issues).
|
||||
|
||||
For bugs, include what you expected, what happened, and enough detail to
|
||||
reproduce it. If a feed is behaving unexpectedly, the feed URL matters most
|
||||
because differences in how providers structure their RSS or Atom output are the
|
||||
usual cause. Relevant log output helps; `dev-logs` follows the application log.
|
||||
|
||||
## Development setup
|
||||
|
||||
Requires PHP 8.2+ and Docker. The development environment runs in containers
|
||||
defined by `docker/dev/docker-compose.yml`.
|
||||
|
||||
On NixOS, or anywhere with Nix installed:
|
||||
|
||||
```bash
|
||||
git clone https://forge.lvl0.xyz/lvl0/fedi-feed-router.git
|
||||
cd fedi-feed-router
|
||||
nix-shell
|
||||
```
|
||||
|
||||
The shell prints the available commands on entry and can start the containers
|
||||
for you:
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `dev-up` | Start the development environment |
|
||||
| `dev-down` | Stop the development environment |
|
||||
| `dev-restart` | Restart the containers |
|
||||
| `dev-rebuild` | Rebuild the images |
|
||||
| `dev-shell` | Enter the app container |
|
||||
| `dev-artisan <cmd>` | Run an artisan command |
|
||||
| `dev-logs` | Follow the application log |
|
||||
| `dev-logs-db` | Follow the database log |
|
||||
|
||||
Once running:
|
||||
|
||||
| Service | URL |
|
||||
|---------|-----|
|
||||
| App | http://localhost:8000 |
|
||||
| Vite | http://localhost:5173 |
|
||||
| MariaDB | localhost:3307 |
|
||||
| Redis | localhost:6380 |
|
||||
|
||||
Without Nix, start the same containers directly from
|
||||
`docker/dev/docker-compose.yml`. Contributions improving the setup instructions
|
||||
for other platforms are welcome.
|
||||
|
||||
## Before opening a pull request
|
||||
|
||||
Three checks run in CI, and all three must pass. Run them locally first, from
|
||||
inside the app container or anywhere the project's dependencies are available:
|
||||
|
||||
```bash
|
||||
vendor/bin/pint --test # code style, Laravel preset
|
||||
vendor/bin/phpstan analyse # static analysis, level 7
|
||||
php artisan test # PHPUnit, Unit and Feature suites
|
||||
```
|
||||
|
||||
Some conventions:
|
||||
|
||||
- **Static analysis.** PHPStan runs at level 7 with a baseline
|
||||
(`phpstan-baseline.neon`) covering pre-existing findings. Don't add baseline
|
||||
entries to silence errors in code you're writing. Fix the cause instead.
|
||||
Inline `@phpstan-ignore` comments aren't used in this project. The baseline is
|
||||
for cases where the analyser or an upstream docblock is wrong, not real bugs.
|
||||
- **Tests.** New behaviour needs a test. Tests must run offline, so use fixtures
|
||||
or fakes rather than reaching for the network.
|
||||
- **Dependencies.** `composer.lock` is committed. If you change dependencies,
|
||||
commit the updated lockfile alongside `composer.json`.
|
||||
|
||||
## Commits
|
||||
|
||||
One commit does one thing. Keep each commit passing all three checks so history
|
||||
stays bisectable. Separate renames from behaviour changes, and mechanical edits
|
||||
from logic.
|
||||
|
||||
Commit messages are a single line, referencing the issue they belong to:
|
||||
|
||||
```
|
||||
141 - Add channel deletion to the Channels page
|
||||
```
|
||||
|
||||
No body, no trailers.
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions are licensed under the
|
||||
[GNU AGPL-3.0](LICENSE), the same license as the project.
|
||||
241
Jenkinsfile
vendored
|
|
@ -1,241 +0,0 @@
|
|||
pipeline {
|
||||
agent any
|
||||
|
||||
environment {
|
||||
APP_ENV = 'testing'
|
||||
DB_CONNECTION = 'mysql'
|
||||
DB_HOST = 'mysql'
|
||||
DB_PORT = '3306'
|
||||
DB_DATABASE = 'ffr_testing'
|
||||
DB_USERNAME = 'ffr_user'
|
||||
DB_PASSWORD = 'ffr_password'
|
||||
CACHE_STORE = 'array'
|
||||
SESSION_DRIVER = 'array'
|
||||
QUEUE_CONNECTION = 'sync'
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout scm
|
||||
}
|
||||
}
|
||||
|
||||
stage('Setup Environment') {
|
||||
steps {
|
||||
script {
|
||||
sh '''
|
||||
echo "Setting up environment for testing..."
|
||||
cp .env.example .env.testing
|
||||
echo "APP_ENV=testing" >> .env.testing
|
||||
echo "DB_CONNECTION=${DB_CONNECTION}" >> .env.testing
|
||||
echo "DB_HOST=${DB_HOST}" >> .env.testing
|
||||
echo "DB_PORT=${DB_PORT}" >> .env.testing
|
||||
echo "DB_DATABASE=${DB_DATABASE}" >> .env.testing
|
||||
echo "DB_USERNAME=${DB_USERNAME}" >> .env.testing
|
||||
echo "DB_PASSWORD=${DB_PASSWORD}" >> .env.testing
|
||||
echo "CACHE_STORE=${CACHE_STORE}" >> .env.testing
|
||||
echo "SESSION_DRIVER=${SESSION_DRIVER}" >> .env.testing
|
||||
echo "QUEUE_CONNECTION=${QUEUE_CONNECTION}" >> .env.testing
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Install Dependencies') {
|
||||
parallel {
|
||||
stage('PHP Dependencies') {
|
||||
steps {
|
||||
sh '''
|
||||
echo "Installing PHP dependencies..."
|
||||
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Node Dependencies') {
|
||||
steps {
|
||||
sh '''
|
||||
echo "Installing Node.js dependencies..."
|
||||
npm ci
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Generate Application Key') {
|
||||
steps {
|
||||
sh '''
|
||||
php artisan key:generate --env=testing --force
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Database Setup') {
|
||||
steps {
|
||||
sh '''
|
||||
echo "Setting up test database..."
|
||||
php artisan migrate:fresh --env=testing --force
|
||||
php artisan config:clear --env=testing
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Code Quality Checks') {
|
||||
parallel {
|
||||
stage('PHP Syntax Check') {
|
||||
steps {
|
||||
sh '''
|
||||
echo "Checking PHP syntax..."
|
||||
find . -name "*.php" -not -path "./vendor/*" -not -path "./node_modules/*" -exec php -l {} \\;
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('PHPStan Analysis') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh '''
|
||||
if [ -f "phpstan.neon" ]; then
|
||||
echo "Running PHPStan static analysis..."
|
||||
./vendor/bin/phpstan analyse --no-progress --error-format=table
|
||||
else
|
||||
echo "PHPStan configuration not found, skipping static analysis"
|
||||
fi
|
||||
'''
|
||||
} catch (Exception e) {
|
||||
unstable(message: "PHPStan found issues")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Security Audit') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh '''
|
||||
echo "Running security audit..."
|
||||
composer audit
|
||||
'''
|
||||
} catch (Exception e) {
|
||||
unstable(message: "Security vulnerabilities found")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Unit Tests') {
|
||||
steps {
|
||||
sh '''
|
||||
echo "Running Unit Tests..."
|
||||
php artisan test tests/Unit/ --env=testing --stop-on-failure
|
||||
'''
|
||||
}
|
||||
post {
|
||||
always {
|
||||
publishTestResults testResultsPattern: 'tests/Unit/results/*.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Feature Tests') {
|
||||
steps {
|
||||
sh '''
|
||||
echo "Running Feature Tests..."
|
||||
php artisan test tests/Feature/ --env=testing --stop-on-failure
|
||||
'''
|
||||
}
|
||||
post {
|
||||
always {
|
||||
publishTestResults testResultsPattern: 'tests/Feature/results/*.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Full Regression Test Suite') {
|
||||
steps {
|
||||
sh '''
|
||||
echo "Running comprehensive regression test suite..."
|
||||
chmod +x ./run-regression-tests.sh
|
||||
./run-regression-tests.sh
|
||||
'''
|
||||
}
|
||||
post {
|
||||
always {
|
||||
// Archive test results
|
||||
archiveArtifacts artifacts: 'tests/reports/**/*', allowEmptyArchive: true
|
||||
|
||||
// Publish coverage reports if available
|
||||
publishHTML([
|
||||
allowMissing: false,
|
||||
alwaysLinkToLastBuild: true,
|
||||
keepAll: true,
|
||||
reportDir: 'coverage',
|
||||
reportFiles: 'index.html',
|
||||
reportName: 'Coverage Report'
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Performance Tests') {
|
||||
steps {
|
||||
script {
|
||||
try {
|
||||
sh '''
|
||||
echo "Running performance tests..."
|
||||
|
||||
# Test memory usage
|
||||
php -d memory_limit=256M artisan test tests/Feature/DatabaseIntegrationTest.php --env=testing
|
||||
|
||||
# Test response times for API endpoints
|
||||
time php artisan test tests/Feature/ApiEndpointRegressionTest.php --env=testing
|
||||
'''
|
||||
} catch (Exception e) {
|
||||
unstable(message: "Performance tests indicated potential issues")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Assets') {
|
||||
when {
|
||||
anyOf {
|
||||
branch 'main'
|
||||
branch 'develop'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
sh '''
|
||||
echo "Building production assets..."
|
||||
npm run build
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
// Clean up
|
||||
sh '''
|
||||
echo "Cleaning up..."
|
||||
rm -f .env.testing
|
||||
'''
|
||||
}
|
||||
success {
|
||||
echo '✅ All regression tests passed successfully!'
|
||||
// Notify success (customize as needed)
|
||||
// slackSend channel: '#dev-team', color: 'good', message: "Regression tests passed for ${env.JOB_NAME} - ${env.BUILD_NUMBER}"
|
||||
}
|
||||
failure {
|
||||
echo '❌ Regression tests failed!'
|
||||
// Notify failure (customize as needed)
|
||||
// slackSend channel: '#dev-team', color: 'danger', message: "Regression tests failed for ${env.JOB_NAME} - ${env.BUILD_NUMBER}"
|
||||
}
|
||||
unstable {
|
||||
echo '⚠️ Tests completed with warnings'
|
||||
}
|
||||
}
|
||||
}
|
||||
661
LICENSE
Normal file
|
|
@ -0,0 +1,661 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
138
README.md
|
|
@ -1,26 +1,77 @@
|
|||
# FFR (Feed to Fediverse Router)
|
||||
# FFR: Feed to Fediverse Router
|
||||
|
||||
A Laravel-based application for routing RSS/Atom feeds to Fediverse platforms like Lemmy. Built with Laravel, Livewire, and FrankenPHP for a modern, single-container deployment.
|
||||
[](https://forge.lvl0.xyz/lvl0/fedi-feed-router/actions)
|
||||
[](https://forge.lvl0.xyz/lvl0/fedi-feed-router/releases)
|
||||
[](LICENSE)
|
||||
|
||||
Routes news articles to Fediverse communities. FFR polls a set of sources,
|
||||
extracts each article, and posts it to the Lemmy communities you map it to,
|
||||
either automatically or after you approve it.
|
||||
|
||||
It is meant to run unattended on your own server: point it at a source, map that
|
||||
source to a community, and let it publish on a schedule you control.
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
The dashboard, showing article volume over a selected range, approval and publish
|
||||
success rates, and per-feed breakdowns.
|
||||
|
||||

|
||||
|
||||
The review queue. Each row is one feed and community pairing, grouped by feed,
|
||||
with the routing shown above the headline.
|
||||
|
||||
## Features
|
||||
|
||||
- **Feed aggregation** - Fetch articles from multiple RSS/Atom feeds
|
||||
- **Fediverse publishing** - Automatically post to Lemmy communities
|
||||
- **Route configuration** - Map feeds to specific channels with keywords
|
||||
- **Approval workflow** - Optional manual approval before publishing
|
||||
- **Queue processing** - Background job handling with Laravel Horizon
|
||||
- **Single container deployment** - Simplified hosting with FrankenPHP
|
||||
- **Article routing**: map each source to one or more Lemmy communities, with
|
||||
optional keyword filtering
|
||||
- **Approval workflow**: review articles before they publish, or let them go out
|
||||
automatically
|
||||
- **Publishing controls**: a global interval and an optional daily cap, so a
|
||||
source returning a large batch cannot flood a community
|
||||
- **Dashboard**: articles fetched and published over time, approval and publish
|
||||
success rates, and per-source and per-community breakdowns
|
||||
- **Activity log**: a chronological record of what the automation has done
|
||||
- **Health checks**: warnings for sources that stop producing articles and for
|
||||
platform credentials that stop working
|
||||
- **Dark theme**
|
||||
- **Single container**: FrankenPHP serves the app, with MariaDB and Redis
|
||||
alongside
|
||||
|
||||
## Sources and platforms
|
||||
|
||||
FFR ships with parsers for three sources:
|
||||
|
||||
| Source | Type |
|
||||
|--------|------|
|
||||
| VRT News | Website |
|
||||
| Belga | Website |
|
||||
| The Guardian | RSS |
|
||||
|
||||
Some sources publish a usable feed and some do not, so a source is either read
|
||||
from RSS or scraped from its pages. Either way a parser handles it, registered
|
||||
in `config/feed.php`.
|
||||
|
||||
Adding a source means implementing `ArticleParserInterface` (three methods:
|
||||
`canParse`, `extractData`, `getSourceName`) and registering it. See
|
||||
[CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
|
||||
Lemmy is currently the only supported platform.
|
||||
|
||||
## Self-hosting
|
||||
|
||||
The production image is available at `forge.lvl0.xyz/lvl0/fedi-feed-router:latest`.
|
||||
Images are published to `forge.lvl0.xyz/lvl0/fedi-feed-router`. The example below
|
||||
pins a release tag; check [Releases](https://forge.lvl0.xyz/lvl0/fedi-feed-router/releases)
|
||||
for the current one, and the [CHANGELOG](CHANGELOG.md) before upgrading.
|
||||
|
||||
### docker-compose.yml
|
||||
|
||||
```yaml
|
||||
services:
|
||||
app:
|
||||
image: forge.lvl0.xyz/lvl0/fedi-feed-router:latest
|
||||
image: forge.lvl0.xyz/lvl0/fedi-feed-router:v1.4.0
|
||||
container_name: ffr_app
|
||||
restart: always
|
||||
ports:
|
||||
|
|
@ -70,42 +121,59 @@ ### docker-compose.yml
|
|||
app_storage:
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
### Environment variables
|
||||
|
||||
| Variable | Required | Description |
|
||||
|----------|----------|-------------|
|
||||
| `APP_KEY` | Yes | Encryption key. Generate with: `echo "base64:$(openssl rand -base64 32)"` |
|
||||
| `APP_URL` | Yes | Your domain (e.g., `https://ffr.example.com`) |
|
||||
| `APP_URL` | Yes | Your domain (e.g. `https://ffr.example.com`) |
|
||||
| `DB_DATABASE` | Yes | Database name |
|
||||
| `DB_USERNAME` | Yes | Database user |
|
||||
| `DB_PASSWORD` | Yes | Database password |
|
||||
| `DB_ROOT_PASSWORD` | Yes | MariaDB root password |
|
||||
|
||||
## Usage
|
||||
|
||||
On first run FFR walks you through onboarding. After that:
|
||||
|
||||
1. **Add a channel** on the Channels page. A channel is a Lemmy community on a
|
||||
given instance, together with the account that posts to it. The community is
|
||||
picked from the instance, so a typo cannot create a channel that fails later.
|
||||
2. **Add a feed** on the Feeds page, choosing one of the supported sources.
|
||||
3. **Add a route** on the Routes page, mapping a feed to a channel. Keywords on a
|
||||
route restrict it to articles that match.
|
||||
|
||||
Articles are then discovered on a schedule. Each one becomes a row per matching
|
||||
route, so an article routed to three communities is three separate decisions.
|
||||
Approve one on the Articles page and it publishes to that route's community;
|
||||
publishing failures come back to you on the Failed tab rather than retrying
|
||||
silently.
|
||||
|
||||
Publishing runs every five minutes, one article per run, bounded by the daily cap
|
||||
if you set one.
|
||||
|
||||
## Development
|
||||
|
||||
### NixOS / Nix
|
||||
|
||||
```bash
|
||||
git clone https://forge.lvl0.xyz/lvl0/fedi-feed-router.git
|
||||
cd ffr
|
||||
cd fedi-feed-router
|
||||
nix-shell
|
||||
```
|
||||
|
||||
The shell will display available commands and optionally start the containers for you.
|
||||
|
||||
#### Available Commands
|
||||
The shell prints the available commands and can start the containers for you.
|
||||
|
||||
| Command | Description |
|
||||
|---------|-------------|
|
||||
| `dev-up` | Start development environment |
|
||||
| `dev-down` | Stop development environment |
|
||||
| `dev-restart` | Restart containers |
|
||||
| `dev-logs` | Follow app logs |
|
||||
| `dev-logs-db` | Follow database logs |
|
||||
| `dev-shell` | Enter app container |
|
||||
| `dev-artisan <cmd>` | Run artisan commands |
|
||||
|
||||
#### Services
|
||||
| `dev-up` | Start the development environment |
|
||||
| `dev-down` | Stop the development environment |
|
||||
| `dev-restart` | Restart the containers |
|
||||
| `dev-rebuild` | Rebuild the images |
|
||||
| `dev-shell` | Enter the app container |
|
||||
| `dev-artisan <cmd>` | Run an artisan command |
|
||||
| `dev-logs` | Follow the application log |
|
||||
| `dev-logs-db` | Follow the database log |
|
||||
|
||||
| Service | URL |
|
||||
|---------|-----|
|
||||
|
|
@ -114,14 +182,22 @@ #### Services
|
|||
| MariaDB | localhost:3307 |
|
||||
| Redis | localhost:6380 |
|
||||
|
||||
### Other Platforms
|
||||
### Other platforms
|
||||
|
||||
Contributions welcome for development setup instructions on other platforms.
|
||||
|
||||
## Contributing
|
||||
|
||||
Issues and pull requests are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for
|
||||
the development setup, the checks that run in CI, and the commit conventions.
|
||||
|
||||
For bugs and questions, use
|
||||
[Issues](https://forge.lvl0.xyz/lvl0/fedi-feed-router/issues).
|
||||
|
||||
## Note on AI assistance
|
||||
|
||||
This project was developed with AI assistance.
|
||||
|
||||
## License
|
||||
|
||||
This project is open-source software licensed under the [AGPL-3.0 license](LICENSE).
|
||||
|
||||
## Support
|
||||
|
||||
For issues and questions, please use [Issues](https://forge.lvl0.xyz/lvl0/fedi-feed-router/issues).
|
||||
FFR is free software, licensed under the [GNU AGPL-3.0](LICENSE).
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\AccountStatusEnum;
|
||||
use App\Exceptions\PlatformAuthException;
|
||||
use App\Models\PlatformAccount;
|
||||
use App\Models\PlatformInstance;
|
||||
|
|
@ -46,7 +47,7 @@ public function execute(string $instanceDomain, string $username, string $passwo
|
|||
'api_token' => $authResponse['jwt'] ?? null,
|
||||
],
|
||||
'is_active' => true,
|
||||
'status' => 'active',
|
||||
'status' => AccountStatusEnum::HEALTHY,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Article;
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\ApprovalStatusEnum;
|
||||
use App\Models\Article;
|
||||
|
|
@ -10,47 +10,9 @@
|
|||
use App\Models\Setting;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class ValidationService
|
||||
class CreateRouteArticlesAction
|
||||
{
|
||||
public function __construct(
|
||||
private ArticleFetcher $articleFetcher
|
||||
) {}
|
||||
|
||||
public function validate(Article $article): Article
|
||||
{
|
||||
logger('Validating article for routes: '.$article->id);
|
||||
|
||||
$articleData = $this->articleFetcher->fetchArticleData($article);
|
||||
|
||||
$updateData = [];
|
||||
|
||||
if (! empty($articleData)) {
|
||||
$updateData['title'] = $articleData['title'] ?? $article->title;
|
||||
$updateData['description'] = $articleData['description'] ?? $article->description;
|
||||
$updateData['content'] = $articleData['full_article'] ?? null;
|
||||
}
|
||||
|
||||
if (! isset($articleData['full_article']) || empty($articleData['full_article'])) {
|
||||
logger()->warning('Article data missing full_article content', [
|
||||
'article_id' => $article->id,
|
||||
'url' => $article->url,
|
||||
]);
|
||||
|
||||
$updateData['validated_at'] = now();
|
||||
$article->update($updateData);
|
||||
|
||||
return $article->refresh();
|
||||
}
|
||||
|
||||
$updateData['validated_at'] = now();
|
||||
$article->update($updateData);
|
||||
|
||||
$this->createRouteArticles($article, $articleData['full_article']);
|
||||
|
||||
return $article->refresh();
|
||||
}
|
||||
|
||||
private function createRouteArticles(Article $article, string $content): void
|
||||
public function execute(Article $article, string $content): void
|
||||
{
|
||||
$activeRoutes = Route::where('feed_id', $article->feed_id)
|
||||
->where('is_active', true)
|
||||
|
|
@ -82,6 +44,7 @@ private function createRouteArticles(Article $article, string $content): void
|
|||
[
|
||||
'approval_status' => $status,
|
||||
'validated_at' => now(),
|
||||
'decided_at' => $status === ApprovalStatusEnum::PENDING ? null : now(),
|
||||
]
|
||||
);
|
||||
}
|
||||
36
app/Actions/FetchArticleDataAction.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Services\Factories\ArticleParserFactory;
|
||||
use App\Services\Http\HttpFetcher;
|
||||
use App\Services\Log\LogSaver;
|
||||
use Exception;
|
||||
|
||||
class FetchArticleDataAction
|
||||
{
|
||||
public function __construct(
|
||||
private LogSaver $logSaver
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function execute(Article $article): array
|
||||
{
|
||||
try {
|
||||
$html = HttpFetcher::fetchHtml($article->url);
|
||||
$parser = ArticleParserFactory::getParser($article->url);
|
||||
|
||||
return $parser->extractData($html);
|
||||
} catch (Exception $e) {
|
||||
$this->logSaver->error('Exception while fetching article data', null, [
|
||||
'url' => $article->url,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
36
app/Actions/FetchFeedArticlesAction.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Feed;
|
||||
use App\Services\Log\LogSaver;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class FetchFeedArticlesAction
|
||||
{
|
||||
public function __construct(
|
||||
private LogSaver $logSaver,
|
||||
private FetchRssArticlesAction $fetchRssArticles,
|
||||
private FetchWebsiteArticlesAction $fetchWebsiteArticles,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Article>
|
||||
*/
|
||||
public function execute(Feed $feed): Collection
|
||||
{
|
||||
if ($feed->type === 'rss') {
|
||||
return $this->fetchRssArticles->execute($feed);
|
||||
} elseif ($feed->type === 'website') {
|
||||
return $this->fetchWebsiteArticles->execute($feed);
|
||||
}
|
||||
|
||||
$this->logSaver->warning('Unsupported feed type', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_type' => $feed->type,
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
}
|
||||
64
app/Actions/FetchRssArticlesAction.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Feed;
|
||||
use App\Services\Http\HttpFetcher;
|
||||
use App\Services\Log\LogSaver;
|
||||
use Exception;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class FetchRssArticlesAction
|
||||
{
|
||||
public function __construct(
|
||||
private LogSaver $logSaver,
|
||||
private SaveArticleAction $saveArticle,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Article>
|
||||
*/
|
||||
public function execute(Feed $feed): Collection
|
||||
{
|
||||
try {
|
||||
$xml = HttpFetcher::fetchHtml($feed->url);
|
||||
|
||||
$previousUseErrors = libxml_use_internal_errors(true);
|
||||
|
||||
try {
|
||||
$rss = simplexml_load_string($xml);
|
||||
} finally {
|
||||
libxml_clear_errors();
|
||||
libxml_use_internal_errors($previousUseErrors);
|
||||
}
|
||||
|
||||
if ($rss === false || ! isset($rss->channel->item)) {
|
||||
$this->logSaver->warning('Failed to parse RSS feed XML', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_url' => $feed->url,
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
|
||||
$articles = collect();
|
||||
foreach ($rss->channel->item as $item) {
|
||||
$link = (string) $item->link;
|
||||
if ($link !== '') {
|
||||
$articles->push($this->saveArticle->execute($link, $feed->id));
|
||||
}
|
||||
}
|
||||
|
||||
return $articles;
|
||||
} catch (Exception $e) {
|
||||
$this->logSaver->error('Failed to fetch articles from RSS feed', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_url' => $feed->url,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
}
|
||||
}
|
||||
53
app/Actions/FetchWebsiteArticlesAction.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Feed;
|
||||
use App\Services\Factories\HomepageParserFactory;
|
||||
use App\Services\Http\HttpFetcher;
|
||||
use App\Services\Log\LogSaver;
|
||||
use Exception;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class FetchWebsiteArticlesAction
|
||||
{
|
||||
public function __construct(
|
||||
private LogSaver $logSaver,
|
||||
private SaveArticleAction $saveArticle,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Article>
|
||||
*/
|
||||
public function execute(Feed $feed): Collection
|
||||
{
|
||||
try {
|
||||
$parser = HomepageParserFactory::getParserForFeed($feed);
|
||||
|
||||
if (! $parser) {
|
||||
$this->logSaver->warning('No parser available for feed URL', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_url' => $feed->url,
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
|
||||
$html = HttpFetcher::fetchHtml($feed->url);
|
||||
$urls = $parser->extractArticleUrls($html);
|
||||
|
||||
return collect($urls)
|
||||
->map(fn (string $url) => $this->saveArticle->execute($url, $feed->id));
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->logSaver->error('Failed to fetch articles from website feed', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_url' => $feed->url,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,14 +2,16 @@
|
|||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use App\Enums\LogLevelEnum;
|
||||
use App\Enums\NotificationSeverityEnum;
|
||||
use App\Enums\NotificationTypeEnum;
|
||||
use App\Enums\PublishStatusEnum;
|
||||
use App\Events\ActionPerformed;
|
||||
use App\Events\ActivityLogged;
|
||||
use App\Exceptions\PublishException;
|
||||
use App\Models\Article;
|
||||
use App\Models\RouteArticle;
|
||||
use App\Services\Article\ArticleFetcher;
|
||||
use App\Services\Notification\NotificationService;
|
||||
use App\Services\Publishing\ArticlePublishingService;
|
||||
use App\Services\Publishing\PublishOutcome;
|
||||
|
|
@ -18,7 +20,7 @@
|
|||
class PublishRouteArticleAction
|
||||
{
|
||||
public function __construct(
|
||||
private ArticleFetcher $articleFetcher,
|
||||
private FetchArticleDataAction $fetchArticleData,
|
||||
private ArticlePublishingService $publishingService,
|
||||
private NotificationService $notificationService,
|
||||
) {}
|
||||
|
|
@ -33,16 +35,26 @@ public function execute(RouteArticle $routeArticle): PublishOutcome
|
|||
$routeArticle->update(['publish_status' => PublishStatusEnum::PUBLISHING]);
|
||||
|
||||
try {
|
||||
$extractedData = $this->articleFetcher->fetchArticleData($article);
|
||||
$outcome = $this->publishingService->publishRouteArticle($routeArticle, $extractedData);
|
||||
$extractedData = $this->resolvePublishData($article);
|
||||
|
||||
$outcome = $this->hasPublishableContent($extractedData)
|
||||
? $this->publishingService->publishRouteArticle($routeArticle, $extractedData)
|
||||
: PublishOutcome::failure('Could not recover the article content to publish');
|
||||
} catch (Exception $e) {
|
||||
$routeArticle->update(['publish_status' => PublishStatusEnum::ERROR]);
|
||||
$routeArticle->recordPublishFailed($e->getMessage());
|
||||
|
||||
ActionPerformed::dispatch('Failed to publish article', LogLevelEnum::ERROR, [
|
||||
'article_id' => $article->id,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::ERROR,
|
||||
"Failed to publish \"{$article->title}\"",
|
||||
['error' => $e->getMessage()],
|
||||
$article,
|
||||
);
|
||||
|
||||
$this->notificationService->send(
|
||||
NotificationTypeEnum::PUBLISH_FAILED,
|
||||
NotificationSeverityEnum::ERROR,
|
||||
|
|
@ -63,14 +75,48 @@ public function execute(RouteArticle $routeArticle): PublishOutcome
|
|||
return $outcome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $extractedData
|
||||
*/
|
||||
private function hasPublishableContent(array $extractedData): bool
|
||||
{
|
||||
return ! empty($extractedData['description']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function resolvePublishData(Article $article): array
|
||||
{
|
||||
if (empty($article->description) && empty($article->image_url)) {
|
||||
return $this->fetchArticleData->execute($article);
|
||||
}
|
||||
|
||||
return [
|
||||
'title' => $article->title,
|
||||
'description' => $article->description,
|
||||
'thumbnail' => $article->image_url,
|
||||
];
|
||||
}
|
||||
|
||||
private function recordPublished(RouteArticle $routeArticle): void
|
||||
{
|
||||
$routeArticle->update(['publish_status' => PublishStatusEnum::PUBLISHED]);
|
||||
$routeArticle->update([
|
||||
'publish_status' => PublishStatusEnum::PUBLISHED,
|
||||
'publish_error' => null,
|
||||
]);
|
||||
|
||||
ActionPerformed::dispatch('Published article', LogLevelEnum::INFO, [
|
||||
'article_id' => $routeArticle->article->id,
|
||||
'title' => $routeArticle->article->title,
|
||||
]);
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::PUBLISH,
|
||||
"Published \"{$routeArticle->article->title}\"",
|
||||
['route_article_id' => $routeArticle->id],
|
||||
$routeArticle->article,
|
||||
);
|
||||
}
|
||||
|
||||
private function recordSkipped(RouteArticle $routeArticle, PublishOutcome $outcome): void
|
||||
|
|
@ -82,13 +128,20 @@ private function recordSkipped(RouteArticle $routeArticle, PublishOutcome $outco
|
|||
'title' => $routeArticle->article->title,
|
||||
'reason' => $outcome->reason,
|
||||
]);
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::PUBLISH,
|
||||
"Skipped \"{$routeArticle->article->title}\"",
|
||||
['skipped' => true, 'reason' => $outcome->reason],
|
||||
$routeArticle->article,
|
||||
);
|
||||
}
|
||||
|
||||
private function recordFailed(RouteArticle $routeArticle, PublishOutcome $outcome): void
|
||||
{
|
||||
$article = $routeArticle->article;
|
||||
|
||||
$routeArticle->update(['publish_status' => PublishStatusEnum::ERROR]);
|
||||
$routeArticle->recordPublishFailed($outcome->reason ?? 'Publishing failed');
|
||||
|
||||
ActionPerformed::dispatch('No publication created for article', LogLevelEnum::WARNING, [
|
||||
'article_id' => $article->id,
|
||||
|
|
@ -96,6 +149,13 @@ private function recordFailed(RouteArticle $routeArticle, PublishOutcome $outcom
|
|||
'reason' => $outcome->reason,
|
||||
]);
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::ERROR,
|
||||
"Failed to publish \"{$article->title}\"",
|
||||
['reason' => $outcome->reason],
|
||||
$article,
|
||||
);
|
||||
|
||||
$this->notificationService->send(
|
||||
NotificationTypeEnum::PUBLISH_FAILED,
|
||||
NotificationSeverityEnum::WARNING,
|
||||
|
|
|
|||
52
app/Actions/SaveArticleAction.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Services\Log\LogSaver;
|
||||
use Exception;
|
||||
|
||||
class SaveArticleAction
|
||||
{
|
||||
public function __construct(
|
||||
private LogSaver $logSaver
|
||||
) {}
|
||||
|
||||
public function execute(string $url, ?int $feedId = null): Article
|
||||
{
|
||||
try {
|
||||
$article = Article::firstOrCreate(
|
||||
['url' => $url],
|
||||
[
|
||||
'feed_id' => $feedId,
|
||||
'title' => $this->generateFallbackTitle($url),
|
||||
]
|
||||
);
|
||||
|
||||
if ($article->wasRecentlyCreated) {
|
||||
$article->dispatchFetchedEvent();
|
||||
}
|
||||
|
||||
return $article;
|
||||
} catch (Exception $e) {
|
||||
$this->logSaver->error('Failed to create article', null, [
|
||||
'url' => $url,
|
||||
'feed_id' => $feedId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function generateFallbackTitle(string $url): string
|
||||
{
|
||||
$path = parse_url($url, PHP_URL_PATH);
|
||||
$filename = basename($path ?: $url);
|
||||
|
||||
$title = preg_replace('/\.[^.]*$/', '', $filename);
|
||||
$title = str_replace(['-', '_'], ' ', $title);
|
||||
$title = ucwords($title);
|
||||
|
||||
return $title ?: 'Untitled Article';
|
||||
}
|
||||
}
|
||||
48
app/Actions/ValidateArticleAction.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Models\Article;
|
||||
|
||||
class ValidateArticleAction
|
||||
{
|
||||
public function __construct(
|
||||
private FetchArticleDataAction $fetchArticleData,
|
||||
private CreateRouteArticlesAction $createRouteArticles,
|
||||
) {}
|
||||
|
||||
public function execute(Article $article): Article
|
||||
{
|
||||
logger('Validating article for routes: '.$article->id);
|
||||
|
||||
$articleData = $this->fetchArticleData->execute($article);
|
||||
|
||||
$updateData = [];
|
||||
|
||||
if (! empty($articleData)) {
|
||||
$updateData['title'] = $articleData['title'] ?? $article->title;
|
||||
$updateData['description'] = $articleData['description'] ?? $article->description;
|
||||
$updateData['content'] = $articleData['full_article'] ?? null;
|
||||
$updateData['image_url'] = ($articleData['thumbnail'] ?? null) ?: $article->image_url;
|
||||
}
|
||||
|
||||
if (! isset($articleData['full_article']) || empty($articleData['full_article'])) {
|
||||
logger()->warning('Article data missing full_article content', [
|
||||
'article_id' => $article->id,
|
||||
'url' => $article->url,
|
||||
]);
|
||||
|
||||
$updateData['validated_at'] = now();
|
||||
$article->update($updateData);
|
||||
|
||||
return $article->refresh();
|
||||
}
|
||||
|
||||
$updateData['validated_at'] = now();
|
||||
$article->update($updateData);
|
||||
|
||||
$this->createRouteArticles->execute($article, $articleData['full_article']);
|
||||
|
||||
return $article->refresh();
|
||||
}
|
||||
}
|
||||
53
app/Dashboard/Stats/ApprovalRate.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
use App\Enums\ApprovalStatusEnum;
|
||||
use App\Models\RouteArticle;
|
||||
use App\Support\DateRange;
|
||||
|
||||
class ApprovalRate extends DailySeriesStat
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'approval-rate';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Approval Rate';
|
||||
}
|
||||
|
||||
protected function series(DateRange $range, array $days): SeriesResult
|
||||
{
|
||||
$decisions = RouteArticle::query()
|
||||
->toBase()
|
||||
->whereNotNull('decided_at')
|
||||
->whereBetween('decided_at', [$range->from, $range->to])
|
||||
->whereIn('approval_status', ApprovalStatusEnum::decidedValues())
|
||||
->selectRaw(
|
||||
'DATE(decided_at) as bucket, COUNT(*) as total, SUM(CASE WHEN approval_status = ? THEN 1 ELSE 0 END) as approved',
|
||||
[ApprovalStatusEnum::APPROVED->value],
|
||||
)
|
||||
->groupBy('bucket')
|
||||
->get()
|
||||
->keyBy('bucket');
|
||||
|
||||
$values = array_map(
|
||||
function (string $day) use ($decisions): ?float {
|
||||
$decision = $decisions->get($day);
|
||||
|
||||
if ($decision === null || (int) $decision->total === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return round(((int) $decision->approved / (int) $decision->total) * 100, 1);
|
||||
},
|
||||
$days,
|
||||
);
|
||||
|
||||
return new SeriesResult($days, [
|
||||
new Series('Approval Rate', $values, zeroIsMeaningful: true),
|
||||
]);
|
||||
}
|
||||
}
|
||||
47
app/Dashboard/Stats/ArticlesPerFeed.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Feed;
|
||||
use App\Support\DateRange;
|
||||
|
||||
class ArticlesPerFeed implements BreakdownStat
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'articles-per-feed';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Articles per Feed';
|
||||
}
|
||||
|
||||
public function for(DateRange $range): BreakdownResult
|
||||
{
|
||||
/** @var array<int, int> $counts */
|
||||
$counts = Article::query()
|
||||
->whereBetween('created_at', [$range->from, $range->to])
|
||||
->selectRaw('feed_id, COUNT(*) as aggregate')
|
||||
->groupBy('feed_id')
|
||||
->pluck('aggregate', 'feed_id')
|
||||
->all();
|
||||
|
||||
// Zero-fill in PHP; assumes the feed table stays small enough to load whole.
|
||||
$rows = Feed::query()
|
||||
->get()
|
||||
->map(fn (Feed $feed): Breakdown => new Breakdown(
|
||||
$feed->name,
|
||||
(int) ($counts[$feed->id] ?? 0),
|
||||
))
|
||||
->all();
|
||||
|
||||
usort(
|
||||
$rows,
|
||||
fn (Breakdown $a, Breakdown $b): int => [$b->count, $a->label] <=> [$a->count, $b->label],
|
||||
);
|
||||
|
||||
return new BreakdownResult($rows);
|
||||
}
|
||||
}
|
||||
51
app/Dashboard/Stats/ArticlesTrend.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\ArticlePublication;
|
||||
use App\Support\DateRange;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ArticlesTrend extends DailySeriesStat
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'articles-trend';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Articles Fetched vs Published';
|
||||
}
|
||||
|
||||
protected function series(DateRange $range, array $days): SeriesResult
|
||||
{
|
||||
return new SeriesResult($days, [
|
||||
new Series('Fetched', $this->countByDay(Article::query(), 'created_at', $range, $days)),
|
||||
new Series('Published', $this->countByDay(ArticlePublication::query(), 'published_at', $range, $days)),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<covariant Model> $query
|
||||
* @param array<int, string> $days
|
||||
* @return array<int, int>
|
||||
*/
|
||||
private function countByDay(Builder $query, string $column, DateRange $range, array $days): array
|
||||
{
|
||||
/** @var array<string, int> $counts */
|
||||
$counts = $query
|
||||
->whereBetween($column, [$range->from, $range->to])
|
||||
->selectRaw("DATE({$column}) as bucket, COUNT(*) as aggregate")
|
||||
->groupBy('bucket')
|
||||
->pluck('aggregate', 'bucket')
|
||||
->all();
|
||||
|
||||
return array_map(
|
||||
fn (string $day): int => (int) ($counts[$day] ?? 0),
|
||||
$days,
|
||||
);
|
||||
}
|
||||
}
|
||||
11
app/Dashboard/Stats/Breakdown.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
class Breakdown
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $label,
|
||||
public readonly int $count,
|
||||
) {}
|
||||
}
|
||||
25
app/Dashboard/Stats/BreakdownResult.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
class BreakdownResult
|
||||
{
|
||||
/**
|
||||
* @param array<int, Breakdown> $rows
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly array $rows,
|
||||
) {}
|
||||
|
||||
public function total(): int
|
||||
{
|
||||
return array_sum(array_map(fn (Breakdown $row): int => $row->count, $this->rows));
|
||||
}
|
||||
|
||||
public function shareOf(Breakdown $row): float
|
||||
{
|
||||
$total = $this->total();
|
||||
|
||||
return $total > 0 ? round(($row->count / $total) * 100, 1) : 0.0;
|
||||
}
|
||||
}
|
||||
10
app/Dashboard/Stats/BreakdownStat.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
use App\Support\DateRange;
|
||||
|
||||
interface BreakdownStat extends Stat
|
||||
{
|
||||
public function for(DateRange $range): BreakdownResult;
|
||||
}
|
||||
22
app/Dashboard/Stats/DailySeriesStat.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
use App\Support\DateRange;
|
||||
|
||||
abstract class DailySeriesStat implements SeriesStat
|
||||
{
|
||||
final public function for(DateRange $range): SeriesResult
|
||||
{
|
||||
if (! $range->isBucketableByDay()) {
|
||||
return SeriesResult::tooWide();
|
||||
}
|
||||
|
||||
return $this->series($range, $range->days());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $days
|
||||
*/
|
||||
abstract protected function series(DateRange $range, array $days): SeriesResult;
|
||||
}
|
||||
47
app/Dashboard/Stats/PublicationsPerChannel.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
use App\Models\ArticlePublication;
|
||||
use App\Models\PlatformChannel;
|
||||
use App\Support\DateRange;
|
||||
|
||||
class PublicationsPerChannel implements BreakdownStat
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'publications-per-channel';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Publications per Channel';
|
||||
}
|
||||
|
||||
public function for(DateRange $range): BreakdownResult
|
||||
{
|
||||
/** @var array<int, int> $counts */
|
||||
$counts = ArticlePublication::query()
|
||||
->whereBetween('published_at', [$range->from, $range->to])
|
||||
->selectRaw('platform_channel_id, COUNT(*) as aggregate')
|
||||
->groupBy('platform_channel_id')
|
||||
->pluck('aggregate', 'platform_channel_id')
|
||||
->all();
|
||||
|
||||
// Zero-fill in PHP; assumes the channel table stays small enough to load whole.
|
||||
$rows = PlatformChannel::query()
|
||||
->get()
|
||||
->map(fn (PlatformChannel $channel): Breakdown => new Breakdown(
|
||||
$channel->display_name,
|
||||
(int) ($counts[$channel->id] ?? 0),
|
||||
))
|
||||
->all();
|
||||
|
||||
usort(
|
||||
$rows,
|
||||
fn (Breakdown $a, Breakdown $b): int => [$b->count, $a->label] <=> [$a->count, $b->label],
|
||||
);
|
||||
|
||||
return new BreakdownResult($rows);
|
||||
}
|
||||
}
|
||||
53
app/Dashboard/Stats/PublishSuccessRate.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
use App\Enums\PublishStatusEnum;
|
||||
use App\Models\RouteArticle;
|
||||
use App\Support\DateRange;
|
||||
|
||||
class PublishSuccessRate extends DailySeriesStat
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'publish-success-rate';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Publish Success Rate';
|
||||
}
|
||||
|
||||
protected function series(DateRange $range, array $days): SeriesResult
|
||||
{
|
||||
// Buckets follow updated_at, so a retry re-dates its article to the retry day.
|
||||
$attempts = RouteArticle::query()
|
||||
->toBase()
|
||||
->whereBetween('updated_at', [$range->from, $range->to])
|
||||
->whereIn('publish_status', PublishStatusEnum::settledValues())
|
||||
->selectRaw(
|
||||
'DATE(updated_at) as bucket, COUNT(*) as total, SUM(CASE WHEN publish_status = ? THEN 1 ELSE 0 END) as published',
|
||||
[PublishStatusEnum::PUBLISHED->value],
|
||||
)
|
||||
->groupBy('bucket')
|
||||
->get()
|
||||
->keyBy('bucket');
|
||||
|
||||
$values = array_map(
|
||||
function (string $day) use ($attempts): ?float {
|
||||
$attempt = $attempts->get($day);
|
||||
|
||||
if ($attempt === null || (int) $attempt->total === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return round(((int) $attempt->published / (int) $attempt->total) * 100, 1);
|
||||
},
|
||||
$days,
|
||||
);
|
||||
|
||||
return new SeriesResult($days, [
|
||||
new Series('Publish Success Rate', $values, zeroIsMeaningful: true),
|
||||
]);
|
||||
}
|
||||
}
|
||||
31
app/Dashboard/Stats/Series.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
class Series
|
||||
{
|
||||
/**
|
||||
* @param array<int, int|float|null> $values
|
||||
* @param bool $zeroIsMeaningful A rate of 0 is a real measurement; a count of 0 is an absence.
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $name,
|
||||
public readonly array $values,
|
||||
public readonly bool $zeroIsMeaningful = false,
|
||||
) {}
|
||||
|
||||
public function hasData(): bool
|
||||
{
|
||||
foreach ($this->values as $value) {
|
||||
if ($value === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->zeroIsMeaningful || $value != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
58
app/Dashboard/Stats/SeriesResult.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
class SeriesResult
|
||||
{
|
||||
private bool $tooWide = false;
|
||||
|
||||
/**
|
||||
* @param array<int, string> $labels
|
||||
* @param array<int, Series> $series
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly array $labels,
|
||||
public readonly array $series,
|
||||
) {
|
||||
foreach ($series as $one) {
|
||||
if (count($one->values) !== count($labels)) {
|
||||
throw new InvalidArgumentException(
|
||||
"Series [{$one->name}] has ".count($one->values).' values for '.count($labels).' labels.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function tooWide(): self
|
||||
{
|
||||
$result = new self([], []);
|
||||
$result->tooWide = true;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function isTooWide(): bool
|
||||
{
|
||||
return $this->tooWide;
|
||||
}
|
||||
|
||||
/** True only when no axis was built; a real range always has one label per day. */
|
||||
public function isEmpty(): bool
|
||||
{
|
||||
return ! $this->tooWide && $this->labels === [];
|
||||
}
|
||||
|
||||
/** True when no series carries a measurement — an axis exists but nothing happened on it. */
|
||||
public function hasNoData(): bool
|
||||
{
|
||||
foreach ($this->series as $one) {
|
||||
if ($one->hasData()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
10
app/Dashboard/Stats/SeriesStat.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
use App\Support\DateRange;
|
||||
|
||||
interface SeriesStat extends Stat
|
||||
{
|
||||
public function for(DateRange $range): SeriesResult;
|
||||
}
|
||||
13
app/Dashboard/Stats/Stat.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard\Stats;
|
||||
|
||||
interface Stat
|
||||
{
|
||||
/**
|
||||
* Stable identifier. Island names in dashboard.blade.php are written to match by hand, not derived from this.
|
||||
*/
|
||||
public function key(): string;
|
||||
|
||||
public function label(): string;
|
||||
}
|
||||
19
app/Enums/AccountStatusEnum.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum AccountStatusEnum: string
|
||||
{
|
||||
case UNTESTED = 'untested';
|
||||
case HEALTHY = 'healthy';
|
||||
case UNHEALTHY = 'unhealthy';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::UNTESTED => 'Untested',
|
||||
self::HEALTHY => 'Healthy',
|
||||
self::UNHEALTHY => 'Unhealthy',
|
||||
};
|
||||
}
|
||||
}
|
||||
39
app/Enums/ActivityTypeEnum.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum ActivityTypeEnum: string
|
||||
{
|
||||
case FETCH = 'fetch';
|
||||
case VALIDATE = 'validate';
|
||||
case APPROVE = 'approve';
|
||||
case REJECT = 'reject';
|
||||
case PUBLISH = 'publish';
|
||||
case ERROR = 'error';
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::FETCH => 'Fetched',
|
||||
self::VALIDATE => 'Validated',
|
||||
self::APPROVE => 'Approved',
|
||||
self::REJECT => 'Rejected',
|
||||
self::PUBLISH => 'Published',
|
||||
self::ERROR => 'Error',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function options(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (self::cases() as $case) {
|
||||
$options[$case->value] = $case->label();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,4 +7,20 @@ enum ApprovalStatusEnum: string
|
|||
case PENDING = 'pending';
|
||||
case APPROVED = 'approved';
|
||||
case REJECTED = 'rejected';
|
||||
|
||||
public function isDecided(): bool
|
||||
{
|
||||
return $this !== self::PENDING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function decidedValues(): array
|
||||
{
|
||||
return array_values(array_map(
|
||||
fn (self $status): string => $status->value,
|
||||
array_filter(self::cases(), fn (self $status): bool => $status->isDecided()),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
36
app/Enums/FeedColorEnum.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum FeedColorEnum: string
|
||||
{
|
||||
case SLATE = 'slate';
|
||||
case AMBER = 'amber';
|
||||
case SKY = 'sky';
|
||||
case VIOLET = 'violet';
|
||||
case TEAL = 'teal';
|
||||
case ROSE = 'rose';
|
||||
case INDIGO = 'indigo';
|
||||
case ORANGE = 'orange';
|
||||
|
||||
public function dotClass(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::SLATE => 'bg-slate-500',
|
||||
self::AMBER => 'bg-amber-500',
|
||||
self::SKY => 'bg-sky-500',
|
||||
self::VIOLET => 'bg-violet-500',
|
||||
self::TEAL => 'bg-teal-500',
|
||||
self::ROSE => 'bg-rose-500',
|
||||
self::INDIGO => 'bg-indigo-500',
|
||||
self::ORANGE => 'bg-orange-500',
|
||||
};
|
||||
}
|
||||
|
||||
public static function forId(int $id): self
|
||||
{
|
||||
$cases = self::cases();
|
||||
|
||||
return $cases[$id % count($cases)];
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ enum NotificationTypeEnum: string
|
|||
{
|
||||
case GENERAL = 'general';
|
||||
case FEED_STALE = 'feed_stale';
|
||||
case FEED_EMPTY = 'feed_empty';
|
||||
case PUBLISH_FAILED = 'publish_failed';
|
||||
case CREDENTIAL_EXPIRED = 'credential_expired';
|
||||
|
||||
|
|
@ -14,6 +15,7 @@ public function label(): string
|
|||
return match ($this) {
|
||||
self::GENERAL => 'General',
|
||||
self::FEED_STALE => 'Feed Stale',
|
||||
self::FEED_EMPTY => 'Feed Empty',
|
||||
self::PUBLISH_FAILED => 'Publish Failed',
|
||||
self::CREDENTIAL_EXPIRED => 'Credential Expired',
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,4 +9,21 @@ enum PublishStatusEnum: string
|
|||
case PUBLISHED = 'published';
|
||||
case SKIPPED = 'skipped';
|
||||
case ERROR = 'error';
|
||||
|
||||
/** Skipped articles were never attempted, so they are not a publish outcome. */
|
||||
public function isSettled(): bool
|
||||
{
|
||||
return $this === self::PUBLISHED || $this === self::ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function settledValues(): array
|
||||
{
|
||||
return array_values(array_map(
|
||||
fn (self $status): string => $status->value,
|
||||
array_filter(self::cases(), fn (self $status): bool => $status->isSettled()),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
app/Events/ActivityLogged.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
|
||||
class ActivityLogged
|
||||
{
|
||||
use Dispatchable;
|
||||
|
||||
public function __construct(
|
||||
public ActivityTypeEnum $type,
|
||||
public string $message,
|
||||
/** @var array<string, mixed> */
|
||||
public array $context = [],
|
||||
public ?Model $subject = null,
|
||||
) {}
|
||||
}
|
||||
|
|
@ -2,10 +2,11 @@
|
|||
|
||||
namespace App\Http\Controllers\Api\V1;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Services\DashboardStatsService;
|
||||
use App\Support\DateRange;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class DashboardController extends BaseController
|
||||
{
|
||||
|
|
@ -18,23 +19,26 @@ public function __construct(
|
|||
*/
|
||||
public function stats(Request $request): JsonResponse
|
||||
{
|
||||
$period = $request->get('period', 'today');
|
||||
$validated = $request->validate([
|
||||
'from' => ['nullable', 'date', 'required_with:to'],
|
||||
'to' => ['nullable', 'date', 'after_or_equal:from', 'required_with:from'],
|
||||
]);
|
||||
|
||||
$range = isset($validated['from'], $validated['to'])
|
||||
? new DateRange(
|
||||
Carbon::parse($validated['from'])->startOfDay(),
|
||||
Carbon::parse($validated['to'])->endOfDay(),
|
||||
)
|
||||
: DateRange::preset('today');
|
||||
|
||||
try {
|
||||
// Get article stats from service
|
||||
$articleStats = $this->dashboardStatsService->getStats($period);
|
||||
|
||||
// Get system stats
|
||||
$systemStats = $this->dashboardStatsService->getSystemStats();
|
||||
|
||||
// Get available periods
|
||||
$availablePeriods = $this->dashboardStatsService->getAvailablePeriods();
|
||||
|
||||
return $this->sendResponse([
|
||||
'article_stats' => $articleStats,
|
||||
'system_stats' => $systemStats,
|
||||
'available_periods' => $availablePeriods,
|
||||
'current_period' => $period,
|
||||
'article_stats' => $this->dashboardStatsService->getStats($range),
|
||||
'system_stats' => $this->dashboardStatsService->getSystemStats(),
|
||||
'range' => [
|
||||
'from' => $range->from->toDateString(),
|
||||
'to' => $range->to->toDateString(),
|
||||
],
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->sendError('Failed to fetch dashboard stats: '.$e->getMessage(), [], 500);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,10 @@ public function reject(RouteArticle $routeArticle): JsonResponse
|
|||
public function restore(RouteArticle $routeArticle): JsonResponse
|
||||
{
|
||||
try {
|
||||
$routeArticle->update(['approval_status' => ApprovalStatusEnum::PENDING]);
|
||||
$routeArticle->update([
|
||||
'approval_status' => ApprovalStatusEnum::PENDING,
|
||||
'decided_at' => null,
|
||||
]);
|
||||
|
||||
return $this->sendResponse(
|
||||
new RouteArticleResource($routeArticle->fresh(['article.feed', 'feed', 'platformChannel'])),
|
||||
|
|
@ -88,7 +91,10 @@ public function clear(): JsonResponse
|
|||
$count = RouteArticle::where('approval_status', ApprovalStatusEnum::PENDING)->count();
|
||||
|
||||
RouteArticle::where('approval_status', ApprovalStatusEnum::PENDING)
|
||||
->update(['approval_status' => ApprovalStatusEnum::REJECTED]);
|
||||
->update([
|
||||
'approval_status' => ApprovalStatusEnum::REJECTED,
|
||||
'decided_at' => now(),
|
||||
]);
|
||||
|
||||
return $this->sendResponse(
|
||||
['rejected_count' => $count],
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public function index(): JsonResponse
|
|||
'article_processing_enabled' => Setting::isArticleProcessingEnabled(),
|
||||
'publishing_approvals_enabled' => Setting::isPublishingApprovalsEnabled(),
|
||||
'article_publishing_interval' => Setting::getArticlePublishingInterval(),
|
||||
'daily_publish_cap' => Setting::getDailyPublishCap(),
|
||||
];
|
||||
|
||||
return $this->sendResponse($settings, 'Settings retrieved successfully.');
|
||||
|
|
@ -37,6 +38,7 @@ public function update(Request $request): JsonResponse
|
|||
'article_processing_enabled' => 'boolean',
|
||||
'publishing_approvals_enabled' => 'boolean',
|
||||
'article_publishing_interval' => 'integer|min:0',
|
||||
'daily_publish_cap' => 'integer|min:0',
|
||||
]);
|
||||
|
||||
if (isset($validated['article_processing_enabled'])) {
|
||||
|
|
@ -51,10 +53,15 @@ public function update(Request $request): JsonResponse
|
|||
Setting::setArticlePublishingInterval($validated['article_publishing_interval']);
|
||||
}
|
||||
|
||||
if (isset($validated['daily_publish_cap'])) {
|
||||
Setting::setDailyPublishCap($validated['daily_publish_cap']);
|
||||
}
|
||||
|
||||
$updatedSettings = [
|
||||
'article_processing_enabled' => Setting::isArticleProcessingEnabled(),
|
||||
'publishing_approvals_enabled' => Setting::isPublishingApprovalsEnabled(),
|
||||
'article_publishing_interval' => Setting::getArticlePublishingInterval(),
|
||||
'daily_publish_cap' => Setting::getDailyPublishCap(),
|
||||
];
|
||||
|
||||
return $this->sendResponse(
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Middleware;
|
||||
|
||||
class HandleInertiaRequests extends Middleware
|
||||
{
|
||||
/**
|
||||
* The root template that's loaded on the first page visit.
|
||||
*
|
||||
* @see https://inertiajs.com/server-side-setup#root-template
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rootView = 'app';
|
||||
|
||||
/**
|
||||
* Determines the current asset version.
|
||||
*
|
||||
* @see https://inertiajs.com/asset-versioning
|
||||
*/
|
||||
public function version(Request $request): ?string
|
||||
{
|
||||
return parent::version($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the props that are shared by default.
|
||||
*
|
||||
* @see https://inertiajs.com/shared-data
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function share(Request $request): array
|
||||
{
|
||||
return array_merge(parent::share($request), [
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,15 @@
|
|||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Actions\FetchFeedArticlesAction;
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use App\Enums\NotificationSeverityEnum;
|
||||
use App\Enums\NotificationTypeEnum;
|
||||
use App\Events\ActivityLogged;
|
||||
use App\Models\Feed;
|
||||
use App\Services\Article\ArticleFetcher;
|
||||
use App\Models\Notification;
|
||||
use App\Services\Log\LogSaver;
|
||||
use App\Services\Notification\NotificationService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
|
|
@ -20,7 +26,7 @@ public function __construct(
|
|||
$this->onQueue('feed-discovery');
|
||||
}
|
||||
|
||||
public function handle(LogSaver $logSaver, ArticleFetcher $articleFetcher): void
|
||||
public function handle(LogSaver $logSaver, FetchFeedArticlesAction $fetchFeedArticles, NotificationService $notificationService): void
|
||||
{
|
||||
$logSaver->info('Starting feed article fetch', null, [
|
||||
'feed_id' => $this->feed->id,
|
||||
|
|
@ -28,7 +34,7 @@ public function handle(LogSaver $logSaver, ArticleFetcher $articleFetcher): void
|
|||
'feed_url' => $this->feed->url,
|
||||
]);
|
||||
|
||||
$articles = $articleFetcher->getArticlesFromFeed($this->feed);
|
||||
$articles = $fetchFeedArticles->execute($this->feed);
|
||||
|
||||
$logSaver->info('Feed article fetch completed', null, [
|
||||
'feed_id' => $this->feed->id,
|
||||
|
|
@ -37,6 +43,48 @@ public function handle(LogSaver $logSaver, ArticleFetcher $articleFetcher): void
|
|||
]);
|
||||
|
||||
$this->feed->update(['last_fetched_at' => now()]);
|
||||
|
||||
if ($articles->isEmpty()) {
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::ERROR,
|
||||
"{$this->feed->name} returned no articles",
|
||||
['articles_count' => 0],
|
||||
$this->feed,
|
||||
);
|
||||
|
||||
$this->warnFeedReturnedNothing($notificationService);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::FETCH,
|
||||
"Fetched {$articles->count()} articles from {$this->feed->name}",
|
||||
['articles_count' => $articles->count()],
|
||||
$this->feed,
|
||||
);
|
||||
}
|
||||
|
||||
private function warnFeedReturnedNothing(NotificationService $notificationService): void
|
||||
{
|
||||
$alreadyNotified = Notification::query()
|
||||
->where('type', NotificationTypeEnum::FEED_EMPTY)
|
||||
->where('notifiable_type', $this->feed->getMorphClass())
|
||||
->where('notifiable_id', $this->feed->getKey())
|
||||
->unread()
|
||||
->exists();
|
||||
|
||||
if ($alreadyNotified) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notificationService->send(
|
||||
type: NotificationTypeEnum::FEED_EMPTY,
|
||||
severity: NotificationSeverityEnum::WARNING,
|
||||
title: "Feed \"{$this->feed->name}\" returned no articles",
|
||||
message: "The fetch completed but produced nothing. Check that {$this->feed->url} is still a valid feed.",
|
||||
notifiable: $this->feed,
|
||||
);
|
||||
}
|
||||
|
||||
public static function dispatchForAllActiveFeeds(): void
|
||||
|
|
|
|||
79
app/Jobs/CheckPlatformCredentialsJob.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Enums\NotificationSeverityEnum;
|
||||
use App\Enums\NotificationTypeEnum;
|
||||
use App\Models\Notification;
|
||||
use App\Models\PlatformAccount;
|
||||
use App\Modules\Lemmy\Services\LemmyApiService;
|
||||
use App\Services\Notification\NotificationService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Throwable;
|
||||
|
||||
class CheckPlatformCredentialsJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function handle(NotificationService $notificationService): void
|
||||
{
|
||||
$accounts = PlatformAccount::where('is_active', true)->get();
|
||||
|
||||
foreach ($accounts as $account) {
|
||||
$this->check($account, $notificationService);
|
||||
}
|
||||
}
|
||||
|
||||
private function check(PlatformAccount $account, NotificationService $notificationService): void
|
||||
{
|
||||
if ($this->canLogIn($account)) {
|
||||
$account->recordCredentialCheckPassed();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$wasUnhealthy = $account->isUnhealthy();
|
||||
$account->recordCredentialCheckFailed();
|
||||
|
||||
if (! $wasUnhealthy && $account->refresh()->isUnhealthy()) {
|
||||
$this->notify($account, $notificationService);
|
||||
}
|
||||
}
|
||||
|
||||
private function canLogIn(PlatformAccount $account): bool
|
||||
{
|
||||
try {
|
||||
return $this->makeApiService($account)->login($account->username, $account->password) !== null;
|
||||
} catch (Throwable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function makeApiService(PlatformAccount $account): LemmyApiService
|
||||
{
|
||||
return new LemmyApiService($account->instance_url);
|
||||
}
|
||||
|
||||
private function notify(PlatformAccount $account, NotificationService $notificationService): void
|
||||
{
|
||||
$alreadyNotified = Notification::query()
|
||||
->where('type', NotificationTypeEnum::CREDENTIAL_EXPIRED)
|
||||
->where('notifiable_type', $account->getMorphClass())
|
||||
->where('notifiable_id', $account->getKey())
|
||||
->unread()
|
||||
->exists();
|
||||
|
||||
if ($alreadyNotified) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notificationService->send(
|
||||
type: NotificationTypeEnum::CREDENTIAL_EXPIRED,
|
||||
severity: NotificationSeverityEnum::ERROR,
|
||||
title: "Credentials failed for {$account->username}",
|
||||
message: "Could not log in to {$account->instance_url} after ".PlatformAccount::FAILURES_BEFORE_UNHEALTHY.' attempts. Publishing to this account will fail until it is fixed.',
|
||||
notifiable: $account,
|
||||
);
|
||||
}
|
||||
}
|
||||
19
app/Jobs/CleanupActivityLogsJob.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\ActivityLog;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class CleanupActivityLogsJob implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
private const RETENTION_DAYS = 90;
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
ActivityLog::where('logged_at', '<', now()->subDays(self::RETENTION_DAYS))->delete();
|
||||
}
|
||||
}
|
||||
|
|
@ -35,6 +35,10 @@ public function __construct()
|
|||
*/
|
||||
public function handle(PublishRouteArticleAction $publishRouteArticle): void
|
||||
{
|
||||
if ($this->dailyCapReached()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$interval = Setting::getArticlePublishingInterval();
|
||||
|
||||
if ($interval > 0) {
|
||||
|
|
@ -47,6 +51,7 @@ public function handle(PublishRouteArticleAction $publishRouteArticle): void
|
|||
|
||||
// Get the oldest approved route_article that hasn't been published to its channel yet
|
||||
$routeArticle = RouteArticle::where('approval_status', ApprovalStatusEnum::APPROVED)
|
||||
->dueForPublishing()
|
||||
->whereDoesntHave('article.articlePublications', function ($query) {
|
||||
$query->whereColumn('article_publications.platform_channel_id', 'route_articles.platform_channel_id');
|
||||
})
|
||||
|
|
@ -69,4 +74,15 @@ public function handle(PublishRouteArticleAction $publishRouteArticle): void
|
|||
|
||||
$publishRouteArticle->execute($routeArticle);
|
||||
}
|
||||
|
||||
private function dailyCapReached(): bool
|
||||
{
|
||||
$cap = Setting::getDailyPublishCap();
|
||||
|
||||
if ($cap <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ArticlePublication::where('published_at', '>=', now()->startOfDay())->count() >= $cap;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
29
app/Listeners/RecordActivityListener.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\ActivityLogged;
|
||||
use App\Models\ActivityLog;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
class RecordActivityListener
|
||||
{
|
||||
private const MESSAGE_LIMIT = 255;
|
||||
|
||||
public function handle(ActivityLogged $event): void
|
||||
{
|
||||
try {
|
||||
ActivityLog::create([
|
||||
'type' => $event->type,
|
||||
'message' => Str::limit($event->message, self::MESSAGE_LIMIT, ''),
|
||||
'context' => $event->context === [] ? null : $event->context,
|
||||
'subject_type' => $event->subject?->getMorphClass(),
|
||||
'subject_id' => $event->subject?->getKey(),
|
||||
'logged_at' => now(),
|
||||
]);
|
||||
} catch (Throwable $e) {
|
||||
error_log('Failed to record activity: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Actions\ValidateArticleAction;
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use App\Enums\LogLevelEnum;
|
||||
use App\Events\ActionPerformed;
|
||||
use App\Events\ActivityLogged;
|
||||
use App\Events\NewArticleFetched;
|
||||
use App\Services\Article\ValidationService;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
|
||||
|
|
@ -14,7 +16,7 @@ class ValidateArticleListener implements ShouldQueue
|
|||
public string $queue = 'default';
|
||||
|
||||
public function __construct(
|
||||
private ValidationService $validationService
|
||||
private ValidateArticleAction $validateArticle
|
||||
) {}
|
||||
|
||||
public function handle(NewArticleFetched $event): void
|
||||
|
|
@ -31,12 +33,26 @@ public function handle(NewArticleFetched $event): void
|
|||
}
|
||||
|
||||
try {
|
||||
$this->validationService->validate($article);
|
||||
$this->validateArticle->execute($article);
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::VALIDATE,
|
||||
"Validated \"{$article->title}\"",
|
||||
[],
|
||||
$article,
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
ActionPerformed::dispatch('Article validation failed', LogLevelEnum::ERROR, [
|
||||
'article_id' => $article->id,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::ERROR,
|
||||
"Validation failed for \"{$article->title}\"",
|
||||
['error' => $e->getMessage()],
|
||||
$article,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
55
app/Livewire/Activity.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use App\Models\ActivityLog;
|
||||
use App\Services\Activity\ActivitySummary;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class Activity extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public string $type = '';
|
||||
|
||||
public int $days = 7;
|
||||
|
||||
public function updatedType(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedDays(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder<ActivityLog>
|
||||
*/
|
||||
private function query(): Builder
|
||||
{
|
||||
return ActivityLog::query()
|
||||
->withSubjectDetails()
|
||||
->since(now()->subDays($this->days))
|
||||
->when(
|
||||
$this->type !== '',
|
||||
fn (Builder $q) => $q->where('type', $this->type),
|
||||
)
|
||||
->latestFirst();
|
||||
}
|
||||
|
||||
public function render(ActivitySummary $summary): View
|
||||
{
|
||||
return view('livewire.activity', [
|
||||
'entries' => $this->query()->paginate(25),
|
||||
'typeOptions' => ActivityTypeEnum::options(),
|
||||
'summaryDay' => $summary->since(now()->subDay()),
|
||||
'summaryWeek' => $summary->since(now()->subWeek()),
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,17 @@
|
|||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use App\Enums\ApprovalStatusEnum;
|
||||
use App\Events\ActivityLogged;
|
||||
use App\Jobs\ArticleDiscoveryJob;
|
||||
use App\Models\Feed;
|
||||
use App\Models\RouteArticle;
|
||||
use App\Support\PendingFeedGroup;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
|
|
@ -17,15 +24,38 @@ class Articles extends Component
|
|||
|
||||
public string $search = '';
|
||||
|
||||
public ?int $feedId = null;
|
||||
|
||||
public bool $isRefreshing = false;
|
||||
|
||||
/** @var array<int, bool> */
|
||||
public array $expandedFeeds = [];
|
||||
|
||||
public function setTab(string $tab): void
|
||||
{
|
||||
$this->tab = $tab;
|
||||
$this->search = '';
|
||||
$this->expandedFeeds = [];
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function updatedFeedId(): void
|
||||
{
|
||||
$this->expandedFeeds = [];
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
public function toggleFeed(int $feedId): void
|
||||
{
|
||||
if (isset($this->expandedFeeds[$feedId])) {
|
||||
unset($this->expandedFeeds[$feedId]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->expandedFeeds[$feedId] = true;
|
||||
}
|
||||
|
||||
public function updatedSearch(): void
|
||||
{
|
||||
$this->resetPage();
|
||||
|
|
@ -44,13 +74,42 @@ public function reject(int $routeArticleId): void
|
|||
public function restore(int $routeArticleId): void
|
||||
{
|
||||
$routeArticle = RouteArticle::findOrFail($routeArticleId);
|
||||
$routeArticle->update(['approval_status' => ApprovalStatusEnum::PENDING]);
|
||||
$routeArticle->update([
|
||||
'approval_status' => ApprovalStatusEnum::PENDING,
|
||||
'decided_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
RouteArticle::where('approval_status', ApprovalStatusEnum::PENDING)
|
||||
->update(['approval_status' => ApprovalStatusEnum::REJECTED]);
|
||||
$feed = $this->feedId !== null ? Feed::find($this->feedId) : null;
|
||||
$cleared = $this->clearableQuery()->update([
|
||||
'approval_status' => ApprovalStatusEnum::REJECTED,
|
||||
'decided_at' => now(),
|
||||
]);
|
||||
|
||||
if ($cleared > 0) {
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::REJECT,
|
||||
$feed !== null
|
||||
? "Cleared {$cleared} pending articles from {$feed->name}"
|
||||
: "Cleared {$cleared} pending articles",
|
||||
['cleared' => $cleared],
|
||||
$feed,
|
||||
);
|
||||
}
|
||||
|
||||
$this->expandedFeeds = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Builder<RouteArticle>
|
||||
*/
|
||||
private function clearableQuery(): Builder
|
||||
{
|
||||
return RouteArticle::query()
|
||||
->where('approval_status', ApprovalStatusEnum::PENDING)
|
||||
->when($this->feedId !== null, fn (Builder $q) => $q->where('feed_id', $this->feedId));
|
||||
}
|
||||
|
||||
public function refresh(): void
|
||||
|
|
@ -62,14 +121,52 @@ public function refresh(): void
|
|||
$this->dispatch('refresh-started');
|
||||
}
|
||||
|
||||
public function retryPublish(int $routeArticleId): void
|
||||
{
|
||||
$routeArticle = RouteArticle::failed()->find($routeArticleId);
|
||||
|
||||
if (! $routeArticle instanceof RouteArticle) {
|
||||
return;
|
||||
}
|
||||
|
||||
$routeArticle->clearPublishFailure();
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::PUBLISH,
|
||||
"Queued \"{$routeArticle->article->title}\" for another publish attempt",
|
||||
['route_article_id' => $routeArticle->id],
|
||||
$routeArticle->article,
|
||||
);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
$pendingCount = RouteArticle::where('approval_status', ApprovalStatusEnum::PENDING)->count();
|
||||
$failedCount = RouteArticle::failed()->count();
|
||||
|
||||
if ($this->tab === 'pending') {
|
||||
return view('livewire.articles', [
|
||||
'routeArticles' => null,
|
||||
'pendingFeeds' => $this->pendingFeeds(),
|
||||
'feedOptions' => $this->feedOptions(),
|
||||
'pendingCount' => $pendingCount,
|
||||
'failedCount' => $failedCount,
|
||||
'clearableCount' => $this->clearableQuery()->count(),
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
$query = RouteArticle::with(['article.feed', 'feed', 'platformChannel'])
|
||||
->orderBy('created_at', 'desc');
|
||||
|
||||
if ($this->tab === 'pending') {
|
||||
$query->where('approval_status', ApprovalStatusEnum::PENDING);
|
||||
} elseif ($this->search !== '') {
|
||||
if ($this->tab === 'failed') {
|
||||
$query->failed();
|
||||
}
|
||||
|
||||
if ($this->feedId !== null) {
|
||||
$query->where('feed_id', $this->feedId);
|
||||
}
|
||||
|
||||
if ($this->search !== '') {
|
||||
$search = $this->search;
|
||||
$query->whereHas('article', function ($q) use ($search) {
|
||||
$q->where('title', 'like', "%{$search}%")
|
||||
|
|
@ -77,13 +174,59 @@ public function render(): View
|
|||
});
|
||||
}
|
||||
|
||||
$routeArticles = $query->paginate(15);
|
||||
|
||||
$pendingCount = RouteArticle::where('approval_status', ApprovalStatusEnum::PENDING)->count();
|
||||
|
||||
return view('livewire.articles', [
|
||||
'routeArticles' => $routeArticles,
|
||||
'routeArticles' => $query->paginate(15),
|
||||
'pendingFeeds' => null,
|
||||
'feedOptions' => $this->feedOptions(),
|
||||
'pendingCount' => $pendingCount,
|
||||
'failedCount' => $failedCount,
|
||||
'clearableCount' => 0,
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, PendingFeedGroup>
|
||||
*/
|
||||
private function pendingFeeds(): Collection
|
||||
{
|
||||
$counts = RouteArticle::query()
|
||||
->selectRaw('feed_id, COUNT(*) as aggregate')
|
||||
->where('approval_status', ApprovalStatusEnum::PENDING)
|
||||
->when($this->feedId !== null, fn ($q) => $q->where('feed_id', $this->feedId))
|
||||
->groupBy('feed_id')
|
||||
->pluck('aggregate', 'feed_id');
|
||||
|
||||
return Feed::whereIn('id', $counts->keys())->get()
|
||||
->map(fn (Feed $feed): PendingFeedGroup => new PendingFeedGroup(
|
||||
$feed,
|
||||
(int) $counts->get($feed->id, 0),
|
||||
isset($this->expandedFeeds[$feed->id])
|
||||
? $this->routeArticlesForFeed($feed->id)
|
||||
: null,
|
||||
))
|
||||
->sortByDesc('count')
|
||||
->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EloquentCollection<int, Feed>
|
||||
*/
|
||||
private function feedOptions(): EloquentCollection
|
||||
{
|
||||
return Feed::whereIn('id', RouteArticle::query()->select('feed_id')->distinct())
|
||||
->orderBy('name')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return EloquentCollection<int, RouteArticle>
|
||||
*/
|
||||
private function routeArticlesForFeed(int $feedId): EloquentCollection
|
||||
{
|
||||
return RouteArticle::with(['article.feed', 'feed', 'platformChannel'])
|
||||
->where('approval_status', ApprovalStatusEnum::PENDING)
|
||||
->where('feed_id', $feedId)
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,14 @@
|
|||
namespace App\Livewire;
|
||||
|
||||
use App\Actions\CreateChannelAction;
|
||||
use App\Enums\LogLevelEnum;
|
||||
use App\Events\ActionPerformed;
|
||||
use App\Models\ArticlePublication;
|
||||
use App\Models\Language;
|
||||
use App\Models\PlatformAccount;
|
||||
use App\Models\PlatformChannel;
|
||||
use App\Models\PlatformInstance;
|
||||
use App\Models\RouteArticle;
|
||||
use App\Services\Platform\CommunityDirectory;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
|
@ -34,6 +38,14 @@ class Channels extends Component
|
|||
|
||||
public string $newDescription = '';
|
||||
|
||||
public ?int $editingChannelId = null;
|
||||
|
||||
public string $editDisplayName = '';
|
||||
|
||||
public ?int $editLanguageId = null;
|
||||
|
||||
public string $editDescription = '';
|
||||
|
||||
public function toggle(int $channelId): void
|
||||
{
|
||||
$channel = PlatformChannel::findOrFail($channelId);
|
||||
|
|
@ -41,6 +53,34 @@ public function toggle(int $channelId): void
|
|||
$channel->save();
|
||||
}
|
||||
|
||||
public function deleteChannel(int $channelId): void
|
||||
{
|
||||
$channel = PlatformChannel::find($channelId);
|
||||
|
||||
if (! $channel instanceof PlatformChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
$name = $channel->display_name;
|
||||
|
||||
// Routes, keywords, route articles, publications, account links and synced posts
|
||||
// all cascade at the database level.
|
||||
$channel->delete();
|
||||
|
||||
if ($this->managingChannelId === $channelId) {
|
||||
$this->managingChannelId = null;
|
||||
}
|
||||
|
||||
if ($this->editingChannelId === $channelId) {
|
||||
$this->editingChannelId = null;
|
||||
}
|
||||
|
||||
ActionPerformed::dispatch('Deleted platform channel', LogLevelEnum::WARNING, [
|
||||
'platform_channel_id' => $channelId,
|
||||
'display_name' => $name,
|
||||
]);
|
||||
}
|
||||
|
||||
public function openCreateModal(): void
|
||||
{
|
||||
$this->reset(['newCommunityId', 'newPlatformInstanceId', 'newLanguageId', 'newDescription', 'availableCommunities', 'communityLoadError']);
|
||||
|
|
@ -127,6 +167,45 @@ public function createChannel(CreateChannelAction $action): void
|
|||
$this->closeCreateModal();
|
||||
}
|
||||
|
||||
public function openEditModal(int $channelId): void
|
||||
{
|
||||
$channel = PlatformChannel::findOrFail($channelId);
|
||||
|
||||
$this->resetErrorBag();
|
||||
$this->editingChannelId = $channelId;
|
||||
$this->editDisplayName = $channel->display_name;
|
||||
$this->editLanguageId = $channel->language_id;
|
||||
$this->editDescription = $channel->description ?? '';
|
||||
}
|
||||
|
||||
public function closeEditModal(): void
|
||||
{
|
||||
$this->editingChannelId = null;
|
||||
}
|
||||
|
||||
// The community pairing (name, channel_id, platform_instance_id) is deliberately immutable:
|
||||
// it is the channel's remote identity, unique per instance, and re-pointing it would change
|
||||
// the meaning of every route already attached.
|
||||
public function updateChannel(): void
|
||||
{
|
||||
if ($this->editingChannelId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->validate([
|
||||
'editDisplayName' => 'required|string|max:255',
|
||||
'editLanguageId' => 'nullable|integer|exists:languages,id',
|
||||
]);
|
||||
|
||||
PlatformChannel::findOrFail($this->editingChannelId)->update([
|
||||
'display_name' => $this->editDisplayName,
|
||||
'language_id' => $this->editLanguageId,
|
||||
'description' => $this->editDescription !== '' ? $this->editDescription : null,
|
||||
]);
|
||||
|
||||
$this->closeEditModal();
|
||||
}
|
||||
|
||||
public function openAccountModal(int $channelId): void
|
||||
{
|
||||
$this->managingChannelId = $channelId;
|
||||
|
|
@ -161,6 +240,39 @@ public function detachAccount(int $channelId, int $accountId): void
|
|||
$channel->platformAccounts()->detach($accountId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Row counts per channel, so the delete confirmation can say what is about to go.
|
||||
*
|
||||
* @return array<int, array{articles: int, publications: int}>
|
||||
*/
|
||||
private function deletionImpact(): array
|
||||
{
|
||||
/** @var array<int, int> $articles */
|
||||
$articles = RouteArticle::query()
|
||||
->selectRaw('platform_channel_id, COUNT(*) as aggregate')
|
||||
->groupBy('platform_channel_id')
|
||||
->pluck('aggregate', 'platform_channel_id')
|
||||
->all();
|
||||
|
||||
/** @var array<int, int> $publications */
|
||||
$publications = ArticlePublication::query()
|
||||
->selectRaw('platform_channel_id, COUNT(*) as aggregate')
|
||||
->groupBy('platform_channel_id')
|
||||
->pluck('aggregate', 'platform_channel_id')
|
||||
->all();
|
||||
|
||||
$impact = [];
|
||||
|
||||
foreach (array_keys($articles + $publications) as $channelId) {
|
||||
$impact[$channelId] = [
|
||||
'articles' => (int) ($articles[$channelId] ?? 0),
|
||||
'publications' => (int) ($publications[$channelId] ?? 0),
|
||||
];
|
||||
}
|
||||
|
||||
return $impact;
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
$channels = PlatformChannel::with(['platformInstance', 'platformAccounts'])->orderBy('name')->get();
|
||||
|
|
@ -177,7 +289,11 @@ public function render(): View
|
|||
return view('livewire.channels', [
|
||||
'channels' => $channels,
|
||||
'managingChannel' => $managingChannel,
|
||||
'editingChannel' => $this->editingChannelId !== null
|
||||
? PlatformChannel::with('platformInstance')->find($this->editingChannelId)
|
||||
: null,
|
||||
'availableAccounts' => $availableAccounts,
|
||||
'deletionImpact' => $this->deletionImpact(),
|
||||
'platformInstances' => PlatformInstance::where('is_active', true)->orderBy('name')->get(),
|
||||
'languages' => Language::where('is_active', true)->orderBy('name')->get(),
|
||||
])->layout('layouts.app');
|
||||
|
|
|
|||
|
|
@ -2,36 +2,243 @@
|
|||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Dashboard\Stats\ApprovalRate;
|
||||
use App\Dashboard\Stats\ArticlesPerFeed;
|
||||
use App\Dashboard\Stats\ArticlesTrend;
|
||||
use App\Dashboard\Stats\BreakdownResult;
|
||||
use App\Dashboard\Stats\BreakdownStat;
|
||||
use App\Dashboard\Stats\PublicationsPerChannel;
|
||||
use App\Dashboard\Stats\PublishSuccessRate;
|
||||
use App\Dashboard\Stats\SeriesResult;
|
||||
use App\Models\ActivityLog;
|
||||
use App\Services\DashboardStatsService;
|
||||
use App\Support\DateRange;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Carbon;
|
||||
use InvalidArgumentException;
|
||||
use Livewire\Attributes\Computed;
|
||||
use Livewire\Component;
|
||||
|
||||
class Dashboard extends Component
|
||||
{
|
||||
public string $period = 'today';
|
||||
public string $from = '';
|
||||
|
||||
public string $to = '';
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
// Default period
|
||||
$this->applyPreset('month');
|
||||
}
|
||||
|
||||
public function setPeriod(string $period): void
|
||||
/**
|
||||
* Islands whose content depends on the global range; skipped islands never re-render on their own.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private const RANGE_DEPENDENT_ISLANDS = [
|
||||
'article-statistics',
|
||||
'articles-trend',
|
||||
'approval-rate',
|
||||
'publish-success-rate',
|
||||
'articles-per-feed',
|
||||
'publications-per-channel',
|
||||
];
|
||||
|
||||
private const RECENT_ACTIVITY_LIMIT = 5;
|
||||
|
||||
public function applyPreset(string $preset): void
|
||||
{
|
||||
$this->period = $period;
|
||||
try {
|
||||
$range = DateRange::preset($preset);
|
||||
} catch (InvalidArgumentException) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->applyRange($range->from->toDateString(), $range->to->toDateString());
|
||||
}
|
||||
|
||||
public function applyRange(string $from, string $to): void
|
||||
{
|
||||
$this->from = $from;
|
||||
$this->to = $to;
|
||||
|
||||
$this->validateRange();
|
||||
$this->refreshRangeDependentIslands();
|
||||
}
|
||||
|
||||
private function refreshRangeDependentIslands(): void
|
||||
{
|
||||
foreach (self::RANGE_DEPENDENT_ISLANDS as $island) {
|
||||
$this->renderIsland(name: $island);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
#[Computed]
|
||||
public function presets(): array
|
||||
{
|
||||
return DateRange::presets();
|
||||
}
|
||||
|
||||
public bool $rangeIsValid = true;
|
||||
|
||||
public function range(): ?DateRange
|
||||
{
|
||||
$from = $this->parseBoundary($this->from);
|
||||
$to = $this->parseBoundary($this->to);
|
||||
|
||||
if (! $from instanceof Carbon || ! $to instanceof Carbon) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return new DateRange($from->startOfDay(), $to->endOfDay());
|
||||
} catch (InvalidArgumentException) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function parseBoundary(string $value): ?Carbon
|
||||
{
|
||||
try {
|
||||
return Carbon::parse($value);
|
||||
} catch (\Exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[Computed]
|
||||
public function articleStats(): array
|
||||
{
|
||||
$range = $this->range();
|
||||
|
||||
if (! $range instanceof DateRange) {
|
||||
return [
|
||||
'articles_fetched' => 0,
|
||||
'articles_published' => 0,
|
||||
'published_percentage' => 0.0,
|
||||
];
|
||||
}
|
||||
|
||||
return app(DashboardStatsService::class)->getStats($range);
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function articlesTrend(): SeriesResult
|
||||
{
|
||||
$range = $this->range();
|
||||
|
||||
return $range instanceof DateRange
|
||||
? app(ArticlesTrend::class)->for($range)
|
||||
: new SeriesResult([], []);
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function approvalRate(): SeriesResult
|
||||
{
|
||||
$range = $this->range();
|
||||
|
||||
return $range instanceof DateRange
|
||||
? app(ApprovalRate::class)->for($range)
|
||||
: new SeriesResult([], []);
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function publishSuccessRate(): SeriesResult
|
||||
{
|
||||
$range = $this->range();
|
||||
|
||||
return $range instanceof DateRange
|
||||
? app(PublishSuccessRate::class)->for($range)
|
||||
: new SeriesResult([], []);
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function articlesPerFeed(): BreakdownResult
|
||||
{
|
||||
return $this->breakdown(ArticlesPerFeed::class);
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
public function publicationsPerChannel(): BreakdownResult
|
||||
{
|
||||
return $this->breakdown(PublicationsPerChannel::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<BreakdownStat> $stat
|
||||
*/
|
||||
private function breakdown(string $stat): BreakdownResult
|
||||
{
|
||||
$range = $this->range();
|
||||
|
||||
return $range instanceof DateRange
|
||||
? app($stat)->for($range)
|
||||
: new BreakdownResult([]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deliberately range-independent: "recent" means latest, not latest within the filter.
|
||||
*
|
||||
* @return Collection<int, ActivityLog>
|
||||
*/
|
||||
#[Computed]
|
||||
public function recentActivity(): Collection
|
||||
{
|
||||
return ActivityLog::query()
|
||||
->withSubjectDetails()
|
||||
->latestFirst()
|
||||
->limit(self::RECENT_ACTIVITY_LIMIT)
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, int>
|
||||
*/
|
||||
#[Computed]
|
||||
public function systemStats(): array
|
||||
{
|
||||
return app(DashboardStatsService::class)->getSystemStats();
|
||||
}
|
||||
|
||||
public function updated(string $property): void
|
||||
{
|
||||
if (in_array($property, ['from', 'to'], true)) {
|
||||
$this->validateRange();
|
||||
$this->refreshRangeDependentIslands();
|
||||
}
|
||||
}
|
||||
|
||||
private function validateRange(): void
|
||||
{
|
||||
$this->resetErrorBag(['from', 'to']);
|
||||
|
||||
$from = $this->parseBoundary($this->from);
|
||||
$to = $this->parseBoundary($this->to);
|
||||
|
||||
if (! $from instanceof Carbon) {
|
||||
$this->addError('from', 'The start date is not a valid date.');
|
||||
}
|
||||
|
||||
if (! $to instanceof Carbon) {
|
||||
$this->addError('to', 'The end date is not a valid date.');
|
||||
}
|
||||
|
||||
if ($from instanceof Carbon && $to instanceof Carbon && $to->lessThan($from)) {
|
||||
$this->addError('to', 'The end date must not be earlier than the start date.');
|
||||
}
|
||||
|
||||
$this->rangeIsValid = $this->range() instanceof DateRange;
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
$service = app(DashboardStatsService::class);
|
||||
|
||||
$articleStats = $service->getStats($this->period);
|
||||
$systemStats = $service->getSystemStats();
|
||||
$availablePeriods = $service->getAvailablePeriods();
|
||||
|
||||
return view('livewire.dashboard', [
|
||||
'articleStats' => $articleStats,
|
||||
'systemStats' => $systemStats,
|
||||
'availablePeriods' => $availablePeriods,
|
||||
])->layout('layouts.app');
|
||||
return view('livewire.dashboard')->layout('layouts.app');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,12 @@ class Feeds extends Component
|
|||
|
||||
public string $newDescription = '';
|
||||
|
||||
public ?int $editingFeedId = null;
|
||||
|
||||
public string $editName = '';
|
||||
|
||||
public string $editDescription = '';
|
||||
|
||||
public function toggle(int $feedId): void
|
||||
{
|
||||
$feed = Feed::findOrFail($feedId);
|
||||
|
|
@ -67,6 +73,41 @@ public function createFeed(CreateFeedAction $action): void
|
|||
$this->closeCreateModal();
|
||||
}
|
||||
|
||||
public function openEditModal(int $feedId): void
|
||||
{
|
||||
$feed = Feed::findOrFail($feedId);
|
||||
|
||||
$this->resetErrorBag();
|
||||
$this->editingFeedId = $feedId;
|
||||
$this->editName = $feed->name;
|
||||
$this->editDescription = $feed->description ?? '';
|
||||
}
|
||||
|
||||
public function closeEditModal(): void
|
||||
{
|
||||
$this->editingFeedId = null;
|
||||
}
|
||||
|
||||
// Provider and language are deliberately not editable: CreateFeedAction derives the unique
|
||||
// feeds.url from that pair, so changing either re-points the feed and orphans its articles.
|
||||
public function updateFeed(): void
|
||||
{
|
||||
if ($this->editingFeedId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->validate([
|
||||
'editName' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
Feed::findOrFail($this->editingFeedId)->update([
|
||||
'name' => $this->editName,
|
||||
'description' => $this->editDescription !== '' ? $this->editDescription : null,
|
||||
]);
|
||||
|
||||
$this->closeEditModal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
|
|
@ -86,6 +127,9 @@ public function render(): View
|
|||
'feeds' => $feeds,
|
||||
'providers' => $this->activeProviders(),
|
||||
'languages' => Language::where('is_active', true)->orderBy('name')->get(),
|
||||
'editingFeed' => $this->editingFeedId !== null
|
||||
? Feed::with('language')->find($this->editingFeedId)
|
||||
: null,
|
||||
])->layout('layouts.app');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ class Settings extends Component
|
|||
|
||||
public int $feedStalenessThreshold = 48;
|
||||
|
||||
public int $dailyPublishCap = 0;
|
||||
|
||||
public ?string $successMessage = null;
|
||||
|
||||
public ?string $errorMessage = null;
|
||||
|
|
@ -26,6 +28,7 @@ public function mount(): void
|
|||
$this->publishingApprovalsEnabled = Setting::isPublishingApprovalsEnabled();
|
||||
$this->articlePublishingInterval = Setting::getArticlePublishingInterval();
|
||||
$this->feedStalenessThreshold = Setting::getFeedStalenessThreshold();
|
||||
$this->dailyPublishCap = Setting::getDailyPublishCap();
|
||||
}
|
||||
|
||||
public function toggleArticleProcessing(): void
|
||||
|
|
@ -62,6 +65,16 @@ public function updateFeedStalenessThreshold(): void
|
|||
$this->showSuccess();
|
||||
}
|
||||
|
||||
public function updateDailyPublishCap(): void
|
||||
{
|
||||
$this->validate([
|
||||
'dailyPublishCap' => 'required|integer|min:0',
|
||||
]);
|
||||
|
||||
Setting::setDailyPublishCap($this->dailyPublishCap);
|
||||
$this->showSuccess();
|
||||
}
|
||||
|
||||
protected function showSuccess(): void
|
||||
{
|
||||
$this->successMessage = 'Settings updated successfully!';
|
||||
|
|
|
|||
94
app/Models/ActivityLog.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use Database\Factories\ActivityLogFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property ActivityTypeEnum $type
|
||||
* @property string $message
|
||||
* @property array<string, mixed>|null $context
|
||||
* @property string|null $subject_type
|
||||
* @property int|null $subject_id
|
||||
* @property Carbon $logged_at
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*/
|
||||
class ActivityLog extends Model
|
||||
{
|
||||
/** @use HasFactory<ActivityLogFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'type',
|
||||
'message',
|
||||
'context',
|
||||
'subject_type',
|
||||
'subject_id',
|
||||
'logged_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'type' => ActivityTypeEnum::class,
|
||||
'context' => 'array',
|
||||
'logged_at' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return MorphTo<Model, $this>
|
||||
*/
|
||||
public function subject(): MorphTo
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<ActivityLog> $query
|
||||
* @return Builder<ActivityLog>
|
||||
*/
|
||||
public function scopeOfType(Builder $query, ActivityTypeEnum $type): Builder
|
||||
{
|
||||
return $query->where('type', $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<ActivityLog> $query
|
||||
* @return Builder<ActivityLog>
|
||||
*/
|
||||
public function scopeSince(Builder $query, Carbon $since): Builder
|
||||
{
|
||||
return $query->where('logged_at', '>=', $since);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<ActivityLog> $query
|
||||
* @return Builder<ActivityLog>
|
||||
*/
|
||||
public function scopeLatestFirst(Builder $query): Builder
|
||||
{
|
||||
return $query->orderByDesc('logged_at')->orderByDesc('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<ActivityLog> $query
|
||||
* @return Builder<ActivityLog>
|
||||
*/
|
||||
public function scopeWithSubjectDetails(Builder $query): Builder
|
||||
{
|
||||
return $query->with(['subject' => function (Relation $morphTo): void {
|
||||
if ($morphTo instanceof MorphTo) {
|
||||
$morphTo->morphWith([Article::class => ['feed']]);
|
||||
}
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* @method static create(array<string, mixed> $array)
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $feed_id
|
||||
* @property int|null $feed_id
|
||||
* @property Feed $feed
|
||||
* @property string $url
|
||||
* @property string $title
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\FeedColorEnum;
|
||||
use Database\Factories\FeedFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
|
@ -19,7 +20,8 @@
|
|||
* @property string $provider
|
||||
* @property int|null $language_id
|
||||
* @property Language|null $language
|
||||
* @property string $description
|
||||
* @property string|null $description
|
||||
* @property FeedColorEnum|null $color
|
||||
* @property array<string, mixed> $settings
|
||||
* @property bool $is_active
|
||||
* @property Carbon|null $last_fetched_at
|
||||
|
|
@ -46,6 +48,7 @@ class Feed extends Model
|
|||
'provider',
|
||||
'language_id',
|
||||
'description',
|
||||
'color',
|
||||
'settings',
|
||||
'is_active',
|
||||
'last_fetched_at',
|
||||
|
|
@ -55,8 +58,14 @@ class Feed extends Model
|
|||
'settings' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'last_fetched_at' => 'datetime',
|
||||
'color' => FeedColorEnum::class,
|
||||
];
|
||||
|
||||
public function displayColor(): FeedColorEnum
|
||||
{
|
||||
return $this->color ?? FeedColorEnum::forId($this->id);
|
||||
}
|
||||
|
||||
public function getTypeDisplayAttribute(): string
|
||||
{
|
||||
return match ($this->type) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\AccountStatusEnum;
|
||||
use App\Enums\PlatformEnum;
|
||||
use Database\Factories\PlatformAccountFactory;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
|
|
@ -21,7 +22,8 @@
|
|||
* @property array<string, mixed> $settings
|
||||
* @property bool $is_active
|
||||
* @property Carbon|null $last_tested_at
|
||||
* @property string $status
|
||||
* @property AccountStatusEnum $status
|
||||
* @property int $consecutive_failures
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Collection<int, PlatformChannel> $activeChannels
|
||||
|
|
@ -44,10 +46,12 @@ class PlatformAccount extends Model
|
|||
'is_active',
|
||||
'last_tested_at',
|
||||
'status',
|
||||
'consecutive_failures',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'platform' => PlatformEnum::class,
|
||||
'status' => AccountStatusEnum::class,
|
||||
'settings' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'last_tested_at' => 'datetime',
|
||||
|
|
@ -136,4 +140,33 @@ public function activeChannels(): BelongsToMany
|
|||
->wherePivot('is_active', true)
|
||||
->orderByPivot('priority', 'desc');
|
||||
}
|
||||
|
||||
public const FAILURES_BEFORE_UNHEALTHY = 3;
|
||||
|
||||
public function recordCredentialCheckPassed(): void
|
||||
{
|
||||
$this->update([
|
||||
'status' => AccountStatusEnum::HEALTHY,
|
||||
'consecutive_failures' => 0,
|
||||
'last_tested_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function recordCredentialCheckFailed(): void
|
||||
{
|
||||
$failures = $this->consecutive_failures + 1;
|
||||
|
||||
$this->update([
|
||||
'status' => $failures >= self::FAILURES_BEFORE_UNHEALTHY
|
||||
? AccountStatusEnum::UNHEALTHY
|
||||
: $this->status,
|
||||
'consecutive_failures' => $failures,
|
||||
'last_tested_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function isUnhealthy(): bool
|
||||
{
|
||||
return $this->status === AccountStatusEnum::UNHEALTHY;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@
|
|||
* @property PlatformInstance $platformInstance
|
||||
* @property int $channel_id
|
||||
* @property string $name
|
||||
* @property int $language_id
|
||||
* @property string $display_name
|
||||
* @property string|null $description
|
||||
* @property int|null $language_id
|
||||
* @property Language|null $language
|
||||
* @property bool $is_active
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use App\Enums\ApprovalStatusEnum;
|
||||
use App\Enums\PublishStatusEnum;
|
||||
use App\Events\ActivityLogged;
|
||||
use App\Events\RouteArticleApproved;
|
||||
use Database\Factories\RouteArticleFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
|
@ -18,7 +21,9 @@
|
|||
* @property int $article_id
|
||||
* @property ApprovalStatusEnum $approval_status
|
||||
* @property PublishStatusEnum $publish_status
|
||||
* @property string|null $publish_error
|
||||
* @property Carbon|null $validated_at
|
||||
* @property Carbon|null $decided_at
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*/
|
||||
|
|
@ -33,13 +38,16 @@ class RouteArticle extends Model
|
|||
'article_id',
|
||||
'approval_status',
|
||||
'publish_status',
|
||||
'publish_error',
|
||||
'validated_at',
|
||||
'decided_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'approval_status' => ApprovalStatusEnum::class,
|
||||
'publish_status' => PublishStatusEnum::class,
|
||||
'validated_at' => 'datetime',
|
||||
'decided_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -96,13 +104,73 @@ public function approve(): void
|
|||
return;
|
||||
}
|
||||
|
||||
$this->update(['approval_status' => ApprovalStatusEnum::APPROVED]);
|
||||
$this->update([
|
||||
'approval_status' => ApprovalStatusEnum::APPROVED,
|
||||
'decided_at' => now(),
|
||||
]);
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::APPROVE,
|
||||
"Approved \"{$this->article->title}\"",
|
||||
['route_article_id' => $this->id],
|
||||
$this->article,
|
||||
);
|
||||
|
||||
event(new RouteArticleApproved($this));
|
||||
}
|
||||
|
||||
public function reject(): void
|
||||
{
|
||||
$this->update(['approval_status' => ApprovalStatusEnum::REJECTED]);
|
||||
if ($this->isRejected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->update([
|
||||
'approval_status' => ApprovalStatusEnum::REJECTED,
|
||||
'decided_at' => now(),
|
||||
]);
|
||||
|
||||
ActivityLogged::dispatch(
|
||||
ActivityTypeEnum::REJECT,
|
||||
"Rejected \"{$this->article->title}\"",
|
||||
['route_article_id' => $this->id],
|
||||
$this->article,
|
||||
);
|
||||
}
|
||||
|
||||
public function recordPublishFailed(string $reason): void
|
||||
{
|
||||
$this->update([
|
||||
'publish_status' => PublishStatusEnum::ERROR,
|
||||
'publish_error' => $reason,
|
||||
]);
|
||||
}
|
||||
|
||||
public function clearPublishFailure(): void
|
||||
{
|
||||
$this->update([
|
||||
'publish_status' => PublishStatusEnum::UNPUBLISHED,
|
||||
'publish_error' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A failed article is never picked up again on its own; the user retries it from the Articles page.
|
||||
*
|
||||
* @param Builder<RouteArticle> $query
|
||||
* @return Builder<RouteArticle>
|
||||
*/
|
||||
public function scopeDueForPublishing(Builder $query): Builder
|
||||
{
|
||||
return $query->where('publish_status', '!=', PublishStatusEnum::ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<RouteArticle> $query
|
||||
* @return Builder<RouteArticle>
|
||||
*/
|
||||
public function scopeFailed(Builder $query): Builder
|
||||
{
|
||||
return $query->where('publish_status', PublishStatusEnum::ERROR);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,4 +81,14 @@ public static function setFeedStalenessThreshold(int $hours): void
|
|||
{
|
||||
static::set('feed_staleness_threshold', (string) $hours);
|
||||
}
|
||||
|
||||
public static function getDailyPublishCap(): int
|
||||
{
|
||||
return (int) static::get('daily_publish_cap', 0);
|
||||
}
|
||||
|
||||
public static function setDailyPublishCap(int $articles): void
|
||||
{
|
||||
static::set('daily_publish_cap', (string) $articles);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
class LemmyRequest
|
||||
{
|
||||
// Uploads carry an image payload; the 30s used for JSON calls is not enough.
|
||||
private const UPLOAD_TIMEOUT_SECONDS = 60;
|
||||
|
||||
private string $instance;
|
||||
|
||||
private ?string $token;
|
||||
|
|
@ -83,6 +86,27 @@ public function post(string $endpoint, array $data = []): Response
|
|||
return $request->post($url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* pict-rs is mounted outside the /api/v3 prefix, so this takes a root-relative path.
|
||||
*
|
||||
* @param string $path Root-relative, e.g. 'pictrs/image'
|
||||
* @param string $name Multipart field name, e.g. 'images[]'
|
||||
* @param string $contents Raw file bytes
|
||||
* @param string $filename Filename sent with the part
|
||||
*/
|
||||
public function postMultipart(string $path, string $name, string $contents, string $filename): Response
|
||||
{
|
||||
$url = sprintf('%s://%s/%s', $this->scheme, $this->instance, ltrim($path, '/'));
|
||||
|
||||
$request = Http::timeout(self::UPLOAD_TIMEOUT_SECONDS);
|
||||
|
||||
if ($this->token) {
|
||||
$request = $request->withToken($this->token);
|
||||
}
|
||||
|
||||
return $request->attach($name, $contents, $filename)->post($url);
|
||||
}
|
||||
|
||||
public function withToken(string $token): self
|
||||
{
|
||||
$this->token = $token;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
use App\Models\PlatformAccount;
|
||||
use App\Models\PlatformChannel;
|
||||
use App\Services\Auth\LemmyAuthService;
|
||||
use App\Services\Log\LogSaver;
|
||||
use Exception;
|
||||
|
||||
class LemmyPublisher
|
||||
|
|
@ -15,10 +16,13 @@ class LemmyPublisher
|
|||
|
||||
private PlatformAccount $account;
|
||||
|
||||
private ThumbnailUploader $thumbnailUploader;
|
||||
|
||||
public function __construct(PlatformAccount $account)
|
||||
{
|
||||
$this->api = new LemmyApiService($account->instance_url);
|
||||
$this->account = $account;
|
||||
$this->thumbnailUploader = new ThumbnailUploader($account->instance_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -33,24 +37,53 @@ public function publishToChannel(Article $article, array $extractedData, Platfor
|
|||
$authService = resolve(LemmyAuthService::class);
|
||||
$token = $authService->getToken($this->account);
|
||||
|
||||
$thumbnail = $this->hostedThumbnail($extractedData, $channel, $article, $token);
|
||||
|
||||
try {
|
||||
return $this->createPost($token, $extractedData, $channel, $article);
|
||||
return $this->createPost($token, $extractedData, $channel, $article, $thumbnail);
|
||||
} catch (Exception $e) {
|
||||
// If the cached token was stale, refresh and retry once
|
||||
if (str_contains($e->getMessage(), 'not_logged_in') || str_contains($e->getMessage(), 'Unauthorized')) {
|
||||
$token = $authService->refreshToken($this->account);
|
||||
|
||||
return $this->createPost($token, $extractedData, $channel, $article);
|
||||
return $this->createPost($token, $extractedData, $channel, $article, $thumbnail);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploaded once per publish, outside the stale-token retry: the upload is the expensive
|
||||
* part and a retry would otherwise re-download, re-encode and re-log.
|
||||
*
|
||||
* @param array<string, mixed> $extractedData
|
||||
*/
|
||||
private function hostedThumbnail(array $extractedData, PlatformChannel $channel, Article $article, string $token): ?string
|
||||
{
|
||||
$source = $extractedData['thumbnail'] ?? null;
|
||||
$source = is_string($source) && $source !== '' ? $source : null;
|
||||
|
||||
if ($source === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$hosted = $this->thumbnailUploader->upload($source, $token);
|
||||
|
||||
if ($hosted === null) {
|
||||
app(LogSaver::class)->warning('Thumbnail upload failed; publishing without one', $channel, [
|
||||
'article_id' => $article->id,
|
||||
'source' => $source,
|
||||
]);
|
||||
}
|
||||
|
||||
return $hosted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $extractedData
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function createPost(string $token, array $extractedData, PlatformChannel $channel, Article $article): array
|
||||
private function createPost(string $token, array $extractedData, PlatformChannel $channel, Article $article, ?string $thumbnail = null): array
|
||||
{
|
||||
$languageId = $extractedData['language_id'] ?? null;
|
||||
|
||||
|
|
@ -60,7 +93,7 @@ private function createPost(string $token, array $extractedData, PlatformChannel
|
|||
$extractedData['description'] ?? '',
|
||||
$channel->channel_id,
|
||||
$article->url,
|
||||
$extractedData['thumbnail'] ?? null,
|
||||
$thumbnail,
|
||||
$languageId
|
||||
);
|
||||
}
|
||||
|
|
|
|||
125
app/Modules/Lemmy/Services/ThumbnailUploader.php
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
namespace App\Modules\Lemmy\Services;
|
||||
|
||||
use App\Modules\Lemmy\LemmyRequest;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Throwable;
|
||||
|
||||
class ThumbnailUploader
|
||||
{
|
||||
private const MAX_WIDTH = 600;
|
||||
|
||||
// A 4000x2256 JPEG decodes to ~27MB in GD; the worker runs with memory_limit=128M.
|
||||
private const MAX_SOURCE_BYTES = 10_485_760;
|
||||
|
||||
private const MAX_SOURCE_PIXELS = 50_000_000;
|
||||
|
||||
private const JPEG_QUALITY = 82;
|
||||
|
||||
public function __construct(private string $instance) {}
|
||||
|
||||
/**
|
||||
* Returns an instance-hosted URL for a downscaled copy, or null if anything fails.
|
||||
*/
|
||||
public function upload(?string $sourceUrl, string $token): ?string
|
||||
{
|
||||
if ($sourceUrl === null || $sourceUrl === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$source = $this->download($sourceUrl);
|
||||
|
||||
if ($source === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$resized = $this->resize($source);
|
||||
|
||||
if ($resized === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->store($resized, $token);
|
||||
} catch (Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function download(string $url): ?string
|
||||
{
|
||||
$response = Http::timeout(30)->get($url);
|
||||
|
||||
if (! $response->successful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$body = $response->body();
|
||||
|
||||
return strlen($body) > self::MAX_SOURCE_BYTES ? null : $body;
|
||||
}
|
||||
|
||||
private function resize(string $source): ?string
|
||||
{
|
||||
$info = @getimagesizefromstring($source);
|
||||
|
||||
if ($info === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
[$width, $height] = $info;
|
||||
|
||||
if ($width < 1 || $height < 1 || $width * $height > self::MAX_SOURCE_PIXELS) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($width <= self::MAX_WIDTH) {
|
||||
return $source;
|
||||
}
|
||||
|
||||
$image = @imagecreatefromstring($source);
|
||||
|
||||
if ($image === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$targetHeight = (int) max(1, round($height * (self::MAX_WIDTH / $width)));
|
||||
$resized = imagescale($image, self::MAX_WIDTH, $targetHeight);
|
||||
imagedestroy($image);
|
||||
|
||||
if ($resized === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
try {
|
||||
imagejpeg($resized, null, self::JPEG_QUALITY);
|
||||
} finally {
|
||||
$bytes = (string) ob_get_clean();
|
||||
imagedestroy($resized);
|
||||
}
|
||||
|
||||
return $bytes === '' ? null : $bytes;
|
||||
}
|
||||
|
||||
private function store(string $bytes, string $token): ?string
|
||||
{
|
||||
$response = (new LemmyRequest($this->instance, $token))
|
||||
->postMultipart('pictrs/image', 'images[]', $bytes, 'thumbnail.jpg');
|
||||
|
||||
if (! $response->successful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$file = $response->json('files.0.file');
|
||||
|
||||
if (! is_string($file) || $file === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// $instance is a full scheme-qualified URL — platform_accounts.instance_url is validated as a URL.
|
||||
return sprintf('%s/pictrs/image/%s', rtrim($this->instance, '/'), $file);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,62 +2,11 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Enums\LogLevelEnum;
|
||||
use App\Events\ActionPerformed;
|
||||
use App\Events\ExceptionOccurred;
|
||||
use App\Events\NewArticleFetched;
|
||||
use App\Events\RouteArticleApproved;
|
||||
use App\Listeners\LogActionListener;
|
||||
use App\Listeners\LogExceptionToDatabase;
|
||||
use App\Listeners\PublishApprovedArticleListener;
|
||||
use App\Listeners\ValidateArticleListener;
|
||||
use Error;
|
||||
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use InvalidArgumentException;
|
||||
use Throwable;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void {}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
Event::listen(
|
||||
ActionPerformed::class,
|
||||
LogActionListener::class,
|
||||
);
|
||||
|
||||
Event::listen(
|
||||
ExceptionOccurred::class,
|
||||
LogExceptionToDatabase::class,
|
||||
);
|
||||
|
||||
Event::listen(
|
||||
NewArticleFetched::class,
|
||||
ValidateArticleListener::class,
|
||||
);
|
||||
|
||||
Event::listen(
|
||||
RouteArticleApproved::class,
|
||||
PublishApprovedArticleListener::class,
|
||||
);
|
||||
|
||||
app()->make(ExceptionHandler::class)
|
||||
->reportable(function (Throwable $e) {
|
||||
$level = $this->mapExceptionToLogLevel($e);
|
||||
|
||||
ExceptionOccurred::dispatch($e, $level, $e->getMessage(), []);
|
||||
});
|
||||
}
|
||||
|
||||
private function mapExceptionToLogLevel(Throwable $exception): LogLevelEnum
|
||||
{
|
||||
return match (true) {
|
||||
$exception instanceof Error => LogLevelEnum::CRITICAL,
|
||||
$exception instanceof InvalidArgumentException => LogLevelEnum::WARNING,
|
||||
default => LogLevelEnum::ERROR,
|
||||
};
|
||||
}
|
||||
public function boot(): void {}
|
||||
}
|
||||
|
|
|
|||
34
app/Services/Activity/ActivitySummary.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Activity;
|
||||
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use App\Models\ActivityLog;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class ActivitySummary
|
||||
{
|
||||
/**
|
||||
* Counts per type since $since, including types with no rows.
|
||||
*
|
||||
* @return array<string, int>
|
||||
*/
|
||||
public function since(Carbon $since): array
|
||||
{
|
||||
/** @var array<string, int> $counts */
|
||||
$counts = ActivityLog::query()
|
||||
->since($since)
|
||||
->selectRaw('type, COUNT(*) as aggregate')
|
||||
->groupBy('type')
|
||||
->pluck('aggregate', 'type')
|
||||
->all();
|
||||
|
||||
$summary = [];
|
||||
|
||||
foreach (ActivityTypeEnum::cases() as $case) {
|
||||
$summary[$case->value] = (int) ($counts[$case->value] ?? 0);
|
||||
}
|
||||
|
||||
return $summary;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,181 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Article;
|
||||
|
||||
use App\Models\Article;
|
||||
use App\Models\Feed;
|
||||
use App\Services\Factories\ArticleParserFactory;
|
||||
use App\Services\Factories\HomepageParserFactory;
|
||||
use App\Services\Http\HttpFetcher;
|
||||
use App\Services\Log\LogSaver;
|
||||
use Exception;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class ArticleFetcher
|
||||
{
|
||||
public function __construct(
|
||||
private LogSaver $logSaver
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Article>
|
||||
*/
|
||||
public function getArticlesFromFeed(Feed $feed): Collection
|
||||
{
|
||||
if ($feed->type === 'rss') {
|
||||
return $this->getArticlesFromRssFeed($feed);
|
||||
} elseif ($feed->type === 'website') {
|
||||
return $this->getArticlesFromWebsiteFeed($feed);
|
||||
}
|
||||
|
||||
$this->logSaver->warning('Unsupported feed type', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_type' => $feed->type,
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Article>
|
||||
*/
|
||||
private function getArticlesFromRssFeed(Feed $feed): Collection
|
||||
{
|
||||
try {
|
||||
$xml = HttpFetcher::fetchHtml($feed->url);
|
||||
|
||||
$previousUseErrors = libxml_use_internal_errors(true);
|
||||
|
||||
try {
|
||||
$rss = simplexml_load_string($xml);
|
||||
} finally {
|
||||
libxml_clear_errors();
|
||||
libxml_use_internal_errors($previousUseErrors);
|
||||
}
|
||||
|
||||
if ($rss === false || ! isset($rss->channel->item)) {
|
||||
$this->logSaver->warning('Failed to parse RSS feed XML', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_url' => $feed->url,
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
|
||||
$articles = collect();
|
||||
foreach ($rss->channel->item as $item) {
|
||||
$link = (string) $item->link;
|
||||
if ($link !== '') {
|
||||
$articles->push($this->saveArticle($link, $feed->id));
|
||||
}
|
||||
}
|
||||
|
||||
return $articles;
|
||||
} catch (Exception $e) {
|
||||
$this->logSaver->error('Failed to fetch articles from RSS feed', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_url' => $feed->url,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Article>
|
||||
*/
|
||||
private function getArticlesFromWebsiteFeed(Feed $feed): Collection
|
||||
{
|
||||
try {
|
||||
// Try to get parser for this feed
|
||||
$parser = HomepageParserFactory::getParserForFeed($feed);
|
||||
|
||||
if (! $parser) {
|
||||
$this->logSaver->warning('No parser available for feed URL', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_url' => $feed->url,
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
|
||||
$html = HttpFetcher::fetchHtml($feed->url);
|
||||
$urls = $parser->extractArticleUrls($html);
|
||||
|
||||
return collect($urls)
|
||||
->map(fn (string $url) => $this->saveArticle($url, $feed->id));
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->logSaver->error('Failed to fetch articles from website feed', null, [
|
||||
'feed_id' => $feed->id,
|
||||
'feed_url' => $feed->url,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return collect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function fetchArticleData(Article $article): array
|
||||
{
|
||||
try {
|
||||
$html = HttpFetcher::fetchHtml($article->url);
|
||||
$parser = ArticleParserFactory::getParser($article->url);
|
||||
|
||||
return $parser->extractData($html);
|
||||
} catch (Exception $e) {
|
||||
$this->logSaver->error('Exception while fetching article data', null, [
|
||||
'url' => $article->url,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private function saveArticle(string $url, ?int $feedId = null): Article
|
||||
{
|
||||
$fallbackTitle = $this->generateFallbackTitle($url);
|
||||
|
||||
try {
|
||||
$article = Article::firstOrCreate(
|
||||
['url' => $url],
|
||||
[
|
||||
'feed_id' => $feedId,
|
||||
'title' => $fallbackTitle,
|
||||
]
|
||||
);
|
||||
|
||||
if ($article->wasRecentlyCreated) {
|
||||
$article->dispatchFetchedEvent();
|
||||
}
|
||||
|
||||
return $article;
|
||||
} catch (Exception $e) {
|
||||
$this->logSaver->error('Failed to create article', null, [
|
||||
'url' => $url,
|
||||
'feed_id' => $feedId,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function generateFallbackTitle(string $url): string
|
||||
{
|
||||
// Extract filename from URL as a basic fallback title
|
||||
$path = parse_url($url, PHP_URL_PATH);
|
||||
$filename = basename($path ?: $url);
|
||||
|
||||
// Remove file extension and convert to readable format
|
||||
$title = preg_replace('/\.[^.]*$/', '', $filename);
|
||||
$title = str_replace(['-', '_'], ' ', $title);
|
||||
$title = ucwords($title);
|
||||
|
||||
return $title ?: 'Untitled Article';
|
||||
}
|
||||
}
|
||||
|
|
@ -8,33 +8,25 @@
|
|||
use App\Models\PlatformAccount;
|
||||
use App\Models\PlatformChannel;
|
||||
use App\Models\Route;
|
||||
use Carbon\Carbon;
|
||||
use App\Support\DateRange;
|
||||
|
||||
class DashboardStatsService
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function getStats(string $period = 'today'): array
|
||||
public function getStats(DateRange $range): array
|
||||
{
|
||||
$dateRange = $this->getDateRange($period);
|
||||
$bounds = [$range->from, $range->to];
|
||||
|
||||
// Get articles fetched for the period
|
||||
$articlesFetchedQuery = Article::query();
|
||||
if ($dateRange) {
|
||||
$articlesFetchedQuery->whereBetween('created_at', $dateRange);
|
||||
}
|
||||
$articlesFetched = $articlesFetchedQuery->count();
|
||||
$articlesFetched = Article::query()
|
||||
->whereBetween('created_at', $bounds)
|
||||
->count();
|
||||
|
||||
// Get articles published for the period
|
||||
$articlesPublishedQuery = ArticlePublication::query()
|
||||
->whereNotNull('published_at');
|
||||
if ($dateRange) {
|
||||
$articlesPublishedQuery->whereBetween('published_at', $dateRange);
|
||||
}
|
||||
$articlesPublished = $articlesPublishedQuery->count();
|
||||
$articlesPublished = ArticlePublication::query()
|
||||
->whereBetween('published_at', $bounds)
|
||||
->count();
|
||||
|
||||
// Calculate published percentage
|
||||
$publishedPercentage = $articlesFetched > 0 ? round(($articlesPublished / $articlesFetched) * 100, 1) : 0.0;
|
||||
|
||||
return [
|
||||
|
|
@ -44,37 +36,6 @@ public function getStats(string $period = 'today'): array
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getAvailablePeriods(): array
|
||||
{
|
||||
return [
|
||||
'today' => 'Today',
|
||||
'week' => 'This Week',
|
||||
'month' => 'This Month',
|
||||
'year' => 'This Year',
|
||||
'all' => 'All Time',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{0: Carbon, 1: Carbon}|null
|
||||
*/
|
||||
private function getDateRange(string $period): ?array
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
return match ($period) {
|
||||
'today' => [$now->copy()->startOfDay(), $now->copy()->endOfDay()],
|
||||
'week' => [$now->copy()->startOfWeek(), $now->copy()->endOfWeek()],
|
||||
'month' => [$now->copy()->startOfMonth(), $now->copy()->endOfMonth()],
|
||||
'year' => [$now->copy()->startOfYear(), $now->copy()->endOfYear()],
|
||||
'all' => null, // No date filtering for all-time stats
|
||||
default => [$now->copy()->startOfDay(), $now->copy()->endOfDay()],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, int>
|
||||
*/
|
||||
|
|
|
|||
78
app/Support/DateRange.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class DateRange
|
||||
{
|
||||
public const MAX_DAYS = 731;
|
||||
|
||||
public function __construct(
|
||||
public readonly Carbon $from,
|
||||
public readonly Carbon $to,
|
||||
) {
|
||||
if ($to->lessThan($from)) {
|
||||
throw new InvalidArgumentException('The end of a date range cannot precede its start.');
|
||||
}
|
||||
}
|
||||
|
||||
public static function preset(string $preset): self
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
return match ($preset) {
|
||||
'today' => new self($now->copy()->startOfDay(), $now->copy()->endOfDay()),
|
||||
'week' => new self($now->copy()->startOfWeek(), $now->copy()->endOfWeek()),
|
||||
'month' => new self($now->copy()->startOfMonth(), $now->copy()->endOfMonth()),
|
||||
'year' => new self($now->copy()->startOfYear(), $now->copy()->endOfYear()),
|
||||
'all' => new self(Carbon::createFromTimestamp(0), $now->copy()->endOfDay()),
|
||||
default => throw new InvalidArgumentException("Unknown date range preset [{$preset}]."),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function presets(): array
|
||||
{
|
||||
return [
|
||||
'today' => 'Today',
|
||||
'week' => 'This Week',
|
||||
'month' => 'This Month',
|
||||
'year' => 'This Year',
|
||||
'all' => 'All Time',
|
||||
];
|
||||
}
|
||||
|
||||
public function isBucketableByDay(): bool
|
||||
{
|
||||
return $this->from->copy()->startOfDay()->diffInDays($this->to->copy()->startOfDay()) < self::MAX_DAYS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every day the range touches, as Y-m-d, so callers can zero-fill empty buckets.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function days(): array
|
||||
{
|
||||
$days = [];
|
||||
$cursor = $this->from->copy()->startOfDay();
|
||||
$last = $this->to->copy()->startOfDay();
|
||||
|
||||
if (! $this->isBucketableByDay()) {
|
||||
throw new InvalidArgumentException(
|
||||
'A range wider than '.self::MAX_DAYS.' days cannot be bucketed by day; bucket by month instead.'
|
||||
);
|
||||
}
|
||||
|
||||
while ($cursor->lessThanOrEqualTo($last)) {
|
||||
$days[] = $cursor->toDateString();
|
||||
$cursor->addDay();
|
||||
}
|
||||
|
||||
return $days;
|
||||
}
|
||||
}
|
||||
24
app/Support/PendingFeedGroup.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\Feed;
|
||||
use App\Models\RouteArticle;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class PendingFeedGroup
|
||||
{
|
||||
/**
|
||||
* @param Collection<int, RouteArticle>|null $routeArticles
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly Feed $feed,
|
||||
public readonly int $count,
|
||||
public readonly ?Collection $routeArticles,
|
||||
) {}
|
||||
|
||||
public function isExpanded(): bool
|
||||
{
|
||||
return $this->routeArticles !== null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +1,35 @@
|
|||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/react-starter-kit",
|
||||
"name": "lvl0/fedi-feed-router",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"description": "Routes news articles from RSS and scraped sources to Fediverse communities.",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"framework"
|
||||
"fediverse",
|
||||
"lemmy",
|
||||
"rss",
|
||||
"atom",
|
||||
"laravel"
|
||||
],
|
||||
"license": "MIT",
|
||||
"homepage": "https://forge.lvl0.xyz/lvl0/fedi-feed-router",
|
||||
"license": "AGPL-3.0-only",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"blade-ui-kit/blade-heroicons": "^2.6",
|
||||
"inertiajs/inertia-laravel": "^2.0",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/horizon": "^5.29",
|
||||
"laravel/sanctum": "^4.2",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"livewire/livewire": "^4.0",
|
||||
"tightenco/ziggy": "^2.4"
|
||||
"livewire/livewire": "^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"larastan/larastan": "^3.5",
|
||||
"laravel/breeze": "^2.3",
|
||||
"laravel/pail": "^1.2.2",
|
||||
"laravel/pint": "^1.18",
|
||||
"laravel/sail": "^1.43",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"phpstan/phpstan": "^2.1",
|
||||
"phpstan/phpstan": "^2.1.32 <2.2",
|
||||
"phpstan/phpstan-mockery": "^2.0",
|
||||
"phpunit/phpunit": "^11.5.3"
|
||||
},
|
||||
|
|
@ -64,11 +65,6 @@
|
|||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||
],
|
||||
"dev:ssr": [
|
||||
"npm run build:ssr",
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"php artisan inertia:start-ssr\" --names=server,queue,logs,ssr --kill-others"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@php artisan test"
|
||||
|
|
|
|||
8754
composer.lock
generated
Normal file
50
database/factories/ActivityLogFactory.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\ActivityTypeEnum;
|
||||
use App\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @extends Factory<ActivityLog>
|
||||
*/
|
||||
class ActivityLogFactory extends Factory
|
||||
{
|
||||
protected $model = ActivityLog::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'type' => fake()->randomElement(ActivityTypeEnum::cases()),
|
||||
'message' => fake()->sentence(4),
|
||||
'context' => null,
|
||||
'subject_type' => null,
|
||||
'subject_id' => null,
|
||||
'logged_at' => now(),
|
||||
];
|
||||
}
|
||||
|
||||
public function type(ActivityTypeEnum $type): static
|
||||
{
|
||||
return $this->state(['type' => $type]);
|
||||
}
|
||||
|
||||
public function loggedAt(Carbon $loggedAt): static
|
||||
{
|
||||
return $this->state(['logged_at' => $loggedAt]);
|
||||
}
|
||||
|
||||
public function forSubject(Model $subject): static
|
||||
{
|
||||
return $this->state([
|
||||
'subject_type' => $subject->getMorphClass(),
|
||||
'subject_id' => $subject->getKey(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,9 +24,22 @@ public function definition(): array
|
|||
'title' => $this->faker->sentence(),
|
||||
'description' => $this->faker->paragraph(),
|
||||
'content' => $this->faker->paragraphs(3, true),
|
||||
'image_url' => $this->faker->optional()->imageUrl(),
|
||||
'image_url' => $this->faker->imageUrl(),
|
||||
'published_at' => $this->faker->optional()->dateTimeBetween('-1 month', 'now'),
|
||||
'author' => $this->faker->optional()->name(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* An article discovered but never validated, so publishing must fetch its data live.
|
||||
*/
|
||||
public function unvalidated(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes): array => [
|
||||
'description' => null,
|
||||
'content' => null,
|
||||
'image_url' => null,
|
||||
'validated_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\AccountStatusEnum;
|
||||
use App\Enums\PlatformEnum;
|
||||
use App\Models\PlatformAccount;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
|
@ -23,7 +24,7 @@ public function definition(): array
|
|||
'settings' => [],
|
||||
'is_active' => true,
|
||||
'last_tested_at' => null,
|
||||
'status' => 'untested',
|
||||
'status' => AccountStatusEnum::UNTESTED,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ public function tested(): static
|
|||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'last_tested_at' => now()->subHours(2),
|
||||
'status' => 'working',
|
||||
'status' => AccountStatusEnum::HEALTHY,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +47,8 @@ public function failed(): static
|
|||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'last_tested_at' => now()->subHours(2),
|
||||
'status' => 'failed',
|
||||
'status' => AccountStatusEnum::UNHEALTHY,
|
||||
'consecutive_failures' => PlatformAccount::FAILURES_BEFORE_UNHEALTHY,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public function pending(): static
|
|||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'approval_status' => ApprovalStatusEnum::PENDING,
|
||||
'decided_at' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -70,6 +71,7 @@ public function approved(): static
|
|||
return $this->state(fn (array $attributes) => [
|
||||
'approval_status' => ApprovalStatusEnum::APPROVED,
|
||||
'validated_at' => now(),
|
||||
'decided_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +80,7 @@ public function rejected(): static
|
|||
return $this->state(fn (array $attributes) => [
|
||||
'approval_status' => ApprovalStatusEnum::REJECTED,
|
||||
'validated_at' => now(),
|
||||
'decided_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('feeds', function (Blueprint $table) {
|
||||
$table->string('color')->nullable()->after('description');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('feeds', function (Blueprint $table) {
|
||||
$table->dropColumn('color');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('articles', function (Blueprint $table) {
|
||||
$table->text('image_url')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('articles', function (Blueprint $table) {
|
||||
$table->string('image_url')->nullable()->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('route_articles', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('publish_attempts')->default(0)->after('publish_status');
|
||||
$table->timestamp('next_attempt_at')->nullable()->after('publish_attempts');
|
||||
|
||||
$table->index('next_attempt_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('route_articles', function (Blueprint $table) {
|
||||
$table->dropIndex(['next_attempt_at']);
|
||||
$table->dropColumn(['publish_attempts', 'next_attempt_at']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('activity_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('type');
|
||||
$table->string('message');
|
||||
$table->json('context')->nullable();
|
||||
$table->string('subject_type')->nullable();
|
||||
$table->unsignedBigInteger('subject_id')->nullable();
|
||||
$table->timestamp('logged_at')->useCurrent();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['type', 'logged_at']);
|
||||
$table->index('logged_at');
|
||||
$table->index(['subject_type', 'subject_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('activity_logs');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('platform_accounts', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('consecutive_failures')->default(0)->after('status');
|
||||
});
|
||||
|
||||
DB::table('platform_accounts')->where('status', 'active')->update(['status' => 'healthy']);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Not a true inverse: accounts the health check marked healthy also become 'active'.
|
||||
DB::table('platform_accounts')->where('status', 'healthy')->update(['status' => 'active']);
|
||||
|
||||
Schema::table('platform_accounts', function (Blueprint $table) {
|
||||
$table->dropColumn('consecutive_failures');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('route_articles', function (Blueprint $table) {
|
||||
$table->timestamp('decided_at')->nullable()->after('validated_at');
|
||||
|
||||
$table->index('decided_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('route_articles', function (Blueprint $table) {
|
||||
$table->dropIndex(['decided_at']);
|
||||
$table->dropColumn('decided_at');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('route_articles', function (Blueprint $table) {
|
||||
$table->text('publish_error')->nullable()->after('publish_status');
|
||||
|
||||
$table->dropIndex(['next_attempt_at']);
|
||||
$table->dropColumn(['publish_attempts', 'next_attempt_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('route_articles', function (Blueprint $table) {
|
||||
$table->dropColumn('publish_error');
|
||||
|
||||
$table->unsignedTinyInteger('publish_attempts')->default(0)->after('publish_status');
|
||||
$table->timestamp('next_attempt_at')->nullable()->after('publish_attempts');
|
||||
|
||||
$table->index('next_attempt_at');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// The column never had a constraint, so pre-existing rows may point at deleted channels.
|
||||
$orphans = DB::table('article_publications')
|
||||
->whereNotIn('platform_channel_id', DB::table('platform_channels')->select('id'));
|
||||
|
||||
if (($count = $orphans->count()) > 0) {
|
||||
Log::warning("Deleting {$count} orphaned article_publications rows before adding the channel foreign key.");
|
||||
$orphans->delete();
|
||||
}
|
||||
|
||||
Schema::table('article_publications', function (Blueprint $table) {
|
||||
$table->foreign('platform_channel_id')
|
||||
->references('id')
|
||||
->on('platform_channels')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Orphan rows deleted in up() are not restored.
|
||||
Schema::table('article_publications', function (Blueprint $table) {
|
||||
$table->dropForeign(['platform_channel_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
BIN
docs/screenshots/articles-light.png
Normal file
|
After Width: | Height: | Size: 672 KiB |
BIN
docs/screenshots/channels-dark.png
Normal file
|
After Width: | Height: | Size: 350 KiB |
BIN
docs/screenshots/dashboard-dark.png
Normal file
|
After Width: | Height: | Size: 663 KiB |
BIN
docs/screenshots/feeds-dark.png
Normal file
|
After Width: | Height: | Size: 269 KiB |
BIN
docs/screenshots/routes-edit-dark.png
Normal file
|
After Width: | Height: | Size: 372 KiB |
|
|
@ -15,7 +15,7 @@
|
|||
"vite": "^6.2.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"alpinejs": "^3.14.8",
|
||||
"axios": "^1.8.0"
|
||||
"axios": "^1.8.0",
|
||||
"chart.js": "^4.5.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
parameters:
|
||||
ignoreErrors:
|
||||
-
|
||||
message: '#^Instanceof between Illuminate\\Http\\Client\\Response and Exception will always evaluate to false\.$#'
|
||||
identifier: instanceof.alwaysFalse
|
||||
count: 1
|
||||
path: app/Services/Http/HttpFetcher.php
|
||||
|
||||
-
|
||||
message: '#^Call to an undefined static method App\\Models\\Feed\:\:withTrashed\(\)\.$#'
|
||||
identifier: staticMethod.notFound
|
||||
|
|
@ -12,18 +18,6 @@ parameters:
|
|||
count: 1
|
||||
path: tests/Unit/Actions/CreateChannelActionTest.php
|
||||
|
||||
-
|
||||
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertNull\(\) with int will always evaluate to false\.$#'
|
||||
identifier: method.impossibleType
|
||||
count: 1
|
||||
path: tests/Unit/Actions/CreateChannelActionTest.php
|
||||
|
||||
-
|
||||
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertNull\(\) with string will always evaluate to false\.$#'
|
||||
identifier: method.impossibleType
|
||||
count: 2
|
||||
path: tests/Unit/Actions/CreateFeedActionTest.php
|
||||
|
||||
-
|
||||
message: '#^Access to an undefined property App\\Models\\Route\:\:\$id\.$#'
|
||||
identifier: property.notFound
|
||||
|
|
@ -120,8 +114,3 @@ parameters:
|
|||
count: 1
|
||||
path: tests/Unit/Models/RouteTest.php
|
||||
|
||||
-
|
||||
message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertNull\(\) with int will always evaluate to false\.$#'
|
||||
identifier: method.impossibleType
|
||||
count: 1
|
||||
path: tests/Unit/Services/ArticleFetcherTest.php
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 21 KiB |
BIN
public/favicon-16x16.png
Normal file
|
After Width: | Height: | Size: 878 B |
BIN
public/favicon-32x32.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
|
@ -1,3 +0,0 @@
|
|||
<svg width="166" height="166" viewBox="0 0 166 166" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M162.041 38.7592C162.099 38.9767 162.129 39.201 162.13 39.4264V74.4524C162.13 74.9019 162.011 75.3435 161.786 75.7325C161.561 76.1216 161.237 76.4442 160.847 76.6678L131.462 93.5935V127.141C131.462 128.054 130.977 128.897 130.186 129.357L68.8474 164.683C68.707 164.763 68.5538 164.814 68.4007 164.868C68.3432 164.887 68.289 164.922 68.2284 164.938C67.7996 165.051 67.3489 165.051 66.9201 164.938C66.8499 164.919 66.7861 164.881 66.7191 164.855C66.5787 164.804 66.4319 164.76 66.2979 164.683L4.97219 129.357C4.58261 129.133 4.2589 128.81 4.0337 128.421C3.8085 128.032 3.68976 127.591 3.68945 127.141L3.68945 22.0634C3.68945 21.8336 3.72136 21.6101 3.7788 21.393C3.79794 21.3196 3.84262 21.2526 3.86814 21.1791C3.91601 21.0451 3.96068 20.9078 4.03088 20.7833C4.07874 20.7003 4.14894 20.6333 4.20638 20.5566C4.27977 20.4545 4.34678 20.3491 4.43293 20.2598C4.50632 20.1863 4.60205 20.1321 4.68501 20.0682C4.77755 19.9916 4.86051 19.9086 4.96581 19.848L35.6334 2.18492C36.0217 1.96139 36.4618 1.84375 36.9098 1.84375C37.3578 1.84375 37.7979 1.96139 38.1862 2.18492L68.8506 19.848H68.857C68.9591 19.9118 69.0452 19.9916 69.1378 20.065C69.2207 20.1289 69.3133 20.1863 69.3867 20.2566C69.476 20.3491 69.5398 20.4545 69.6164 20.5566C69.6707 20.6333 69.7441 20.7003 69.7887 20.7833C69.8621 20.911 69.9036 21.0451 69.9546 21.1791C69.9802 21.2526 70.0248 21.3196 70.044 21.3962C70.1027 21.6138 70.1328 21.8381 70.1333 22.0634V87.6941L95.686 72.9743V39.4232C95.686 39.1997 95.7179 38.9731 95.7753 38.7592C95.7977 38.6826 95.8391 38.6155 95.8647 38.5421C95.9157 38.408 95.9604 38.2708 96.0306 38.1463C96.0785 38.0633 96.1487 37.9962 96.2029 37.9196C96.2795 37.8175 96.3433 37.7121 96.4326 37.6227C96.506 37.5493 96.5986 37.495 96.6815 37.4312C96.7773 37.3546 96.8602 37.2716 96.9623 37.2109L127.633 19.5479C128.021 19.324 128.461 19.2062 128.91 19.2062C129.358 19.2062 129.798 19.324 130.186 19.5479L160.85 37.2109C160.959 37.2748 161.042 37.3546 161.137 37.428C161.217 37.4918 161.31 37.5493 161.383 37.6195C161.473 37.7121 161.536 37.8175 161.613 37.9196C161.67 37.9962 161.741 38.0633 161.785 38.1463C161.859 38.2708 161.9 38.408 161.951 38.5421C161.98 38.6155 162.021 38.6826 162.041 38.7592ZM157.018 72.9743V43.8477L146.287 50.028L131.462 58.5675V87.6941L157.021 72.9743H157.018ZM126.354 125.663V96.5176L111.771 104.85L70.1301 128.626V158.046L126.354 125.663ZM8.80126 26.4848V125.663L65.0183 158.043V128.629L35.6494 112L35.6398 111.994L35.6271 111.988C35.5281 111.93 35.4452 111.847 35.3526 111.777C35.2729 111.713 35.1803 111.662 35.1101 111.592L35.1038 111.582C35.0208 111.502 34.9634 111.403 34.8932 111.314C34.8293 111.228 34.7528 111.154 34.7017 111.065L34.6985 111.055C34.6411 110.96 34.606 110.845 34.5645 110.736C34.523 110.64 34.4688 110.551 34.4432 110.449C34.4113 110.328 34.4049 110.197 34.3922 110.072C34.3794 109.976 34.3539 109.881 34.3539 109.785V109.778V41.2045L19.5322 32.6619L8.80126 26.4848ZM36.913 7.35007L11.3635 22.0634L36.9066 36.7768L62.4529 22.0602L36.9066 7.35007H36.913ZM50.1999 99.1736L65.0215 90.6374V26.4848L54.2906 32.6651L39.4657 41.2045V105.357L50.1999 99.1736ZM128.91 24.713L103.363 39.4264L128.91 54.1397L154.453 39.4232L128.91 24.713ZM126.354 58.5675L111.529 50.028L100.798 43.8477V72.9743L115.619 81.5106L126.354 87.6941V58.5675ZM67.5711 124.205L105.042 102.803L123.772 92.109L98.2451 77.4053L68.8538 94.3341L42.0663 109.762L67.5711 124.205Z" fill="#FF2D20"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.5 KiB |
BIN
public/images/logo.png
Normal file
|
After Width: | Height: | Size: 793 KiB |
|
|
@ -1,16 +0,0 @@
|
|||
<svg width="1991" height="500" viewBox="0 0 1991 500" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="path-1-outside-1_1_7" maskUnits="userSpaceOnUse" x="765" y="175" width="253" height="226" fill="black">
|
||||
<rect fill="white" x="765" y="175" width="253" height="226"/>
|
||||
<path d="M971.537 248.894C968.887 247.988 966.217 247.145 963.529 246.365C963.975 244.551 964.386 242.726 964.763 240.892C970.827 211.403 966.862 187.646 953.33 179.825C940.374 172.321 919.125 180.141 897.69 198.84C895.582 200.685 893.518 202.585 891.496 204.541C890.149 203.242 888.767 201.97 887.35 200.727C864.884 180.732 842.365 172.31 828.849 180.157C815.893 187.677 812.042 210.009 817.499 237.958C818.045 240.722 818.658 243.474 819.339 246.214C816.152 247.121 813.073 248.09 810.13 249.117C783.823 258.316 767 272.739 767 287.696C767 303.15 785.056 318.646 812.488 328.042C814.713 328.799 816.959 329.502 819.225 330.152C818.489 333.085 817.838 336.051 817.271 339.05C812.089 366.518 816.131 388.321 829.062 395.795C842.417 403.511 864.822 395.582 886.661 376.458C888.389 374.945 890.116 373.347 891.844 371.664C894.027 373.775 896.273 375.824 898.581 377.811C919.726 396.043 940.607 403.408 953.517 395.914C966.862 388.171 971.2 364.746 965.566 336.246C965.134 334.07 964.637 331.848 964.074 329.582C965.649 329.115 967.192 328.633 968.702 328.136C997.206 318.667 1015.78 303.358 1015.78 287.711C1015.76 272.682 998.403 258.165 971.537 248.894ZM904.681 206.873C923.043 190.854 940.208 184.531 948.033 189.05C956.362 193.865 959.601 213.279 954.367 238.741C954.021 240.399 953.648 242.053 953.247 243.701C942.289 241.208 931.177 239.449 919.985 238.435C913.577 229.204 906.553 220.417 898.959 212.133C900.818 210.33 902.722 208.576 904.671 206.873H904.681ZM840.453 300.476C842.702 304.829 845.053 309.129 847.507 313.376C850.005 317.708 852.608 321.977 855.317 326.182C847.616 325.345 839.963 324.111 832.389 322.487C834.586 315.376 837.292 307.991 840.453 300.476ZM840.453 275.429C837.343 268.074 834.711 260.84 832.55 253.853C839.65 252.262 847.216 250.962 855.104 249.977C852.461 254.102 849.918 258.288 847.475 262.534C845.033 266.781 842.687 271.079 840.437 275.429H840.453ZM846.102 287.955C849.377 281.124 852.905 274.425 856.685 267.857C860.461 261.292 864.481 254.878 868.745 248.614C876.146 248.054 883.733 247.759 891.398 247.759C899.063 247.759 906.697 248.054 914.093 248.619C918.311 254.869 922.307 261.261 926.08 267.795C929.853 274.328 933.427 280.996 936.803 287.799C933.472 294.654 929.906 301.381 926.106 307.981C922.336 314.545 918.363 320.978 914.186 327.281C906.801 327.799 899.156 328.084 891.382 328.084C883.609 328.084 876.109 327.84 868.859 327.369C864.564 321.084 860.511 314.642 856.7 308.043C852.89 301.444 849.352 294.748 846.087 287.955H846.102ZM935.305 313.303C937.81 308.957 940.215 304.553 942.519 300.093C945.678 307.255 948.467 314.576 950.874 322.025C943.21 323.751 935.462 325.074 927.661 325.99C930.293 321.813 932.842 317.584 935.305 313.303ZM942.416 275.434C940.121 271.063 937.736 266.744 935.258 262.477C932.84 258.269 930.319 254.113 927.697 250.008C935.632 251.013 943.245 252.35 950.381 253.983C948.087 261.262 945.428 268.421 942.416 275.434ZM891.502 219.747C896.677 225.401 901.563 231.314 906.143 237.461C896.347 236.994 886.545 236.994 876.736 237.461C881.572 231.066 886.521 225.131 891.502 219.747ZM834.198 189.366C842.521 184.536 860.924 191.439 880.323 208.682C881.561 209.786 882.81 210.941 884.054 212.139C876.422 220.421 869.348 229.201 862.878 238.42C851.711 239.426 840.621 241.157 829.678 243.602C829.046 241.059 828.476 238.499 827.968 235.922C823.278 211.962 826.382 193.901 834.198 189.366ZM822.065 319.89C819.992 319.299 817.945 318.658 815.924 317.967C803.796 313.821 793.779 308.411 786.901 302.518C780.744 297.237 777.624 291.966 777.624 287.696C777.624 278.621 791.13 267.043 813.654 259.191C816.483 258.207 819.337 257.307 822.215 256.491C825.561 267.242 829.612 277.759 834.343 287.976C829.555 298.333 825.454 308.994 822.065 319.89ZM879.659 368.436C870.004 376.894 860.333 382.89 851.808 385.911C844.148 388.622 838.048 388.7 834.363 386.569C826.517 382.035 823.252 364.523 827.704 341.035C828.232 338.271 828.837 335.507 829.518 332.743C840.57 335.124 851.771 336.75 863.044 337.609C869.577 346.876 876.71 355.706 884.396 364.041C882.852 365.559 881.271 367.021 879.659 368.436ZM891.797 356.402C886.76 350.955 881.732 344.927 876.83 338.449C881.594 338.636 886.445 338.729 891.382 338.729C896.451 338.729 901.468 338.62 906.412 338.397C901.849 344.643 896.971 350.652 891.797 356.402ZM956.331 371.219C954.849 379.221 951.869 384.559 948.184 386.694C940.342 391.244 923.577 385.331 905.5 369.736C903.427 367.954 901.354 366.041 899.244 364.036C906.781 355.668 913.747 346.803 920.094 337.501C931.429 336.54 942.685 334.8 953.781 332.292C954.289 334.344 954.738 336.355 955.128 338.325C957.621 350.918 957.979 362.31 956.331 371.219ZM965.349 318.024C963.991 318.475 962.591 318.911 961.171 319.336C957.692 308.535 953.483 297.983 948.572 287.753C953.299 277.659 957.343 267.26 960.679 256.626C963.224 257.367 965.696 258.145 968.075 258.969C991.096 266.908 1005.14 278.663 1005.14 287.696C1005.14 297.335 989.971 309.846 965.349 318.024Z"/>
|
||||
</mask>
|
||||
<path d="M971.537 248.894C968.887 247.988 966.217 247.145 963.529 246.365C963.975 244.551 964.386 242.726 964.763 240.892C970.827 211.403 966.862 187.646 953.33 179.825C940.374 172.321 919.125 180.141 897.69 198.84C895.582 200.685 893.518 202.585 891.496 204.541C890.149 203.242 888.767 201.97 887.35 200.727C864.884 180.732 842.365 172.31 828.849 180.157C815.893 187.677 812.042 210.009 817.499 237.958C818.045 240.722 818.658 243.474 819.339 246.214C816.152 247.121 813.073 248.09 810.13 249.117C783.823 258.316 767 272.739 767 287.696C767 303.15 785.056 318.646 812.488 328.042C814.713 328.799 816.959 329.502 819.225 330.152C818.489 333.085 817.838 336.051 817.271 339.05C812.089 366.518 816.131 388.321 829.062 395.795C842.417 403.511 864.822 395.582 886.661 376.458C888.389 374.945 890.116 373.347 891.844 371.664C894.027 373.775 896.273 375.824 898.581 377.811C919.726 396.043 940.607 403.408 953.517 395.914C966.862 388.171 971.2 364.746 965.566 336.246C965.134 334.07 964.637 331.848 964.074 329.582C965.649 329.115 967.192 328.633 968.702 328.136C997.206 318.667 1015.78 303.358 1015.78 287.711C1015.76 272.682 998.403 258.165 971.537 248.894ZM904.681 206.873C923.043 190.854 940.208 184.531 948.033 189.05C956.362 193.865 959.601 213.279 954.367 238.741C954.021 240.399 953.648 242.053 953.247 243.701C942.289 241.208 931.177 239.449 919.985 238.435C913.577 229.204 906.553 220.417 898.959 212.133C900.818 210.33 902.722 208.576 904.671 206.873H904.681ZM840.453 300.476C842.702 304.829 845.053 309.129 847.507 313.376C850.005 317.708 852.608 321.977 855.317 326.182C847.616 325.345 839.963 324.111 832.389 322.487C834.586 315.376 837.292 307.991 840.453 300.476ZM840.453 275.429C837.343 268.074 834.711 260.84 832.55 253.853C839.65 252.262 847.216 250.962 855.104 249.977C852.461 254.102 849.918 258.288 847.475 262.534C845.033 266.781 842.687 271.079 840.437 275.429H840.453ZM846.102 287.955C849.377 281.124 852.905 274.425 856.685 267.857C860.461 261.292 864.481 254.878 868.745 248.614C876.146 248.054 883.733 247.759 891.398 247.759C899.063 247.759 906.697 248.054 914.093 248.619C918.311 254.869 922.307 261.261 926.08 267.795C929.853 274.328 933.427 280.996 936.803 287.799C933.472 294.654 929.906 301.381 926.106 307.981C922.336 314.545 918.363 320.978 914.186 327.281C906.801 327.799 899.156 328.084 891.382 328.084C883.609 328.084 876.109 327.84 868.859 327.369C864.564 321.084 860.511 314.642 856.7 308.043C852.89 301.444 849.352 294.748 846.087 287.955H846.102ZM935.305 313.303C937.81 308.957 940.215 304.553 942.519 300.093C945.678 307.255 948.467 314.576 950.874 322.025C943.21 323.751 935.462 325.074 927.661 325.99C930.293 321.813 932.842 317.584 935.305 313.303ZM942.416 275.434C940.121 271.063 937.736 266.744 935.258 262.477C932.84 258.269 930.319 254.113 927.697 250.008C935.632 251.013 943.245 252.35 950.381 253.983C948.087 261.262 945.428 268.421 942.416 275.434ZM891.502 219.747C896.677 225.401 901.563 231.314 906.143 237.461C896.347 236.994 886.545 236.994 876.736 237.461C881.572 231.066 886.521 225.131 891.502 219.747ZM834.198 189.366C842.521 184.536 860.924 191.439 880.323 208.682C881.561 209.786 882.81 210.941 884.054 212.139C876.422 220.421 869.348 229.201 862.878 238.42C851.711 239.426 840.621 241.157 829.678 243.602C829.046 241.059 828.476 238.499 827.968 235.922C823.278 211.962 826.382 193.901 834.198 189.366ZM822.065 319.89C819.992 319.299 817.945 318.658 815.924 317.967C803.796 313.821 793.779 308.411 786.901 302.518C780.744 297.237 777.624 291.966 777.624 287.696C777.624 278.621 791.13 267.043 813.654 259.191C816.483 258.207 819.337 257.307 822.215 256.491C825.561 267.242 829.612 277.759 834.343 287.976C829.555 298.333 825.454 308.994 822.065 319.89ZM879.659 368.436C870.004 376.894 860.333 382.89 851.808 385.911C844.148 388.622 838.048 388.7 834.363 386.569C826.517 382.035 823.252 364.523 827.704 341.035C828.232 338.271 828.837 335.507 829.518 332.743C840.57 335.124 851.771 336.75 863.044 337.609C869.577 346.876 876.71 355.706 884.396 364.041C882.852 365.559 881.271 367.021 879.659 368.436ZM891.797 356.402C886.76 350.955 881.732 344.927 876.83 338.449C881.594 338.636 886.445 338.729 891.382 338.729C896.451 338.729 901.468 338.62 906.412 338.397C901.849 344.643 896.971 350.652 891.797 356.402ZM956.331 371.219C954.849 379.221 951.869 384.559 948.184 386.694C940.342 391.244 923.577 385.331 905.5 369.736C903.427 367.954 901.354 366.041 899.244 364.036C906.781 355.668 913.747 346.803 920.094 337.501C931.429 336.54 942.685 334.8 953.781 332.292C954.289 334.344 954.738 336.355 955.128 338.325C957.621 350.918 957.979 362.31 956.331 371.219ZM965.349 318.024C963.991 318.475 962.591 318.911 961.171 319.336C957.692 308.535 953.483 297.983 948.572 287.753C953.299 277.659 957.343 267.26 960.679 256.626C963.224 257.367 965.696 258.145 968.075 258.969C991.096 266.908 1005.14 278.663 1005.14 287.696C1005.14 297.335 989.971 309.846 965.349 318.024Z" fill="#FF2D20"/>
|
||||
<path d="M971.537 248.894C968.887 247.988 966.217 247.145 963.529 246.365C963.975 244.551 964.386 242.726 964.763 240.892C970.827 211.403 966.862 187.646 953.33 179.825C940.374 172.321 919.125 180.141 897.69 198.84C895.582 200.685 893.518 202.585 891.496 204.541C890.149 203.242 888.767 201.97 887.35 200.727C864.884 180.732 842.365 172.31 828.849 180.157C815.893 187.677 812.042 210.009 817.499 237.958C818.045 240.722 818.658 243.474 819.339 246.214C816.152 247.121 813.073 248.09 810.13 249.117C783.823 258.316 767 272.739 767 287.696C767 303.15 785.056 318.646 812.488 328.042C814.713 328.799 816.959 329.502 819.225 330.152C818.489 333.085 817.838 336.051 817.271 339.05C812.089 366.518 816.131 388.321 829.062 395.795C842.417 403.511 864.822 395.582 886.661 376.458C888.389 374.945 890.116 373.347 891.844 371.664C894.027 373.775 896.273 375.824 898.581 377.811C919.726 396.043 940.607 403.408 953.517 395.914C966.862 388.171 971.2 364.746 965.566 336.246C965.134 334.07 964.637 331.848 964.074 329.582C965.649 329.115 967.192 328.633 968.702 328.136C997.206 318.667 1015.78 303.358 1015.78 287.711C1015.76 272.682 998.403 258.165 971.537 248.894ZM904.681 206.873C923.043 190.854 940.208 184.531 948.033 189.05C956.362 193.865 959.601 213.279 954.367 238.741C954.021 240.399 953.648 242.053 953.247 243.701C942.289 241.208 931.177 239.449 919.985 238.435C913.577 229.204 906.553 220.417 898.959 212.133C900.818 210.33 902.722 208.576 904.671 206.873H904.681ZM840.453 300.476C842.702 304.829 845.053 309.129 847.507 313.376C850.005 317.708 852.608 321.977 855.317 326.182C847.616 325.345 839.963 324.111 832.389 322.487C834.586 315.376 837.292 307.991 840.453 300.476ZM840.453 275.429C837.343 268.074 834.711 260.84 832.55 253.853C839.65 252.262 847.216 250.962 855.104 249.977C852.461 254.102 849.918 258.288 847.475 262.534C845.033 266.781 842.687 271.079 840.437 275.429H840.453ZM846.102 287.955C849.377 281.124 852.905 274.425 856.685 267.857C860.461 261.292 864.481 254.878 868.745 248.614C876.146 248.054 883.733 247.759 891.398 247.759C899.063 247.759 906.697 248.054 914.093 248.619C918.311 254.869 922.307 261.261 926.08 267.795C929.853 274.328 933.427 280.996 936.803 287.799C933.472 294.654 929.906 301.381 926.106 307.981C922.336 314.545 918.363 320.978 914.186 327.281C906.801 327.799 899.156 328.084 891.382 328.084C883.609 328.084 876.109 327.84 868.859 327.369C864.564 321.084 860.511 314.642 856.7 308.043C852.89 301.444 849.352 294.748 846.087 287.955H846.102ZM935.305 313.303C937.81 308.957 940.215 304.553 942.519 300.093C945.678 307.255 948.467 314.576 950.874 322.025C943.21 323.751 935.462 325.074 927.661 325.99C930.293 321.813 932.842 317.584 935.305 313.303ZM942.416 275.434C940.121 271.063 937.736 266.744 935.258 262.477C932.84 258.269 930.319 254.113 927.697 250.008C935.632 251.013 943.245 252.35 950.381 253.983C948.087 261.262 945.428 268.421 942.416 275.434ZM891.502 219.747C896.677 225.401 901.563 231.314 906.143 237.461C896.347 236.994 886.545 236.994 876.736 237.461C881.572 231.066 886.521 225.131 891.502 219.747ZM834.198 189.366C842.521 184.536 860.924 191.439 880.323 208.682C881.561 209.786 882.81 210.941 884.054 212.139C876.422 220.421 869.348 229.201 862.878 238.42C851.711 239.426 840.621 241.157 829.678 243.602C829.046 241.059 828.476 238.499 827.968 235.922C823.278 211.962 826.382 193.901 834.198 189.366ZM822.065 319.89C819.992 319.299 817.945 318.658 815.924 317.967C803.796 313.821 793.779 308.411 786.901 302.518C780.744 297.237 777.624 291.966 777.624 287.696C777.624 278.621 791.13 267.043 813.654 259.191C816.483 258.207 819.337 257.307 822.215 256.491C825.561 267.242 829.612 277.759 834.343 287.976C829.555 298.333 825.454 308.994 822.065 319.89ZM879.659 368.436C870.004 376.894 860.333 382.89 851.808 385.911C844.148 388.622 838.048 388.7 834.363 386.569C826.517 382.035 823.252 364.523 827.704 341.035C828.232 338.271 828.837 335.507 829.518 332.743C840.57 335.124 851.771 336.75 863.044 337.609C869.577 346.876 876.71 355.706 884.396 364.041C882.852 365.559 881.271 367.021 879.659 368.436ZM891.797 356.402C886.76 350.955 881.732 344.927 876.83 338.449C881.594 338.636 886.445 338.729 891.382 338.729C896.451 338.729 901.468 338.62 906.412 338.397C901.849 344.643 896.971 350.652 891.797 356.402ZM956.331 371.219C954.849 379.221 951.869 384.559 948.184 386.694C940.342 391.244 923.577 385.331 905.5 369.736C903.427 367.954 901.354 366.041 899.244 364.036C906.781 355.668 913.747 346.803 920.094 337.501C931.429 336.54 942.685 334.8 953.781 332.292C954.289 334.344 954.738 336.355 955.128 338.325C957.621 350.918 957.979 362.31 956.331 371.219ZM965.349 318.024C963.991 318.475 962.591 318.911 961.171 319.336C957.692 308.535 953.483 297.983 948.572 287.753C953.299 277.659 957.343 267.26 960.679 256.626C963.224 257.367 965.696 258.145 968.075 258.969C991.096 266.908 1005.14 278.663 1005.14 287.696C1005.14 297.335 989.971 309.846 965.349 318.024Z" stroke="#FF2D20" stroke-width="4" mask="url(#path-1-outside-1_1_7)"/>
|
||||
<path d="M891.382 309.96C895.793 309.974 900.109 308.679 903.783 306.24C907.457 303.8 910.325 300.324 912.023 296.253C913.721 292.182 914.172 287.699 913.321 283.372C912.469 279.044 910.352 275.066 907.239 271.943C904.125 268.819 900.154 266.689 895.829 265.823C891.504 264.957 887.02 265.394 882.944 267.079C878.867 268.764 875.383 271.62 872.931 275.286C870.479 278.953 869.17 283.264 869.17 287.675C869.164 290.597 869.733 293.492 870.847 296.193C871.96 298.895 873.595 301.351 875.658 303.421C877.72 305.49 880.171 307.133 882.869 308.255C885.567 309.377 888.46 309.957 891.382 309.96Z" fill="#FF2D20"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M484.904 113.113C485.084 113.78 485.176 114.467 485.178 115.157V222.481C485.178 223.859 484.815 225.212 484.125 226.404C483.435 227.596 482.443 228.584 481.25 229.27L391.267 281.132V383.926C391.267 386.724 389.782 389.306 387.359 390.715L199.527 498.958C199.097 499.202 198.628 499.359 198.159 499.525C197.984 499.584 197.817 499.691 197.632 499.74C196.319 500.087 194.939 500.087 193.626 499.74C193.411 499.682 193.215 499.564 193.01 499.486C192.58 499.33 192.131 499.193 191.72 498.958L3.92801 390.715C2.73502 390.029 1.74377 389.04 1.05416 387.848C0.364547 386.656 0.000945257 385.304 0 383.926L0 61.9554C0 61.2511 0.0977118 60.5664 0.273593 59.9012C0.33222 59.6762 0.469016 59.4708 0.547186 59.2459C0.693753 58.835 0.83055 58.4144 1.04552 58.0329C1.19208 57.7786 1.40705 57.5732 1.58293 57.3384C1.80767 57.0254 2.01286 56.7026 2.27668 56.4288C2.50142 56.2038 2.79456 56.0375 3.04861 55.8419C3.33197 55.6071 3.58602 55.3528 3.90847 55.1669L97.8192 1.04537C99.0082 0.360469 100.356 0 101.728 0C103.099 0 104.447 0.360469 105.636 1.04537L199.537 55.1669H199.557C199.869 55.3626 200.133 55.6071 200.417 55.8321C200.671 56.0277 200.954 56.2038 201.179 56.419C201.452 56.7026 201.648 57.0254 201.882 57.3384C202.048 57.5732 202.273 57.7786 202.41 58.0329C202.635 58.4242 202.762 58.835 202.918 59.2459C202.996 59.4708 203.133 59.6762 203.192 59.911C203.371 60.5776 203.463 61.2649 203.465 61.9554V263.055L281.713 217.952V115.148C281.713 114.463 281.81 113.768 281.986 113.113C282.055 112.878 282.182 112.673 282.26 112.448C282.416 112.037 282.553 111.617 282.768 111.235C282.915 110.981 283.13 110.775 283.296 110.541C283.53 110.228 283.726 109.905 283.999 109.631C284.224 109.406 284.507 109.24 284.761 109.044C285.054 108.809 285.309 108.555 285.621 108.369L379.542 54.2475C380.73 53.5616 382.078 53.2006 383.45 53.2006C384.822 53.2006 386.17 53.5616 387.359 54.2475L481.26 108.369C481.592 108.565 481.846 108.809 482.139 109.034C482.383 109.23 482.667 109.406 482.891 109.621C483.165 109.905 483.36 110.228 483.595 110.541C483.771 110.775 483.986 110.981 484.123 111.235C484.347 111.617 484.474 112.037 484.631 112.448C484.719 112.673 484.846 112.878 484.904 113.113ZM469.524 217.952V128.705L436.664 147.642L391.267 173.808V263.055L469.534 217.952H469.524ZM375.623 379.397V290.091L330.969 315.621L203.455 388.475V478.622L375.623 379.397ZM15.6534 75.5029V379.397L187.802 478.612V388.485L97.8681 337.532L97.8388 337.513L97.7997 337.493C97.4968 337.317 97.2427 337.063 96.9594 336.847C96.7151 336.652 96.4317 336.495 96.2167 336.28L96.1972 336.251C95.9432 336.006 95.7673 335.703 95.5523 335.429C95.3569 335.165 95.1224 334.94 94.966 334.666L94.9563 334.637C94.7804 334.343 94.6729 333.991 94.5459 333.659C94.4188 333.365 94.2527 333.091 94.1746 332.778C94.0769 332.407 94.0573 332.006 94.0182 331.624C93.9791 331.331 93.901 331.037 93.901 330.744V120.606L48.5139 94.4303L15.6534 75.5029ZM101.737 16.872L23.4997 61.9554L101.718 107.039L179.946 61.9456L101.718 16.872H101.737ZM142.425 298.23L187.812 272.074V75.5029L154.951 94.44L109.554 120.606V317.177L142.425 298.23ZM383.45 70.0741L305.222 115.157L383.45 160.241L461.668 115.148L383.45 70.0741ZM375.623 173.808L330.227 147.642L297.366 128.705V217.952L342.753 244.108L375.623 263.055V173.808ZM195.619 374.927L310.362 309.351L367.719 276.583L289.549 231.529L199.547 283.401L117.518 330.675L195.619 374.927Z" fill="#FF2D20"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M661.371 63V345.115H763.474V393.787H607V63H661.371ZM1047.57 393.787V173.576H1187.5V224.268H1099.09V393.811H1047.57V393.787ZM1374.22 203.347V173.576H1425.75V393.799H1374.22V364.016C1367.29 375.045 1357.45 383.712 1344.68 390.004C1331.92 396.308 1319.08 399.454 1306.15 399.454C1289.45 399.454 1274.17 396.394 1260.3 390.249C1246.79 384.36 1234.64 375.751 1224.61 364.958C1214.66 354.224 1206.81 341.728 1201.45 328.112C1195.88 313.965 1193.07 298.88 1193.17 283.675C1193.17 268.251 1195.93 253.513 1201.45 239.484C1206.77 225.777 1214.62 213.193 1224.6 202.393C1234.64 191.605 1246.79 183 1260.3 177.114C1274.17 170.969 1289.45 167.909 1306.15 167.909C1319.07 167.909 1331.92 171.055 1344.68 177.359C1357.45 183.663 1367.29 192.318 1374.22 203.347ZM1369.5 310.619C1372.67 301.995 1374.27 292.875 1374.22 283.688C1374.22 274.225 1372.63 265.252 1369.5 256.757C1366.54 248.576 1362.06 241.035 1356.27 234.538C1350.5 228.166 1343.5 223.021 1335.7 219.408C1327.67 215.638 1318.75 213.74 1308.99 213.74C1299.22 213.74 1290.39 215.638 1282.52 219.408C1274.81 223.064 1267.9 228.206 1262.19 234.538C1256.42 241.001 1252 248.551 1249.2 256.744C1246.17 265.399 1244.65 274.508 1244.7 283.675C1244.7 293.126 1246.18 302.111 1249.2 310.606C1252.18 319.126 1256.52 326.52 1262.19 332.824C1267.9 339.159 1274.81 344.302 1282.52 347.955C1290.39 351.737 1299.22 353.623 1308.99 353.623C1318.75 353.623 1327.67 351.737 1335.7 347.955C1343.51 344.346 1350.5 339.2 1356.27 332.824C1362.06 326.332 1366.54 318.795 1369.5 310.619ZM1632.33 173.576H1684.52L1599.96 393.799H1535.18L1450.61 173.576H1502.8L1567.57 342.214L1632.33 173.576ZM1796.91 167.909C1867.06 167.909 1914.91 230.07 1905.92 302.821H1734.98C1734.98 321.819 1754.17 358.544 1799.74 358.544C1838.92 358.544 1865.19 324.084 1865.2 324.06L1900.01 350.991C1868.89 384.202 1843.4 399.467 1803.49 399.467C1732.19 399.467 1683.85 354.369 1683.85 283.688C1683.85 219.751 1733.82 167.909 1796.91 167.909ZM1735.11 264.542H1858.6C1858.22 260.307 1851.52 208.819 1796.49 208.819C1741.45 208.819 1735.51 260.307 1735.11 264.542ZM1939.47 393.787V63H1991V393.787H1939.47Z" fill="#FF2D20"/>
|
||||
<path d="M1472.8 35.462C1474.96 33.432 1477.74 31.605 1481.12 29.981C1483.96 28.6277 1487.48 27.4097 1491.68 26.327C1495.87 25.109 1500.81 24.5 1506.49 24.5V42.77C1500.4 42.9053 1494.99 44.191 1490.25 46.627C1488.22 47.7097 1486.19 49.063 1484.16 50.687C1482.13 52.1757 1480.31 54.138 1478.68 56.574C1477.06 59.01 1475.71 61.9197 1474.62 65.303C1473.54 68.551 1472.93 72.3403 1472.8 76.671V126H1454.53V27.342H1472.8V35.462Z" fill="black"/>
|
||||
<path d="M1615.77 94.941C1615.77 99.6777 1614.49 104.076 1611.91 108.136C1609.34 112.196 1605.82 115.782 1601.36 118.895C1597.03 122.008 1591.89 124.444 1585.93 126.203C1580.11 127.962 1573.82 128.842 1567.05 128.842C1559.88 128.842 1553.11 127.489 1546.75 124.782C1540.39 122.075 1534.84 118.354 1530.11 113.617C1525.37 108.88 1521.65 103.332 1518.94 96.971C1516.23 90.6103 1514.88 83.8437 1514.88 76.671C1514.88 69.4983 1516.23 62.7317 1518.94 56.371C1521.65 50.0103 1525.37 44.5293 1530.11 39.928C1534.84 35.1913 1540.39 31.4697 1546.75 28.763C1553.11 26.0563 1559.88 24.703 1567.05 24.703C1574.09 24.703 1580.99 26.0563 1587.76 28.763C1594.52 31.4697 1600.41 35.3943 1605.42 40.537C1610.43 45.6797 1614.15 52.108 1616.58 59.822C1619.15 67.4007 1619.76 76.062 1618.41 85.806H1534.37C1534.37 88.242 1535.25 90.881 1537.01 93.723C1538.77 96.565 1541.07 99.2717 1543.91 101.843C1546.89 104.279 1550.34 106.377 1554.26 108.136C1558.32 109.76 1562.59 110.572 1567.05 110.572C1570.98 110.572 1574.63 110.166 1578.01 109.354C1581.53 108.542 1584.58 107.459 1587.15 106.106C1589.72 104.617 1591.75 102.926 1593.24 101.031C1594.73 99.1363 1595.47 97.1063 1595.47 94.941H1615.77ZM1599.53 67.536C1599.13 65.3707 1598.04 62.9347 1596.28 60.228C1594.52 57.386 1592.22 54.6793 1589.38 52.108C1586.54 49.5367 1583.22 47.3713 1579.43 45.612C1575.65 43.8527 1571.52 42.973 1567.05 42.973C1562.59 42.973 1558.39 43.8527 1554.47 45.612C1550.68 47.3713 1547.36 49.5367 1544.52 52.108C1541.68 54.6793 1539.38 57.386 1537.62 60.228C1535.86 62.9347 1534.77 65.3707 1534.37 67.536H1599.53Z" fill="black"/>
|
||||
<path d="M1709.72 126V116.256C1709.04 117.068 1707.76 118.151 1705.86 119.504C1704.1 120.857 1701.74 122.278 1698.76 123.767C1695.92 125.12 1692.53 126.271 1688.61 127.218C1684.82 128.301 1680.62 128.842 1676.02 128.842C1668.85 128.842 1662.08 127.489 1655.72 124.782C1649.36 122.075 1643.81 118.354 1639.08 113.617C1634.34 108.88 1630.62 103.332 1627.91 96.971C1625.21 90.6103 1623.85 83.8437 1623.85 76.671C1623.85 69.4983 1625.21 62.7317 1627.91 56.371C1630.62 50.0103 1634.34 44.4617 1639.08 39.725C1643.81 34.9883 1649.36 31.2667 1655.72 28.56C1662.08 25.8533 1668.85 24.5 1676.02 24.5C1680.62 24.5 1684.68 24.906 1688.2 25.718C1691.72 26.53 1694.83 27.545 1697.54 28.763C1700.25 29.981 1702.55 31.3343 1704.44 32.823C1706.47 34.3117 1708.23 35.7327 1709.72 37.086V27.342H1727.99V126H1709.72ZM1642.12 76.671C1642.12 80.8663 1643.07 84.994 1644.96 89.054C1646.99 93.114 1649.57 96.768 1652.68 100.016C1655.93 103.129 1659.58 105.7 1663.64 107.73C1667.7 109.625 1671.83 110.572 1676.02 110.572C1680.22 110.572 1684.35 109.625 1688.41 107.73C1692.47 105.7 1696.05 103.129 1699.16 100.016C1702.28 96.768 1704.78 93.114 1706.68 89.054C1708.71 84.994 1709.72 80.8663 1709.72 76.671C1709.72 72.4757 1708.71 68.348 1706.68 64.288C1704.78 60.228 1702.28 56.6417 1699.16 53.529C1696.05 50.281 1692.47 47.7097 1688.41 45.815C1684.35 43.785 1680.22 42.77 1676.02 42.77C1671.83 42.77 1667.7 43.785 1663.64 45.815C1659.58 47.7097 1655.93 50.281 1652.68 53.529C1649.57 56.6417 1646.99 60.228 1644.96 64.288C1643.07 68.348 1642.12 72.4757 1642.12 76.671Z" fill="black"/>
|
||||
<path d="M1836.68 85.806C1836.68 91.7607 1835.32 97.377 1832.62 102.655C1829.91 107.798 1826.25 112.331 1821.65 116.256C1817.05 120.045 1811.57 123.09 1805.21 125.391C1798.98 127.692 1792.35 128.842 1785.32 128.842C1778.14 128.842 1771.38 127.489 1765.02 124.782C1758.79 122.075 1753.31 118.354 1748.57 113.617C1743.84 108.88 1740.11 103.332 1737.41 96.971C1734.7 90.6103 1733.35 83.8437 1733.35 76.671C1733.35 69.4983 1734.7 62.7317 1737.41 56.371C1740.11 50.0103 1743.84 44.5293 1748.57 39.928C1753.31 35.1913 1758.79 31.4697 1765.02 28.763C1771.38 26.0563 1778.14 24.703 1785.32 24.703C1792.35 24.703 1798.98 25.8533 1805.21 28.154C1811.57 30.3193 1817.05 33.3643 1821.65 37.289C1826.25 41.2137 1829.91 45.815 1832.62 51.093C1835.32 56.2357 1836.68 61.7167 1836.68 67.536H1818C1818 64.1527 1817.12 60.9723 1815.36 57.995C1813.74 55.0177 1811.44 52.4463 1808.46 50.281C1805.48 47.9803 1802.03 46.221 1798.11 45.003C1794.18 43.6497 1789.92 42.973 1785.32 42.973C1780.58 42.973 1776.18 43.8527 1772.12 45.612C1768.06 47.3713 1764.47 49.8073 1761.36 52.92C1758.38 55.8973 1756.02 59.4837 1754.26 63.679C1752.5 67.739 1751.62 72.0697 1751.62 76.671C1751.62 81.4077 1752.5 85.806 1754.26 89.866C1756.02 93.926 1758.38 97.5123 1761.36 100.625C1764.47 103.738 1768.06 106.174 1772.12 107.933C1776.18 109.692 1780.58 110.572 1785.32 110.572C1789.92 110.572 1794.18 109.963 1798.11 108.745C1802.03 107.392 1805.48 105.632 1808.46 103.467C1811.44 101.166 1813.74 98.5273 1815.36 95.55C1817.12 92.5727 1818 89.3247 1818 85.806H1836.68Z" fill="black"/>
|
||||
<path d="M1862.21 126V45.612H1843.94V27.342H1862.21V5.418H1880.48V27.342H1898.75V45.612H1880.48V126H1862.21Z" fill="black"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 26 KiB |
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
Before Width: | Height: | Size: 1.5 KiB |
|
|
@ -1,2 +1,32 @@
|
|||
@import 'tailwindcss';
|
||||
@plugin '@tailwindcss/forms';
|
||||
|
||||
@custom-variant dark (&:where(.dark, .dark *));
|
||||
|
||||
[x-cloak] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* @tailwindcss/forms paints controls white; utilities on each tag would not cover option/placeholder. */
|
||||
@layer base {
|
||||
.dark :is(input, select, textarea):not([type='checkbox']):not([type='radio']) {
|
||||
background-color: var(--color-gray-700);
|
||||
border-color: var(--color-gray-600);
|
||||
color: var(--color-gray-100);
|
||||
}
|
||||
|
||||
.dark :is(input, select, textarea)::placeholder {
|
||||
color: var(--color-gray-400);
|
||||
}
|
||||
|
||||
.dark option {
|
||||
background-color: var(--color-gray-700);
|
||||
color: var(--color-gray-100);
|
||||
}
|
||||
|
||||
/* Only the unchecked box; checked uses currentColor for the accent. */
|
||||
.dark :is([type='checkbox'], [type='radio']):not(:checked) {
|
||||
background-color: var(--color-gray-700);
|
||||
border-color: var(--color-gray-600);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,7 @@
|
|||
import "./bootstrap";
|
||||
import { Alpine, Livewire } from '../../vendor/livewire/livewire/dist/livewire.esm';
|
||||
import './bootstrap';
|
||||
import trendChart from './chart';
|
||||
|
||||
Alpine.data('trendChart', trendChart);
|
||||
|
||||
Livewire.start();
|
||||
|
|
|
|||