diff --git a/.gitignore b/.gitignore index dc07d31..db570a8 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ yarn-error.log /public/uploads/ !/public/uploads/.gitkeep +/data diff --git a/Makefile b/Makefile index ea624af..3fe9916 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,9 @@ asset: $(YARN) $(WEBPACK) +jsroute: + $(PHP) bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json + clean: rm -fr var/cache/dev/* rm -fr var/cache/prod/* diff --git a/assets/css/app.scss b/assets/css/app.scss index 82e01d9..d44b40f 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -384,6 +384,11 @@ a:focus .logo-svg * { border-top-right-radius: 0; border-top-left-radius: 0; } + + &[class*="language-"] { + padding-bottom: 10px; + border: 1px solid #3c3c3c; + } } } diff --git a/assets/js/app.js b/assets/js/app.js index 3d92424..08fcad8 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,3 +1,28 @@ import '../css/app.scss'; +const App = require('./app/app') +const FormPnw = require('./app/form-pwn') +const Post = require('./app/post') +const LazyLoad = require('./app/lazy-load') +const QuickPost = require('./app/quick-post') +const Code = require('./app/code') +const Knmc = require('./app/knmc') +const VideoRatio = require('./app/video-ratio') +const Stats = require('./app/stats') +const Particles = require('./app/particles') +const app = new App([ + new FormPnw(window), + new Post(window), + new LazyLoad(window), + new QuickPost(window), + new Code(window), + new Knmc(window), + new VideoRatio(window), + new Stats(), + new Particles(window), +]); + +window.addEventListener('load', function() { + app.init(); +}, false); diff --git a/assets/js/app/app.js b/assets/js/app/app.js index 66c8c34..6b3cfa2 100644 --- a/assets/js/app/app.js +++ b/assets/js/app/app.js @@ -1,4 +1,4 @@ -var App = function(components) { +const App = function(components) { this.components = components || []; } @@ -13,3 +13,5 @@ App.prototype.init = function() { this.components[u].init(); } } + +module.exports = App diff --git a/assets/js/app/code.js b/assets/js/app/code.js index 189ee6f..defb40c 100644 --- a/assets/js/app/code.js +++ b/assets/js/app/code.js @@ -1,11 +1,33 @@ -var Code = function(w) { +const Prism = require('prismjs'); + +require('prismjs/plugins/line-numbers/prism-line-numbers.css'); +require('prismjs/themes/prism-twilight.css'); + +require('prismjs/components/prism-scss'); +require('prismjs/components/prism-markup'); +require('prismjs/components/prism-markup-templating'); +require('prismjs/components/prism-css'); +require('prismjs/components/prism-clike'); +require('prismjs/components/prism-javascript'); +require('prismjs/components/prism-bash'); +require('prismjs/components/prism-markdown'); +require('prismjs/components/prism-nginx'); +require('prismjs/components/prism-php'); +require('prismjs/components/prism-python'); +require('prismjs/components/prism-sql'); +require('prismjs/components/prism-yaml'); + +require('prismjs/plugins/keep-markup/prism-keep-markup'); +require('prismjs/plugins/line-highlight/prism-line-highlight'); +require('prismjs/plugins/line-numbers/prism-line-numbers'); + +const Code = function(w) { this.window = w; } Code.prototype.init = function() { - Prism.highlightAllUnder(document); - - var elements = this.window.document.querySelectorAll('code[data-title], div[data-title]'); + Prism.highlightAllUnder(document) + var elements = this.window.document.querySelectorAll('code[data-title], div[data-title]') for (var i = 0, len = elements.length; i < len; i++) { var element = elements[i]; diff --git a/assets/js/app/form-pwn.js b/assets/js/app/form-pwn.js index b39b632..966c68e 100644 --- a/assets/js/app/form-pwn.js +++ b/assets/js/app/form-pwn.js @@ -1,23 +1,28 @@ -var FormPnw = function(w) { - this.window = w; +const Routing = require('./routing') + +const FormPnw = function(w) { + this.window = w } FormPnw.prototype.init = function() { - var doc = this.window.document; + var doc = this.window.document doc.addEventListener('mousemove', function() { - var forms = doc.querySelectorAll('form[data-form-bot]'); + var forms = doc.querySelectorAll('form[data-form-bot]') for (var i = 0, len = forms.length; i < len; i++) { - var form = forms[i]; - var action = form.getAttribute('action'); - action = action.replace(Routing.generate('form_without_javascript') + '?page=', ''); - action = decodeURIComponent(action); + var form = forms[i] + var action = form.getAttribute('action') - form.setAttribute('action', action); - form.removeAttribute('data-form-bot'); + console.log([action, Routing.generate('blog_tech_form_without_javascript', [], true)]) + + action = action.replace(Routing.generate('blog_tech_form_without_javascript', [], false) + '?page=', '') + action = decodeURIComponent(action) + + form.setAttribute('action', action) + form.removeAttribute('data-form-bot') } - }); + }) } module.exports = FormPnw diff --git a/assets/js/app/knmc.js b/assets/js/app/knmc.js index 69a58a6..c20c9c3 100644 --- a/assets/js/app/knmc.js +++ b/assets/js/app/knmc.js @@ -1,4 +1,4 @@ -var Knmc = function(w) { +const Knmc = function(w) { this.window = w; } diff --git a/assets/js/app/lazy-load.js b/assets/js/app/lazy-load.js index dae8bfe..cf680d9 100644 --- a/assets/js/app/lazy-load.js +++ b/assets/js/app/lazy-load.js @@ -1,4 +1,6 @@ -var LazyLoad = function() { +const lozad = require('lozad') + +const LazyLoad = function() { } LazyLoad.prototype.init = function() { diff --git a/assets/js/app/particles.js b/assets/js/app/particles.js index 44107d0..a695fea 100644 --- a/assets/js/app/particles.js +++ b/assets/js/app/particles.js @@ -1,4 +1,6 @@ -var Particles = function(w) { +require('particles.js'); + +const Particles = function(w) { this.window = w; } diff --git a/assets/js/app/post.js b/assets/js/app/post.js index 690fe3a..6bdf49d 100644 --- a/assets/js/app/post.js +++ b/assets/js/app/post.js @@ -1,4 +1,4 @@ -var Post = function(w) { +const Post = function(w) { this.window = w; } diff --git a/assets/js/app/quick-post.js b/assets/js/app/quick-post.js index 3e0becb..f6de7c4 100644 --- a/assets/js/app/quick-post.js +++ b/assets/js/app/quick-post.js @@ -1,4 +1,4 @@ -var QuickPost = function(w) { +const QuickPost = function(w) { this.window = w; } diff --git a/assets/js/app/routing.js b/assets/js/app/routing.js new file mode 100644 index 0000000..746b1dc --- /dev/null +++ b/assets/js/app/routing.js @@ -0,0 +1,8 @@ +const routes = require('../../../public/js/fos_js_routes.json'); +const Routing = require('./../../../vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js'); + +Routing.setRoutingData(routes); +Routing.setScheme(location.protocol.replace(':', '')) + +module.exports = Routing + diff --git a/assets/js/app/stats.js b/assets/js/app/stats.js index 79f5764..91fbdc1 100644 --- a/assets/js/app/stats.js +++ b/assets/js/app/stats.js @@ -1,4 +1,4 @@ -var Stats = function() { +const Stats = function() { } Stats.prototype.init = function() { diff --git a/assets/js/app/video-ratio.js b/assets/js/app/video-ratio.js index afdc2b4..500461c 100644 --- a/assets/js/app/video-ratio.js +++ b/assets/js/app/video-ratio.js @@ -1,4 +1,4 @@ -var VideoRatio = function(w) { +const VideoRatio = function(w) { this.window = w; } diff --git a/composer.json b/composer.json index ce721b7..66f8e75 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ "doctrine/doctrine-bundle": "^2.2", "doctrine/doctrine-migrations-bundle": "^3.0", "doctrine/orm": "^2.8", + "friendsofsymfony/jsrouting-bundle": "^2.7", "knplabs/knp-markdown-bundle": "^1.9", "knplabs/knp-menu-bundle": "^3.1", "knplabs/knp-paginator-bundle": "^5.4", diff --git a/config/bundles.php b/config/bundles.php index 33bdb5d..9aad270 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -21,4 +21,5 @@ return [ App\Bundle\AppBundle::class => ['all' => true], Knp\Bundle\MarkdownBundle\KnpMarkdownBundle::class => ['all' => true], Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], + FOS\JsRoutingBundle\FOSJsRoutingBundle::class => ['all' => true], ]; diff --git a/config/packages/app.yaml b/config/packages/app.yaml index d32abb5..757dd10 100644 --- a/config/packages/app.yaml +++ b/config/packages/app.yaml @@ -19,3 +19,7 @@ core: name: 'Page titrée' templates: - {name: "Par défaut", file: "page/titled/default.html.twig"} + +fos_js_routing: + routes_to_expose: + - blog_tech_form_without_javascript diff --git a/config/routes/fos_js_routing.yaml b/config/routes/fos_js_routing.yaml new file mode 100644 index 0000000..79d25e2 --- /dev/null +++ b/config/routes/fos_js_routing.yaml @@ -0,0 +1,2 @@ +fos_js_routing: + resource: "@FOSJsRoutingBundle/Resources/config/routing/routing-sf4.xml" diff --git a/package.json b/package.json index 1b9bd66..346f3b2 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,11 @@ "bootstrap": "^4.3.1", "choices.js": "^9.0.1", "jquery": "^3.6.0", + "lozad": "^1.16.0", "particles.js": "^2.0.0", + "particlesjs": "^2.2.3", "popper.js": "^1.16.0", + "prismjs": "^1.23.0", "qrcodejs": "^1.0.0", "simplemde": "^1.11.2", "tinymce": "^5.7.1", diff --git a/public/js/fos_js_routes.json b/public/js/fos_js_routes.json new file mode 100644 index 0000000..1003fe6 --- /dev/null +++ b/public/js/fos_js_routes.json @@ -0,0 +1 @@ +{"base_url":"","routes":{"blog_tech_form_without_javascript":{"tokens":[["text","\/nojs"]],"defaults":[],"requirements":[],"hosttokens":[["text","local.deblan"]],"methods":[],"schemes":[]}},"prefix":"","host":"localhost","port":"","scheme":"http","locale":[]} \ No newline at end of file diff --git a/public/js/particles.classic.json b/public/js/particles.classic.json new file mode 100644 index 0000000..274ea00 --- /dev/null +++ b/public/js/particles.classic.json @@ -0,0 +1,101 @@ +{ + "particles": { + "number": { + "value": 90, + "density": { + "enable": true, + "value_area": 900 + } + }, + "color": { + "value": "#ffffff" + }, + "opacity": { + "value": 0.5, + "random": false, + "anim": { + "enable": false, + "speed": 1, + "opacity_min": 0.1, + "sync": false + } + }, + "size": { + "value": 5, + "random": true, + "anim": { + "enable": false, + "speed": 1, + "size_min": 0.1, + "sync": false + } + }, + "line_linked": { + "enable": true, + "distance": 150, + "color": "#ffffff", + "opacity": 0.4, + "width": 1 + }, + "move": { + "enable": true, + "speed": 6, + "direction": "none", + "random": false, + "straight": false, + "out_mode": "out", + "attract": { + "enable": false, + "rotateX": 600, + "rotateY": 1200 + } + } + }, + "interactivity": { + "detect_on": "canvas", + "events": { + "onhover": { + "enable": false, + "mode": "repulse" + }, + "onclick": { + "enable": true, + "mode": "push" + }, + "resize": true + }, + "modes": { + "grab": { + "distance": 400, + "line_linked": { + "opacity": 1 + } + }, + "bubble": { + "distance": 400, + "size": 40, + "duration": 2, + "opacity": 8, + "speed": 3 + }, + "repulse": { + "distance": 200 + }, + "push": { + "particles_nb": 4 + }, + "remove": { + "particles_nb": 2 + } + } + }, + "retina_detect": true, + "config_demo": { + "hide_card": false, + "background_color": "#b61924", + "background_image": "", + "background_position": "50% 50%", + "background_repeat": "no-repeat", + "background_size": "cover" + } +} diff --git a/public/js/particles.flocons.json b/public/js/particles.flocons.json new file mode 100644 index 0000000..9172a71 --- /dev/null +++ b/public/js/particles.flocons.json @@ -0,0 +1,110 @@ +{ + "particles": { + "number": { + "value": 100, + "density": { + "enable": false, + "value_area": 800 + } + }, + "color": { + "value": "#fff" + }, + "shape": { + "type": "circle", + "stroke": { + "width": 0, + "color": "#000000" + }, + "polygon": { + "nb_sides": 5 + }, + "image": { + "src": "img/github.svg", + "width": 100, + "height": 100 + } + }, + "opacity": { + "value": 0.5, + "random": true, + "anim": { + "enable": false, + "speed": 1, + "opacity_min": 0.1, + "sync": false + } + }, + "size": { + "value": 10, + "random": true, + "anim": { + "enable": false, + "speed": 40, + "size_min": 0.1, + "sync": false + } + }, + "line_linked": { + "enable": false, + "distance": 500, + "color": "#ffffff", + "opacity": 0.4, + "width": 2 + }, + "move": { + "enable": true, + "speed": 3, + "direction": "bottom", + "random": false, + "straight": false, + "out_mode": "out", + "bounce": false, + "attract": { + "enable": false, + "rotateX": 600, + "rotateY": 1200 + } + } + }, + "interactivity": { + "detect_on": "canvas", + "events": { + "onhover": { + "enable": false, + "mode": "repulse" + }, + "onclick": { + "enable": true, + "mode": "push" + }, + "resize": true + }, + "modes": { + "grab": { + "distance": 400, + "line_linked": { + "opacity": 0.5 + } + }, + "bubble": { + "distance": 400, + "size": 4, + "duration": 0.3, + "opacity": 1, + "speed": 3 + }, + "repulse": { + "distance": 200, + "duration": 0.7 + }, + "push": { + "particles_nb": 4 + }, + "remove": { + "particles_nb": 2 + } + } + }, + "retina_detect": false +} diff --git a/public/js/particles.json b/public/js/particles.json new file mode 100644 index 0000000..274ea00 --- /dev/null +++ b/public/js/particles.json @@ -0,0 +1,101 @@ +{ + "particles": { + "number": { + "value": 90, + "density": { + "enable": true, + "value_area": 900 + } + }, + "color": { + "value": "#ffffff" + }, + "opacity": { + "value": 0.5, + "random": false, + "anim": { + "enable": false, + "speed": 1, + "opacity_min": 0.1, + "sync": false + } + }, + "size": { + "value": 5, + "random": true, + "anim": { + "enable": false, + "speed": 1, + "size_min": 0.1, + "sync": false + } + }, + "line_linked": { + "enable": true, + "distance": 150, + "color": "#ffffff", + "opacity": 0.4, + "width": 1 + }, + "move": { + "enable": true, + "speed": 6, + "direction": "none", + "random": false, + "straight": false, + "out_mode": "out", + "attract": { + "enable": false, + "rotateX": 600, + "rotateY": 1200 + } + } + }, + "interactivity": { + "detect_on": "canvas", + "events": { + "onhover": { + "enable": false, + "mode": "repulse" + }, + "onclick": { + "enable": true, + "mode": "push" + }, + "resize": true + }, + "modes": { + "grab": { + "distance": 400, + "line_linked": { + "opacity": 1 + } + }, + "bubble": { + "distance": 400, + "size": 40, + "duration": 2, + "opacity": 8, + "speed": 3 + }, + "repulse": { + "distance": 200 + }, + "push": { + "particles_nb": 4 + }, + "remove": { + "particles_nb": 2 + } + } + }, + "retina_detect": true, + "config_demo": { + "hide_card": false, + "background_color": "#b61924", + "background_image": "", + "background_position": "50% 50%", + "background_repeat": "no-repeat", + "background_size": "cover" + } +} diff --git a/symfony.lock b/symfony.lock index 5d9ad95..46bac53 100644 --- a/symfony.lock +++ b/symfony.lock @@ -105,6 +105,18 @@ "friendsofphp/proxy-manager-lts": { "version": "v1.0.3" }, + "friendsofsymfony/jsrouting-bundle": { + "version": "2.3", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "master", + "version": "2.3", + "ref": "a9f2e49180f75cdc71ae279a929c4b2e0638de84" + }, + "files": [ + "config/routes/fos_js_routing.yaml" + ] + }, "gedmo/doctrine-extensions": { "version": "v3.0.3" }, @@ -652,5 +664,8 @@ }, "webmozart/assert": { "version": "1.10.0" + }, + "willdurand/jsonp-callback-validator": { + "version": "v1.1.0" } } diff --git a/templates/module/_navigation.html.twig b/templates/module/_navigation.html.twig index 30c345a..7ad2ed8 100644 --- a/templates/module/_navigation.html.twig +++ b/templates/module/_navigation.html.twig @@ -53,7 +53,6 @@