Skip to content

Commit

Permalink
Update dependencies, fix requiest bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Fox committed Mar 24, 2014
1 parent f58be2b commit e060f0e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 79 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -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"
},
Expand Down
4 changes: 2 additions & 2 deletions tests/system/features/generator-form.feature
Expand Up @@ -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:"
2 changes: 1 addition & 1 deletion tests/system/features/landing-page.feature
Expand Up @@ -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."
2 changes: 1 addition & 1 deletion views/home.html.twig
Expand Up @@ -25,7 +25,7 @@
<div class="alert alert-info">

<strong><i class="icon-info-sign"></i> Um, so now what?</strong>
<p>Fill in the fields to the left and below. Add some variables to your <a href="http://neverstopbuilding.net/the-dto-pattern-how-to-generate-php-dtos-quickly-with-dtox/">DTO</a>. Feel free to update them on the fly. Put your new code in your project. Use the time you saved to go have a <a href="http://www.sintbernardus.be/stbernardusabt12.php?l=en">beer</a>.</p>
<p>Fill in the fields to the left and below. Once you add some variables to your <a href="http://www.neverstopbuilding.com/data-transfer-object">DTO</a> 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 <a href="http://www.sintbernardus.be/stbernardusabt12.php?l=en">beer</a>.</p>
</div>
</div>
</div>
Expand Down
46 changes: 3 additions & 43 deletions views/layouts/default.html.twig
@@ -1,70 +1,30 @@
<html ng-app="DTOx">
<head>
<title>DTOx</title>

<link rel="stylesheet" href="//codemirror.net/lib/codemirror.css">
<link rel="stylesheet" type="text/css" href="//angular-ui.github.com/angular-ui/build/angular-ui.css">
<link rel="stylesheet" type="text/css" href="/css/angular-ui.min.css">

<link rel="stylesheet" type="text/css" href="http://codemirror.net/theme/vibrant-ink.css">
<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/css/app.css">








<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.3/angular.min.js"></script>
<script src="//codemirror.net/lib/codemirror.js"></script>





<script src="//codemirror.net/addon/edit/matchbrackets.js"></script>
<script src="//codemirror.net/mode/htmlmixed/htmlmixed.js"></script>
<script src="//codemirror.net/mode/xml/xml.js"></script>
<script src="//codemirror.net/mode/javascript/javascript.js"></script>
<script src="//codemirror.net/mode/css/css.js"></script>
<script src="//codemirror.net/mode/clike/clike.js"></script>
<script src="//codemirror.net/mode/php/php.js"></script>
<script src="//angular-ui.github.com/angular-ui/build/angular-ui.js"></script>



<script src="/js/angular-ui.min.js"></script>
<script src="/js/app.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-37389931-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

<!-- start Mixpanel --><script type="text/javascript">(function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src=("https:"===e.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.2.min.js';f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f);b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==
typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" ");for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,
e,d])};b.__SV=1.2}})(document,window.mixpanel||[]);
mixpanel.init("93079fe0b604caba2424c8bff74d9d6f");</script><!-- end Mixpanel -->

</head>
<body>
<div class="container">
<a href="https://github.com/jrobertfox/DTOx"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub"></a>
{% block content %}
{% endblock %}
</div>
<script src="//static.getclicky.com/js" type="text/javascript"></script>
<script type="text/javascript">try{ clicky.init(100585853); }catch(e){}</script>
<noscript><p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/100585853ns.gif" /></p></noscript>
</body>
</html>
31 changes: 21 additions & 10 deletions web/app.php
Expand Up @@ -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(
Expand All @@ -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);
}
);
Expand Down
51 changes: 30 additions & 21 deletions 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();
};
}

0 comments on commit e060f0e

Please sign in to comment.