Chapter 14

This commit is contained in:
José David Guillén 2022-01-20 19:15:20 +00:00
parent dfce94d9e3
commit 669a34628f
21 changed files with 1037 additions and 23 deletions

View File

@ -8,10 +8,12 @@
"ext-ctype": "*",
"ext-iconv": "*",
"sensio/framework-extra-bundle": "^6.2",
"symfony/asset": "5.4.*",
"symfony/console": "5.4.*",
"symfony/dotenv": "5.4.*",
"symfony/flex": "^1.17|^2",
"symfony/framework-bundle": "5.4.*",
"symfony/monolog-bundle": "^3.0",
"symfony/runtime": "5.4.*",
"symfony/twig-bundle": "5.4.*",
"symfony/yaml": "5.4.*",
@ -65,5 +67,10 @@
"allow-contrib": false,
"require": "5.4.*"
}
},
"require-dev": {
"symfony/debug-bundle": "5.4.*",
"symfony/stopwatch": "5.4.*",
"symfony/web-profiler-bundle": "5.4.*"
}
}

564
composer.lock generated
View File

@ -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": "97a6f0cb2e02b9594875c6d2a7187deb",
"content-hash": "31848baa63099948e513e4c28dced967",
"packages": [
{
"name": "doctrine/annotations",
@ -154,6 +154,105 @@
],
"time": "2022-01-12T08:27:12+00:00"
},
{
"name": "monolog/monolog",
"version": "2.3.5",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "fd4380d6fc37626e2f799f29d91195040137eba9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd4380d6fc37626e2f799f29d91195040137eba9",
"reference": "fd4380d6fc37626e2f799f29d91195040137eba9",
"shasum": ""
},
"require": {
"php": ">=7.2",
"psr/log": "^1.0.1 || ^2.0 || ^3.0"
},
"provide": {
"psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"elasticsearch/elasticsearch": "^7",
"graylog2/gelf-php": "^1.4.2",
"mongodb/mongodb": "^1.8",
"php-amqplib/php-amqplib": "~2.4 || ^3",
"php-console/php-console": "^3.1.3",
"phpspec/prophecy": "^1.6.1",
"phpstan/phpstan": "^0.12.91",
"phpunit/phpunit": "^8.5",
"predis/predis": "^1.1",
"rollbar/rollbar": "^1.3",
"ruflin/elastica": ">=0.90@dev",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler",
"ext-mbstring": "Allow to work properly with unicode symbols",
"ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
"ext-openssl": "Required to send log messages using SSL",
"ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "https://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "https://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.3.5"
},
"funding": [
{
"url": "https://github.com/Seldaek",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/monolog/monolog",
"type": "tidelift"
}
],
"time": "2021-10-01T21:08:31+00:00"
},
{
"name": "psr/cache",
"version": "1.0.1",
@ -429,6 +528,80 @@
},
"time": "2022-01-02T16:55:10+00:00"
},
{
"name": "symfony/asset",
"version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/asset.git",
"reference": "49e355b57b4b6a5cef1d2dbc4e36cee49369cf7d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/asset/zipball/49e355b57b4b6a5cef1d2dbc4e36cee49369cf7d",
"reference": "49e355b57b4b6a5cef1d2dbc4e36cee49369cf7d",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-php80": "^1.16"
},
"conflict": {
"symfony/http-foundation": "<5.3"
},
"require-dev": {
"symfony/http-client": "^4.4|^5.0|^6.0",
"symfony/http-foundation": "^5.3|^6.0",
"symfony/http-kernel": "^4.4|^5.0|^6.0"
},
"suggest": {
"symfony/http-foundation": ""
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Asset\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/asset/tree/v5.4.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-11-23T10:19:22+00:00"
},
{
"name": "symfony/cache",
"version": "v5.4.2",
@ -1775,6 +1948,171 @@
],
"time": "2021-12-29T13:20:26+00:00"
},
{
"name": "symfony/monolog-bridge",
"version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/monolog-bridge.git",
"reference": "6ce6f39536a718ec2ece37eae81c6899030fc571"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/monolog-bridge/zipball/6ce6f39536a718ec2ece37eae81c6899030fc571",
"reference": "6ce6f39536a718ec2ece37eae81c6899030fc571",
"shasum": ""
},
"require": {
"monolog/monolog": "^1.25.1|^2",
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/http-kernel": "^5.3|^6.0",
"symfony/polyfill-php80": "^1.16",
"symfony/service-contracts": "^1.1|^2|^3"
},
"conflict": {
"symfony/console": "<4.4",
"symfony/http-foundation": "<5.3"
},
"require-dev": {
"symfony/console": "^4.4|^5.0|^6.0",
"symfony/http-client": "^4.4|^5.0|^6.0",
"symfony/mailer": "^4.4|^5.0|^6.0",
"symfony/messenger": "^4.4|^5.0|^6.0",
"symfony/mime": "^4.4|^5.0|^6.0",
"symfony/security-core": "^4.4|^5.0|^6.0",
"symfony/var-dumper": "^4.4|^5.0|^6.0"
},
"suggest": {
"symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings.",
"symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.",
"symfony/var-dumper": "For using the debugging handlers like the console handler or the log server handler."
},
"type": "symfony-bridge",
"autoload": {
"psr-4": {
"Symfony\\Bridge\\Monolog\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides integration for Monolog with various Symfony components",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/monolog-bridge/tree/v5.4.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-11-23T10:19:22+00:00"
},
{
"name": "symfony/monolog-bundle",
"version": "v3.7.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/monolog-bundle.git",
"reference": "fde12fc628162787a4e53877abadc30047fd868b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/monolog-bundle/zipball/fde12fc628162787a4e53877abadc30047fd868b",
"reference": "fde12fc628162787a4e53877abadc30047fd868b",
"shasum": ""
},
"require": {
"monolog/monolog": "~1.22 || ~2.0",
"php": ">=7.1.3",
"symfony/config": "~4.4 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
"symfony/http-kernel": "~4.4 || ^5.0 || ^6.0",
"symfony/monolog-bridge": "~4.4 || ^5.0 || ^6.0"
},
"require-dev": {
"symfony/console": "~4.4 || ^5.0 || ^6.0",
"symfony/phpunit-bridge": "^5.2 || ^6.0",
"symfony/yaml": "~4.4 || ^5.0 || ^6.0"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Bundle\\MonologBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony MonologBundle",
"homepage": "https://symfony.com",
"keywords": [
"log",
"logging"
],
"support": {
"issues": "https://github.com/symfony/monolog-bundle/issues",
"source": "https://github.com/symfony/monolog-bundle/tree/v3.7.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-11-05T10:34:29+00:00"
},
{
"name": "symfony/polyfill-intl-grapheme",
"version": "v1.24.0",
@ -3281,7 +3619,229 @@
"time": "2022-01-03T21:15:37+00:00"
}
],
"packages-dev": [],
"packages-dev": [
{
"name": "symfony/debug-bundle",
"version": "v5.4.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug-bundle.git",
"reference": "3f3e9c9f77c9b1813d07181975a8c154fb4eb215"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug-bundle/zipball/3f3e9c9f77c9b1813d07181975a8c154fb4eb215",
"reference": "3f3e9c9f77c9b1813d07181975a8c154fb4eb215",
"shasum": ""
},
"require": {
"ext-xml": "*",
"php": ">=7.2.5",
"symfony/http-kernel": "^4.4|^5.0|^6.0",
"symfony/polyfill-php80": "^1.16",
"symfony/twig-bridge": "^4.4|^5.0|^6.0",
"symfony/var-dumper": "^4.4|^5.0|^6.0"
},
"conflict": {
"symfony/config": "<4.4",
"symfony/dependency-injection": "<5.2"
},
"require-dev": {
"symfony/config": "^4.4|^5.0|^6.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/web-profiler-bundle": "^4.4|^5.0|^6.0"
},
"suggest": {
"symfony/config": "For service container configuration",
"symfony/dependency-injection": "For using as a service from the container"
},
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Symfony\\Bundle\\DebugBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides a tight integration of the Symfony VarDumper component and the ServerLogCommand from MonologBridge into the Symfony full-stack framework",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/debug-bundle/tree/v5.4.2"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-12-11T13:33:37+00:00"
},
{
"name": "symfony/stopwatch",
"version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
"reference": "208ef96122bfed82a8f3a61458a07113a08bdcfe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/208ef96122bfed82a8f3a61458a07113a08bdcfe",
"reference": "208ef96122bfed82a8f3a61458a07113a08bdcfe",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/service-contracts": "^1|^2|^3"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Stopwatch\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides a way to profile code",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/stopwatch/tree/v5.4.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-11-23T10:19:22+00:00"
},
{
"name": "symfony/web-profiler-bundle",
"version": "v5.4.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/web-profiler-bundle.git",
"reference": "c779222d5a87b7d947e56ac09b02adb34cf8b610"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/web-profiler-bundle/zipball/c779222d5a87b7d947e56ac09b02adb34cf8b610",
"reference": "c779222d5a87b7d947e56ac09b02adb34cf8b610",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/config": "^4.4|^5.0|^6.0",
"symfony/framework-bundle": "^5.3|^6.0",
"symfony/http-kernel": "^5.3|^6.0",
"symfony/polyfill-php80": "^1.16",
"symfony/routing": "^4.4|^5.0|^6.0",
"symfony/twig-bundle": "^4.4|^5.0|^6.0",
"twig/twig": "^2.13|^3.0.4"
},
"conflict": {
"symfony/dependency-injection": "<5.2",
"symfony/form": "<4.4",
"symfony/mailer": "<5.4",
"symfony/messenger": "<4.4"
},
"require-dev": {
"symfony/browser-kit": "^4.4|^5.0|^6.0",
"symfony/console": "^4.4|^5.0|^6.0",
"symfony/css-selector": "^4.4|^5.0|^6.0",
"symfony/stopwatch": "^4.4|^5.0|^6.0"
},
"type": "symfony-bundle",
"autoload": {
"psr-4": {
"Symfony\\Bundle\\WebProfilerBundle\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides a development tool that gives detailed information about the execution of any request",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/web-profiler-bundle/tree/v5.4.2"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-12-21T21:22:06+00:00"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],

View File

@ -5,4 +5,7 @@ return [
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
];

View File

@ -0,0 +1,4 @@
debug:
# Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser.
# See the "server:dump" command to start a new server.
dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%"

View File

@ -0,0 +1,19 @@
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]

View File

@ -0,0 +1,6 @@
web_profiler:
toolbar: true
intercept_redirects: false
framework:
profiler: { only_exceptions: false }

View File

@ -0,0 +1,8 @@
# As of Symfony 5.1, deprecations are logged in the dedicated "deprecation" channel when it exists
#monolog:
# channels: [deprecation]
# handlers:
# deprecation:
# type: stream
# channels: [deprecation]
# path: php://stderr

View File

@ -0,0 +1,17 @@
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
nested:
type: stream
path: php://stderr
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]

