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

Updated the UI #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ gem 'coffee-rails', '~> 4.0.0'
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
Expand Down
25 changes: 19 additions & 6 deletions app/assets/stylesheets/waywework.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,34 @@ blockquote,pre {background-color: #eee; padding: 10px; font-size: 11px; }
#message {padding: 14px; z-index: 100000; position: fixed; top: 38%; left: 40%; display: none; background: #78c89d; color: #222; font-size: 28px;}
#waiter {z-index:100000; position:fixed; background:white; display: none; height: 13px; width: 208px; border:0px; top: 50%; left: 50%; margin: -6px 0 0 -104px;}

.blogs .row { clear: both;} .blogs .row .col { width: 20%; margin: 1%; background-color: #fff; color: #777; float: left; height: 35em; border: 1px #eee solid; overflow-x: auto; overflow-y: hidden; font-family: SourceSansProRegular; width: 22%;}
.blogs .row { clear: both;}
.blogs .row .col { margin: 1%; background-color: #fff; color: #777; float: left; height: 35em; border: 1px #eee solid; overflow-x: auto; overflow-y: hidden; font-family: SourceSansProRegular;}
.blogs .row .col img { max-width: 100%; height: auto !important; }
.col .post-container { overflow-y: hidden; overflow-x: auto; height: 32em;}
.col .container-red, .col .container-green, .col .container-orange, .col .container-blue, .col .container-lime, .col .container-purple, .col .container-yellow, .col .container-black {min-height: 93%; padding: 5%; }
.col .container-red { border-bottom: 8px solid #E78E94; } .col .container-green { border-bottom: 8px solid #A2DBE2; } .col .container-orange { border-bottom: 8px solid #FE8142; } .col .container-blue { border-bottom: 8px solid #88BBDE; }
.col a { color: inherit;} .col h1 { margin-top: 0; padding-top: 0.25em; }
.col .container-purple { border-bottom: 8px solid #D895C6;} .col .container-yellow { border-bottom: 8px solid #FDCD49;} .col .container-black { border-bottom: 8px solid #3C3431;} .col .container-lime { border-bottom: 8px solid #FEEB43; }
.col.red h1 a { color: #E78E94;} .col.green h1 a { color: #A2DBE2;} .col.orange h1 a { color: #FE8142; } .col.blue h1 a { color: #88BBDE; } .col.purple h1 a { color: #D895C6;} .col.yellow h1 a { color: #FDCD49;} .col.black h1 a { color: #3C3431;} .col.lime h1 a { color: #FEEB43; }
.col h2 {font-size: 1em;font-style: italic; color: #BBB;}

@media all and (min-width: 1025px) {
.blogs .row .col { width: 22%;}
.col .container-red, .col .container-green, .col .container-orange, .col .container-blue, .col .container-lime, .col .container-purple, .col .container-yellow, .col .container-black {min-height: 93%; padding: 5%; }
}
@media all and (min-width: 400px) and (max-width: 1024px) {
.blogs .row .col { width: 45%;}
.col .container-red, .col .container-green, .col .container-orange, .col .container-blue, .col .container-lime, .col .container-purple, .col .container-yellow, .col .container-black {min-height: 95%; padding: 2% 5%; }
}
@media all and (max-width: 399px) {
.blogs .row .col { width: 95%;}
.col .container-red, .col .container-green, .col .container-orange, .col .container-blue, .col .container-lime, .col .container-purple, .col .container-yellow, .col .container-black {min-height: 96%; padding: 2% 5%; }
}

nav {
margin: 0;
height: 3em;
margin-bottom: 2em;
padding: 0 1em;
display: inline-block;
}
nav ul {
display: inline-block;
Expand All @@ -87,7 +101,7 @@ margin: 0;
padding: 0;
}
nav ul li {
float: left;
display: inline-block;
}
nav ul li a {
color: #736D64;
Expand Down Expand Up @@ -145,5 +159,4 @@ padding: 5px;
#authors li a { text-decoration: none; color: #666;}
#archives li a { text-decoration: none; }
#archives { padding: 0 1em; }


a.nextPage { background: #ddd; border: 1px solid #ccc; margin: 1%; padding: 0.5em 3em; }
22 changes: 15 additions & 7 deletions app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,23 @@ def twitter_username_with_at_sign

def tweet
if Rails.env.production?
begin
short_url_length = 20 # should query as this may change. See https://dev.twitter.com/docs/tco-link-wrapper/faq#Will_t.co-wrapped_links_always_be_the_same_length
non_title_part_of_tweet = " #{'x'*short_url_length} via #{twitter_username_with_at_sign}"
max_title_length = 140 - non_title_part_of_tweet.length
if newPost?
begin
short_url_length = 20 # should query as this may change. See https://dev.twitter.com/docs/tco-link-wrapper/faq#Will_t.co-wrapped_links_always_be_the_same_length
non_title_part_of_tweet = " #{'x'*short_url_length} via #{twitter_username_with_at_sign}"
max_title_length = 140 - non_title_part_of_tweet.length

Twitter.update("#{title.truncate(max_title_length)} #{url_with_source_and_medium('twitter')} via #{twitter_username_with_at_sign}")
rescue
puts "there was an error sending the tweet"
Twitter.update("#{title.truncate(max_title_length)} #{url_with_source_and_medium('twitter')} via #{twitter_username_with_at_sign}")
rescue
puts "there was an error sending the tweet"
end
end
end

end

def newPost?
two_days_ago = (Date.today - 2)
published && published > two_days_ago
end
end
6 changes: 6 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="keywords" content="java, .net, c#, ruby, rails, nodejs, javascript, angularjs, agile, scrum">
<meta name="description" content="blog feed aggregator of various technology sites">

<title>Way We Work</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
Expand Down
29 changes: 18 additions & 11 deletions app/views/posts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
</nav>

<%= render 'posts/posts'%>
<div class="row">
<a class="nextPage" onclick="javascript:nextPage();">More</a>
</div>
</div>

</div>
Expand All @@ -34,20 +37,24 @@ var endOfDoc = false;
$(window).scroll(function(){
if(!endOfDoc){
if ($(window).scrollTop() >= $(document).height() - $(window).height()) {
endOfDoc = true;
page++;
var path = document.location.href;

if (document.location.pathname === "/") path = document.location.href + "posts/all";

$(".next-page").last().append().load(path + '/' + page,function(event){
endOfDoc = false;
//event.preventDefault();
return false;
});
nextPage();
};
};
});

function nextPage() {
endOfDoc = true;
page++;
var path = document.location.href;

if (document.location.pathname === "/") path = document.location.href + "posts/all";

$(".next-page").last().append().load(path + '/' + page,function(event){
endOfDoc = false;
//event.preventDefault();
return false;
});
}

</script>

2 changes: 1 addition & 1 deletion spec/atom2.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;DEYCRH87fSp7ImA9WxRXFUg.&quot;'><id>tag:blogger.com,1999:blog-7658573079763034733</id><updated>2008-10-20T19:29:25.105-07:00</updated><title>easy_software = Agile.find(ruby_on_rails)</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gouravtiwari.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://gouravtiwari.blogspot.com/feeds/posts/default'/><link rel='alternate' type='text/html' href='http://gouravtiwari.blogspot.com/'/><author><name>Gourav Tiwari</name><uri>http://www.blogger.com/profile/15757586299976339864</uri><email>[email protected]</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage>


<entry gd:etag='W/&quot;DEYCRH09fCp7ImA9WxRXFUg.&quot;'><id>tag:blogger.com,1999:blog-7658573079763034733.post-1670715680510439958</id><published>2008-10-19T08:50:00.000-07:00</published><updated>2008-10-20T19:29:25.364-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2008-10-20T19:29:25.364-07:00</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='Rails'/><title>Title for my first post</title><content type='html'>&lt;span style="font-size:85%;"&gt; Recently, I joined a new project.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://gouravtiwari.blogspot.com/feeds/1670715680510439958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7658573079763034733&amp;postID=1670715680510439958' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7658573079763034733/posts/default/1670715680510439958?v=2'/><link rel='self' type='application/atom+xml' href='http://gouravtiwari.blogspot.com/feeds/posts/default/1670715680510439958'/><link rel='alternate' type='text/html' href='http://gouravtiwari.blogspot.com/2008/10/if-you-smell-something-stinking-flog-it.html' title='If you smell something stinking, flog it!!!'/><author><name>Gourav Tiwari</name><uri>http://www.blogger.com/profile/15757586299976339864</uri><email>[email protected]</email></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_q-Yw-1yDoHc/SP06ZvLnmQI/AAAAAAAACWk/NO2M438pvs0/s72-c/example.bmp' height='72' width='72'/></entry>
<entry gd:etag='W/&quot;DEYCRH09fCp7ImA9WxRXFUg.&quot;'><id>tag:blogger.com,1999:blog-7658573079763034733.post-1670715680510439958</id><published>2008-10-19T08:50:00.000Z</published><updated>2008-10-20T19:29:25.364Z</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2008-10-20T19:29:25.364Z</app:edited><category scheme='http://www.blogger.com/atom/ns#' term='Ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='Rails'/><title>Title for my first post</title><content type='html'>&lt;span style="font-size:85%;"&gt; Recently, I joined a new project.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://gouravtiwari.blogspot.com/feeds/1670715680510439958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7658573079763034733&amp;postID=1670715680510439958' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7658573079763034733/posts/default/1670715680510439958?v=2'/><link rel='self' type='application/atom+xml' href='http://gouravtiwari.blogspot.com/feeds/posts/default/1670715680510439958'/><link rel='alternate' type='text/html' href='http://gouravtiwari.blogspot.com/2008/10/if-you-smell-something-stinking-flog-it.html' title='If you smell something stinking, flog it!!!'/><author><name>Gourav Tiwari</name><uri>http://www.blogger.com/profile/15757586299976339864</uri><email>[email protected]</email></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_q-Yw-1yDoHc/SP06ZvLnmQI/AAAAAAAACWk/NO2M438pvs0/s72-c/example.bmp' height='72' width='72'/></entry>
</feed>
2 changes: 1 addition & 1 deletion spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
contents { Faker::Lorem.paragraphs.join(' ') }
title { Faker::Lorem.words.join(' ') }
url { "#{feed.url}/#{title.gsub(' ', '/')}" }
published { rand(10).days.ago }
published { rand(1).days.ago }
end
end

2 changes: 1 addition & 1 deletion spec/models/feed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
it 'should parse an atom feed from blogger' do
feed = Feed.create!(@valid_attributes)
xml=IO.read(File.join(Rails.root, 'spec', 'atom2.xml'))
feed.should_receive(:create_post).with(hash_including(:contents=>'<span style="font-size:85%;"> Recently, I joined a new project.</span>', :category=>nil, :title=>'Title for my first post', :url=>'http://gouravtiwari.blogspot.com/2008/10/if-you-smell-something-stinking-flog-it.html')).and_return(post1=mock('post1'))
feed.should_receive(:create_post).with(hash_including(:contents=>'<span style="font-size:85%;"> Recently, I joined a new project.</span>', :category=>nil, :title=>'Title for my first post', :published=>Time.zone.parse('2008-10-19 08:50:00').to_s(:db), :updated=>Time.zone.parse("2008-10-20 19:29:25").to_s(:db), :url=>'http://gouravtiwari.blogspot.com/2008/10/if-you-smell-something-stinking-flog-it.html')).and_return(post1=mock('post1'))
feed.stub!(:puts)
feed.get_posts_from_atom(xml)
end
Expand Down
11 changes: 10 additions & 1 deletion spec/models/post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
end
describe 'for feed with a twitter account' do
before { Twitter.should_receive(:follow).with('alexrothenberg') }
it 'should tweet when' do
it 'should tweet' do
Twitter.should_receive(:update).
with('This is an interesting blog post http://some.blog.com/2011/about_stuff?utm_source=waywework&utm_medium=twitter via @alexrothenberg')

Expand All @@ -57,6 +57,15 @@
:url => 'http://some.blog.com/2011/about_stuff',
:feed => feed_with_twitter_account)
end
it 'should not tweet when the post is too old' do
Twitter.should_not_receive(:update).
with('This is an interesting blog post http://some.blog.com/2011/about_stuff?utm_source=waywework&utm_medium=twitter via @alexrothenberg')

FactoryGirl.create(:post, :title => 'This is an interesting blog post',
:url => 'http://some.blog.com/2011/about_stuff',
:feed => feed_with_twitter_account,
:published => 10.days.ago)
end
end
end
describe 'in Development does not tweet' do
Expand Down