Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api #17

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open

Api #17

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d4fe5f1
basic lapse api
May 30, 2014
f9d4953
updated paperclip to v 4.1.1
May 30, 2014
755dc2c
update models with association attribute methods
May 30, 2014
ad191d1
removed extra routes
May 30, 2014
c452bca
cleaned up extra controller methods in api
May 30, 2014
43fd908
added request spec @eprothro will you take a look something in rspec …
May 30, 2014
bdf287c
api covered with test
Jun 4, 2014
619d9d8
removed the puts breaking rspec progress bar
Jun 4, 2014
56a1aaa
removed controller specs
Jun 5, 2014
8036785
cleaned up request specs
Jun 5, 2014
9f84809
changed return method
Jun 5, 2014
bda1185
removed unused helper method
Jun 5, 2014
3633940
code review changes
Jun 5, 2014
ba4ea50
extended spec coverage on moments
Jun 5, 2014
1f8fe82
extended spec coverage on lapses
Jun 5, 2014
aa29ad5
updated lapse api errors
Jun 9, 2014
b569e4b
dirty research with yard
eprothro Jun 5, 2014
b67272c
first stab and purely static docs
eprothro Jun 6, 2014
1d3b47f
fixup
eprothro Jun 6, 2014
ee6137a
some quick and dirty styles
eprothro Jun 6, 2014
6158223
docs with js examples and helpers
eprothro Jun 9, 2014
0183f7d
hacky json layout appending root node
eprothro Jun 9, 2014
9873ae3
Merge pull request #18 from rocketmobile/api-doc
eprothro Jun 9, 2014
f3352f2
syntax highlighting
eprothro Jun 9, 2014
1ce6014
error refactor
Jun 9, 2014
963a974
style tweaks
eprothro Jun 9, 2014
03172b9
update error response format
Jun 10, 2014
f839691
change to json builder gem
Jun 10, 2014
151a23e
add specs for lapse patch with invalid id
Jun 10, 2014
3a4069b
remove erb template and replace with jbuilder
Jun 10, 2014
ad13699
add response status to doc example
eprothro Jun 10, 2014
12d3336
change 422 response to 400
Jun 10, 2014
4f7184b
url param inputs JS
eprothro Jun 10, 2014
7fefa15
update specs for error responses/active record error respose concern
Jun 10, 2014
d92356c
doc copy
eprothro Jun 10, 2014
9043acf
tweaked the param and full messages method
Jun 10, 2014
daa4de7
doc style tweak
eprothro Jun 10, 2014
3d566fb
spec tweak
Jun 10, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ gem 'rack-timeout', github: 'kch/rack-timeout',
# views: asset generation, javascripts, stylesheets
gem 'asset_sync', '~> 1.0.0'
gem 'aws-sdk', '~> 1.30.0'
gem 'foundation-rails', '~> 5.2.1'
gem 'foundation-rails', '~> 5.2.3'
gem 'jquery-fileupload-rails', '~> 0.4.1'
gem 'jquery-rails', '~> 3.0.4'
gem 'jquery-ui-sass-rails', '~> 4.0.3.0'
Expand All @@ -29,7 +29,8 @@ gem 'select2-rails', '~> 3.5.3'
# views: cacheing, templateing, html generation
gem 'dalli', '~> 2.6.4'
gem 'haml-rails', '~> 0.5.2'
gem 'rabl', '~> 0.9.3'
gem 'jbuilder', '~> 2.1.0'
gem 'redcarpet', '~> 3.1.2'
gem 'roadie', '~> 2.4.3'
gem 's3_direct_upload', '~> 0.1.6' # buffer uploading from slow-clients
gem 'will_paginate-foundation', '~> 5.3.3'
Expand All @@ -44,7 +45,7 @@ gem 'will_paginate', '~> 3.0.5'
gem 'delayed_paperclip', '~> 2.6.1' # asyncronous image processing
gem 'devise', '~> 3.2.2'
gem 'hashie', '~> 2.0.5'
gem 'paperclip', '~> 3.5.0' # easy object attachment with s3 storage
gem 'paperclip', '~> 4.1.1'
gem 'ruby-progressbar', '~> 1.4.2'

