Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,3 @@ DEPENDENCIES
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)

BUNDLED WITH
1.10.5
11 changes: 11 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
$(document).ready(function(){
var counter = 1;
// this function controls the clicks on the article navigation bar to sort content by time
/*
// DRYing:
function animate_width(el, amount, display_val){
el.animate({width: amount}, 800).css("display", display_val)
}
*/
$(".columns").click(function(){
var self = this
$('h1').each(function(){
Expand All @@ -28,6 +34,7 @@ $(document).ready(function(){
$(this).parent().animate({
width: "100%"
}, 800, function() {})
// This last argument, the function, is an optional parameter
$(this).parent().css("display", "block")
} else {
$(this).parent().animate({
Expand All @@ -47,6 +54,8 @@ $(document).ready(function(){

// this function controls clicks on Guardian content (if it has been loaded after a search) and controls expanding/descreasing the size of the columns
$(".guardianClick").click(function(){
// No need to declare twice
// var self = this
if (counter % 2 != 0) {
var self = this;

Expand All @@ -73,3 +82,5 @@ $(document).ready(function(){
}); // closes guardianClick function

}); // closes document.ready

// If you have to comment your code to remind yourself which brackets close what, you should probably extract a bunch of your code into new, smaller methods.
7 changes: 7 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@
border-bottom: 5px solid #FFAF94;
}

/*
Might make a class for all of these above with:
border-bottom-style: solid;
border-bottom-width: 5px;
That way, you only need to specify the color on each of them.
*/

/*************************content container elements**************************/
.no-overflow {
height: 30px;
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
class ArticlesController < ApplicationController

######## CRUD ROUTES ########

# Don't call them names! They're very sensitive.
#index
def index
if params[:query] != nil
@guardian_article = GuardianArticle.new(params[:query])
end
@articles = Article.all
# Could save some text by making a custom current_user method in your ApplicationController
@user = User.find(session[:user]["id"])
end

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def sign_up!
def sign_in
end

# This is a really long method! Granted, it's pretty much just taken from what we did in class. Still, I'd suggest seeing if you can keep all your methods to 5 lines or fewer. This is an actual programming methodology used by many.
def sign_in!
@user = User.find_by(username: params[:username])
if !@user
Expand All @@ -68,7 +69,7 @@ def sign_in!
message = "You're signed in, #{@user.username}!"
cookies[:username] = {
value: @user.username,

# Watch out for the dangling comma here
}
session[:user] = @user
redirect_to articles_path
Expand Down
1 change: 1 addition & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def most_read?(article)
end

# manages length class assigned to Guardian articles
# This method is included in the Article model. How could you DRY it up?
def ext_length_class(result)
article_length = sanitize(result['fields']['body'], :tags=>[]).split(" ").length
if article_length <= 400
Expand Down
2 changes: 1 addition & 1 deletion app/models/guardian_article.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'httparty'

# Great use of a custom model
class GuardianArticle
API_URL = 'http://content.guardianapis.com'
attr_reader :response, :results, :length
Expand Down
2 changes: 2 additions & 0 deletions app/views/articles/_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
<div class="two columns" id="sixMinutes">6 Minutes</div>
<div class="two columns" id="tenMinutes">10 Minutes</div>
<!-- </div> is added on the index/show pages; don't add it here-->
<!-- How the heck did you manage to center your HTML source code?!-->
<!-- Why not just wrap all these "two columns" in one big div called "two columns" and avoid having to add the class to each of them?-->
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# get '/pins', to: 'pins#index'
# post '/pins', to: 'pins#create'
# Might call this a "save" instead of a like
get '/likes', to: 'likes#create'
# get '/likes/:id', to: 'likes#destroy'
# post '/likes', to: 'likes#create'
Expand Down