diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index 36cedc4..829a89e 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -42,3 +42,16 @@ services: ports: # change database:port here (edit left-one) - "10000:80" + + node: + container_name: Node + build: + context: ./.. + dockerfile: ./.docker/node/Dockerfile + working_dir: /srv + volumes: + - ./../:/srv:delegated + ports: + - "8080:8080" + - "8888:8888" + command: [ "tail", "-f", "/dev/null" ] diff --git a/.docker/node/Dockerfile b/.docker/node/Dockerfile new file mode 100644 index 0000000..eb6ca12 --- /dev/null +++ b/.docker/node/Dockerfile @@ -0,0 +1,15 @@ +FROM node:18.0.0-alpine3.14 + +USER root + +# Setup user docker +# RUN adduser -S docker + +WORKDIR /srv/ + +# RUN rm -rf /srv/node_modules +# RUN mkdir /srv/node_modules +# RUN chown -R docker /srv/node_modules +# RUN chown docker /srv/package.json + +# USER docker \ No newline at end of file diff --git a/.gitignore b/.gitignore index 08bfde0..f4e9d96 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .idea config/local.neon vendor +package-lock.json +node_modules +www/dist/* \ No newline at end of file diff --git a/Makefile b/Makefile index 5d95bdc..2cee8af 100644 --- a/Makefile +++ b/Makefile @@ -59,4 +59,13 @@ start: fix: # phpstan -l (level 0-9, max - newest) - docker-compose -f .docker/docker-compose.yml exec php vendor/bin/phpstan analyse app -l max \ No newline at end of file + docker-compose -f .docker/docker-compose.yml exec php vendor/bin/phpstan analyse app -l max + +# Exec sh on Node container +exec\:node: + docker-compose -f .docker/docker-compose.yml exec node sh; + +setup: + docker-compose -f .docker/docker-compose.yml exec php composer install; + docker-compose -f .docker/docker-compose.yml exec node npm install; + make init \ No newline at end of file diff --git a/app/Module/Front/Homepage/templates/defaultSlider.latte b/app/Module/Front/Homepage/templates/defaultSlider.latte index 2c5faeb..b9966d6 100755 --- a/app/Module/Front/Homepage/templates/defaultSlider.latte +++ b/app/Module/Front/Homepage/templates/defaultSlider.latte @@ -83,3 +83,5 @@ + + \ No newline at end of file diff --git a/app/Module/templates/@layout.latte b/app/Module/templates/@layout.latte index c374796..4e5c7cf 100755 --- a/app/Module/templates/@layout.latte +++ b/app/Module/templates/@layout.latte @@ -17,8 +17,14 @@ {include meta} {ifset title}{include title|stripHtml} - {/ifset}Filmátor + + {* JS files *} + + +
+
{include flashMessage} @@ -39,6 +45,8 @@ {/if}
+
+
diff --git a/app/components/test.vue b/app/components/test.vue new file mode 100644 index 0000000..25e8ea6 --- /dev/null +++ b/app/components/test.vue @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/composer.json b/composer.json index 75a118a..1ac230d 100755 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "nettrine/fixtures": "^0.6.2", "nettrine/cache": "^0.3.0", "nextras/mail-panel": "^2.6", - "phpstan/phpstan": "^1.9" + "phpstan/phpstan": "^1.9", + "contributte/webpack": "^2.2" }, "require-dev": { "nette/tester": "^2.3", diff --git a/composer.lock b/composer.lock index 253cbeb..b7e38ec 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "54c6e1f4dc47064cf2befe4d9ef86665", + "content-hash": "6bcbadc5530e4622b321d79f6b20759f", "packages": [ { "name": "contributte/console", @@ -160,6 +160,83 @@ ], "time": "2022-07-08T10:07:27+00:00" }, + { + "name": "contributte/webpack", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/contributte/webpack.git", + "reference": "f29901bdcdf2a6481c0845e400b7662555f15ee5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/contributte/webpack/zipball/f29901bdcdf2a6481c0845e400b7662555f15ee5", + "reference": "f29901bdcdf2a6481c0845e400b7662555f15ee5", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "nette/di": "^3.0", + "php": ">=7.4" + }, + "require-dev": { + "latte/latte": "^2.4 || ^3.0", + "nette/application": "^3.0", + "nette/bootstrap": "^3.0", + "nette/tester": "^2.0", + "phpstan/phpstan": "^0.12", + "symplify/easy-coding-standard": "^8.3", + "tracy/tracy": "^2.4" + }, + "suggest": { + "latte/latte": "to enable Latte integration via {webpack} macro", + "tracy/tracy": "to enable asset debugging in the debug bar panel" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Contributte\\Webpack\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jiří Pudil", + "email": "me@jiripudil.cz", + "homepage": "https://jiripudil.cz" + } + ], + "description": "Webpack integration for Nette Framework.", + "homepage": "https://github.com/contributte/webpack", + "keywords": [ + "nette", + "webpack" + ], + "support": { + "email": "me@jiripudil.cz", + "issues": "https://github.com/contributte/webpack/issues", + "source": "https://github.com/contributte/webpack/tree/2.2.1" + }, + "funding": [ + { + "url": "https://contributte.org/partners.html", + "type": "custom" + }, + { + "url": "https://github.com/f3l1x", + "type": "github" + } + ], + "time": "2022-06-12T09:38:15+00:00" + }, { "name": "doctrine/annotations", "version": "1.14.2", diff --git a/config/common.neon b/config/common.neon index fecb18a..5d82f56 100644 --- a/config/common.neon +++ b/config/common.neon @@ -1,3 +1,5 @@ +# Main configuration file, has to include every other file + parameters: doctrine: host: mariadb @@ -5,59 +7,20 @@ parameters: password: root dbname: filmator - application: errorPresenter: Ghost:Error mapping: *: [App\Module, * ,*\*Presenter] - session: expiration: 14 days - di: export: parameters: no tags: no - -extensions: - console: Contributte\Console\DI\ConsoleExtension(%consoleMode%) - doctrine.annotations: Nettrine\Annotations\DI\AnnotationsExtension - doctrine.dbal: Nettrine\DBAL\DI\DbalExtension - doctrine.dbal.console: Nettrine\DBAL\DI\DbalConsoleExtension - doctrine.orm: Nettrine\ORM\DI\OrmExtension - doctrine.orm.annotations: Nettrine\ORM\DI\OrmAnnotationsExtension - nettrine.orm.attributes: Nettrine\ORM\DI\OrmAttributesExtension - doctrine.orm.console: Nettrine\ORM\DI\OrmConsoleExtension - doctrine.cache: Nettrine\Cache\DI\CacheExtension - doctrine.migrations: Nettrine\Migrations\DI\MigrationsExtension - doctrine.fixtures: Nettrine\Fixtures\DI\FixturesExtension - - -doctrine.dbal: - debug: - panel: false - connection: - driver: pdo_mysql - host: %doctrine.host% - user: %doctrine.user% - password: %doctrine.password% - dbname: %doctrine.dbname% - -doctrine.orm.annotations: - mapping: - App\Model: %appDir%/Model - - -nettrine.orm.attributes: - mapping: - App\Model: %appDir%/Model - -doctrine.migrations: - directory: migrations/ - -doctrine.fixtures: - paths: - - %appDir%/Model/Database/Fixture +includes: + - extensions.neon + - doctrine.neon + - webpack.neon diff --git a/config/doctrine.neon b/config/doctrine.neon new file mode 100644 index 0000000..142a190 --- /dev/null +++ b/config/doctrine.neon @@ -0,0 +1,26 @@ +doctrine.dbal: + debug: + panel: false + connection: + driver: pdo_mysql + host: %doctrine.host% + user: %doctrine.user% + password: %doctrine.password% + dbname: %doctrine.dbname% + +# enable annotations +doctrine.orm.annotations: + mapping: + App\Model: %appDir%/Model + +# enable attributes +nettrine.orm.attributes: + mapping: + App\Model: %appDir%/Model + +doctrine.migrations: + directory: migrations/ + +doctrine.fixtures: + paths: + - %appDir%/Model/Database/Fixture \ No newline at end of file diff --git a/config/extensions.neon b/config/extensions.neon new file mode 100644 index 0000000..dc80939 --- /dev/null +++ b/config/extensions.neon @@ -0,0 +1,15 @@ +extensions: + console: Contributte\Console\DI\ConsoleExtension(%consoleMode%) + # doctrine + doctrine.annotations: Nettrine\Annotations\DI\AnnotationsExtension + doctrine.dbal: Nettrine\DBAL\DI\DbalExtension + doctrine.dbal.console: Nettrine\DBAL\DI\DbalConsoleExtension + doctrine.orm: Nettrine\ORM\DI\OrmExtension + doctrine.orm.annotations: Nettrine\ORM\DI\OrmAnnotationsExtension + nettrine.orm.attributes: Nettrine\ORM\DI\OrmAttributesExtension + doctrine.orm.console: Nettrine\ORM\DI\OrmConsoleExtension + doctrine.cache: Nettrine\Cache\DI\CacheExtension + doctrine.migrations: Nettrine\Migrations\DI\MigrationsExtension + doctrine.fixtures: Nettrine\Fixtures\DI\FixturesExtension + # webpack + webpack: Contributte\Webpack\DI\WebpackExtension(%debugMode%, %consoleMode%) diff --git a/config/webpack.neon b/config/webpack.neon new file mode 100644 index 0000000..27ef9a0 --- /dev/null +++ b/config/webpack.neon @@ -0,0 +1,9 @@ +webpack: + build: + directory: %wwwDir%/dist + publicPath: /dist + devServer: + enabled: %debugMode% + url: http://localhost:90/dist + manifest: + name: manifest.json \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..30337de --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "filmator", + "version": "1.0.0", + "description": "movie & serial database", + "main": "index.js", + "scripts": { + "dev-server": "encore dev-server --host localhost --port 90", + "dev": "encore dev", + "watch": "encore dev --watch", + "build": "encore production --progress" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Chrynn/Filmator.git" + }, + "author": "filip machala", + "license": "ISC", + "bugs": { + "url": "https://github.com/Chrynn/Filmator/issues" + }, + "homepage": "https://github.com/Chrynn/Filmator#readme", + "dependencies": { + "@symfony/webpack-encore": "^4.3.0", + "vue": "^3.3.4", + "vue-loader": "^17.1.1", + "webpack-cli": "^5.1.1", + "webpack-notifier": "^1.15.0" + } +} diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..e5a6645 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,30 @@ +const Encore = require('@symfony/webpack-encore'); + +if (!Encore.isRuntimeEnvironmentConfigured()) { + Encore.configureRuntimeEnvironment(process.env.NODE_ENV || "dev"); +} + +Encore + // where webpack files are generated + .setOutputPath('./www/dist') + // where webpack generated files are placed to use by webpack + .setPublicPath('/dist') + // where Vue config file is + .addEntry('main', './www/js/main.js') + .enableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableBuildNotifications() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableVueLoader(() => {}, { runtimeCompilerBuild: true }) + // setting manifest files 1 folder back + .configureManifestPlugin(options => { + options.publicPath = ''; + }) + .configureDevServerOptions(options => { + options.port = 90; + options.allowedHosts = 'all'; + }) +; + +module.exports = Encore.getWebpackConfig(); \ No newline at end of file diff --git a/www/js/main.js b/www/js/main.js new file mode 100644 index 0000000..17eda63 --- /dev/null +++ b/www/js/main.js @@ -0,0 +1,10 @@ +import {createApp} from 'vue/dist/vue.esm-bundler'; +import Test from '../../app/components/test.vue'; + +document.addEventListener('VueMount', (e) => { + const app = createApp({}); + + app.component('test', Test); + + app.mount('#app'); +}); \ No newline at end of file