# operations
Expand Down
21 changes: 12 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ GEM
fog-json (1.0.0)
multi_json (~> 1.0)
formatador (0.2.4)
foundation-rails (5.2.2.0)
foundation-rails (5.2.3.0)
railties (>= 3.1.0)
sass (>= 3.2.0)
fuubar (1.3.3)
Expand Down Expand Up @@ -199,6 +199,9 @@ GEM
ruby_parser (~> 3.1.1)
http_parser.rb (0.6.0)
i18n (0.6.9)
jbuilder (2.1.0)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jquery-fileupload-rails (0.4.1)
actionpack (>= 3.1)
railties (>= 3.1)
Expand Down Expand Up @@ -251,7 +254,7 @@ GEM
nokogiri (1.6.2.1)
mini_portile (= 0.6.0)
orm_adapter (0.5.0)
paperclip (3.5.4)
paperclip (4.1.1)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
Expand All @@ -271,8 +274,6 @@ GEM
websocket (~> 1.0)
quiet_assets (1.0.2)
railties (>= 3.1, < 5.0)
rabl (0.9.3)
activesupport (>= 2.3.14)
rack (1.5.2)
rack-livereload (0.3.15)
rack
Expand Down Expand Up @@ -300,6 +301,7 @@ GEM
rb-fsevent (0.9.4)
rb-inotify (0.9.4)
ffi (>= 0.5.0)
redcarpet (3.1.2)
rest-client (1.6.7)
mime-types (>= 1.16)
roadie (2.4.3)
Expand Down Expand Up @@ -376,7 +378,7 @@ GEM
eventmachine (>= 1.0.0)
rack (>= 1.0.0)
thor (0.19.1)
thread_safe (0.3.3)
thread_safe (0.3.4)
tilt (1.4.1)
timers (1.1.0)
tins (1.3.0)
Expand All @@ -396,7 +398,7 @@ GEM
polyglot (>= 0.3.1)
typhoeus (0.6.8)
ethon (>= 0.7.0)
tzinfo (1.1.0)
tzinfo (1.2.1)
thread_safe (~> 0.1)
uglifier (2.1.2)
execjs (>= 0.3.0)
Expand Down Expand Up @@ -432,7 +434,7 @@ DEPENDENCIES
email_spec (>= 1.2.1)
factory_girl_rails (~> 4.3.0)
faker (~> 1.3.0)
foundation-rails (~> 5.2.1)
foundation-rails (~> 5.2.3)
fuubar
guard (>= 0.6.2)
guard-bundler (>= 0.1.3)
Expand All @@ -445,23 +447,24 @@ DEPENDENCIES
hashie (~> 2.0.5)
honeybadger (~> 1.10)
html2haml
jbuilder (~> 2.1.0)
jquery-fileupload-rails (~> 0.4.1)
jquery-rails (~> 3.0.4)
jquery-ui-sass-rails (~> 4.0.3.0)
lodash-rails (~> 2.4.1)
mailcatcher
modernizr-rails (~> 2.6.2.3)
newrelic_rpm (~> 3.7)
paperclip (~> 3.5.0)
paperclip (~> 4.1.1)
pg (~> 0.17)
pry-nav
pry-rails
quiet_assets
rabl (~> 0.9.3)
rack-livereload
rack-rewrite (~> 1.4)
rack-timeout!
rails (~> 4.1.1)
redcarpet (~> 3.1.2)
roadie (~> 2.4.3)
rspec-rails (>= 2.14.0)
ruby-progressbar (~> 1.4.2)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
//= require jquery
//= require jquery_ujs
//= require puts
//= require prism.min
//= require foundation/foundation
//= require foundation/foundation.alert
//
Expand Down
104 changes: 104 additions & 0 deletions app/assets/javascripts/elements/endpoint_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
function EndpointExample($el) {
var self = this;

self.$el = $el;
self.$form = $el.find('form');
self.$code = $el.find('.response code');
self.$urlParamInputs = self.$form.find('input[data-url-param]');

self.init();
}

