Skip to content

Commit

Permalink
add new theme!
Browse files Browse the repository at this point in the history
  • Loading branch information
Blair Anderson committed Mar 16, 2015
1 parent 6d3224b commit f63e2f0
Show file tree
Hide file tree
Showing 27 changed files with 1,344 additions and 127 deletions.
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gem 'active_model_serializers'
gem 'active_api', github: 'blairanderson/active_api'
# gem 'active_api', path: '../active_api'

gem 'bootstrap-sass', '~> 3.3.3'
gem 'jquery-rails'
gem 'pg'
gem 'rails', '4.2.0'
Expand All @@ -16,6 +17,11 @@ gem 'turbolinks'
gem 'uglifier', '>= 1.3.0'
gem 'validate_url'

# This allows us to import bower packages
source 'https://rails-assets.org' do
gem 'rails-assets-bootstrap-material-design'
end

group :production do
gem 'rails_12factor'
end
Expand All @@ -31,6 +37,7 @@ group :development, :test do

gem 'factory_girl_rails'
gem 'faker'
gem 'pry'
gem 'rspec-rails', '~> 3.0' # https://github.com/rspec/rspec-rails
gem 'rspec_api_documentation' # https://github.com/zipmark/rspec_api_documentation
gem 'shoulda-matchers'
Expand Down
21 changes: 20 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: git://github.com/blairanderson/active_api.git
revision: 3a842f983dcb01e6f2e84e5924c5f7f014732290
revision: 37b285bb3d4ba03d907e4b69474fe98d51ab4adb
specs:
active_api (0.0.1)
active_model_serializers
Expand All @@ -10,6 +10,7 @@ GIT

