Skip to content

Commit

Permalink
Everything ready to go - serving the client app as a stand-alone HTML…
Browse files Browse the repository at this point in the history
…5 app.
  • Loading branch information
Rodolfo Carvalho committed Aug 9, 2013
1 parent f91341a commit 0b361fc
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 23 deletions.
21 changes: 6 additions & 15 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,15 @@ module.exports = function(grunt) {
watch: {
coffee: {
files: coffeePaths,
tasks: ['coffeelint', 'coffee', 'copy:js', 'concat:application_js', 'karma'],
options: {
atBegin: true,
}
tasks: ['coffeelint', 'coffee', 'copy:js', 'concat:application_js', 'karma']
},
less: {
files: [assetPath('src/less/*.less'), assetPath('src/less/**/*.less')],
tasks: ['less', 'copy:css', 'concat:screen_css'],
options: {
atBegin: true,
}
tasks: ['less', 'copy:css', 'concat:screen_css']
},
html: {
files: [assetPath('src/*.html'), assetPath('src/**/*.html')],
tasks: ['copy:html', 'copy:images'],
options: {
atBegin: true,
}
tasks: ['copy:html', 'copy:images']
}
},

Expand Down Expand Up @@ -180,7 +171,7 @@ module.exports = function(grunt) {
endpoint: 'http://pyregex.com/api'
},
development: {
endpoint: '/api'
endpoint: 'http://localhost:5000/api'
}
},

Expand Down Expand Up @@ -224,7 +215,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-s3-sync')
grunt.loadNpmTasks('grunt-s3-sync');

grunt.event.on('watch', function(action, filepath, target) {
grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
Expand All @@ -243,6 +234,6 @@ module.exports = function(grunt) {
grunt.registerTask('deploy', ['clean', 'build_prod', 's3-sync'])
grunt.registerTask('test', ['karma']);

grunt.registerTask('default', ['clean', 'watch']);
grunt.registerTask('default', ['clean', 'build', 'watch']);
grunt.registerTask('server', ['build', 'connect']);
};
3 changes: 2 additions & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
web: uwsgi uwsgi.ini
grunt: grunt
grunt_watch: grunt
grunt_server: grunt connect
5 changes: 4 additions & 1 deletion assets/src/coffee/main.coffee
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
"use strict"

config = ($locationProvider, $routeProvider) ->
config = ($locationProvider, $routeProvider, $httpProvider) ->
$locationProvider.html5Mode(true)

$routeProvider.when('/',
templateUrl: '/assets/templates/index.html'
controller: 'RegexParserController').
otherwise(redirectTo: '/')

$httpProvider.defaults.useXDomain = true
delete $httpProvider.defaults.headers.common['X-Requested-With']

app = angular.module('pyregex', ['ui.select2']).config(config)

l = location
Expand Down
4 changes: 2 additions & 2 deletions assets/src/html/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h1>Your Python Regular Expression's Best Buddy</h1>
</div>
<div class="form-inline">
<label>&gt;&gt;&gt; re.compile(regex, flags).
<select ng-model="re.matchType" ui-select2>
<select ng-model="re.matchType" ui-select2 ng-change="getResults()">
<option>match</option>
<option>findall</option>
<option>search</option>
Expand All @@ -35,6 +35,6 @@ <h1>Your Python Regular Expression's Best Buddy</h1>
</div>
</div>
<div class="span5">
<div class="well" ng-include src="resultTemplateUrl"></div>
<div class="well" ng-include src="resultTemplateUrl" ng-animage="'scale'"></div>
</div>
</div>
25 changes: 25 additions & 0 deletions assets/src/less/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,29 @@ div.container {
overflow: auto;
}
}
}

/*
The animate-enter prefix is the event name that you
have provided within the ngAnimate attribute.
*/
.animate-enter-setup {
-webkit-transition: 1s linear all; /* Safari/Chrome */
-moz-transition: 1s linear all; /* Firefox */
-ms-transition: 1s linear all; /* IE10 */
-o-transition: 1s linear all; /* Opera */
transition: 1s linear all; /* Future Browsers */

/* The animation preparation code */
opacity: 0;
}

/*
Keep in mind that you want to combine both CSS
classes together to avoid any CSS-specificity
conflicts
*/
.animate-enter-setup.animate-enter-start {
/* The animation code itself */
opacity: 1;
}
5 changes: 5 additions & 0 deletions pyregex/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class ApiBaseResource(webapp2.RequestHandler):
def api_error(self, message, *args):
return dict(result_type='error', message=message % args)

def options(self):
self.response.headers['Access-Control-Allow-Origin'] = "*"
self.response.headers['Access-Control-Allow-Method'] = "GET"
return self.response


class RegexResource(ApiBaseResource):
__urls__ = ('regex/', 'regex/<key>', 'regex/test/')
Expand Down
1 change: 0 additions & 1 deletion pyregex/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def route_dispatcher(router, request, response):
rv = webapp2.Response(*rv)

rv.headers['Access-Control-Allow-Origin'] = "*"
rv.headers['Access-Control-Allow-Methods'] = "GET"
return rv

application = webapp2.WSGIApplication(routes, debug=True)
Expand Down
3 changes: 2 additions & 1 deletion tests/client/controllers/regex_parser_controller_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ describe "RegexParserController", ->

inject (_$httpBackend_) ->
$httpBackend = _$httpBackend_
$httpBackend.expectGET('/api/regex/test/?' + data).
baseUrl = 'http://localhost:5000/api'
$httpBackend.expectGET(baseUrl + '/regex/test/?' + data).
respond(result_type: 'success', match_type: 'search')

expect($scope.processing).toBe false
Expand Down
2 changes: 1 addition & 1 deletion tests/client/module_config_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe "App Configuration", ->
beforeEach module('pyregex')

it "should have a value for API endpoint", inject (apiUrl) ->
expect(apiUrl).toBe('/api')
expect(apiUrl).toBe('http://localhost:5000/api')

describe "factories", ->
it "should reflect jQuery global object", inject (jQuery) ->
Expand Down
4 changes: 3 additions & 1 deletion uwsgi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ memory-report = true
enable-threads = true

static-index = index.html
static-map = /=public/
static-map = /=public/

touch-reload = .

0 comments on commit 0b361fc

Please sign in to comment.