EndpointExample.prototype = {
constructor : EndpointExample,

init : function() {
var self = this;
puts('EndpointExample initialized');

self.initUrlParams();

self.$el.on('ajax:send', function(e, data, status, xhr){
self.clearResults();
});

self.$el.on('ajax:success', function(e, data, status, xhr){
self.responseText = xhr.responseText;
self.statusCode = xhr.status;
self.statusText = xhr.statusText;

self.displayResults();
});

self.$el.on('ajax:error', function(e, xhr, status, error){
self.responseText = xhr.responseText;
self.statusCode = xhr.status;
self.statusText = xhr.statusText;

self.displayResults();
});
},

initUrlParams : function() {
var self = this;

// cache the action attr for future re-assignemnts
if(self.$urlParamInputs.length){
self.$form.data('original-action', self.$form.attr('action'))
}

self.$urlParamInputs.on('change keydown paste', function(e){
var $input = $(this);
// edit url param to be new value
// setTimeout to place in buffer after event has completed
// so the value will be present
setTimeout(function(){
var paramName = $input.attr('data-url-param');
var value = $input.val();
var newAction = self.$form.data('original-action').replace(paramName, value);

puts('URL param input edited: replacing form[action] with ' + newAction);
self.$form.attr('action', newAction);
// }
}, 0)
})

},

displayResults : function() {
var self = this;

self.$code.text(self.formattedResults());
Prism.highlightAll();
},

formattedResults : function() {
var self = this;
var formattedString = null;
var jsonString = null;
var statusString = 'HTTP ' + self.statusCode + ' (' + self.statusText + ')';

try {
jsonString = JSON.stringify(JSON.parse(self.responseText), null, 2);
}
catch(err) {
jsonString = self.responseText;
}

formattedString = statusString + '\n\n' + jsonString;

return formattedString;
},

clearResults : function(){
var self = this;

self.$code.text('');
}
}

$(window).load(function(){
$('[data-endpoint-example]').each(function(){
var endpointExample = new EndpointExample($(this));
});
});
66 changes: 66 additions & 0 deletions app/assets/javascripts/elements/expander.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
function Expander($el) {
var self = this;

self.$trigger = $el;

self.settings = {
target: $el.attr('href'),
activeClass: 'expanded'
};
$.extend(self.settings, Foundation.utils.data_options($el, 'expander'));

self.$target = $(self.settings.target);

self.init();
}

Expander.prototype = {
constructor : Expander,

init : function() {
var self = this;
puts('Expander initialized');

if(self.isExpanded()){
self.$trigger.addClass(self.settings.activeClass);
}

self.$trigger.on('click', function(e){
e.preventDefault();
puts('expander trigger clicked');

if(self.isExpanded()){
self.contract();
}else{
self.expand();
}
});
},

expand : function() {
var self = this;
self.$target.slideDown('fast', function(){
self.$trigger.addClass(self.settings.activeClass);
});
},

contract : function() {
var self = this;

self.$target.slideUp('slow', function(){
self.$trigger.removeClass(self.settings.activeClass);
});
},
isExpanded : function() {
var self = this;

return self.$target.is(":visible");
}

}

$(window).load(function(){
$('[data-expander]').each(function(){
new Expander($(this));
});
});
4 changes: 3 additions & 1 deletion app/assets/stylesheets/application.sass
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*= require select2
*= require jquery.ui.core
*= require jquery.ui.datepicker
*= require prism
*
*
* 2. Application specific styles and overrides:
Expand Down Expand Up @@ -63,4 +64,5 @@
// Application Styles
@import partials/navigation
@import partials/footer
@import partials/typography
@import partials/typography
@import partials/documentation
Loading