diff --git a/composer.json b/composer.json index cdbf52f..ecc58c5 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ } }, "require": { - "symfony/console": ">=v2.1.3" + "symfony/console": ">=v2.1.3", "silex/silex": "1.0.*@dev", "twig/twig": ">=1.8,<2.0-dev" }, diff --git a/tests/system/features/generator-form.feature b/tests/system/features/generator-form.feature index 42ac528..3f75ff7 100644 --- a/tests/system/features/generator-form.feature +++ b/tests/system/features/generator-form.feature @@ -6,5 +6,5 @@ Feature: There is a form that I can enter details about the feature Scenario: I can see the form on the home page Given I am on homepage - Then I should see "Build me a DTO named" - And I should see "in the Namespace" + Then I should see "Name your DTO:" + And I should see "Give it a Namespace:" diff --git a/tests/system/features/landing-page.feature b/tests/system/features/landing-page.feature index 1582f17..38fcb02 100644 --- a/tests/system/features/landing-page.feature +++ b/tests/system/features/landing-page.feature @@ -6,4 +6,4 @@ Feature: Provide a web interface for DTOx Scenario: Given I am on homepage Then I should see "DTOx" - And I should see "DTOx is a program that lets you create DTOs." + And I should see "Writing tedious code sucks. Generate it with DTOx." diff --git a/views/home.html.twig b/views/home.html.twig index 88c1996..f0b963e 100644 --- a/views/home.html.twig +++ b/views/home.html.twig @@ -25,7 +25,7 @@
Um, so now what? -

Fill in the fields to the left and below. Add some variables to your DTO. Feel free to update them on the fly. Put your new code in your project. Use the time you saved to go have a beer.

+

Fill in the fields to the left and below. Once you add some variables to your DTO the code will be generated. Feel free to update them on the fly. Put your new code in your project. Use the time you saved to go have a beer.

diff --git a/views/layouts/default.html.twig b/views/layouts/default.html.twig index d462c3f..320ce8a 100644 --- a/views/layouts/default.html.twig +++ b/views/layouts/default.html.twig @@ -1,30 +1,15 @@ DTOx - - + - - - - - - - - - - + - - - - - @@ -32,30 +17,8 @@ - - - - + - - - -
@@ -63,8 +26,5 @@ mixpanel.init("93079fe0b604caba2424c8bff74d9d6f"); {% block content %} {% endblock %}
- - - diff --git a/web/app.php b/web/app.php index b19606a..5ce3a38 100644 --- a/web/app.php +++ b/web/app.php @@ -11,6 +11,15 @@ require_once __DIR__.'/../vendor/autoload.php'; +// TODO: This hack should be pulled out somewhere. +function isValid($dtoInfo) +{ + return property_exists($dtoInfo, 'name') + && property_exists($dtoInfo, 'namespace') + && property_exists($dtoInfo, 'vars') + && count($dtoInfo->vars) > 0; +} + $app = new Silex\Application(); $app->register( @@ -32,17 +41,19 @@ function () use ($app) { function (Request $request) use ($app) { $dtoInfo = json_decode($request->getContent()); - $variablesArray = array(); - $testDataArray = array(); - foreach ($dtoInfo->vars as $var) { - $variablesArray[$var->name] = $var->type; - $testDataArray[$var->name] = $var->testData; + $returnData = new \StdClass(); + if (isValid($dtoInfo)) { + $variablesArray = array(); + $testDataArray = array(); + foreach ($dtoInfo->vars as $var) { + $variablesArray[$var->name] = $var->type; + $testDataArray[$var->name] = $var->testData; + } + $generator = new DTOx\Generator\DTO($dtoInfo->name, $dtoInfo->namespace, $variablesArray); + $returnData->dto = $generator->generate(); + $generator = new DTOx\TestGenerator\DTOUnit($dtoInfo->name, $dtoInfo->namespace, $testDataArray); + $returnData->test = $generator->generate(); } - $returnData = new \StdClass(); - $generator = new DTOx\Generator\DTO($dtoInfo->name, $dtoInfo->namespace, $variablesArray); - $returnData->dto = $generator->generate(); - $generator = new DTOx\TestGenerator\DTOUnit($dtoInfo->name, $dtoInfo->namespace, $testDataArray); - $returnData->test = $generator->generate(); return $app->json($returnData); } ); diff --git a/web/js/app.js b/web/js/app.js index d096e5c..726800d 100644 --- a/web/js/app.js +++ b/web/js/app.js @@ -1,33 +1,42 @@ -var DTOx = angular.module('DTOx',['ui']); +var DTOx = angular.module('DTOx', ['ui']); DTOx.value('ui.config', { - codemirror: { - mode: 'text/x-php', - lineNumbers: true, - matchBrackets: true, - theme: 'vibrant-ink' - } + codemirror: { + mode: 'text/x-php', + lineNumbers: true, + matchBrackets: true, + theme: 'vibrant-ink' + } }); -function DTOCtrl($scope, $timeout, $http){ - $scope.dto = {vars: []}; +function DTOCtrl($scope, $timeout, $http) { + $scope.dto = { + vars: [] + }; - $scope.change = function() { + $scope.change = function () { var prom = 0; $timeout.cancel(prom); - prom = $timeout(function(){ - $http.post('/dto/', angular.toJson($scope.dto)).success(function(data){ - var returnData = angular.fromJson(data); - $scope.code = {dto: returnData.dto, test: returnData.test}; - }); + prom = $timeout(function () { + $http.post('/dto/', angular.toJson($scope.dto)).success(function (data) { + var returnData = angular.fromJson(data); + $scope.code = { + dto: returnData.dto, + test: returnData.test + }; + }); }, 1000); }; - $scope.addVar = function() { - $scope.dto.vars.push({name: $scope.varName, type: $scope.varType, testData: $scope.varTestData}); - $scope.varName = ''; - $scope.varType = ''; - $scope.varTestData = ''; - $scope.change(); + $scope.addVar = function () { + $scope.dto.vars.push({ + name: $scope.varName, + type: $scope.varType, + testData: $scope.varTestData + }); + $scope.varName = ''; + $scope.varType = ''; + $scope.varTestData = ''; + $scope.change(); }; }