View File

@ -0,0 +1,12 @@
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
channels: ["!event"]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug

View File

@ -0,0 +1,6 @@
web_profiler:
toolbar: false
intercept_redirects: false
framework:
profiler: { collect: false }

View File

@ -0,0 +1,7 @@
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt
web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler

127
public/css/app.css Normal file
View File

@ -0,0 +1,127 @@
body {
font-family: spartan;
color: #444;
}
.jumbotron-img {
background: rgb(237,116,88);
background: linear-gradient(302deg, rgba(237,116,88,1) 16%, rgba(51,61,81,1) 97%);
color: #fff;
}
.q-container {
border-top-right-radius: .25rem;
border-top-left-radius: .25rem;
background-color: #efefee;
}
.q-container-show {
border-top-right-radius: .25rem;
border-top-left-radius: .25rem;
background-color: #ED7458 ;
}
.q-container img, .q-container-show img {
border: 2px solid #fff;
border-radius: 50%;
}
.q-display {
background: #fff;
border-radius: .25rem;
}
.q-title-show {
text-transform: uppercase;
font-size: 1.3rem;
color: #fff;
}
.q-title {
text-transform: uppercase;
color: #444;
}
.q-title:hover {
color: #2B2B2B;
}
.q-title h2 {
font-size: 1.3rem;
}
.q-display-response {
background: #333D51;
color: #fff;
}
.answer-link:hover .magic-wand {
transform: rotate(20deg);
}
.vote-arrows {
font-size: 1.5rem;
}
.vote-arrows span {
font-size: 1rem;
}
.vote-arrows a {
color: #444;
}
.vote-up:hover {
color: #3D9970;
}
.vote-down:hover {
color: #FF4136;
}
.btn-question {
color: #FFFFFF;
background-color: #ED7458;
border-color: #D45B3F;
}
.btn-question:hover,
.btn-question:focus,
.btn-question:active,
.btn-question.active,
.open .dropdown-toggle.btn-question {
color: #FFFFFF;
background-color: #D45B3F;
border-color: #D45B3F;
}
.btn-question:active,
.btn-question.active,
.open .dropdown-toggle.btn-question {
background-image: none;
}
.btn-question.disabled,
.btn-question[disabled],
fieldset[disabled] .btn-question,
.btn-question.disabled:hover,
.btn-question[disabled]:hover,
fieldset[disabled] .btn-question:hover,
.btn-question.disabled:focus,
.btn-question[disabled]:focus,
fieldset[disabled] .btn-question:focus,
.btn-question.disabled:active,
.btn-question[disabled]:active,
fieldset[disabled] .btn-question:active,
.btn-question.disabled.active,
.btn-question[disabled].active,
fieldset[disabled] .btn-question.active {
background-color: #ED7458;
border-color: #D45B3F;
}
.btn-question .badge {
color: #ED7458;
background-color: #FFFFFF;
}
footer {
background-color: #efefee;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

BIN
public/images/tisha.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

View File

@ -0,0 +1,16 @@
/**
* Simple (ugly) code to handle the comment vote up/down
*/
var $container = $('.js-vote-arrows');
$container.find('a').on('click', function(e) {
e.preventDefault();
var $link = $(e.currentTarget);
$.ajax({
url: '/comments/10/vote/'+$link.data('direction'),
method: 'POST'
}).then(function(response) {
$container.find('.js-vote-total').text(response.votes);
});
});

View File

@ -0,0 +1,29 @@
<?php
namespace App\Controller;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
// use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class CommentController extends AbstractController
{
/**
* @Route("/comments/{id}/vote/{direction<up|down>}", methods="POST")
*/
public function commentVote($id, $direction)
{
if ($direction === 'up') {
$logger->info('Voting up!');
$currentVoteCount = rand(7,100);
} else {
$logger->info('Voting down!');
$currentVoteCount = rand(0,5);
}
// return new JsonResponse(['votes'=>$currentVoteCount]);
return $this->json(['votes'=>$currentVoteCount]);
}
}

View File

@ -11,15 +11,15 @@ use Symfony\Component\Routing\Annotation\Route;
class QuestionController extends AbstractController
{
/**
* @Route("/")
* @Route("/", name="app_homepage")
*/
public function homepage()
{
return new Response('What a bewitching controller we have conjured!');
return $this->render('question/homepage.html.twig');
}
/**
* @Route("/questions/{slug}")
* @Route("/questions/{slug}", name="app_question_show")
*/
public function show($slug)
{
@ -28,6 +28,10 @@ class QuestionController extends AbstractController
'Honestly, I like furry shoes better than MY cat',
'Maybe... try saying the spell backwards?',
];
dump($slug,$this);
// dd($slug,$this);
return $this->render('question/show.html.twig', [
'question'=>ucwords(str_replace('-', ' ', $slug)),
'answers' => $answers,

View File

@ -14,6 +14,9 @@
"doctrine/lexer": {
"version": "1.2.2"
},
"monolog/monolog": {
"version": "2.3.5"
},
"psr/cache": {
"version": "1.0.1"
},
@ -38,6 +41,9 @@
"config/packages/sensio_framework_extra.yaml"
]
},
"symfony/asset": {
"version": "v5.4.0"
},
"symfony/cache": {
"version": "v5.4.2"
},
@ -59,6 +65,18 @@
"bin/console"
]
},
"symfony/debug-bundle": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "4.1",
"ref": "0ce7a032d344fb7b661cd25d31914cd703ad445b"
},
"files": [
"config/packages/dev/debug.yaml"
]
},
"symfony/dependency-injection": {
"version": "v5.4.2"
},
@ -120,6 +138,24 @@
"symfony/http-kernel": {
"version": "v5.4.2"
},
"symfony/monolog-bridge": {
"version": "v5.4.0"
},
"symfony/monolog-bundle": {
"version": "3.7",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.7",
"ref": "a7bace7dbc5a7ed5608dbe2165e0774c87175fe6"
},
"files": [
"config/packages/dev/monolog.yaml",
"config/packages/prod/deprecations.yaml",
"config/packages/prod/monolog.yaml",
"config/packages/test/monolog.yaml"
]
},
"symfony/polyfill-intl-grapheme": {
"version": "v1.24.0"
},
@ -157,6 +193,9 @@
"symfony/service-contracts": {
"version": "v2.5.0"
},
"symfony/stopwatch": {
"version": "v5.4.0"
},
"symfony/string": {
"version": "v5.4.2"
},
@ -185,6 +224,20 @@
"symfony/var-exporter": {
"version": "v5.4.2"
},
"symfony/web-profiler-bundle": {
"version": "5.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "3.3",
"ref": "6bdfa1a95f6b2e677ab985cd1af2eae35d62e0f6"
},
"files": [
"config/packages/dev/web_profiler.yaml",
"config/packages/test/web_profiler.yaml",
"config/routes/dev/web_profiler.yaml"
]
},
"symfony/yaml": {
"version": "v5.4.2"
},

