diff --git a/.github/workflows/coding-standards.yml b/.github/coding-standards.yml similarity index 100% rename from .github/workflows/coding-standards.yml rename to .github/coding-standards.yml diff --git a/.github/workflows/tests.yml b/.github/tests.yml similarity index 100% rename from .github/workflows/tests.yml rename to .github/tests.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..56658c9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,66 @@ +name: Image Build and Push + +on: + push: + branches: + - '*' + +env: + IMAGE_NAME: paste + +jobs: + push: + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} + + - name: Cache Composer dependencies + uses: actions/cache@v3 + with: + path: /tmp/composer-cache + key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} + + - name: Install composer dependencies + uses: php-actions/composer@v6 + with: + php_version: "8.2" + args: --profile --ignore-platform-reqs + dev: no + + - uses: actions/setup-node@v3 + with: + node-version: 17 + cache: 'npm' + cache-dependency-path: package-lock.json + + - name: Install node dependencies + run: | + npm install + npm run build + + - name: Build image + run: docker build . --file docker/app/Dockerfile --tag $IMAGE_NAME + + - name: Push image + run: | + IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + COMMIT=$(echo "${{ github.sha }}") + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + [ "$VERSION" == "main" ] && VERSION=latest + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker tag $IMAGE_NAME $IMAGE_ID:$COMMIT + docker push $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$COMMIT \ No newline at end of file diff --git a/.gitignore b/.gitignore index d692e89..1f8e272 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ .env .env.backup .phpunit.result.cache +.idea diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 3391630..559dd2f 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -12,7 +12,7 @@ class TrustProxies extends Middleware * * @var array|string|null */ - protected $proxies; + protected $proxies = '*'; /** * The headers that should be used to detect proxies. diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ee8ca5b..c3b924d 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; +use Illuminate\Routing\UrlGenerator; class AppServiceProvider extends ServiceProvider { @@ -21,8 +22,11 @@ public function register() * * @return void */ - public function boot() + public function boot(UrlGenerator $url) { - // + if (str_starts_with(config('app.url'), 'https://')) { + $this->app['request']->server->set('HTTPS', true); + $url->forceScheme('https'); + } } } diff --git a/composer.json b/composer.json index 613413f..e2f5aa3 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "license": "MIT", "require": { "php": "8.2.*", + "andreiio/blade-iconoir": "^2.2", "blade-ui-kit/blade-heroicons": "^2.0", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^9.19", diff --git a/composer.lock b/composer.lock index 9f74c07..af9c041 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,66 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "70a046e68da748fb9a362f8057ae4184", + "content-hash": "b598635e0a5f09010e4ab7fc3b9e57a0", "packages": [ + { + "name": "andreiio/blade-iconoir", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/andreiio/blade-iconoir.git", + "reference": "2ca3b845389b1ff7662914314e69e3378b808add" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/andreiio/blade-iconoir/zipball/2ca3b845389b1ff7662914314e69e3378b808add", + "reference": "2ca3b845389b1ff7662914314e69e3378b808add", + "shasum": "" + }, + "require": { + "blade-ui-kit/blade-icons": "^1.0", + "php": "^7.4|^8.0" + }, + "require-dev": { + "orchestra/testbench": "^6.0|^7.0", + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "AndreiIonita\\BladeIconoir\\BladeIconoirServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "AndreiIonita\\BladeIconoir\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andrei Ioniță", + "homepage": "https://andrei.io/" + } + ], + "description": "A package to easily make use of Iconoir in your Laravel Blade views.", + "support": { + "issues": "https://github.com/andreiio/blade-iconoir/issues", + "source": "https://github.com/andreiio/blade-iconoir/tree/2.2.0" + }, + "funding": [ + { + "url": "https://github.com/code4romania", + "type": "github" + } + ], + "time": "2023-02-07T12:19:12+00:00" + }, { "name": "aws/aws-crt-php", "version": "v1.0.2", diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile new file mode 100644 index 0000000..d902804 --- /dev/null +++ b/docker/app/Dockerfile @@ -0,0 +1,15 @@ +FROM ghcr.io/rene-roscher/php-docker:php-8.2 AS APP_BASE + +WORKDIR /var/www + +COPY . /var/www + +RUN echo "" > /var/www/storage/logs/laravel.log + +RUN chmod -R gu+w storage/ && chmod -R guo+w storage/ && chmod -R gu+w bootstrap/cache/ && chmod -R guo+w bootstrap/cache/ + +RUN chown -R www-data:www-data /var/www + +COPY ./docker/supervisord.conf /etc/supervisord.conf + +CMD ["supervisord", "-c", "/etc/supervisord.conf"] \ No newline at end of file diff --git a/docker/supervisord.conf b/docker/supervisord.conf new file mode 100644 index 0000000..9df0b58 --- /dev/null +++ b/docker/supervisord.conf @@ -0,0 +1,14 @@ +[supervisord] +logfile=/dev/null +loglevel=info +pidfile=/var/run/supervisord.pid +nodaemon=true +user=root + +[program:php-fpm] +process_name=%(program_name)s_%(process_num)02d +command=php-fpm -R +autostart=true +autorestart=true +user=root +numprocs=1 \ No newline at end of file diff --git a/public/index.php b/public/index.php index 75dd887..7f96441 100644 --- a/public/index.php +++ b/public/index.php @@ -33,6 +33,13 @@ require __DIR__.'/../vendor/autoload.php'; +/* +| Cloudflare Proxy +*/ +if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { + $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; +} + /* |-------------------------------------------------------------------------- | Run The Application diff --git a/resources/css/_scroll.scss b/resources/css/_scroll.scss new file mode 100644 index 0000000..90e1b25 --- /dev/null +++ b/resources/css/_scroll.scss @@ -0,0 +1,23 @@ +.light { + *::-webkit-scrollbar { + width: 13px; + } + *::-webkit-scrollbar-track { + @apply bg-transparent; + } + *::-webkit-scrollbar-thumb { + @apply bg-gray-200/50 rounded-full border-solid border-white + } +} + +.dark { + *::-webkit-scrollbar { + width: 13px; + } + *::-webkit-scrollbar-track { + @apply bg-transparent; + } + *::-webkit-scrollbar-thumb { + @apply bg-zinc-800/50 rounded-full border-solid border-zinc-900 + } +} \ No newline at end of file diff --git a/resources/css/app.scss b/resources/css/app.scss index f2d816e..19317d2 100644 --- a/resources/css/app.scss +++ b/resources/css/app.scss @@ -1,19 +1,22 @@ @import 'https://github.com/tailwindcss/base'; +@import 'https://github.com/tailwindcss/components'; +@import 'https://github.com/tailwindcss/utilities'; +@import "https://github.com/scroll"; .light { @import 'https://github.com/highlight.js/styles/a11y-light'; + .hljs { + @apply bg-white; + } } .dark { @import 'https://github.com/highlight.js/styles/a11y-dark'; + .hljs { + @apply bg-zinc-900; + } } -@import 'https://github.com/tailwindcss/components'; -@import 'https://github.com/tailwindcss/utilities'; - -.hljs { - @apply bg-white; -} .hljs-ln td.hljs-ln-numbers { @apply text-gray-400 pr-3 inline-block w-full text-right; } diff --git a/resources/js/app.js b/resources/js/app.js index a01205f..87dde2e 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -42,3 +42,18 @@ for (let i = 0; i < darkModeToggles.length; i++) { } }; } + +// Shortcut to save +document.addEventListener("keydown", keyDownEvent => { + if (keyDownEvent.ctrlKey && keyDownEvent.code === "KeyS") { + keyDownEvent.preventDefault(); + document.getElementById('save').click(); + } +}); +// WIP +// document.addEventListener("keydown", keyDownEvent => { +// if (keyDownEvent.ctrlKey && keyDownEvent.code === "KeyA") { +// keyDownEvent.preventDefault(); +// window.getSelection().selectAllChildren(document.getElementById('code')); +// } +// }); \ No newline at end of file diff --git a/resources/views/_editor.blade.php b/resources/views/_editor.blade.php index 52a9e14..ef5a2cf 100644 --- a/resources/views/_editor.blade.php +++ b/resources/views/_editor.blade.php @@ -1,6 +1,9 @@ -
+{{--WIP--}} +{{--
--}} +{{--
3512 Lines
--}} +{{--
--}} +
-
+ name="code" class="dark:bg-zinc-900 text-gray-900 dark:text-white w-full h-full resize-none outline-none" + placeholder="{{ optional($paste ?? null)->code }} +
\ No newline at end of file diff --git a/resources/views/components/main.blade.php b/resources/views/components/main.blade.php index 658a947..12f9ac0 100644 --- a/resources/views/components/main.blade.php +++ b/resources/views/components/main.blade.php @@ -1,6 +1,6 @@
-
+
-
+
-
+
{!! $slot !!}
diff --git a/resources/views/components/nav-item.blade.php b/resources/views/components/nav-item.blade.php index b2a45c5..dd1953e 100644 --- a/resources/views/components/nav-item.blade.php +++ b/resources/views/components/nav-item.blade.php @@ -2,15 +2,15 @@
merge(['class' => 'inline-flex items-center w-full px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-gray-700 dark:text-white bg-gray-200 dark:bg-gray-500 hover:bg-gray-300 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500']) }} + {{ $attributes->merge(['class' => 'transition ease-in-out duration-150 inline-flex items-center w-full px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-gray-700 dark:text-white bg-gray-200 dark:bg-zinc-900 hover:bg-gray-300 dark:hover:bg-zinc-900/50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500']) }} > @svg($icon, '-ml-0.5 mr-2 h-4 w-4') {{ $label }} @else -