##Web Application Code##
Within the request handling code:
_ = require('underscore');
var user = new User(_.pick(req.body, User.userCreateSafeFields));
Within the User model:
UserSchema.statics = {
| HTTP/1.1 200 OK | |
| Content-Type: application/json; charset=utf-8 | |
| X-UA-Compatible: IE=Edge | |
| ETag: "6b4caf343a20865de174b2b530b945dd" | |
| Cache-Control: max-age=0, private, must-revalidate | |
| X-Request-Id: c3b0a57861087c0b827aab231747ef0c | |
| X-Runtime: 0.051734 | |
| Connection: close | |
| {"admin":false,"created_at":"2014-01-23T16:17:10Z","email": | 
| def show | |
| respond_with @user.as_json | |
| end | 
| <script type='text/javascript'> | |
| jwplayer('my-video').setup({ | |
| primary: "flash", | |
| sources: [ | |
| {file: <%= sanitize(@video.signed_html5.inspect) %>}, | |
| {file: <%= sanitize(@video.signed_flash.inspect) %>} | |
| ], | |
| skin: 'someSkin', | |
| flashplayer: <%= sanitize(asset_path('swf/jwplayer.flash.swf').inspect) %>, | 
| # cf_url is http://dSomething.cloudfront.net/path | |
| # video_name is test.mp4 | |
| def signed_html5 | |
| parsed_uri = URI.parse(cf_url) | |
| url = "#{parsed_uri.scheme}://#{parsed_uri.host}#{parsed_uri.path}/#{video_name}" | |
| signed_url = sign(url) | |
| end | |
| # cf_url is http://dSomething.cloudfront.net/path | |
| # video_name is test.mp4 | 
| # AWS URL Signing Gem | |
| gem 'aws_cf_signer' | 
| # Add config/keys/pk-someRandomString.pem to your .gitignore file so... | |
| # that it isn't stored in source code repos | |
| key_file = Rails.root.join("config", "keys", "pk-someRandomString.pem") | |
| SIGNER = AwsCfSigner.new(key_file) | |
##Web Application Code##
Within the request handling code:
_ = require('underscore');
var user = new User(_.pick(req.body, User.userCreateSafeFields));
Within the User model:
UserSchema.statics = {
##Client Request##
The following is a post request sent by a user during the registration process
POST /api/create_user HTTP/1.1
Accept: application/json
Content-Type: application/json;charset=UTF-8
Host: localhost
Connection: Keep-Alive
Accept-Encoding: gzip
| /* | |
| To use this file, save it to a JS file and include it (<script src=) or | |
| wrap it in <script type="text/javascript"> </script> tags on the page you are embedding the code on. | |
| 1) When you craft the script tag for including the gist assign it a class="embed-gist" | |
| 2) Give a file parameter, this is the name of the file, this is something absolutely necessary, | |
| needs to be the first parameter (before lines) | |
| cd /usr/share/tomcat7 | |
| sudo ln –s /var/lib/tomcat7/conf conf | |
| sudo ln –s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy | |
| sudo ln –s /var/log/tomcat7 log | |
| sudo chmod –R 777 /usr/share/tomcat7/conf |