Compare commits
2 commits
dev
...
feat/add-l
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d70f459ea | ||
|
|
602bdcbe17 |
195 changed files with 136 additions and 11784 deletions
|
|
@ -1,32 +0,0 @@
|
|||
# Ignore .env files
|
||||
.env
|
||||
.env.*
|
||||
.envrc
|
||||
|
||||
# Ignore node_modules
|
||||
node_modules/
|
||||
|
||||
# Ignore vendor folder
|
||||
vendor/
|
||||
|
||||
# Ignore log files
|
||||
*.log
|
||||
|
||||
# Ignore IDE and editor files
|
||||
.idea/
|
||||
.vscode/
|
||||
|
||||
# Ignore system files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Ignore Laravel storage
|
||||
/storage/*.key
|
||||
/storage/*.log
|
||||
/storage/framework/cache/*
|
||||
/storage/framework/sessions/*
|
||||
/storage/framework/views/*
|
||||
/storage/logs/*
|
||||
|
||||
# Ignore database files if in development
|
||||
database/database.sqlite
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
DUSK_HEADLESS_DISABLED=true
|
||||
ADMIN_EMAIL=login-test@example.com
|
||||
APP_ENV=testing
|
||||
DB_DATABASE=database/dusk.sqlite
|
||||
|
||||
APP_NAME=Laravel
|
||||
APP_KEY=base64:YOUR_GENERATED_KEY_HERE=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://127.0.0.1:8000
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
# PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
MEDIA_DISK=s3
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
||||
|
|
@ -61,7 +61,5 @@ AWS_SECRET_ACCESS_KEY=
|
|||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
# AWS_BUCKET=share-lt-images
|
||||
# MEDIA_DISK=s3
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
|
|
|||
13
.github/copilot-instructions.md
vendored
13
.github/copilot-instructions.md
vendored
|
|
@ -9,15 +9,11 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
|
|||
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
|
||||
|
||||
- php - 8.3.6
|
||||
- filament/filament (FILAMENT) - v4
|
||||
- laravel/fortify (FORTIFY) - v1
|
||||
- laravel/framework (LARAVEL) - v12
|
||||
- laravel/prompts (PROMPTS) - v0
|
||||
- laravel/reverb (REVERB) - v1
|
||||
- laravel/sanctum (SANCTUM) - v4
|
||||
- livewire/flux (FLUXUI_FREE) - v2
|
||||
- livewire/livewire (LIVEWIRE) - v3
|
||||
- laravel/dusk (DUSK) - v8
|
||||
- laravel/mcp (MCP) - v0
|
||||
- laravel/pint (PINT) - v1
|
||||
- laravel/sail (SAIL) - v1
|
||||
|
|
@ -500,12 +496,3 @@ Fortify is a headless authentication backend that provides authentication routes
|
|||
- `Features::updatePasswords()` to let users change their passwords.
|
||||
- `Features::resetPasswords()` for password reset via email.
|
||||
</laravel-boost-guidelines>
|
||||
|
||||
|
||||
=== docker/core rules ===
|
||||
## Over-Engineering & Bloat
|
||||
- Do not add unnecessary boilerplate or "nice-to-have" features.
|
||||
- Only implement what solves the immediate problem.
|
||||
- Ask before adding optional infrastructure or configuration sections.
|
||||
- If a system worked before without something, don't add it "just in case".
|
||||
- Minimize configuration, complexity, and dependencies.
|
||||
|
|
|
|||
11
.gitignore
vendored
11
.gitignore
vendored
|
|
@ -9,7 +9,6 @@
|
|||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.env.dev
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
Homestead.json
|
||||
|
|
@ -22,13 +21,3 @@ yarn-error.log
|
|||
/.nova
|
||||
/.vscode
|
||||
/.zed
|
||||
.vite
|
||||
*.deleted
|
||||
.env.dusk.local
|
||||
log*.txt
|
||||
.envrc
|
||||
database/backups
|
||||
*backup.tar.gz
|
||||
public/css
|
||||
public/js
|
||||
notes
|
||||
|
|
|
|||
|
|
@ -1,64 +0,0 @@
|
|||
when:
|
||||
- event: push
|
||||
branch: dev
|
||||
steps:
|
||||
build-local:
|
||||
image: docker:24-dind
|
||||
privileged: true
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
commands:
|
||||
- echo "Pulling base images to ensure latest layers..."
|
||||
- docker pull --quiet php:8.4-fpm-alpine3.23 || true
|
||||
- echo "Try to pull previous image to use as cache ..."
|
||||
- docker pull quay.io/marshyon/share-lt:latest || true
|
||||
- echo "Building image for testing (amd64 only for CI compatibility)..."
|
||||
- docker build --platform linux/amd64 --cache-from=quay.io/marshyon/share-lt:latest -t share-lt:test .
|
||||
- echo "Tagging test image as quay.io/marshyon/share-lt:v0.0.8..."
|
||||
- docker tag share-lt:test quay.io/marshyon/share-lt:v0.0.8
|
||||
- echo "Generating SBOM..."
|
||||
- docker run --rm -v /var/run/docker.sock:/var/run/docker.sock anchore/syft:latest scan quay.io/marshyon/share-lt:v0.0.8 -o cyclonedx-json > sbom.json
|
||||
scan-vulnerabilities:
|
||||
image: aquasec/trivy:0.67.2
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
commands:
|
||||
- echo "Ensuring latest Trivy image is pulled..."
|
||||
- docker pull aquasec/trivy:latest || true
|
||||
- echo "Scanning for vulnerabilities via Docker daemon..."
|
||||
# Disabling scan for testing, will re-enable once a fix for
|
||||
# vulnerability is available.
|
||||
# Scan the image present in the Docker daemon; fail on CRITICAL severities
|
||||
# - trivy image --exit-code 1 --severity CRITICAL --no-progress share-lt:test
|
||||
# Run a full scan without failing just for logs
|
||||
- trivy image --severity HIGH,MEDIUM,LOW --no-progress share-lt:test
|
||||
- echo "Generating vulnerability report..."
|
||||
- trivy image --format cyclonedx --output trivy-vuln-bom.json share-lt:test
|
||||
- echo "Vulnerability Summary:"
|
||||
- trivy image --format table share-lt:test | tee trivy-vuln-summary.txt
|
||||
publish:
|
||||
image: woodpeckerci/plugin-docker-buildx
|
||||
settings:
|
||||
registry: quay.io
|
||||
repo: quay.io/marshyon/share-lt
|
||||
platforms: linux/amd64
|
||||
tags:
|
||||
- v0.0.8
|
||||
- latest
|
||||
username:
|
||||
from_secret: QUAY_USERNAME
|
||||
password:
|
||||
from_secret: QUAY_PASSWORD
|
||||
upload-sbom:
|
||||
image: cgr.dev/chainguard/cosign:latest
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
COSIGN_REGISTRY_USERNAME:
|
||||
from_secret: QUAY_USERNAME
|
||||
COSIGN_REGISTRY_PASSWORD:
|
||||
from_secret: QUAY_PASSWORD
|
||||
commands:
|
||||
- cosign attach sbom --sbom sbom.json quay.io/marshyon/share-lt:v0.0.8 || echo "SBOM attach failed"
|
||||
- echo "Done - trivy report saved to workspace for manual review"
|
||||
|
||||
62
CHANGELOG.md
62
CHANGELOG.md
|
|
@ -1,67 +1,5 @@
|
|||
|
||||
# CHANGELOG
|
||||
|
||||
## 2026-02-17
|
||||
|
||||
added reverb, echo and toast messages for site builds
|
||||
|
||||
added change log for go-live logging and audit
|
||||
|
||||
## 2026-02-09
|
||||
|
||||
added reference compose files
|
||||
|
||||
added basic NATS integration
|
||||
|
||||
## 2026-01-25
|
||||
|
||||
added s3, docker build
|
||||
|
||||
## 2026-01-19
|
||||
|
||||
added text widgets
|
||||
|
||||
added categories
|
||||
|
||||
updated api to access text widgets and categories
|
||||
|
||||
added url and call to action for entries for use in cards
|
||||
|
||||
added import image and blogs import commands
|
||||
|
||||
## 2026-01-08
|
||||
|
||||
added tags to entry model
|
||||
|
||||
added text widget and category
|
||||
|
||||
## 2026-01-07
|
||||
|
||||
added simple API for entries model
|
||||
- to view entries
|
||||
- implement initial access control
|
||||
|
||||
this is sufficient to test static site generation
|
||||
|
||||
## 2026-01-06
|
||||
|
||||
added
|
||||
- Spatie Media Library
|
||||
- media library configuration file
|
||||
- Updated Entry model to support media handling
|
||||
- featured image upload with gallery selection and preview
|
||||
- login tests with Dusk for user authentication
|
||||
- Dusk test for featured image selection
|
||||
|
||||
## 2026-01-02
|
||||
|
||||
added initial model and filament resource
|
||||
|
||||
## 2026-01-01
|
||||
|
||||
added: laravel 12
|
||||
|
||||
added: AGPLv3
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
107
Dockerfile
107
Dockerfile
|
|
@ -1,107 +0,0 @@
|
|||
# Build stage for NATS CLI
|
||||
FROM golang:1.26-alpine AS nats-builder
|
||||
RUN apk add --no-cache git
|
||||
RUN git clone --depth 1 https://github.com/nats-io/natscli.git /src
|
||||
WORKDIR /src/nats
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o nats .
|
||||
|
||||
|
||||
|
||||
FROM php:8.4-fpm-alpine3.23
|
||||
|
||||
ENV APP_ENV=production
|
||||
ENV APP_DEBUG=false
|
||||
WORKDIR /var/www
|
||||
RUN apk update && apk add --no-cache \
|
||||
build-base \
|
||||
libpng-dev \
|
||||
libjpeg-turbo-dev \
|
||||
freetype-dev \
|
||||
zip \
|
||||
jpegoptim optipng pngquant gifsicle \
|
||||
vim \
|
||||
unzip \
|
||||
git \
|
||||
curl \
|
||||
libzip-dev \
|
||||
oniguruma-dev \
|
||||
nodejs \
|
||||
npm \
|
||||
icu-dev \
|
||||
sqlite-dev \
|
||||
sqlite-libs \
|
||||
nginx \
|
||||
supervisor \
|
||||
su-exec \
|
||||
tini \
|
||||
unzip \
|
||||
bash \
|
||||
jq \
|
||||
&& rm -rf /var/cache/apk/*
|
||||
|
||||
COPY --from=nats-builder /src/nats/nats /usr/local/bin/nats
|
||||
RUN chmod +x /usr/local/bin/nats
|
||||
|
||||
RUN rm -rf /var/cache/apk/*
|
||||
RUN docker-php-ext-install mbstring zip exif pcntl intl gd pdo pdo_sqlite bcmath
|
||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY cmd/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
# Copy supervisord configuration
|
||||
COPY ./docker/supervisord.conf /etc/supervisord.conf
|
||||
RUN mkdir -p /var/log/supervisor \
|
||||
&& mkdir -p /run/nginx /var/cache/nginx /var/lib/nginx /var/tmp/nginx \
|
||||
&& chown -R root:root /run/nginx /var/cache/nginx /var/lib/nginx /var/tmp/nginx
|
||||
|
||||
# Create www user and add to www-data group
|
||||
RUN adduser -u 1000 -G www-data -s /bin/sh -D www
|
||||
|
||||
# Configure PHP-FPM to run as www user
|
||||
RUN sed -i 's/user = www-data/user = www/g' /usr/local/etc/php-fpm.d/www.conf
|
||||
|
||||
# Remove the semicolon to uncomment the listen directive
|
||||
RUN sed -i 's/;listen = 127.0.0.1:9000/listen = 9000/' /usr/local/etc/php-fpm.d/www.conf
|
||||
|
||||
# Ensure the worker running the code is correct (usually www-data or nginx)
|
||||
RUN sed -i 's/;listen.owner = www-data/listen.owner = www/' /usr/local/etc/php-fpm.d/www.conf
|
||||
RUN sed -i 's/;listen.group = www-data/listen.group = www-data/' /usr/local/etc/php-fpm.d/www.conf
|
||||
|
||||
# Update nginx.conf to use 'www' user instead of 'nginx'
|
||||
RUN sed -i 's/user nginx;/user www;/' /etc/nginx/nginx.conf
|
||||
|
||||
# Remove user and group directives from nginx and php-fpm configs to avoid conflicts
|
||||
RUN sed -i '/^user /d' /etc/nginx/nginx.conf
|
||||
RUN sed -i '/^user = /d' /usr/local/etc/php-fpm.d/www.conf
|
||||
RUN sed -i '/^group = /d' /usr/local/etc/php-fpm.d/www.conf
|
||||
|
||||
# Set permissions for nginx directories
|
||||
RUN mkdir -p /var/lib/nginx/tmp/client_body /var/log/nginx \
|
||||
&& chown -R www:www-data /var/lib/nginx /var/log/nginx \
|
||||
&& chmod -R 755 /var/lib/nginx /var/log/nginx \
|
||||
&& touch /run/nginx/nginx.pid \
|
||||
&& chown www:www-data /run/nginx/nginx.pid
|
||||
|
||||
# Copy application code (includes database/migrations/) and excluding
|
||||
# files in .dockerignore
|
||||
COPY --chown=www:www-data . /var/www
|
||||
RUN chown -R www:www-data /var/www
|
||||
RUN chown -R www:www-data /var/log/supervisor
|
||||
|
||||
# Switch to www user
|
||||
USER www
|
||||
|
||||
# Install app dependencies
|
||||
RUN composer install --optimize-autoloader --no-dev
|
||||
RUN npm ci
|
||||
RUN npm run build
|
||||
|
||||
# run laravel cache optimization
|
||||
RUN php artisan optimize
|
||||
|
||||
EXPOSE 8889
|
||||
|
||||
ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
|
||||
CMD ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]
|
||||
|
|
@ -9,15 +9,11 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
|
|||
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
|
||||
|
||||
- php - 8.3.6
|
||||
- filament/filament (FILAMENT) - v4
|
||||
- laravel/fortify (FORTIFY) - v1
|
||||
- laravel/framework (LARAVEL) - v12
|
||||
- laravel/prompts (PROMPTS) - v0
|
||||
- laravel/reverb (REVERB) - v1
|
||||
- laravel/sanctum (SANCTUM) - v4
|
||||
- livewire/flux (FLUXUI_FREE) - v2
|
||||
- livewire/livewire (LIVEWIRE) - v3
|
||||
- laravel/dusk (DUSK) - v8
|
||||
- laravel/mcp (MCP) - v0
|
||||
- laravel/pint (PINT) - v1
|
||||
- laravel/sail (SAIL) - v1
|
||||
|
|
|
|||
127
LICENSE
127
LICENSE
|
|
@ -1,57 +1,60 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright © 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
|
||||
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 GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
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.
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is 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. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||
|
||||
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.
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
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.
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||
|
||||
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.
|
||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
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.
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
“This License” refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
“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.
|
||||
“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.
|
||||
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.
|
||||
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 “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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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 “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” 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.
|
||||
|
||||
|
|
@ -79,13 +82,13 @@ You may convey a work based on the Program, or the modifications to produce it f
|
|||
|
||||
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".
|
||||
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.
|
||||
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:
|
||||
|
|
@ -102,9 +105,9 @@ You may convey a covered work in object code form under the terms of sections 4
|
|||
|
||||
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.
|
||||
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.
|
||||
“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).
|
||||
|
||||
|
|
@ -113,7 +116,7 @@ The requirement to provide Installation Information does not include a requireme
|
|||
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.
|
||||
“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.
|
||||
|
||||
|
|
@ -131,14 +134,13 @@ Notwithstanding any other provision of this License, for material you add to a c
|
|||
|
||||
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.
|
||||
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.
|
||||
|
|
@ -148,88 +150,83 @@ Moreover, your license from a particular copyright holder is reinstated permanen
|
|||
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.
|
||||
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" 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.
|
||||
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.
|
||||
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 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.
|
||||
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.
|
||||
|
||||
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.
|
||||
13. Use with the GNU Affero General Public License.
|
||||
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 Affero 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 special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU 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.
|
||||
|
||||
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 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 General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||
|
||||
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.
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU 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.
|
||||
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
|
||||
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.
|
||||
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.
|
||||
|
||||
share-lt
|
||||
Copyright (C) 2026 jon
|
||||
Copyright (C) 2026 headshed
|
||||
|
||||
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 free software: you can redistribute it and/or modify it under the terms of the GNU 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.
|
||||
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 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 <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU 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.
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
share-lt Copyright (C) 2026 headshed
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||
|
||||
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 GPL, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
|
|
|||
46
README.md
46
README.md
|
|
@ -1,52 +1,10 @@
|
|||
# share-lt
|
||||
|
||||
Share Light CMS - Headless CMS with Real-time Publishing
|
||||
|
||||
[](https://wpk.headshed.dev/repos/2) [](https://quay.io/repository/marshyon/share-lt)
|
||||
|
||||
## Overview
|
||||
|
||||
Share Light is a modern headless CMS built with Laravel 12 that enables real-time content management and automated static site generation. It provides a complete backend solution for content creators and developers who need a robust, scalable CMS with live preview capabilities.
|
||||
|
||||
## Architecture
|
||||
|
||||
This application runs as a **fat container** orchestrated by **tini** and **supervisor**, managing multiple services:
|
||||
|
||||
- **Laravel 12** - Core CMS application with Filament admin interface
|
||||
- **PHP-FPM** - PHP process manager
|
||||
- **nginx** - Web server and reverse proxy
|
||||
- **Queue Worker** - Background job processing
|
||||
- **Laravel Reverb** - WebSocket server for real-time communication
|
||||
|
||||
### Integration with External Services
|
||||
|
||||
- **NATS Messaging** - Publishes messages to NATS streams when content changes
|
||||
- **share-lt-astro-consumer** - Companion application that consumes NATS messages to rebuild static sites
|
||||
- **Real-time Notifications** - Uses Reverb to send toast alerts to users about build status
|
||||
|
||||
## Features
|
||||
|
||||
### Content Management
|
||||
- **Entry Model** - Core content entities with media library support
|
||||
- **Text Widgets** - Reusable content blocks
|
||||
- **Categories** - Content organization and taxonomy
|
||||
- **Media Library** - Image and file management with Spatie Media Library
|
||||
|
||||
### Real-time Publishing Workflow
|
||||
1. **Content Updates** - When entries are modified, messages are automatically sent to NATS streams
|
||||
2. **Consumer Notifications** - External applications (like share-lt-astro-consumer) listen for these messages
|
||||
3. **Preview Generation** - Consumers rebuild preview websites based on content changes
|
||||
4. **Status Updates** - Build results are sent back via API
|
||||
5. **Live Alerts** - Users receive real-time toast notifications about build status through Reverb
|
||||
|
||||
### API & Integration
|
||||
- **RESTful API** - Complete API for content retrieval and management
|
||||
- **Access Control** - Built-in authorization and authentication
|
||||
- **NATS Integration** - Message streaming for distributed architecture
|
||||
Share Light CMS
|
||||
|
||||
this project is in 'Alpha'
|
||||
|
||||
it is published as "R&D", open source, [GNU AFFERO GENERAL PUBLIC V3](LICENSE)
|
||||
it is published as "R&D", open source, [GPLv3](LICENSE)
|
||||
|
||||
default branch is currently `dev`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,144 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\Entry;
|
||||
|
||||
class ImportBlogs extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:import-blogs';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
/*
|
||||
|
||||
{
|
||||
"id": 7,
|
||||
"title": "Low/No Code FlowiseAI",
|
||||
"slug": "lowno-code-flowiseai",
|
||||
"content": "<p><img alt=\"\" src=\"http://127.0.0.1:8000/storage/99/ZsTHWAQRbdvgRUEwGmCIsm4TyChIjBwiY71VmnnR.webp\"/></p>\n<p>In <a href=\"https://flowiseai.com/\">FlowiseAI</a>, applications based on the JavaScript fork of LangChain are modeled in a 'no/low-code' environment. If you are coming from a closed source world, yet trying to implement devops principles this may fill you with fear, dread and uncertainty. FlowiseAI offers the advantage of using plain-text JSON files to represent each workflow. These files are easy to understand, open, and readily backup-able, unlike opaque proprietary binary formats\nThe data used at runtime and other component prerequisites like credentials are stored in the FlowiseAI data volume, which looks like this</p>\n<p><code>bash\nMode LastWriteTime ..... 8ZS1C0ZBB.webp",
|
||||
"created_at": "2024-12-17 11:24:59",
|
||||
"updated_at": "2024-12-17 12:53:54",
|
||||
"category_id": 1,
|
||||
"blog_date": "2024-02-26 00:00",
|
||||
"is_featured": 0,
|
||||
"published": 1
|
||||
},
|
||||
|
||||
*/
|
||||
|
||||
$filePath = '/home/user/projects/laravel/12/media_library/boring-astro-static/imported_database/blogs.json';
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
$this->error("File not found: $filePath");
|
||||
return 1;
|
||||
}
|
||||
|
||||
$jsonContent = file_get_contents($filePath);
|
||||
$blogs = json_decode($jsonContent, true);
|
||||
|
||||
if (!$blogs) {
|
||||
$this->error("Could not parse JSON file: $filePath");
|
||||
return 1;
|
||||
}
|
||||
|
||||
foreach ($blogs as $blog) {
|
||||
// Only process the blog with ID 51
|
||||
if (($blog['id'] ?? null) !== 51) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$slug = $blog['slug'] ?? null;
|
||||
$this->info("Processing blog ID: {$blog['id']} with slug: {$slug}");
|
||||
// Check if the entry already exists
|
||||
$existingEntry = Entry::where('slug', $slug)->first();
|
||||
|
||||
if ($existingEntry) {
|
||||
// Update existing entry with cleaned content
|
||||
$existingEntry->update([
|
||||
'content' => $this->cleanHtmlForFilament($blog['content'] ?? ''),
|
||||
'description' => $this->extractPlainTextFromHtml($blog['content'] ?? ''),
|
||||
]);
|
||||
$this->info("Updated content for: {$existingEntry->title}");
|
||||
} else {
|
||||
// Create new entry
|
||||
Entry::create([
|
||||
'title' => $blog['title'] ?? null,
|
||||
'slug' => $slug,
|
||||
'description' => $this->extractPlainTextFromHtml($blog['content'] ?? ''),
|
||||
'is_published' => $blog['published'] ?? false,
|
||||
'is_featured' => $blog['is_featured'] ?? false,
|
||||
'published_at' => $blog['blog_date'] ?? null,
|
||||
'content' => $this->cleanHtmlForFilament($blog['content'] ?? ''),
|
||||
'category_id' => 1, // Default category
|
||||
]);
|
||||
$this->info("Created new entry: " . ($blog['title'] ?? 'Untitled'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Blogs imported successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract plain text from HTML for description field
|
||||
*/
|
||||
private function extractPlainTextFromHtml(string $html): string
|
||||
{
|
||||
if (empty($html)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Decode HTML entities and strip tags
|
||||
$text = html_entity_decode(strip_tags($html));
|
||||
|
||||
// Clean up whitespace
|
||||
$text = preg_replace('/\s+/', ' ', $text);
|
||||
|
||||
// Limit to reasonable length for description
|
||||
return trim(substr($text, 0, 500));
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean HTML content for Filament rich editor
|
||||
*/
|
||||
private function cleanHtmlForFilament(string $html): string
|
||||
{
|
||||
if (empty($html)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Convert escaped newlines to actual newlines
|
||||
$html = str_replace(['\\n', '\\r\\n', '\\r'], "\n", $html);
|
||||
|
||||
// Decode HTML entities
|
||||
$html = html_entity_decode($html, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
|
||||
// Clean up excessive whitespace but preserve paragraph structure
|
||||
$html = preg_replace('/\s*\n\s*/', ' ', $html);
|
||||
$html = preg_replace('/[ \t]+/', ' ', $html);
|
||||
|
||||
// Ensure paragraphs have proper spacing
|
||||
$html = str_replace('</p><p>', '</p>' . "\n" . '<p>', $html);
|
||||
|
||||
return trim($html);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Entry;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ImportImages extends Command
|
||||
{
|
||||
protected $signature = 'app:import-images {--entry-id=1}';
|
||||
protected $description = 'Import images into the media library';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$entryId = $this->option('entry-id');
|
||||
$entry = Entry::find($entryId);
|
||||
|
||||
if (!$entry) {
|
||||
$this->error("Entry with ID {$entryId} not found");
|
||||
return;
|
||||
}
|
||||
|
||||
$files = Storage::disk('public')->files('imported_images');
|
||||
|
||||
if (empty($files)) {
|
||||
$this->info('No files found in storage/app/public/imported_images/');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->info("Found " . count($files) . " files to import");
|
||||
|
||||
foreach ($files as $filePath) {
|
||||
try {
|
||||
$fullPath = storage_path('app/public/' . $filePath);
|
||||
$fileName = pathinfo($fullPath, PATHINFO_BASENAME);
|
||||
|
||||
if (!file_exists($fullPath)) {
|
||||
$this->error("File not found: {$fullPath}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if already exists
|
||||
$existingMedia = $entry->getMedia()->where('file_name', $fileName)->first();
|
||||
if ($existingMedia) {
|
||||
$this->info("Skipping existing: {$fileName}");
|
||||
continue;
|
||||
}
|
||||
|
||||
$media = $entry->addMedia($fullPath)
|
||||
->toMediaCollection('default');
|
||||
|
||||
$this->info("Imported: {$fileName}");
|
||||
} catch (\Exception $e) {
|
||||
$this->error("Failed to import {$filePath}: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->info('Import completed');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Entry;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use function Livewire\str;
|
||||
|
||||
class RemediateBlogS3Images extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:remediate-blog-s3-images';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$stringToFind = 'src="http://127.0.0.1:8000/storage';
|
||||
$stringToReplace = 'src="https://your-s3-bucket-here/yours-site-static-media-dir-here';
|
||||
|
||||
Log::info('RemediateBlogS3Images command executed.');
|
||||
foreach (Entry::all() as $entry) {
|
||||
|
||||
$this->info('Entry ID: ' . $entry->id);
|
||||
if (str_contains($entry->content, $stringToFind)) {
|
||||
$this->info(' - Found occurrence in entry ID: ' . $entry->id);
|
||||
// Extract all image srcs that match the pattern
|
||||
preg_match_all('/src=\"http:\/\/127.0.0.1:8000\/storage([^\"]*)/', $entry->content, $matches);
|
||||
if (!empty($matches[0])) {
|
||||
foreach ($matches[0] as $i => $foundUrl) {
|
||||
$this->info(' - Found image src: ' . $foundUrl);
|
||||
// Compute the replacement for this specific image
|
||||
$relativePath = $matches[1][$i] ?? '';
|
||||
$newUrl = 'src="https://your-s3-bucket-here/yours-site-static-media-dir-here' . $relativePath;
|
||||
$this->info(' - Will replace with: ' . $newUrl);
|
||||
}
|
||||
}
|
||||
$updatedContent = \str_replace($stringToFind, $stringToReplace, $entry->content);
|
||||
// uncomment the following when your sure about the changes
|
||||
// $entry->content = $updatedContent;
|
||||
// $entry->save();
|
||||
// $this->info(' - Updated entry ID: ' . $entry->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Events\PreviewSiteBuilt;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SendPreviewSiteBuiltNotification extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'test:preview-site-built {--message=Preview site is built}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send a test notification that the preview site is built';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$message = $this->option('message');
|
||||
|
||||
$this->info("Command :: Broadcasting preview site built notification: {$message}");
|
||||
|
||||
PreviewSiteBuilt::dispatch($message, 'success');
|
||||
|
||||
$this->info('Notification broadcasted successfully!');
|
||||
$this->info('Check your Filament admin panel for the toast notification.');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class PreviewSiteBuilt implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public string $message = 'Preview site is built',
|
||||
public string $type = 'success'
|
||||
) {}
|
||||
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new Channel('filament-notifications'),
|
||||
];
|
||||
}
|
||||
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'preview-site.built';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class TestEvent implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public string $message = 'Test message from Laravel'
|
||||
) {}
|
||||
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new Channel('test-channel'),
|
||||
];
|
||||
}
|
||||
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'test.message';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Assets;
|
||||
|
||||
use App\Filament\Resources\Assets\Pages\CreateAsset;
|
||||
use App\Filament\Resources\Assets\Pages\EditAsset;
|
||||
use App\Filament\Resources\Assets\Pages\ListAssets;
|
||||
use App\Filament\Resources\Assets\Schemas\AssetForm;
|
||||
use App\Filament\Resources\Assets\Tables\AssetsTable;
|
||||
use App\Models\Asset;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class AssetResource extends Resource
|
||||
{
|
||||
protected static bool $shouldRegisterNavigation = false;
|
||||
|
||||
protected static ?string $model = Asset::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ArrowUpTray;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return AssetForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return AssetsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListAssets::route('/'),
|
||||
'create' => CreateAsset::route('/create'),
|
||||
'edit' => EditAsset::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Assets\Pages;
|
||||
|
||||
use App\Filament\Resources\Assets\AssetResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateAsset extends CreateRecord
|
||||
{
|
||||
protected static string $resource = AssetResource::class;
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Assets\Pages;
|
||||
|
||||
use App\Filament\Resources\Assets\AssetResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditAsset extends EditRecord
|
||||
{
|
||||
protected static string $resource = AssetResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Assets\Pages;
|
||||
|
||||
use App\Filament\Resources\Assets\AssetResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAssets extends ListRecords
|
||||
{
|
||||
protected static string $resource = AssetResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Assets\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class AssetForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('alt_text'),
|
||||
SpatieMediaLibraryFileUpload::make('image')
|
||||
->collection('default')
|
||||
->image()
|
||||
->disk('s3')
|
||||
->visibility('public')
|
||||
->label('Upload Image'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Assets\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class AssetsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('alt_text')
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Categroys;
|
||||
|
||||
use App\Filament\Resources\Categroys\Pages\CreateCategroy;
|
||||
use App\Filament\Resources\Categroys\Pages\EditCategroy;
|
||||
use App\Filament\Resources\Categroys\Pages\ListCategroys;
|
||||
use App\Filament\Resources\Categroys\Schemas\CategroyForm;
|
||||
use App\Filament\Resources\Categroys\Tables\CategroysTable;
|
||||
use App\Models\Category;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CategroyResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Category::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::RectangleGroup;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return CategroyForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return CategroysTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListCategroys::route('/'),
|
||||
'create' => CreateCategroy::route('/create'),
|
||||
'edit' => EditCategroy::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Categroys\Pages;
|
||||
|
||||
use App\Filament\Resources\Categroys\CategroyResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCategroy extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CategroyResource::class;
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Categroys\Pages;
|
||||
|
||||
use App\Filament\Resources\Categroys\CategroyResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCategroy extends EditRecord
|
||||
{
|
||||
protected static string $resource = CategroyResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Categroys\Pages;
|
||||
|
||||
use App\Filament\Resources\Categroys\CategroyResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCategroys extends ListRecords
|
||||
{
|
||||
protected static string $resource = CategroyResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Categroys\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class CategroyForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label('Category Name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Categroys\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CategroysTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Category Name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes;
|
||||
|
||||
use App\Filament\Resources\Changes\Pages\CreateChange;
|
||||
use App\Filament\Resources\Changes\Pages\EditChange;
|
||||
use App\Filament\Resources\Changes\Pages\ListChanges;
|
||||
use App\Filament\Resources\Changes\Schemas\ChangeForm;
|
||||
use App\Filament\Resources\Changes\Tables\ChangesTable;
|
||||
use App\Models\Change as ModelsChange;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ChangeResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ModelsChange::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ArrowUpOnSquareStack;
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return 'Settings';
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ChangeForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ChangesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListChanges::route('/'),
|
||||
'create' => CreateChange::route('/create'),
|
||||
'edit' => EditChange::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Pages;
|
||||
|
||||
use App\Filament\Resources\Changes\ChangeResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateChange extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ChangeResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$data['user_id'] = auth()->id();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Pages;
|
||||
|
||||
use App\Filament\Resources\Changes\ChangeResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditChange extends EditRecord
|
||||
{
|
||||
protected static string $resource = ChangeResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Pages;
|
||||
|
||||
use App\Filament\Resources\Changes\ChangeResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListChanges extends ListRecords
|
||||
{
|
||||
protected static string $resource = ChangeResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Select as FormSelect;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ChangeForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Textarea::make('note')
|
||||
->label('Note')
|
||||
->required(),
|
||||
FormSelect::make('type')
|
||||
->label('Type')
|
||||
->options([
|
||||
'go-live' => 'Go Live',
|
||||
'general' => 'General',
|
||||
])
|
||||
->default('go-live')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ChangesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('note')
|
||||
->label('Note')
|
||||
->wrap(),
|
||||
TextColumn::make('type')
|
||||
->label('Type'),
|
||||
TextColumn::make('user.name')
|
||||
->label('User'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Entries;
|
||||
|
||||
use App\Filament\Resources\Entries\Pages\CreateEntry;
|
||||
use App\Filament\Resources\Entries\Pages\EditEntry;
|
||||
use App\Filament\Resources\Entries\Pages\ListEntries;
|
||||
use App\Filament\Resources\Entries\Pages\ViewEntry;
|
||||
use App\Filament\Resources\Entries\Schemas\EntryForm;
|
||||
use App\Filament\Resources\Entries\Schemas\EntryInfolist;
|
||||
use App\Filament\Resources\Entries\Tables\EntriesTable;
|
||||
use App\Models\Entry;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class EntryResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Entry::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::PencilSquare;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return EntryForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return EntryInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return EntriesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListEntries::route('/'),
|
||||
'create' => CreateEntry::route('/create'),
|
||||
'view' => ViewEntry::route('/{record}'),
|
||||
'edit' => EditEntry::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Entries\Pages;
|
||||
|
||||
use App\Filament\Resources\Entries\EntryResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateEntry extends CreateRecord
|
||||
{
|
||||
protected static string $resource = EntryResource::class;
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Entries\Pages;
|
||||
|
||||
use App\Filament\Resources\Entries\EntryResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditEntry extends EditRecord
|
||||
{
|
||||
protected static string $resource = EntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Entries\Pages;
|
||||
|
||||
use App\Filament\Resources\Entries\EntryResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListEntries extends ListRecords
|
||||
{
|
||||
protected static string $resource = EntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Entries\Pages;
|
||||
|
||||
use App\Filament\Resources\Entries\EntryResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewEntry extends ViewRecord
|
||||
{
|
||||
protected static string $resource = EntryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,544 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Entries\Schemas;
|
||||
|
||||
use App\Models\Category;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
||||
use Filament\Forms\Components\SpatieTagsInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
class EntryForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('type')
|
||||
->options([
|
||||
'article' => 'Article',
|
||||
'card' => 'Card',
|
||||
'text' => 'Text',
|
||||
'image' => 'Image',
|
||||
])
|
||||
->default('article')
|
||||
->required()
|
||||
->live(),
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function ($state, $set): void {
|
||||
$set('slug', Str::slug((string) $state));
|
||||
}),
|
||||
TextInput::make('slug')
|
||||
->required()
|
||||
->visible(fn($get) => $get('type') === 'article')
|
||||
->dehydrated()
|
||||
->readOnly(),
|
||||
Textarea::make('description')
|
||||
->visible(fn($get) => $get('type') === 'article')
|
||||
->columnSpanFull(),
|
||||
SpatieTagsInput::make('tags')
|
||||
->type('entry-tags')
|
||||
->visible(fn($get) => $get('type') === 'article')
|
||||
->columnSpanFull(),
|
||||
SpatieMediaLibraryFileUpload::make('featured_image')
|
||||
->multiple() // <- force array handling for Filament v4 bug
|
||||
->visible(
|
||||
fn($get) =>
|
||||
$get('type') === 'article' || $get('type') === 'image'
|
||||
)
|
||||
->collection('featured-image')
|
||||
->image()
|
||||
->imageEditor()
|
||||
->disk(config('media-library.disk_name', 'public'))
|
||||
->visibility('public')
|
||||
->columnSpanFull()
|
||||
->dehydrated(false)
|
||||
->saveUploadedFileUsing(function ($file, $record) {
|
||||
if (is_array($file)) {
|
||||
$file = reset($file);
|
||||
}
|
||||
|
||||
// Validate upload object early
|
||||
if (
|
||||
! is_object($file) ||
|
||||
! (method_exists($file, 'getRealPath') || method_exists($file, 'getPathname') || method_exists($file, 'getStream') || method_exists($file, 'store'))
|
||||
) {
|
||||
Log::error('Invalid upload object', ['type' => gettype($file)]);
|
||||
throw new \Exception('Invalid upload object provided to saveUploadedFileUsing');
|
||||
}
|
||||
|
||||
// Use safe variables for further calls
|
||||
$realPath = method_exists($file, 'getRealPath') ? $file->getRealPath() : null;
|
||||
$exists = $realPath ? file_exists($realPath) : false;
|
||||
$name = method_exists($file, 'getClientOriginalName') ? $file->getClientOriginalName() : null;
|
||||
|
||||
|
||||
|
||||
|
||||
Log::info('TemporaryUploadedFile Debug', [
|
||||
'path' => $file->getRealPath(),
|
||||
'exists' => file_exists($file->getRealPath()),
|
||||
'name' => $file->getClientOriginalName(),
|
||||
'temp_dir' => sys_get_temp_dir(),
|
||||
'disk_root' => config('filesystems.disks.local.root'),
|
||||
'is_readable' => is_readable($file->getRealPath()),
|
||||
'is_writable' => is_writable($file->getRealPath()),
|
||||
]);
|
||||
|
||||
// Additional debug: Check if the file is being moved to livewire-tmp
|
||||
$livewireTmpPath = storage_path('framework/livewire-tmp');
|
||||
Log::info('Livewire Temp Directory Debug', [
|
||||
'livewire_tmp_path' => $livewireTmpPath,
|
||||
'exists' => file_exists($livewireTmpPath),
|
||||
'is_writable' => is_writable($livewireTmpPath),
|
||||
]);
|
||||
|
||||
// Check if the file is being moved
|
||||
$tempFilePath = $file->getRealPath();
|
||||
$newFilePath = $livewireTmpPath . '/' . $file->getClientOriginalName();
|
||||
if (file_exists($tempFilePath)) {
|
||||
Log::info('File exists in temp directory', ['temp_file_path' => $tempFilePath]);
|
||||
} else {
|
||||
Log::error('File does not exist in temp directory', ['temp_file_path' => $tempFilePath]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// $diskName = config('media-library.disk_name', 'public');
|
||||
$diskName = config('media-library.disk_name');
|
||||
|
||||
if (config('logging.channels.' . config('logging.default') . '.level') === 'debug') {
|
||||
Log::info('Featured Image Upload Debug', [
|
||||
'disk' => $diskName,
|
||||
'file_name' => $file->getClientOriginalName(),
|
||||
'file_size' => $file->getSize(),
|
||||
'file_mime' => $file->getMimeType(),
|
||||
'file_path' => $file->getRealPath(),
|
||||
'record_id' => $record?->id,
|
||||
'aws_config' => [
|
||||
'bucket' => config('filesystems.disks.s3.bucket'),
|
||||
'region' => config('filesystems.disks.s3.region'),
|
||||
'key_exists' => !empty(config('filesystems.disks.s3.key')),
|
||||
'secret_exists' => !empty(config('filesystems.disks.s3.secret')),
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!$record) {
|
||||
throw new \Exception('Record not found during upload');
|
||||
}
|
||||
|
||||
// Test S3 connection if using S3
|
||||
if ($diskName === 's3') {
|
||||
$disk = \Storage::disk('s3');
|
||||
|
||||
// Test basic S3 connectivity
|
||||
$testFile = 'test-' . time() . '.txt';
|
||||
$disk->put($testFile, 'test content');
|
||||
$disk->delete($testFile);
|
||||
|
||||
if (config('logging.channels.' . config('logging.default') . '.level') === 'debug') {
|
||||
Log::info('S3 connectivity test passed');
|
||||
}
|
||||
}
|
||||
|
||||
// Use addMedia with the file directly, not addMediaFromRequest
|
||||
// Generate secure filename similar to Livewire temp files
|
||||
$originalName = $file->getClientOriginalName();
|
||||
$extension = pathinfo($originalName, PATHINFO_EXTENSION);
|
||||
$baseName = pathinfo($originalName, PATHINFO_FILENAME);
|
||||
|
||||
// Generate secure filename with encoded original name
|
||||
$encodedName = base64_encode($originalName);
|
||||
$secureFileName = Str::random(32) . '-meta' . $encodedName . '-.' . $extension;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Resolve possibly-relative Livewire temp path + safe fallbacks
|
||||
$realPath = $realPath ?: (method_exists($file, 'getRealPath') ? $file->getRealPath() : null);
|
||||
$candidates = [];
|
||||
|
||||
if ($realPath && str_starts_with($realPath, '/')) {
|
||||
$candidates[] = $realPath;
|
||||
} else {
|
||||
$candidates[] = sys_get_temp_dir() . '/' . ltrim((string)$realPath, '/');
|
||||
$candidates[] = storage_path('framework/' . ltrim((string)$realPath, '/'));
|
||||
$candidates[] = storage_path(ltrim((string)$realPath, '/'));
|
||||
$candidates[] = base_path(ltrim((string)$realPath, '/'));
|
||||
}
|
||||
|
||||
if ($realPath) {
|
||||
$candidates[] = storage_path('framework/livewire-tmp/' . basename($realPath));
|
||||
$candidates[] = sys_get_temp_dir() . '/' . basename($realPath);
|
||||
}
|
||||
|
||||
// 1) Try storing to local disk (creates an absolute path we control)
|
||||
$stored = null;
|
||||
if (method_exists($file, 'store')) {
|
||||
try {
|
||||
$stored = $file->store('livewire-temp', 'local'); // storage/app/livewire-temp/...
|
||||
if ($stored && \Storage::disk('local')->exists($stored)) {
|
||||
$resolved = \Storage::disk('local')->path($stored);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::debug('store() fallback failed', ['err' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
// 2) If not resolved, check candidates
|
||||
if (! isset($resolved)) {
|
||||
foreach ($candidates as $p) {
|
||||
if ($p && file_exists($p)) {
|
||||
$resolved = $p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3) If still not resolved, try stream -> temp file copy
|
||||
$is_tmp_copy = false;
|
||||
if (! isset($resolved)) {
|
||||
try {
|
||||
$stream = null;
|
||||
if (method_exists($file, 'getStream')) {
|
||||
$stream = $file->getStream();
|
||||
} elseif (method_exists($file, 'getRealPath') && is_readable($file->getRealPath())) {
|
||||
$stream = fopen($file->getRealPath(), 'r');
|
||||
}
|
||||
|
||||
if ($stream) {
|
||||
$tmpPath = tempnam(sys_get_temp_dir(), 'filament-upload-');
|
||||
$out = fopen($tmpPath, 'w');
|
||||
stream_copy_to_stream($stream, $out);
|
||||
fclose($out);
|
||||
if (is_resource($stream)) {
|
||||
@fclose($stream);
|
||||
}
|
||||
$resolved = $tmpPath;
|
||||
$is_tmp_copy = true;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::debug('stream fallback failed', ['err' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
// 4) Still nothing -> error
|
||||
if (empty($resolved)) {
|
||||
Log::error('Featured Image Upload: could not resolve temp path', [
|
||||
'original' => $realPath,
|
||||
'checked_candidates' => $candidates,
|
||||
'stored' => $stored,
|
||||
]);
|
||||
throw new \Exception("File `{$realPath}` does not exist");
|
||||
}
|
||||
|
||||
// 5) Use resolved absolute path
|
||||
$media = $record->addMedia($resolved)
|
||||
->usingName($baseName)
|
||||
->usingFileName($secureFileName)
|
||||
->toMediaCollection('featured-image', $diskName);
|
||||
|
||||
// 6) Cleanup short-lived artifacts
|
||||
if (! empty($is_tmp_copy) && file_exists($resolved)) {
|
||||
@unlink($resolved);
|
||||
}
|
||||
if (! empty($stored) && \Storage::disk('local')->exists($stored)) {
|
||||
\Storage::disk('local')->delete($stored);
|
||||
}
|
||||
|
||||
Log::info('Featured image resolved', ['resolved' => $resolved, 'media_id' => $media->id ?? null]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (config('logging.channels.' . config('logging.default') . '.level') === 'debug') {
|
||||
Log::info('Featured Image Upload Success', [
|
||||
'media_id' => $media->id,
|
||||
'media_url' => $media->getUrl(),
|
||||
'media_path' => $media->getPathRelativeToRoot(),
|
||||
'disk' => $media->disk
|
||||
]);
|
||||
}
|
||||
|
||||
return $media->getUrl();
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Featured Image Upload Failed', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'disk' => $diskName,
|
||||
'file_name' => $file->getClientOriginalName()
|
||||
]);
|
||||
|
||||
|
||||
// Also show error to user
|
||||
\Filament\Notifications\Notification::make()
|
||||
->danger()
|
||||
->title('Upload Failed')
|
||||
->body($e->getMessage())
|
||||
->persistent()
|
||||
->send();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
})
|
||||
->hintAction(
|
||||
Action::make('featured_picker')
|
||||
->label('Featured Image from Gallery')
|
||||
->icon('heroicon-m-photo')
|
||||
->extraAttributes(['id' => 'featured-picker-button'])
|
||||
->schema([
|
||||
Select::make('image_id')
|
||||
->label('Select an existing image')
|
||||
->allowHtml()
|
||||
->options(function () {
|
||||
$currentDisk = config('media-library.disk_name', 'public');
|
||||
return Media::where('disk', $currentDisk)
|
||||
->latest()
|
||||
->limit(50)
|
||||
->get(['id', 'file_name', 'name', 'disk'])
|
||||
->mapWithKeys(function (Media $item) {
|
||||
try {
|
||||
$url = $item->getUrl();
|
||||
$fileName = e($item->file_name);
|
||||
$name = e($item->name ?? '');
|
||||
|
||||
$html = "<div class='flex items-center gap-3'>" .
|
||||
"<img src='{$url}' class='rounded' style='width:60px;height:60px;object-fit:cover;' alt='{$fileName}' loading='lazy' />" .
|
||||
"<div class='flex flex-col'>" .
|
||||
"<span class='font-medium text-sm'>{$name}</span>" .
|
||||
"<span class='text-xs text-gray-500'>{$fileName}</span>" .
|
||||
'</div></div>';
|
||||
|
||||
return [$item->id => $html];
|
||||
} catch (\Exception $e) {
|
||||
return [];
|
||||
}
|
||||
})->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data, SpatieMediaLibraryFileUpload $component): void {
|
||||
$record = $component->getRecord();
|
||||
$diskName = config('media-library.disk_name', 'public');
|
||||
|
||||
if (config('logging.channels.' . config('logging.default') . '.level') === 'debug') {
|
||||
Log::info('Featured Image Picker Action Debug', [
|
||||
'disk' => $diskName,
|
||||
'record_id' => $record?->id,
|
||||
'image_id' => $data['image_id'] ?? null
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $record) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->warning()
|
||||
->title('Save the entry first')
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $data['image_id']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sourceMedia = Media::find($data['image_id']);
|
||||
if (! $sourceMedia) {
|
||||
Log::error('Source media not found', ['image_id' => $data['image_id']]);
|
||||
\Filament\Notifications\Notification::make()
|
||||
->danger()
|
||||
->title('Source image not found in database')
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// For S3, we need to handle file copying differently
|
||||
if ($sourceMedia->disk === 's3') {
|
||||
if (config('logging.channels.' . config('logging.default') . '.level') === 'debug') {
|
||||
Log::info('Copying S3 media to new collection', [
|
||||
'source_disk' => $sourceMedia->disk,
|
||||
'source_path' => $sourceMedia->getPathRelativeToRoot(),
|
||||
'target_disk' => $diskName
|
||||
]);
|
||||
}
|
||||
|
||||
// Copy from S3 to S3 or download temporarily
|
||||
$sourceDisk = \Storage::disk($sourceMedia->disk);
|
||||
$sourceContent = $sourceDisk->get($sourceMedia->getPathRelativeToRoot());
|
||||
|
||||
if (!$sourceContent) {
|
||||
throw new \Exception('Could not read source file from S3');
|
||||
}
|
||||
|
||||
$tempCopy = sys_get_temp_dir() . '/' . uniqid() . '_' . $sourceMedia->file_name;
|
||||
file_put_contents($tempCopy, $sourceContent);
|
||||
} else {
|
||||
// Local file handling
|
||||
$sourceFile = $sourceMedia->getPath();
|
||||
if (! file_exists($sourceFile)) {
|
||||
throw new \Exception('Source file not found on disk');
|
||||
}
|
||||
|
||||
$tempCopy = sys_get_temp_dir() . '/' . uniqid() . '_' . $sourceMedia->file_name;
|
||||
copy($sourceFile, $tempCopy);
|
||||
}
|
||||
|
||||
// Verify record has ID
|
||||
if (! $record->id) {
|
||||
\Filament\Notifications\Notification::make()
|
||||
->danger()
|
||||
->title('Entry must be saved first')
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the copy to the entry's featured-image collection
|
||||
$newMedia = $record->addMedia($tempCopy)
|
||||
->usingName($sourceMedia->name ?: pathinfo($sourceMedia->file_name, PATHINFO_FILENAME))
|
||||
->usingFileName($sourceMedia->file_name)
|
||||
->toMediaCollection('featured-image', $diskName);
|
||||
|
||||
if (config('logging.channels.' . config('logging.default') . '.level') === 'debug') {
|
||||
Log::info('Featured Image Picker Success', [
|
||||
'new_media_id' => $newMedia->id,
|
||||
'new_media_disk' => $newMedia->disk,
|
||||
'new_media_url' => $newMedia->getUrl()
|
||||
]);
|
||||
}
|
||||
|
||||
// Dispatch event for app.js to handle
|
||||
$component->getLivewire()->dispatch('featured-image-added', ['mediaId' => $newMedia->id]);
|
||||
|
||||
\Filament\Notifications\Notification::make()
|
||||
->success()
|
||||
->title('Image added to featured image')
|
||||
->send();
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Featured Image Picker Failed', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'source_media_id' => $data['image_id'],
|
||||
'disk' => $diskName
|
||||
]);
|
||||
|
||||
\Filament\Notifications\Notification::make()
|
||||
->danger()
|
||||
->title('Error: ' . $e->getMessage())
|
||||
->persistent()
|
||||
->send();
|
||||
} finally {
|
||||
if (isset($tempCopy) && file_exists($tempCopy)) {
|
||||
unlink($tempCopy);
|
||||
}
|
||||
}
|
||||
})
|
||||
),
|
||||
Toggle::make('is_published')
|
||||
->required(),
|
||||
Toggle::make('is_featured')
|
||||
->required(),
|
||||
TextInput::make('priority')
|
||||
->label('Priority')
|
||||
->numeric()
|
||||
->default(0)
|
||||
->required(),
|
||||
DatePicker::make('published_at')
|
||||
->visible(fn($get) => $get('type') === 'article'),
|
||||
Select::make('category_id')
|
||||
->label('Category')
|
||||
->options(function () {
|
||||
return Category::all()
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->searchable(),
|
||||
TextInput::make('call_to_action_text')
|
||||
->label('Call to Action Text')
|
||||
->visible(fn($get) => $get('type') !== 'article'),
|
||||
TextInput::make('call_to_action_link')
|
||||
->label('Call to Action URL')
|
||||
->visible(fn($get) => $get('type') !== 'article'),
|
||||
|
||||
RichEditor::make('content')
|
||||
->visible(fn($get) => $get('type') !== 'image')
|
||||
->columnSpanFull()
|
||||
->hintAction(
|
||||
Action::make('picker')
|
||||
->label('Gallery Picker')
|
||||
->icon('heroicon-m-photo')
|
||||
->schema([
|
||||
Select::make('image_url')
|
||||
->label('Select an existing image')
|
||||
->allowHtml()
|
||||
->options(function () {
|
||||
return Media::latest()
|
||||
->limit(30) // Limit to 30 most recent items for performance
|
||||
->get(['id', 'file_name', 'name', 'uuid', 'collection_name', 'model_type', 'model_id', 'disk'])
|
||||
->filter(function (Media $item) {
|
||||
// Only include media items that have a valid disk
|
||||
return $item->disk !== null;
|
||||
})
|
||||
->mapWithKeys(function (Media $item) {
|
||||
try {
|
||||
$url = $item->getUrl();
|
||||
} catch (\Exception $e) {
|
||||
// Skip items that can't generate URLs
|
||||
return [];
|
||||
}
|
||||
|
||||
$fileName = e($item->file_name);
|
||||
$name = e($item->name ?? '');
|
||||
|
||||
// Smaller image preview for better performance
|
||||
$html = "<div class='flex items-center gap-3'>" .
|
||||
"<img src='{$url}' class='rounded' style='width:60px;height:60px;object-fit:cover;' alt='{$fileName}' loading='lazy' />" .
|
||||
"<div class='flex flex-col'>" .
|
||||
"<span class='font-medium text-sm'>{$name}</span>" .
|
||||
"<span class='text-xs text-gray-500'>{$fileName}</span>" .
|
||||
'</div></div>';
|
||||
|
||||
return [$url => $html];
|
||||
})->toArray();
|
||||
})
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data, RichEditor $component) {
|
||||
// We dispatch the URL to the browser to be inserted into TipTap
|
||||
$component->getLivewire()->dispatch('insert-editor-content', [
|
||||
'statePath' => $component->getStatePath(),
|
||||
'html' => "<img src='{$data['image_url']}' alt=''>",
|
||||
]);
|
||||
})
|
||||
),
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Entries\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
use Filament\Infolists\Components\SpatieMediaLibraryImageEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class EntryInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('title'),
|
||||
TextEntry::make('slug'),
|
||||
TextEntry::make('description')
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
SpatieMediaLibraryImageEntry::make('featured_image')
|
||||
->collection('featured-image')
|
||||
->columnSpanFull(),
|
||||
IconEntry::make('is_published')
|
||||
->boolean(),
|
||||
IconEntry::make('is_featured')
|
||||
->boolean(),
|
||||
TextEntry::make('published_at')
|
||||
->date()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('content')
|
||||
->placeholder('-')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime()
|
||||
->placeholder('-'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Entries\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class EntriesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('id')
|
||||
->label('ID')
|
||||
->sortable(query: function ($query, $direction) {
|
||||
$query->orderBy('id', $direction);
|
||||
}),
|
||||
SpatieMediaLibraryImageColumn::make('featured_image')
|
||||
->collection('featured-image')
|
||||
->label('Image')
|
||||
->circular()
|
||||
->stacked()
|
||||
->limit(3),
|
||||
TextColumn::make('title')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('category.name')
|
||||
->label('Category')
|
||||
->sortable(query: function ($query, $direction) {
|
||||
$query->join('categories', 'entries.category_id', '=', 'categories.id')
|
||||
->orderBy('categories.name', $direction)
|
||||
->select('entries.*');
|
||||
})
|
||||
->searchable(),
|
||||
IconColumn::make('is_published')
|
||||
->label('pub')
|
||||
->boolean(),
|
||||
IconColumn::make('is_featured')
|
||||
->label('feat')
|
||||
->boolean(),
|
||||
TextColumn::make('published_at')
|
||||
->date()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Media;
|
||||
|
||||
use App\Filament\Resources\Media\Pages\CreateMedia;
|
||||
use App\Filament\Resources\Media\Pages\EditMedia;
|
||||
use App\Filament\Resources\Media\Pages\ListMedia;
|
||||
use App\Filament\Resources\Media\Pages\ViewMedia;
|
||||
use App\Filament\Resources\Media\Schemas\MediaForm;
|
||||
use App\Filament\Resources\Media\Schemas\MediaInfolist;
|
||||
use App\Filament\Resources\Media\Tables\MediaTable;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
class MediaResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Media::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'file_name';
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::Photo
|
||||
|
||||
;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return MediaForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return MediaInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return MediaTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListMedia::route('/'),
|
||||
'create' => CreateMedia::route('/create'),
|
||||
'view' => ViewMedia::route('/{record}'),
|
||||
'edit' => EditMedia::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Media\Pages;
|
||||
|
||||
use App\Filament\Resources\Media\MediaResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
class CreateMedia extends CreateRecord
|
||||
{
|
||||
protected static string $resource = MediaResource::class;
|
||||
|
||||
protected ?string $uploadedFile = null;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
// Extract the file data before creating the media record
|
||||
$file = $data['file'] ?? null;
|
||||
unset($data['file']);
|
||||
|
||||
// Store file path for later
|
||||
$this->uploadedFile = $file;
|
||||
|
||||
// Set required fields for Media model
|
||||
$data['model_type'] = $data['model_type'] ?? 'temp';
|
||||
$data['model_id'] = $data['model_id'] ?? 0;
|
||||
$data['collection_name'] = $data['collection_name'] ?? 'default';
|
||||
$data['disk'] = $data['disk'] ?? 'public';
|
||||
$data['file_name'] = $file ? basename($file) : '';
|
||||
$data['mime_type'] = $file && Storage::disk('public')->exists($file)
|
||||
? Storage::disk('public')->mimeType($file)
|
||||
: 'application/octet-stream';
|
||||
$data['size'] = $file && Storage::disk('public')->exists($file)
|
||||
? Storage::disk('public')->size($file)
|
||||
: 0;
|
||||
$data['manipulations'] = [];
|
||||
$data['custom_properties'] = [];
|
||||
$data['generated_conversions'] = [];
|
||||
$data['responsive_images'] = [];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function afterCreate(): void
|
||||
{
|
||||
if ($this->uploadedFile && $this->record) {
|
||||
$disk = Storage::disk('public');
|
||||
|
||||
// Create the directory for this media ID (Spatie structure: {id}/{filename})
|
||||
$mediaDirectory = (string) $this->record->id;
|
||||
$disk->makeDirectory($mediaDirectory);
|
||||
|
||||
// Move file from temporary upload location to Spatie's expected location
|
||||
if ($disk->exists($this->uploadedFile)) {
|
||||
$newPath = $mediaDirectory.'/'.$this->record->file_name;
|
||||
$disk->move($this->uploadedFile, $newPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Media\Pages;
|
||||
|
||||
use App\Filament\Resources\Media\MediaResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class EditMedia extends EditRecord
|
||||
{
|
||||
protected static string $resource = MediaResource::class;
|
||||
|
||||
protected ?string $uploadedFile = null;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
// Extract the file data if a new file was uploaded
|
||||
$file = $data['file'] ?? null;
|
||||
unset($data['file']);
|
||||
|
||||
// Only update file-related fields if a new file was uploaded
|
||||
if ($file && $file !== $this->record->getPathRelativeToRoot()) {
|
||||
$this->uploadedFile = $file;
|
||||
|
||||
// Keep the original file_name to prevent breaking existing references
|
||||
// $data['file_name'] is not updated - we preserve the original filename
|
||||
$data['mime_type'] = Storage::disk('public')->exists($file)
|
||||
? Storage::disk('public')->mimeType($file)
|
||||
: 'application/octet-stream';
|
||||
$data['size'] = Storage::disk('public')->exists($file)
|
||||
? Storage::disk('public')->size($file)
|
||||
: 0;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function afterSave(): void
|
||||
{
|
||||
if ($this->uploadedFile && $this->record) {
|
||||
$disk = Storage::disk('public');
|
||||
$mediaDirectory = (string) $this->record->id;
|
||||
|
||||
// Delete old file if it exists
|
||||
$oldPath = $mediaDirectory.'/'.$this->record->getOriginal('file_name');
|
||||
if ($disk->exists($oldPath)) {
|
||||
$disk->delete($oldPath);
|
||||
}
|
||||
|
||||
// Move new file to Spatie's expected location using the original filename
|
||||
if ($disk->exists($this->uploadedFile)) {
|
||||
$disk->makeDirectory($mediaDirectory);
|
||||
// Use the original file_name to preserve existing references
|
||||
$newPath = $mediaDirectory.'/'.$this->record->file_name;
|
||||
$disk->move($this->uploadedFile, $newPath);
|
||||
}
|
||||
|
||||
// Redirect to the same page to refresh the form state
|
||||
$this->redirect(static::getUrl(['record' => $this->record]), navigate: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Media\Pages;
|
||||
|
||||
use App\Filament\Resources\Media\MediaResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListMedia extends ListRecords
|
||||
{
|
||||
protected static string $resource = MediaResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
// CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Media\Pages;
|
||||
|
||||
use App\Filament\Resources\Media\MediaResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewMedia extends ViewRecord
|
||||
{
|
||||
protected static string $resource = MediaResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Media\Schemas;
|
||||
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media as SpatieMedia;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class MediaForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('collection_name')
|
||||
->default('default')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Hidden::make('disk')
|
||||
->default('public'),
|
||||
FileUpload::make('file')
|
||||
->multiple() // workaround for Filament v4 single-file bug
|
||||
->label('File')
|
||||
->imageEditor()
|
||||
->imageEditorAspectRatios([
|
||||
'16:9',
|
||||
'4:3',
|
||||
'1:1',
|
||||
])
|
||||
->columnSpanFull()
|
||||
->disk('s3')
|
||||
->directory('media')
|
||||
->visibility('public')
|
||||
->acceptedFileTypes(['image/*', 'application/pdf'])
|
||||
->maxSize(10240)
|
||||
->required(fn($context) => $context === 'create')
|
||||
|
||||
|
||||
->afterStateHydrated(function (FileUpload $component, $state, $record): void {
|
||||
Log::info('MediaForm afterStateHydrated invoked', ['record_id' => $record?->id, 'state' => $state]);
|
||||
|
||||
try {
|
||||
if (! $record) {
|
||||
return;
|
||||
}
|
||||
|
||||
$media = $record;
|
||||
if (! $media instanceof SpatieMedia) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Construct the correct path: {media_id}/{filename}
|
||||
$path = $media->id . '/' . $media->file_name;
|
||||
|
||||
try {
|
||||
$disk = $media->disk ?? 'public';
|
||||
if (Storage::disk($disk)->exists($path)) {
|
||||
$component->state($path);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('MediaForm afterStateHydrated storage check failed', [
|
||||
'err' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'disk' => $media->disk ?? null,
|
||||
'path' => $path,
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('MediaForm afterStateHydrated unhandled', [
|
||||
'err' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'record' => $record?->id,
|
||||
'state' => $state,
|
||||
]);
|
||||
throw $e;
|
||||
}
|
||||
}),
|
||||
|
||||
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Media\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\ImageEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class MediaInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
ImageEntry::make('file_name')
|
||||
->label('Preview')
|
||||
->getStateUsing(fn ($record) => $record->getUrl())
|
||||
->visible(fn ($record) => $record->mime_type && str_starts_with($record->mime_type, 'image/')),
|
||||
TextEntry::make('name'),
|
||||
TextEntry::make('file_name'),
|
||||
TextEntry::make('mime_type'),
|
||||
TextEntry::make('collection_name'),
|
||||
TextEntry::make('size')
|
||||
->formatStateUsing(fn ($state) => number_format($state / 1024, 2).' KB'),
|
||||
TextEntry::make('model_type')
|
||||
->label('Attached to Model'),
|
||||
TextEntry::make('model_id'),
|
||||
TextEntry::make('custom_properties')
|
||||
->formatStateUsing(fn ($state) => json_encode($state, JSON_PRETTY_PRINT)),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime(),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Media\Tables;
|
||||
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
class MediaTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->modifyQueryUsing(fn($query) => $query->where('collection_name', '!=', 'avatars'))
|
||||
->columns([
|
||||
ImageColumn::make('url')
|
||||
->label('Preview')
|
||||
->getStateUsing(
|
||||
fn($record) =>
|
||||
// Prefer the stored path produced by Filament's FileUpload (saved in custom_properties),
|
||||
// fall back to Spatie's getUrl() when no stored_path exists.
|
||||
($record->getCustomProperty('stored_path'))
|
||||
? Storage::url($record->getCustomProperty('stored_path'))
|
||||
: $record->getUrl()
|
||||
)
|
||||
->height(40)
|
||||
->width(40),
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('file_name')
|
||||
->searchable(),
|
||||
TextColumn::make('collection_name')
|
||||
->badge(),
|
||||
TextColumn::make('mime_type'),
|
||||
TextColumn::make('size')
|
||||
->formatStateUsing(fn($state) => number_format($state / 1024, 2) . ' KB'),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('collection_name')
|
||||
->options([
|
||||
'images' => 'Images',
|
||||
'documents' => 'Documents',
|
||||
]),
|
||||
])
|
||||
->recordActions([
|
||||
// EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->action(function (Media $record) {
|
||||
// Delete the actual stored file path if we saved one, otherwise fall back to the Spatie path.
|
||||
$stored = $record->getCustomProperty('stored_path');
|
||||
if ($stored) {
|
||||
Storage::disk($record->disk)->delete($stored);
|
||||
} else {
|
||||
Storage::disk($record->disk)->delete($record->getPath());
|
||||
}
|
||||
|
||||
$record->delete();
|
||||
}),
|
||||
])
|
||||
->toolbarActions([
|
||||
|
||||
Action::make('add')
|
||||
->label('Add')
|
||||
->icon('heroicon-o-plus')
|
||||
->url(fn() => url('admin/assets/create'))
|
||||
->color('primary'),
|
||||
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make()
|
||||
->action(function (Collection $records) {
|
||||
$records->each(function (Media $record) {
|
||||
$stored = $record->getCustomProperty('stored_path');
|
||||
if ($stored) {
|
||||
Storage::disk($record->disk)->delete($stored);
|
||||
} else {
|
||||
Storage::disk($record->disk)->delete($record->getPath());
|
||||
}
|
||||
$record->delete();
|
||||
});
|
||||
}),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TextWidgets\Pages;
|
||||
|
||||
use App\Filament\Resources\TextWidgets\TextWidgetResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTextWidget extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TextWidgetResource::class;
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TextWidgets\Pages;
|
||||
|
||||
use App\Filament\Resources\TextWidgets\TextWidgetResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTextWidget extends EditRecord
|
||||
{
|
||||
protected static string $resource = TextWidgetResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TextWidgets\Pages;
|
||||
|
||||
use App\Filament\Resources\TextWidgets\TextWidgetResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTextWidgets extends ListRecords
|
||||
{
|
||||
protected static string $resource = TextWidgetResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TextWidgets\Schemas;
|
||||
|
||||
use App\Models\Category;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TextWidgetForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->live(onBlur: true),
|
||||
TextInput::make('description')
|
||||
->nullable(),
|
||||
Textarea::make('content')
|
||||
->rows(5)
|
||||
->columnSpanFull(),
|
||||
Select::make('category_id')
|
||||
->label('Category')
|
||||
->options(function () {
|
||||
return Category::all()
|
||||
->pluck('name', 'id')
|
||||
->toArray();
|
||||
})
|
||||
->searchable(),
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TextWidgets\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TextWidgetsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('title')
|
||||
->label('Title')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Created')
|
||||
->dateTime('M d, Y H:i')
|
||||
->sortable(),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Updated')
|
||||
->dateTime('M d, Y H:i')
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TextWidgets;
|
||||
|
||||
use App\Filament\Resources\TextWidgets\Pages\CreateTextWidget;
|
||||
use App\Filament\Resources\TextWidgets\Pages\EditTextWidget;
|
||||
use App\Filament\Resources\TextWidgets\Pages\ListTextWidgets;
|
||||
use App\Filament\Resources\TextWidgets\Schemas\TextWidgetForm;
|
||||
use App\Filament\Resources\TextWidgets\Tables\TextWidgetsTable;
|
||||
use App\Models\TextWidget;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TextWidgetResource extends Resource
|
||||
{
|
||||
|
||||
protected static bool $shouldRegisterNavigation = false;
|
||||
|
||||
protected static ?string $model = TextWidget::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::DocumentText;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'title';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TextWidgetForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TextWidgetsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTextWidgets::route('/'),
|
||||
'create' => CreateTextWidget::route('/create'),
|
||||
'edit' => EditTextWidget::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\StoreCategoryRequest;
|
||||
use App\Http\Requests\UpdateCategoryRequest;
|
||||
use App\Http\Resources\CategoryResource;
|
||||
use App\Models\Category;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return CategoryResource::collection(Category::all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(StoreCategoryRequest $request)
|
||||
{
|
||||
return new CategoryResource(Category::create($request->validated()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Category $category)
|
||||
{
|
||||
return new CategoryResource($category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(UpdateCategoryRequest $request, Category $category)
|
||||
{
|
||||
$category->update($request->validated());
|
||||
|
||||
return new CategoryResource($category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Category $category)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if (! $user || $user->email !== config('app.admin_email')) {
|
||||
return response()->json(['message' => 'Forbidden'], 403);
|
||||
}
|
||||
|
||||
$category->delete();
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\EntryResource;
|
||||
use App\Models\Entry;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class EntryController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return EntryResource::collection(Entry::with('category')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (! $user || $user->email !== config('app.admin_email')) {
|
||||
return response()->json(['message' => 'Forbidden'], 403);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'content' => 'required|string',
|
||||
]);
|
||||
|
||||
$validated['slug'] = $this->generateUniqueSlug($validated['title']);
|
||||
|
||||
return new EntryResource(Entry::create($validated));
|
||||
}
|
||||
|
||||
private function generateUniqueSlug(string $title): string
|
||||
{
|
||||
do {
|
||||
$slug = Str::slug($title).'-'.Str::random(8);
|
||||
} while (Entry::where('slug', $slug)->exists());
|
||||
|
||||
return $slug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(Entry $entry)
|
||||
{
|
||||
$this->authorize('view', $entry);
|
||||
|
||||
return new EntryResource($entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Entry $entry)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'sometimes|required|string|max:255',
|
||||
'content' => 'sometimes|required|string',
|
||||
]);
|
||||
|
||||
$entry->update($validated);
|
||||
|
||||
return new EntryResource($entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Entry $entry)
|
||||
{
|
||||
$entry->delete();
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::check();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Events\PreviewSiteBuilt;
|
||||
use App\Http\Requests\SendPreviewSiteBuiltNotificationRequest;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class NotificationController extends Controller
|
||||
{
|
||||
/**
|
||||
* Send preview site built notification.
|
||||
*/
|
||||
public function sendPreviewSiteBuilt(SendPreviewSiteBuiltNotificationRequest $request): JsonResponse
|
||||
{
|
||||
$message = $request->validated()['message'];
|
||||
|
||||
PreviewSiteBuilt::dispatch($message, 'success');
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Preview site built notification sent successfully',
|
||||
'data' => [
|
||||
'notification_message' => $message,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Resources\TextWidgetResource;
|
||||
use App\Models\TextWidget;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class TextWidgetController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return response()->json([
|
||||
'data' => TextWidget::with('category')->get()->map(fn ($tw) => new TextWidgetResource($tw))
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
if (! $user || $user->email !== config('app.admin_email')) {
|
||||
return response()->json(['message' => 'Forbidden'], 403);
|
||||
}
|
||||
|
||||
$validated = $request->validate([
|
||||
'title' => 'required|string|max:255',
|
||||
'description' => 'nullable|string',
|
||||
'content' => 'required|string',
|
||||
]);
|
||||
|
||||
return new TextWidgetResource(TextWidget::create($validated));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(TextWidget $textWidget)
|
||||
{
|
||||
return new TextWidgetResource($textWidget->load('category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, TextWidget $textWidget)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'title' => 'sometimes|required|string|max:255',
|
||||
'description' => 'sometimes|nullable|string',
|
||||
'content' => 'sometimes|required|string',
|
||||
]);
|
||||
|
||||
$textWidget->update($validated);
|
||||
|
||||
return new TextWidgetResource($textWidget->load('category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(TextWidget $textWidget)
|
||||
{
|
||||
$textWidget->delete();
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class SendPreviewSiteBuiltNotificationRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() && $this->user()->email === config('app.admin_email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'message' => 'required|string|max:255',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreCategoryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() && $this->user()->email === config('app.admin_email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255|unique:categories,name',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreEntryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() && $this->user()->email === config('app.admin_email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'required|string|max:255',
|
||||
'content' => 'required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateCategoryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() && $this->user()->email === config('app.admin_email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'sometimes|required|string|max:255|unique:categories,name,'.$this->category->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateEntryRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user() && $this->user()->email === config('app.admin_email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'sometimes|required|string|max:255',
|
||||
'content' => 'sometimes|required|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class CategoryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class EntryResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'slug' => $this->slug,
|
||||
'description' => $this->description,
|
||||
'is_published' => $this->is_published,
|
||||
'is_featured' => $this->is_featured,
|
||||
'published_at' => $this->published_at,
|
||||
'content' => $this->content,
|
||||
'category' => $this->category->name ?? null,
|
||||
'featured_image_url' => $this->getFirstMediaUrl('featured-image') ?: null,
|
||||
'call_to_action_text' => $this->call_to_action_text,
|
||||
'call_to_action_link' => $this->call_to_action_link,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'priority' => $this->priority,
|
||||
'type' => $this->type,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class TextWidgetResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'description' => $this->description,
|
||||
'content' => $this->content,
|
||||
'category' => $this->category->name ?? null,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Services\ProcessUpdateService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class ProcessChangeUpdate implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public int $changeId,
|
||||
public string $action,
|
||||
public string $type = 'change_update_'
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
Log::info("Processing change update: changeId={$this->changeId}, action={$this->action}");
|
||||
(new ProcessUpdateService)->processUpdate($this->changeId, $this->action, $this->type);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Services\ProcessUpdateService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ProcessEntryUpdate implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(
|
||||
public int $entryId,
|
||||
public string $action,
|
||||
public string $type = 'entry_update_'
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
(new ProcessUpdateService)->processUpdate($this->entryId, $this->action, $this->type);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Spatie\MediaLibrary\MediaCollections\Models\Media;
|
||||
|
||||
class GalleryPicker extends Component
|
||||
{
|
||||
#[\Livewire\Attributes\Reactive]
|
||||
public $entryId;
|
||||
|
||||
public $mediaItems = [];
|
||||
public $selectedMediaId = null;
|
||||
public $showModal = false;
|
||||
|
||||
#[\Livewire\Attributes\On('open-gallery-picker')]
|
||||
public function openPicker($entryId): void
|
||||
{
|
||||
$this->entryId = $entryId;
|
||||
$this->loadMediaItems();
|
||||
$this->showModal = true;
|
||||
}
|
||||
|
||||
public function loadMediaItems(): void
|
||||
{
|
||||
$this->mediaItems = Media::where('model_type', 'temp')
|
||||
->where('model_id', 0)
|
||||
->where('disk', 'public')
|
||||
->latest()
|
||||
->limit(30)
|
||||
->get(['id', 'file_name', 'name', 'disk'])
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function selectMedia($mediaId): void
|
||||
{
|
||||
$this->selectedMediaId = $mediaId;
|
||||
}
|
||||
|
||||
public function copyToEntry(): void
|
||||
{
|
||||
if (!$this->selectedMediaId || !$this->entryId) {
|
||||
$this->dispatch('notify-error', ['message' => 'Please select an image']);
|
||||
return;
|
||||
}
|
||||
|
||||
$sourceMedia = Media::find($this->selectedMediaId);
|
||||
if (!$sourceMedia) {
|
||||
$this->dispatch('notify-error', ['message' => 'Media not found']);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get the entry
|
||||
$entry = \App\Models\Entry::find($this->entryId);
|
||||
if (!$entry) {
|
||||
$this->dispatch('notify-error', ['message' => 'Entry not found']);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get source file
|
||||
$sourceFile = $sourceMedia->getPath();
|
||||
if (!file_exists($sourceFile)) {
|
||||
$this->dispatch('notify-error', ['message' => 'Source file not found']);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create temp copy
|
||||
$tempCopy = sys_get_temp_dir() . '/' . uniqid() . '_' . $sourceMedia->file_name;
|
||||
copy($sourceFile, $tempCopy);
|
||||
|
||||
try {
|
||||
// Clear existing featured image
|
||||
$entry->clearMediaCollection('featured-image');
|
||||
|
||||
// Add to entry
|
||||
$newMedia = $entry->addMedia($tempCopy)
|
||||
->usingName($sourceMedia->name ?: pathinfo($sourceMedia->file_name, PATHINFO_FILENAME))
|
||||
->usingFileName($sourceMedia->file_name)
|
||||
->toMediaCollection('featured-image', 'public');
|
||||
|
||||
// Close modal and notify
|
||||
$this->showModal = false;
|
||||
$this->selectedMediaId = null;
|
||||
$this->dispatch('media-selected', ['mediaId' => $newMedia->id, 'fileName' => $newMedia->file_name]);
|
||||
$this->dispatch('notify-success', ['message' => 'Image added to entry']);
|
||||
} finally {
|
||||
if (file_exists($tempCopy)) {
|
||||
unlink($tempCopy);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->dispatch('notify-error', ['message' => 'Error: ' . $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
public function closePicker(): void
|
||||
{
|
||||
$this->showModal = false;
|
||||
$this->selectedMediaId = null;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.gallery-picker');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
|
||||
class Asset extends Model implements HasMedia
|
||||
{
|
||||
use InteractsWithMedia;
|
||||
|
||||
protected $fillable = [
|
||||
'alt_text',
|
||||
];
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['name'];
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Change extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'note',
|
||||
'user_id',
|
||||
'type',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Filament\Forms\Components\RichEditor\FileAttachmentProviders\SpatieMediaLibraryFileAttachmentProvider;
|
||||
use Filament\Forms\Components\RichEditor\Models\Concerns\InteractsWithRichContent;
|
||||
use Filament\Forms\Components\RichEditor\Models\Contracts\HasRichContent;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
use Spatie\Tags\HasTags;
|
||||
|
||||
/*
|
||||
Entry model with rich content and media library integration
|
||||
This is the main article / blog rich content model
|
||||
*/
|
||||
|
||||
class Entry extends Model implements HasMedia, HasRichContent
|
||||
{
|
||||
use HasFactory, HasTags, InteractsWithMedia, InteractsWithRichContent;
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'type',
|
||||
'slug',
|
||||
'description',
|
||||
'is_published',
|
||||
'is_featured',
|
||||
'published_at',
|
||||
'content',
|
||||
'call_to_action_link',
|
||||
'call_to_action_text',
|
||||
'category_id',
|
||||
'priority',
|
||||
];
|
||||
|
||||
/**
|
||||
* Set up rich content configuration for media library integration
|
||||
*/
|
||||
public function setUpRichContent(): void
|
||||
{
|
||||
$this->registerRichContent('content')
|
||||
->fileAttachmentProvider(
|
||||
SpatieMediaLibraryFileAttachmentProvider::make()
|
||||
->collection('content-attachments')
|
||||
->preserveFilenames()
|
||||
);
|
||||
}
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($entry) {
|
||||
if (empty($entry->slug)) {
|
||||
$entry->slug = Str::slug($entry->title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class TextWidget extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'description',
|
||||
'content',
|
||||
'category_id',
|
||||
];
|
||||
|
||||
public function category(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Category::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -3,20 +3,16 @@
|
|||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Str;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasApiTokens, HasFactory, Notifiable, TwoFactorAuthenticatable;
|
||||
use HasFactory, Notifiable, TwoFactorAuthenticatable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
|
@ -65,17 +61,4 @@ class User extends Authenticatable implements FilamentUser
|
|||
->map(fn ($word) => Str::substr($word, 0, 1))
|
||||
->implode('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user can access Filament admin panel.
|
||||
*/
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
return $this->email === config('app.admin_email') || $this->role === 'admin';
|
||||
}
|
||||
|
||||
public function changes()
|
||||
{
|
||||
return $this->hasMany(Change::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Jobs\ProcessChangeUpdate;
|
||||
use App\Models\Change;
|
||||
|
||||
class ChangeObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Change "created" event.
|
||||
*/
|
||||
public function created(Change $change): void
|
||||
{
|
||||
ProcessChangeUpdate::dispatch($change->id, 'created');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Change "updated" event.
|
||||
*/
|
||||
public function updated(Change $change): void
|
||||
{
|
||||
ProcessChangeUpdate::dispatch($change->id, 'updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Change "deleted" event.
|
||||
*/
|
||||
public function deleted(Change $change): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Change "restored" event.
|
||||
*/
|
||||
public function restored(Change $change): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Change "force deletecURLd" event.
|
||||
*/
|
||||
public function forceDeleted(Change $change): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Jobs\ProcessEntryUpdate;
|
||||
use App\Models\Entry;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class EntryObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Entry "created" event.
|
||||
*/
|
||||
public function created(Entry $entry): void
|
||||
{
|
||||
ProcessEntryUpdate::dispatch($entry->id, 'created');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Entry "updated" event.
|
||||
*/
|
||||
public function updated(Entry $entry): void
|
||||
{
|
||||
ProcessEntryUpdate::dispatch($entry->id, 'updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Entry "deleted" event.
|
||||
*/
|
||||
public function deleted(Entry $entry): void
|
||||
{
|
||||
ProcessEntryUpdate::dispatch($entry->id, 'deleted');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Entry "restored" event.
|
||||
*/
|
||||
public function restored(Entry $entry): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Entry "force deleted" event.
|
||||
*/
|
||||
public function forceDeleted(Entry $entry): void
|
||||
{
|
||||
// ProcessEntryUpdate::dispatch($entry, 'force deleted');
|
||||
}
|
||||
}
|
||||
|
|
@ -2,12 +2,7 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Entry;
|
||||
use App\Observers\EntryObserver;
|
||||
use App\Models\Change;
|
||||
use App\Observers\ChangeObserver;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
|
@ -24,13 +19,6 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
// Ensure the livewire-tmp directory exists
|
||||
$livewireTmpPath = storage_path('framework/livewire-tmp');
|
||||
if (!File::exists($livewireTmpPath)) {
|
||||
File::makeDirectory($livewireTmpPath, 0755, true);
|
||||
}
|
||||
|
||||
Entry::observe(EntryObserver::class);
|
||||
Change::observe(ChangeObserver::class);
|
||||
//
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,234 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Pages\Dashboard;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Support\Facades\FilamentView;
|
||||
use Filament\View\PanelsRenderHook;
|
||||
use Filament\Widgets\AccountWidget;
|
||||
use Filament\Widgets\FilamentInfoWidget;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
|
||||
class AdminPanelProvider extends PanelProvider
|
||||
{
|
||||
public function panel(Panel $panel): Panel
|
||||
{
|
||||
$previewSiteUrl = env('PREVIEW_SITE_URL');
|
||||
$liveSiteUrl = env('LIVE_SITE_URL');
|
||||
|
||||
$navigationItems = [];
|
||||
if ($previewSiteUrl && $liveSiteUrl) {
|
||||
$navigationItems = [
|
||||
\Filament\Navigation\NavigationItem::make('Preview Site')
|
||||
->url($previewSiteUrl, shouldOpenInNewTab: true)
|
||||
->icon('heroicon-o-eye')
|
||||
->group('External Links')
|
||||
->sort(1),
|
||||
\Filament\Navigation\NavigationItem::make('Live Site')
|
||||
->url($liveSiteUrl, shouldOpenInNewTab: true)
|
||||
->icon('heroicon-o-rocket-launch')
|
||||
->group('External Links')
|
||||
->sort(2),
|
||||
];
|
||||
}
|
||||
|
||||
return $panel
|
||||
->default()
|
||||
->sidebarCollapsibleOnDesktop()
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
->login()
|
||||
->colors([
|
||||
'primary' => Color::Blue,
|
||||
])
|
||||
->resources([
|
||||
\App\Filament\Resources\Entries\EntryResource::class,
|
||||
\App\Filament\Resources\Media\MediaResource::class,
|
||||
\App\Filament\Resources\Categroys\CategroyResource::class,
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
||||
->pages([
|
||||
Dashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
|
||||
->widgets([
|
||||
AccountWidget::class,
|
||||
FilamentInfoWidget::class,
|
||||
])
|
||||
->navigationItems($navigationItems)
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
StartSession::class,
|
||||
AuthenticateSession::class,
|
||||
ShareErrorsFromSession::class,
|
||||
VerifyCsrfToken::class,
|
||||
SubstituteBindings::class,
|
||||
DisableBladeIconComponents::class,
|
||||
DispatchServingFilamentEvent::class,
|
||||
])
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
]);
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
FilamentView::registerRenderHook(
|
||||
PanelsRenderHook::BODY_END,
|
||||
fn(): string => \Illuminate\Support\Facades\Blade::render('@vite("resources/js/app.js")'),
|
||||
);
|
||||
|
||||
FilamentView::registerRenderHook(
|
||||
PanelsRenderHook::BODY_END,
|
||||
function (): string {
|
||||
return '
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
if (window.Echo) {
|
||||
console.log("Setting up Filament Reverb notifications...");
|
||||
console.log("Available globals:", {
|
||||
FilamentNotification: typeof FilamentNotification,
|
||||
Livewire: typeof window.Livewire,
|
||||
filament: typeof window.filament
|
||||
});
|
||||
|
||||
// Listen for preview site built events
|
||||
window.Echo.channel("filament-notifications")
|
||||
.listen("preview-site.built", function(event) {
|
||||
console.log("🎉 Received preview site built event:", event);
|
||||
|
||||
// Use Filament v4 notification system
|
||||
if (typeof FilamentNotification !== "undefined") {
|
||||
new FilamentNotification()
|
||||
.title(event.message)
|
||||
.success()
|
||||
.duration(5000)
|
||||
.send();
|
||||
console.log("✅ Sent via FilamentNotification v4");
|
||||
} else {
|
||||
console.warn("FilamentNotification not available");
|
||||
// Fallback notification
|
||||
const notification = document.createElement("div");
|
||||
notification.style.cssText = `
|
||||
position: fixed !important;
|
||||
top: 20px !important;
|
||||
right: 20px !important;
|
||||
z-index: 999999 !important;
|
||||
background: #10b981 !important;
|
||||
color: white !important;
|
||||
padding: 16px 20px !important;
|
||||
border-radius: 8px !important;
|
||||
box-shadow: 0 10px 25px rgba(0,0,0,0.3) !important;
|
||||
font-family: system-ui, -apple-system, sans-serif !important;
|
||||
font-size: 14px !important;
|
||||
font-weight: 500 !important;
|
||||
max-width: 350px !important;
|
||||
display: block !important;
|
||||
opacity: 1 !important;
|
||||
`;
|
||||
|
||||
notification.innerHTML = `
|
||||
<div style="display: flex; align-items: center; justify-content: space-between;">
|
||||
<div style="margin-right: 15px;">
|
||||
✓ ${event.message}
|
||||
</div>
|
||||
<button onclick="this.parentElement.parentElement.remove()"
|
||||
style="background: none; border: none; color: white; font-size: 18px; cursor: pointer; padding: 0;">
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.body.appendChild(notification);
|
||||
console.log("✅ Created fallback notification");
|
||||
|
||||
// Auto-remove after 5 seconds
|
||||
setTimeout(() => {
|
||||
if (notification.parentNode) {
|
||||
notification.remove();
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
})
|
||||
.listen(".preview-site.built", function(event) {
|
||||
console.log("🔄 Also listening with dot prefix (the working one):", event);
|
||||
console.log("message:", event.message);
|
||||
|
||||
// Use Filament v4 notification system
|
||||
if (typeof FilamentNotification !== "undefined") {
|
||||
new FilamentNotification()
|
||||
.title(event.message)
|
||||
.success()
|
||||
.duration(5000)
|
||||
.send();
|
||||
console.log("✅ Sent via FilamentNotification v4 (from dot prefix)");
|
||||
} else {
|
||||
console.warn("FilamentNotification not available, creating fallback");
|
||||
// Fallback notification
|
||||
const notification = document.createElement("div");
|
||||
notification.style.cssText = `
|
||||
position: fixed !important;
|
||||
top: 20px !important;
|
||||
right: 20px !important;
|
||||
z-index: 999999 !important;
|
||||
background: #3b82f6 !important;
|
||||
color: white !important;
|
||||
padding: 16px 20px !important;
|
||||
border-radius: 8px !important;
|
||||
box-shadow: 0 10px 25px rgba(0,0,0,0.3) !important;
|
||||
font-family: system-ui, -apple-system, sans-serif !important;
|
||||
font-size: 14px !important;
|
||||
font-weight: 500 !important;
|
||||
max-width: 350px !important;
|
||||
display: block !important;
|
||||
opacity: 1 !important;
|
||||
`;
|
||||
|
||||
notification.innerHTML = `
|
||||
<div style="display: flex; align-items: center; justify-content: space-between;">
|
||||
<div style="margin-right: 15px;">
|
||||
🔄 ${event.message}
|
||||
</div>
|
||||
<button onclick="this.parentElement.parentElement.remove()"
|
||||
style="background: none; border: none; color: white; font-size: 18px; cursor: pointer; padding: 0;">
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.body.appendChild(notification);
|
||||
console.log("✅ Created dot prefix fallback notification");
|
||||
|
||||
// Auto-remove after 5 seconds
|
||||
setTimeout(() => {
|
||||
if (notification.parentNode) {
|
||||
notification.remove();
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
|
||||
console.log("✅ Event listeners set up for filament-notifications channel");
|
||||
} else {
|
||||
console.error("❌ Echo is not available for Filament notifications");
|
||||
}
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
|
||||
class ProcessUpdateService
|
||||
{
|
||||
public function processUpdate(int $entryId, string $action, string $type = 'entry_update_'): void
|
||||
{
|
||||
$subject = env('NATS_SUBJECT', 'entry_update');
|
||||
$appUrl = env('APP_URL', 'http://localhost');
|
||||
|
||||
$incoming = [
|
||||
'id' => $entryId,
|
||||
'action' => $action,
|
||||
'subject' => $subject,
|
||||
'app_url' => $appUrl,
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
$jsonData = json_encode($incoming, JSON_THROW_ON_ERROR);
|
||||
$tempFile = tempnam(sys_get_temp_dir(), $type);
|
||||
file_put_contents($tempFile, $jsonData);
|
||||
|
||||
$scriptPath = env('HANDLE_ENTRY_UPDATES_SCRIPT', base_path('cmd/handle_cms_updates.sh'));
|
||||
|
||||
try {
|
||||
// Log what we're about to execute
|
||||
Log::info("Executing script: {$scriptPath} with action: {$action}", [
|
||||
'entry_id' => $entryId,
|
||||
'temp_file' => $tempFile,
|
||||
'script_exists' => file_exists($scriptPath),
|
||||
'script_executable' => is_executable($scriptPath),
|
||||
]);
|
||||
|
||||
$result = Process::run([
|
||||
'bash',
|
||||
$scriptPath,
|
||||
$action,
|
||||
$tempFile,
|
||||
]);
|
||||
|
||||
if ($result->failed()) {
|
||||
$errorDetails = [
|
||||
'exit_code' => $result->exitCode(),
|
||||
'stdout' => $result->output(),
|
||||
'stderr' => $result->errorOutput(),
|
||||
'command' => ['bash', $scriptPath, $action, $tempFile],
|
||||
'script_path' => $scriptPath,
|
||||
'script_exists' => file_exists($scriptPath),
|
||||
'temp_file_exists' => file_exists($tempFile),
|
||||
'temp_file_contents' => file_exists($tempFile) ? file_get_contents($tempFile) : 'N/A',
|
||||
];
|
||||
|
||||
Log::error('Script execution failed', $errorDetails);
|
||||
|
||||
throw new RuntimeException(
|
||||
"Script execution failed with exit code {$result->exitCode()}. " .
|
||||
'STDOUT: ' . ($result->output() ?: 'empty') . ' ' .
|
||||
'STDERR: ' . ($result->errorOutput() ?: 'empty')
|
||||
);
|
||||
}
|
||||
|
||||
Log::info('Script executed successfully', [
|
||||
'stdout' => $result->output(),
|
||||
'entry_id' => $entryId,
|
||||
'action' => $action,
|
||||
]);
|
||||
} finally {
|
||||
// Clean up temp file
|
||||
if (file_exists($tempFile)) {
|
||||
unlink($tempFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,9 +7,7 @@ use Illuminate\Foundation\Configuration\Middleware;
|
|||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
channels: __DIR__.'/../routes/channels.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,5 @@
|
|||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\Filament\AdminPanelProvider::class,
|
||||
App\Providers\FortifyServiceProvider::class,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#SQLITE_DB_PATH="../share-lt/database/database.sqlite"
|
||||
SQLITE_DB_PATH="../share-lt/database/database.sqlite.backup5.recovery"
|
||||
BACKUP_DIR="database/backups"
|
||||
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
||||
BACKUP_FILE="$BACKUP_DIR/backup_$TIMESTAMP.sql"
|
||||
TABLES="taggables media tags categories text_widgets entries users"
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
for TABLE in $TABLES; do
|
||||
echo "Backing up table: $TABLE"
|
||||
sqlite3 "$SQLITE_DB_PATH" ".dump $TABLE" > "$BACKUP_DIR/${TABLE}_backup_$TIMESTAMP.sql"
|
||||
done
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
LARAVEL_CONTAINER_NAME="quay.io/marshyon/share-lt"
|
||||
CONTAINER_LABEL="0.0.7"
|
||||
CACHE="--no-cache"
|
||||
CACHE=""
|
||||
|
||||
docker build \
|
||||
$CACHE \
|
||||
-t ${LARAVEL_CONTAINER_NAME}:${CONTAINER_LABEL} \
|
||||
-f Dockerfile .
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
LARAVEL_CONTAINER_NAME="quay.io/marshyon/share-lt"
|
||||
CONTAINER_LABEL="v0.0.8"
|
||||
CACHE="--no-cache"
|
||||
# CACHE=""
|
||||
|
||||
docker build \
|
||||
$CACHE \
|
||||
-t ${LARAVEL_CONTAINER_NAME}:${CONTAINER_LABEL} .
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# TOKEN="your_api_token_here"
|
||||
# ensure to have set TOKEN to a valid value before running
|
||||
# ideally add this to an .envrc file and source it
|
||||
# tokens need to be created with tinker or similar method
|
||||
|
||||
|
||||
URL='http://127.0.0.1:8000/api/categories'
|
||||
|
||||
curl -s -X GET \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Accept: application/json" \
|
||||
$URL
|
||||
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# TOKEN="your_api_token_here"
|
||||
# ensure to have set TOKEN to a valid value before running
|
||||
# ideally add this to an .envrc file and source it
|
||||
# tokens need to be created with tinker or similar method
|
||||
|
||||
|
||||
URL='http://127.0.0.1:8000/api/categories'
|
||||
|
||||
curl -s -X GET \
|
||||
-H "Accept: application/json" \
|
||||
$URL
|
||||
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# TOKEN="your_api_token_here"
|
||||
# ensure to have set TOKEN to a valid value before running
|
||||
# ideally add this to an .envrc file and source it
|
||||
# tokens need to be created with tinker or similar method
|
||||
|
||||
|
||||
URL="${ADDRESS:-http://127.0.0.1:8000/api/entries}"
|
||||
curl -s -X GET \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Accept: application/json" \
|
||||
$URL
|
||||
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# this should fail, no token provided
|
||||
# users need to be authenticated and have been
|
||||
# granted access to view entries by being given
|
||||
# a token
|
||||
|
||||
URL="${ADDRESS:-http://127.0.0.1:8000/api/entries}"
|
||||
curl -s -X GET \
|
||||
-H "Accept: application/json" \
|
||||
$URL
|
||||
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# TOKEN="your_api_token_here"
|
||||
# ensure to have set TOKEN to a valid value before running
|
||||
# ideally add this to an .envrc file and source it
|
||||
# tokens need to be created with tinker or similar method
|
||||
|
||||
|
||||
URL='http://127.0.0.1:8000/api/text-widgets'
|
||||
|
||||
curl -s -X GET \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Accept: application/json" \
|
||||
$URL
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# this should fail, no token provided
|
||||
# users need to be authenticated and have been
|
||||
# granted access to view text widgets by being given
|
||||
# a token
|
||||
|
||||
URL='http://127.0.0.1:8000/api/text-widgets'
|
||||
|
||||
curl -s -X GET \
|
||||
-H "Accept: application/json" \
|
||||
$URL
|
||||
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# TOKEN="your_api_token_here"
|
||||
# ensure to have set TOKEN to a valid value before running
|
||||
# ideally add this to an .envrc file and source it
|
||||
# only the admin user can create entries so this should
|
||||
# fail unless .env has ADMIN_EMAIL set to the user that
|
||||
# the token belongs to
|
||||
|
||||
URL='http://127.0.0.1:8000/api/entries'
|
||||
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"title": "Yet Another New Entry Title",
|
||||
"content": "This is the content yet again of the new entry."
|
||||
}' \
|
||||
$URL
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# this should fail as no token is provided
|
||||
# user is not authenticated
|
||||
# no token has been granted
|
||||
|
||||
URL='http://127.0.0.1:8000/api/entries'
|
||||
|
||||
curl -X POST \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"title": "Yet Another New Entry Title",
|
||||
"content": "This is the content yet again of the new entry."
|
||||
}' \
|
||||
$URL
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# TOKEN="your_api_token_here"
|
||||
# ensure to have set TOKEN to a valid value before running
|
||||
# ideally add this to an .envrc file and source it
|
||||
# only the admin user can create entries so this should
|
||||
# fail unless .env has ADMIN_EMAIL set to the user that
|
||||
# the token belongs to
|
||||
|
||||
URL='http://127.0.0.1:8000/api/text-widgets'
|
||||
|
||||
curl -X POST \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"title": "Yet Another New text widget Title",
|
||||
"content": "This is the content yet again of the new text widget."
|
||||
}' \
|
||||
$URL
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# this should fail as no token is provided
|
||||
# user is not authenticated
|
||||
# no token has been granted
|
||||
|
||||
URL='http://127.0.0.1:8000/api/text-widgets'
|
||||
|
||||
curl -X POST \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"title": "Yet Another New Entry Title",
|
||||
"content": "This is the content yet again of the new entry."
|
||||
}' \
|
||||
$URL
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# URL='http://127.0.0.1:8000'
|
||||
|
||||
curl -X POST $URL/api/notifications/preview-site-built \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"message": "Published to LIVE 💯🚀🎯 - site notification!"}'
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Ensure APP_KEY is set and persisted
|
||||
PERSISTED_KEY="/var/www/storage/.app_key"
|
||||
|
||||
if [ -z "$APP_KEY" ]; then
|
||||
if [ -f "$PERSISTED_KEY" ]; then
|
||||
echo "Using persisted APP_KEY from: $PERSISTED_KEY"
|
||||
export APP_KEY=$(cat "$PERSISTED_KEY")
|
||||
else
|
||||
# Generate key, strip "base64:", and save
|
||||
NEW_KEY=$(php artisan key:generate --show --no-interaction)
|
||||
echo "Generated new APP_KEY to: $PERSISTED_KEY"
|
||||
echo "$NEW_KEY" > "$PERSISTED_KEY"
|
||||
export APP_KEY="$NEW_KEY"
|
||||
fi
|
||||
fi
|
||||
|
||||
# check to see if /var/www/database/database.sqlite exists
|
||||
# if not, run migrations
|
||||
if [ ! -f /var/www/database/database.sqlite ]; then
|
||||
php artisan migrate --force
|
||||
fi
|
||||
|
||||
# check to see if /var/www/public/storage exists
|
||||
# if not, run storage:link
|
||||
if [ ! -d /var/www/public/storage ]; then
|
||||
php artisan storage:link
|
||||
fi
|
||||
|
||||
php artisan config:clear
|
||||
npm run build
|
||||
|
||||
# Start supervisord directly
|
||||
exec "$@"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue