Skip to content

Commit

Permalink
Merge pull request #82 from sproogen/develop
Browse files Browse the repository at this point in the history
Merge v2.0.0
  • Loading branch information
sproogen committed Jun 29, 2017
2 parents 098ee6f + 4f421d1 commit 468e016
Show file tree
Hide file tree
Showing 161 changed files with 7,032 additions and 3,765 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
18 changes: 12 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
!app/logs/.gitkeep

# Cache and logs (Symfony3)
/var/*
!/var/cache
/var/cache/*
/var/logs/*
!var/cache/.gitkeep
!/var/logs
/var/logs/*
!var/logs/.gitkeep
!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
!var/SymfonyRequirements.php

# Parameters
/app/config/parameters.yml
Expand Down Expand Up @@ -50,8 +57,7 @@ npm-debug.log*
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules

#Compiled Files
/web/js/itsgoingtobe.js
/web/js/itsgoingtobe.min.js
/web/css/itsgoingtobe.css
/web/css/itsgoingtobe.min.css
#React Files
/web/client/
/app/Resources/views/react/index.html
/client/
21 changes: 16 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
language: php

php:
- 5.6
- 5.6

env:
- NODE_VERSION="7"

cache:
directories:
- vendor
- node_modules

branches:
only:
Expand All @@ -14,18 +22,21 @@ before_install:

install:
- phpenv config-rm xdebug.ini
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $NODE_VERSION
- composer install
- npm install

before_script:
- php app/console doctrine:database:create --env=test
- php app/console doctrine:schema:create --env=test
- php bin/console doctrine:database:create --env=test
- php bin/console doctrine:schema:create --env=test

script:
- bin/phpcs --standard=PSR2 src/
- bin/phplint src
- bin/phpunit -c app
- bin/phpunit
- npm run lint
- npm run test

notifications:
email:
- sprog31@gmail.com
- sprog31@gmail.com
75 changes: 56 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# itsgoingto.be [![Build Status](https://travis-ci.org/sproogen/itsgoingto.be.svg)](https://travis-ci.org/sproogen/itsgoingto.be) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/95ef266848d44348a421142d2ed6f8cb)](https://www.codacy.com/app/sproogen/itsgoingto.be?utm_source=github.com&utm_medium=referral&utm_content=sproogen/itsgoingto.be&utm_campaign=Badge_Grade)
Symfony magic behind itsgoingto.be

Symfony and React magic behind itsgoingto.be

The root of this project contains the Symfony app.

The React app can be found at app/Resources/client. This can been loaded through symfony for developing or compiled into the web folder for prodcution builds.

There are a number of number of NPM scripts that can be run from the project root.

API
-------------
Expand Down Expand Up @@ -49,11 +56,11 @@ GET /api/questions
},
"answers": [
{
"type": "answer",
"type": "Answer",
"id": 1
},
{
"type": "answer",
"type": "Answer",
"id": 2
}
],
Expand Down Expand Up @@ -89,17 +96,27 @@ GET /api/questions/:identifier
},
"answers": [
{
"type": "answer",
"id": 1
"id": 1,
"answer": "Answer Text",
"question": {
"type": "Question",
"id": 1
},
"responsesCount": 2
},
{
"type": "answer",
"id": 2
"id": 2,
"answer": "Answer Text",
"question": {
"type": "Question",
"id": 1
},
"responsesCount": 3
}
],
"responses" : [
"userResponses" : [
2
]
],
"responsesCount": 5
}
```
Expand Down Expand Up @@ -134,14 +151,25 @@ POST /api/questions
},
"answers": [
{
"type": "answer",
"id": 1
"id": 1,
"answer": "Answer Text",
"question": {
"type": "Question",
"id": 1
},
"responsesCount": 0
},
{
"type": "answer",
"id": 2
"id": 2,
"answer": "Answer Text",
"question": {
"type": "Question",
"id": 1
},
"responsesCount": 0
}
],
"userResponses": [],
"responsesCount": 0
}
```
Expand Down Expand Up @@ -171,11 +199,11 @@ DELETE /api/questions/:identifier
},
"answers": [
{
"type": "answer",
"type": "Answer",
"id": 1
},
{
"type": "answer",
"type": "Answer",
"id": 2
}
],
Expand All @@ -191,7 +219,10 @@ GET /api/questions/:identifier/responses
###### Response
```
{
"responsesCount": 5
"userResponses" : [
2
],
"responsesCount": 5,
"answers": [
{
"id": 1,
Expand All @@ -201,7 +232,7 @@ GET /api/questions/:identifier/responses
"id": 2,
"responsesCount": 3
}
],
]
}
```

Expand All @@ -216,7 +247,13 @@ POST /api/questions/:identifier/responses
###### Response
```
{
"responsesCount": 6
"userResponses": [
2
],
"responsesCount": 6,
"responses" : [
1
],
"answers": [
{
"id": 1,
Expand All @@ -226,7 +263,7 @@ POST /api/questions/:identifier/responses
"id": 2,
"responsesCount": 3
}
],
]
}
```

Expand Down
2 changes: 0 additions & 2 deletions app/AppCache.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

require_once __DIR__.'/AppKernel.php';

use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;

class AppCache extends HttpCache
Expand Down
21 changes: 18 additions & 3 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,36 @@ public function registerBundles()
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new ItsGoingToBeBundle\ItsGoingToBeBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle()
);

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}

return $bundles;
}

public function getRootDir()
{
return __DIR__;
}

public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}

public function getLogDir()
{
return dirname(__DIR__).'/var/logs';
}

public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
Expand Down
48 changes: 48 additions & 0 deletions app/DoctrineMigrations/Version20170626180355.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Application\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20170626180355 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('CREATE TABLE answer (id INT AUTO_INCREMENT NOT NULL, question_id INT DEFAULT NULL, answer LONGTEXT NOT NULL, INDEX IDX_DADD4A251E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE login_attempt (id INT AUTO_INCREMENT NOT NULL, ip LONGTEXT NOT NULL, succesful TINYINT(1) NOT NULL, username LONGTEXT NOT NULL, password LONGTEXT NOT NULL, created DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE question (id INT AUTO_INCREMENT NOT NULL, identifier VARCHAR(255) NOT NULL, question LONGTEXT NOT NULL, multiple_choice TINYINT(1) NOT NULL, deleted TINYINT(1) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE sessions (sess_id VARCHAR(255) NOT NULL, sess_data LONGBLOB NOT NULL, sess_time INT NOT NULL, sess_lifetime BIGINT NOT NULL, PRIMARY KEY(sess_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE response (id INT AUTO_INCREMENT NOT NULL, question_id INT DEFAULT NULL, answer_id INT DEFAULT NULL, user_ip VARCHAR(100) NOT NULL, user_session_id VARCHAR(100) NOT NULL, custom_user_id VARCHAR(100) NOT NULL, created DATETIME NOT NULL, updated DATETIME NOT NULL, INDEX IDX_3E7B0BFB1E27F6BF (question_id), INDEX IDX_3E7B0BFBAA334807 (answer_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE answer ADD CONSTRAINT FK_DADD4A251E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
$this->addSql('ALTER TABLE response ADD CONSTRAINT FK_3E7B0BFB1E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
$this->addSql('ALTER TABLE response ADD CONSTRAINT FK_3E7B0BFBAA334807 FOREIGN KEY (answer_id) REFERENCES answer (id)');
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE response DROP FOREIGN KEY FK_3E7B0BFBAA334807');
$this->addSql('ALTER TABLE answer DROP FOREIGN KEY FK_DADD4A251E27F6BF');
$this->addSql('ALTER TABLE response DROP FOREIGN KEY FK_3E7B0BFB1E27F6BF');
$this->addSql('DROP TABLE answer');
$this->addSql('DROP TABLE login_attempt');
$this->addSql('DROP TABLE question');
$this->addSql('DROP TABLE sessions');
$this->addSql('DROP TABLE response');
}
}
54 changes: 54 additions & 0 deletions app/DoctrineMigrations/Version20170626181829.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Application\Migrations;

use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;

/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20170626181829 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE answer DROP FOREIGN KEY FK_DADD4A251E27F6BF');
$this->addSql('ALTER TABLE response DROP FOREIGN KEY FK_3E7B0BFB1E27F6BF');
$this->addSql('RENAME TABLE question TO poll');
$this->addSql('DROP INDEX IDX_DADD4A251E27F6BF ON answer');
$this->addSql('ALTER TABLE answer CHANGE question_id poll_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE answer ADD CONSTRAINT FK_DADD4A253C947C0F FOREIGN KEY (poll_id) REFERENCES poll (id)');
$this->addSql('CREATE INDEX IDX_DADD4A253C947C0F ON answer (poll_id)');
$this->addSql('DROP INDEX IDX_3E7B0BFB1E27F6BF ON response');
$this->addSql('ALTER TABLE response CHANGE question_id poll_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE response ADD CONSTRAINT FK_3E7B0BFB3C947C0F FOREIGN KEY (poll_id) REFERENCES poll (id)');
$this->addSql('CREATE INDEX IDX_3E7B0BFB3C947C0F ON response (poll_id)');
}

/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE answer DROP FOREIGN KEY FK_DADD4A253C947C0F');
$this->addSql('ALTER TABLE response DROP FOREIGN KEY FK_3E7B0BFB3C947C0F');
$this->addSql('RENAME TABLE poll TO question');
$this->addSql('DROP INDEX IDX_DADD4A253C947C0F ON answer');
$this->addSql('ALTER TABLE answer CHANGE poll_id question_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE answer ADD CONSTRAINT FK_DADD4A251E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
$this->addSql('CREATE INDEX IDX_DADD4A251E27F6BF ON answer (question_id)');
$this->addSql('DROP INDEX IDX_3E7B0BFB3C947C0F ON response');
$this->addSql('ALTER TABLE response CHANGE poll_id question_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE response ADD CONSTRAINT FK_3E7B0BFB1E27F6BF FOREIGN KEY (question_id) REFERENCES question (id)');
$this->addSql('CREATE INDEX IDX_3E7B0BFB1E27F6BF ON response (question_id)');
}
}
4 changes: 4 additions & 0 deletions app/Resources/client/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage/**
node_modules/**
dist/**
src/index.html
Loading

0 comments on commit 468e016

Please sign in to comment.