View File

@ -3,17 +3,31 @@
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text></svg>">
{# Run `composer require symfony/webpack-encore-bundle` to start using Symfony UX #}
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Spartan&display=swap">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
{% endblock %}
</head>
<body>
<nav class="navbar navbar-light bg-light" style="height: 100px;">
<a class="navbar-brand" href="{{ path('app_homepage') }}">
<i style="color: #444; font-size: 2rem;" class="pb-1 fad fa-cauldron"></i>
<p class="pl-2 d-inline font-weight-bold" style="color: #444;">Cauldron Overflow</p>
</a>
<button class="btn btn-dark">Sign up</button>
</nav>
{% block body %}{% endblock %}
<footer class="mt-5 p-3 text-center">
Made with <i style="color: red;" class="fa fa-heart"></i> by the guys and gals at <a style="color: #444; text-decoration: underline;" href="https://symfonycasts.com">SymfonyCasts</a>
</footer>
{% block javascripts %}
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
{% endblock %}
</body>
</html>

View File

@ -0,0 +1,75 @@
{% extends 'base.html.twig' %}
{% block body %}
<div class="jumbotron-img jumbotron jumbotron-fluid">
<div class="container">
<h1 class="display-4">Your Questions Answered</h1>
<p class="lead">And even answers for those questions you didn't think to ask!</p>
</div>
</div>
<div class="container">
<div class="row mb-3">
<div class="col">
<button class="btn btn-question">Ask a Question</button>
</div>
</div>
<div class="row">
<div class="col-12">
<div style="box-shadow: 2px 3px 9px 4px rgba(0,0,0,0.04);">
<div class="q-container p-4">
<div class="row">
<div class="col-2 text-center">
<img src="{{ asset('images/tisha.png') }}" width="100" height="100">
<div class="d-block mt-3 vote-arrows">
<a class="vote-up" href="#"><i class="far fa-arrow-alt-circle-up"></i></a>
<a class="vote-down" href="#"><i class="far fa-arrow-alt-circle-down"></i></a>
</div>
</div>
<div class="col">
<a class="q-title" href="{{ path('app_question_show', { slug: 'reversing-a-spell' }) }}"><h2>Reversing a Spell</h2></a>
<div class="q-display p-3">
<i class="fa fa-quote-left mr-3"></i>
<p class="d-inline">I've been turned into a cat, any thoughts on how to turn back? While I'm adorable, I don't really care for cat food.</p>
<p class="pt-4"><strong>--Tisha</strong></p>
</div>
</div>
</div>
</div>
<a class="answer-link" href="{{ path('app_question_show', { slug: 'reversing-a-spell' }) }}" style="color: #fff;">
<p class="q-display-response text-center p-3">
<i class="fa fa-magic magic-wand"></i> 6 answers
</p>
</a>
</div>
</div>
<div class="col-12 mt-3">
<div class="q-container p-4">
<div class="row">
<div class="col-2 text-center">
<img src="{{ asset('images/magic-photo.png') }}" width="100" height="100">
<div class="d-block mt-3 vote-arrows">
<a class="vote-up" href="#"><i class="far fa-arrow-alt-circle-up"></i></a>
<a class="vote-down" href="#"><i class="far fa-arrow-alt-circle-down"></i></a>
</div>
</div>
<div class="col">
<a class="q-title" href="{{ path('app_question_show', { slug: 'pausing-a-spell' }) }}"><h2>Pausing a Spell</h2></a>
<div class="q-display p-3">
<i class="fa fa-quote-left mr-3"></i>
<p class="d-inline">I mastered the floating card, but now how do I get it back to the ground?</p>
<p class="pt-4"><strong>--Jerry</strong></p>
</div>
</div>
</div>
</div>
<a class="answer-link" href="{{ path('app_question_show', { slug: 'pausing-a-spell' }) }}" style="color: #fff;">
<p class="q-display-response text-center p-3">
<i class="fa fa-magic magic-wand"></i> 15 answers
</p>
</a>
</div>
</div>
</div>
{% endblock %}

View File

@ -1,16 +1,63 @@
{% extends 'base.html.twig' %}
{% block title %}Question: {{ question }}{% endblock %}
{% block body %}
<h1>{{ question }}</h1>
<div>
Eventually, we'll print the full question here!
</div>
<div class="container">
<div class="row">
<div class="col-12">
<h2 class="my-4">Question</h2>
<div style="box-shadow: 2px 3px 9px 4px rgba(0,0,0,0.04);">
<div class="q-container-show p-4">
<div class="row">
<div class="col-2 text-center">
<img src="{{ asset('images/tisha.png') }}" alt="Mallory Avatar" width="100" height="100">
</div>
<div class="col">
<h1 class="q-title-show">{{ question }}</h1>
<div class="q-display p-3">
<i class="fa fa-quote-left mr-3"></i>
<p class="d-inline">I've been turned into a cat, any thoughts on how to turn back? While I'm adorable, I don't really care for cat food.</p>
<p class="pt-4"><strong>--Tisha</strong></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<h2>Answers</h2>
<ul>
<div class="d-flex justify-content-between my-4">
<h2 class="">Answers <span style="font-size:1.2rem;">({{ answers|length }})</span></h2>
<button class="btn btn-sm btn-secondary">Submit an Answer</button>
</div>
<ul class="list-unstyled">
{% for answer in answers %}
<li>{{ answer }}</li>
<li class="mb-4">
<div class="d-flex justify-content-center">
<div class="mr-2 pt-2">
<img src="{{ asset('images/tisha.png') }}" alt="Mallory Avatar" width="50" height="50">
</div>
<div class="mr-3 pt-2">
{{ answer }}
<p>-- Mallory</p>
</div>
<div class="vote-arrows flex-fill pt-2 js-vote-arrows" style="min-width: 90px;">
<a class="vote-up" href="#" data-direction="up"><i class="far fa-arrow-alt-circle-up"></i></a>
<a class="vote-down" href="#" data-direction="down"><i class="far fa-arrow-alt-circle-down"></i></a>
<span>+ <span class="js-vote-total">6</span></span>
</div>
</div>
</li>
{% endfor %}
</ul>
</ul>
</div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script src="{{ asset('js/question_show.js') }}"></script>
{% endblock %}