diff --git a/.gitignore b/.gitignore index 300d5fa..0cbf95e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ ###< symfony/web-server-bundle ### .idea/* +node_modules/* +package-lock.json diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..c99d4e8 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,24 @@ +module.exports = function (grunt) { + + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + + uglify: { + "jquery.follow": { + src: "public/js/raw/jquery.follow.js", + dest: "public/js/jquery.follow.min.js" + } + + } + + }); + + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-internal'); + grunt.loadNpmTasks('grunt-contrib-clean'); + grunt.loadNpmTasks('grunt-contrib-uglify-es'); + + grunt.registerTask('js', ['uglify']); + + grunt.registerTask('default', ['js']); +}; diff --git a/config/packages/security.yaml b/config/packages/security.yaml index f478af6..4526e23 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -32,4 +32,4 @@ security: # Note: Only the *first* access control that matches will be used access_control: - { path: ^/admin, roles: ROLE_ADMIN } - # - { path: ^/profile, roles: ROLE_USER } + - { path: ^/follow_plugin, roles: ROLE_USER } diff --git a/package.json b/package.json new file mode 100644 index 0000000..a241bd6 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "inforesurs-test", + "version": "0.0.1", + "devDependencies": { + "grunt": ">= 0.4.1", + "grunt-contrib-imagemin": "~3.1.0", + "grunt-contrib-internal": "~3.1.0", + "grunt-contrib-jshint": "~2.0.0", + "grunt-contrib-uglify": "~4.0.0", + "grunt-sass": "^2.1.0", + "jimp": "^0.2.28", + "node-sprite-generator": "~0.10.2", + "grunt-postcss": "~0.9.0", + "pixrem": "~4.0.1", + "cssnano": "~3.10.0", + "autoprefixer": "~8.0.0", + "grunt-contrib-clean": "^2.0.0" + }, + "dependencies": { + "grunt-contrib-uglify-es": "github:gruntjs/grunt-contrib-uglify#harmony" + } +} diff --git a/public/js/jquery.follow.min.js b/public/js/jquery.follow.min.js new file mode 100644 index 0000000..91cb997 --- /dev/null +++ b/public/js/jquery.follow.min.js @@ -0,0 +1 @@ +!function(o){o.fn.follow=function(){o(this).mouseover(function(f,e){var n;n=this,o("body").mousemove(function(f,e){o(n).offset({top:f.pageY,left:f.pageX}),o(n).click(function(){o("body").off("mousemove")})})})}}(jQuery); \ No newline at end of file diff --git a/public/js/raw/jquery.follow.js b/public/js/raw/jquery.follow.js new file mode 100644 index 0000000..28964c6 --- /dev/null +++ b/public/js/raw/jquery.follow.js @@ -0,0 +1,18 @@ +(function ($) { + $.fn.follow = function () { + var $this = $(this); + + function follow_mouse(obj) { + $('body').mousemove(function (e, h) { + $(obj).offset({top: e.pageY, left: e.pageX}); + $(obj).click(function () { + $('body').off('mousemove') + }) + }) + } + + $this.mouseover(function (e, h) { + follow_mouse(this); + }); + }; +})(jQuery); \ No newline at end of file diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index b8b677d..629c27a 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -14,4 +14,12 @@ class IndexController extends AbstractController { return $this->render('index.html.twig'); } + + /** + * @Route("/follow", name="follow_page", methods={"GET"}) + */ + public function follow() + { + return $this->render('follow.html.twig'); + } } diff --git a/templates/follow.html.twig b/templates/follow.html.twig new file mode 100644 index 0000000..5afb73f --- /dev/null +++ b/templates/follow.html.twig @@ -0,0 +1,51 @@ +{% extends "base.html.twig" %} +{% block title %} + Плагин follow +{% endblock %} +{% block body %} +
+ ← Главная +

But I must explain to you how all this mistaken idea of denouncing + pleasure and praising pain + was born and I will give you a complete account of the system, and + expound the actual teachings of the great explorer of the truth, the + master-builder of human happiness. No one rejects, dislikes, or + avoids pleasure itself, because it is pleasure, but because those + who do not know how to pursue pleasure rationally encounter + consequences that are extremely painful. Nor again is there anyone + who loves or pursues or desires to obtain pain of itself, because it + is pain, but because occasionally circumstances occur in which toil + and pain can procure him some great pleasure. To take a trivial + example, which of us ever undertakes laborious physical exercise, + except to obtain some advantage from it? But who has any right to + find fault with a man who chooses to enjoy a pleasure that has no + annoying consequences, or one who avoids a pain that produces no + resultant pleasure?

+

follow

+

At vero eos et accusamus et iusto odio dignissimos ducimus qui + blanditiis praesentium + voluptatum deleniti atque corrupti quos dolores et quas molestias + excepturi sint occaecati cupiditate non provident, similique sunt in + culpa qui officia deserunt mollitia animi, id est laborum et dolorum + fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam + libero tempore, cum soluta nobis est eligendi optio cumque nihil + impedit quo minus id quod maxime placeat facere possimus, omnis + voluptas assumenda est, omnis dolor repellendus. Temporibus autem + quibusdam et aut officiis debitis aut rerum necessitatibus saepe + eveniet ut et voluptates repudiandae sint et molestiae non + recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut + aut reiciendis voluptatibus maiores alias consequatur aut + perferendis doloribus asperiores repellat.

+
+{% endblock %} +{% block javascripts %} + + + +{% endblock %} \ No newline at end of file diff --git a/templates/index.html.twig b/templates/index.html.twig index 60dd0f5..06ef3a5 100644 --- a/templates/index.html.twig +++ b/templates/index.html.twig @@ -10,6 +10,9 @@ Выйти {% endif %}
+ {% if is_granted('ROLE_USER') %} + Плагин follow + {% endif %} {% if is_granted('ROLE_ADMIN') %} Список пользователей {% endif %}