GEM
remote: https://rubygems.org/
remote: https://rails-assets.org/
specs:
actionmailer (4.2.0)
actionpack (= 4.2.0)
Expand Down Expand Up @@ -50,18 +51,25 @@ GEM
tzinfo (~> 1.1)
addressable (2.3.7)
arel (6.0.0)
autoprefixer-rails (5.1.7)
execjs
json
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
bcrypt (3.1.10)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap-sass (3.3.3)
autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.2.19)
builder (3.2.2)
byebug (3.5.1)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
coderay (1.1.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
coffee-rails (4.1.0)
Expand Down Expand Up @@ -124,6 +132,7 @@ GEM
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1)
Expand All @@ -141,6 +150,10 @@ GEM
multi_xml (~> 0.5)
rack (~> 1.2)
pg (0.18.1)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.0)
rack-accept (0.4.5)
rack (>= 0.4)
Expand All @@ -159,6 +172,9 @@ GEM
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.0)
sprockets-rails
rails-assets-bootstrap-material-design (0.2.2)
rails-assets-jquery (~> 2.1.1)
rails-assets-jquery (2.1.3)
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.5)
Expand Down Expand Up @@ -261,12 +277,15 @@ PLATFORMS
DEPENDENCIES
active_api!
active_model_serializers
bootstrap-sass (~> 3.3.3)
byebug
factory_girl_rails
faker
jquery-rails
pg
pry
rails (= 4.2.0)
rails-assets-bootstrap-material-design!
rails_12factor
rspec-rails (~> 3.0)
rspec_api_documentation
Expand Down
73 changes: 44 additions & 29 deletions app/assets/javascripts/admin/root.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,57 @@
var ready = function() {
$('#reset-and-load-from-hn').click(function(e) {
function fetchStory(id, callback) {
$.getJSON('https://hacker-news.firebaseio.com/v0/item/' + id + '.json?print=pretty', function(story, status, jqxhr) {
if (status === "error") {
return callback(status)
} else {
if (story.text) {
story.content = story.text;
}

callback(null, {
item: story,
status: status
});
}
});
}


ready(function() {
$(document).on('click', '#reset-and-load-from-hn', function(e) {
var apiRoot = $(this).data('api');

// use API to fetch all items.
// use api to destroy all items?

debugger

//https://github.com/HackerNews/API
// use api to fetch the top hackernews stories.
$.getJSON("https://hacker-news.firebaseio.com/v0/topstories.json", function(stories, status, jqxhr){
debugger
stories.forEach(function(story) {
var data = {
title: story.title
};

if (story.url){
data.url = story.url;
}
if (story.content){
data.content = story.content;
}

$.ajax({
type: "POST",
url: apiRoot+"/items",
data: data,
success: function(e){
$.getJSON("https://hacker-news.firebaseio.com/v0/topstories.json", function(stories, status, jqxhr) {

stories.forEach(function(story_id) {
fetchStory(story_id, function(error, result) {
if (error || !result.item ) {
console.log('rawr', error, result);
return
}

$.ajax({
type: "POST",
url: apiRoot + "/items",
data: result,
dataType: "JSON",
headers: {
"Authorization": "Token token="+window.current_user.token
}
}).success(function(e) {
debugger

}).error(function(e) {
debugger
},
dataType: "JSON"
});

});
})
});
// use api to add all the hackernews stories
})
};

$(document).ready(ready);
$(document).on('page:load', ready);
})
5 changes: 4 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
//
//= require jquery
//= require jquery_ujs
//= require ready
//= require turbolinks
//= require admin/root
//= require bootstrap
//= require bootstrap-material-design
//= require vendor/bootstrap_material_design_config
6 changes: 6 additions & 0 deletions app/assets/javascripts/ready.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function ready(callback) {
$(document).ready(callback);
$(document).on('page:load', callback);
}

window.ready = ready;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ready(function() {
$.material.init()
})
77 changes: 77 additions & 0 deletions app/assets/javascripts/vendor/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
ready(function() {
var $container = $('.portfolio'),
$items = $container.find('.portfolio-item'),
portfolioLayout = 'fitRows';

if ($container.hasClass('portfolio-centered')) {
portfolioLayout = 'masonry';
}

$container.isotope({
filter: '*',
animationEngine: 'best-available',
layoutMode: portfolioLayout,
animationOptions: {
duration: 750,
easing: 'linear',
queue: false
},
masonry: {}
}, refreshWaypoints());

function refreshWaypoints() {
setTimeout(function() {
}, 1000);
}

$('nav.portfolio-filter ul a').on('click', function() {
var selector = $(this).attr('data-filter');
$container.isotope({filter: selector}, refreshWaypoints());
$('nav.portfolio-filter ul a').removeClass('active');
$(this).addClass('active');
return false;
});

function getColumnNumber() {
var winWidth = $(window).width(),
columnNumber = 1;

if (winWidth > 1200) {
columnNumber = 5;
} else if (winWidth > 950) {
columnNumber = 4;
} else if (winWidth > 600) {
columnNumber = 3;
} else if (winWidth > 400) {
columnNumber = 2;
} else if (winWidth > 250) {
columnNumber = 1;
}
return columnNumber;
}

function setColumns() {
var winWidth = $(window).width(),
columnNumber = getColumnNumber(),
itemWidth = Math.floor(winWidth / columnNumber);

$container.find('.portfolio-item').each(function() {
$(this).css({
width: itemWidth + 'px'
});
});
}

function setPortfolio() {
setColumns();
$container.isotope('reLayout');
}

$container.imagesLoaded(function() {
setPortfolio();
});

$(window).on('resize', function() {
setPortfolio();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*= bootstrap-material-design
*/

@import "bootstrap_and_overrides";
@import "theme";
@import "items";
2 changes: 2 additions & 0 deletions app/assets/stylesheets/bootstrap_and_overrides.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import "bootstrap-sprockets";
@import "bootstrap";
15 changes: 0 additions & 15 deletions app/assets/stylesheets/components/navigation.scss
Original file line number Diff line number Diff line change
@@ -1,15 +0,0 @@
@mixin clearfix() {
&:before,
&:after {
content: " "; // 1
display: table; // 2
}
&:after {
clear: both;
}
}


.row {
@include clearfix();
}
Loading

0 comments on commit f63e2f0

Please sign in to comment.