Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

IT'S WORKING

  • Loading branch information...
commit ad05088c59fac516dd97f7f5a02e17e7736a41ba 1 parent 1ac6f03
@dbc-apprentice dbc-apprentice authored
View
9 app/controllers/static_pages_controller.rb
@@ -0,0 +1,9 @@
+class StaticPagesController < ApplicationController
+ def show
+ if File.exist? "app/views/static_pages/#{params[:page]}.html"
+ render params[:page]
+ else
+ render '404'
+ end
+ end
+end
View
10 app/models/post.rb
@@ -24,5 +24,15 @@ def author
user.name
end
+ def self.ordered_by(param)
+ case param
+ when 'title' then Article.order('title')
+ when 'published' then Article.order('created_at DESC')
+ # length of body - all the spaces from the body = pseudo word count (body + body - spaces)
+ # Article.order('LENGTH(body)') <-- small version
+ when 'word_count'then Article.order('(LENGTH(body) - (LENGTH(REPLACE(body, " ", "")))) DESC')
+ else Article.all
+ end
+ end
end
View
8 app/views/layouts/application.html.erb
@@ -56,7 +56,9 @@
<% else %>
<li><%= link_to "Sign In", signin_path%></li>
<% end %>
- <li><%= link_to "Random Post", post_path(Post.random_post) %></li>
+ <% if Post.count > 0 %>
+ <li><%= link_to "Random Post", post_path(Post.random_post) %></li>
+ <% end %>
<% if signed_in? %>
<div class="brand"><%= link_to "Welcome, #{current_user.name}!", current_user %> </div>
<% end %>
@@ -98,7 +100,9 @@
<% else %>
<li><%= link_to "Why Join Us?", "/about" %></li>
<% end %>
- <li><%= link_to "Random Post", post_path(Post.random_post) %></li>
+ <% if Post.count > 0 %>
+ <li><%= link_to "Random Post", post_path(Post.random_post) %></li>
+ <% end %>
<li><%= link_to "Our Fav Post", "/posts/31" %></li>
</ul>
View
2  app/views/posts/index.html.erb
@@ -31,7 +31,7 @@
</table>
-<%= paginate @posts_sorted %>
+ <%= paginate @posts_sorted %>
<br /> <b><%= link_to 'Submit a new Post!', new_post_path %></b>
View
29 app/views/static_pages/404.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>The page you were looking for doesn't exist (404)</title>
+<img src="http://i.imgur.com/bJRBY.gif">
+ <style type="text/css">
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
+ div.dialog {
+ width: 25em;
+ padding: 0 4em;
+ margin: 4em auto 0 auto;
+/* border: 1px solid #ccc;*/
+ border-right-color: #999;
+ border-bottom-color: #999;
+ font-size:20px;
+ }
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
+ </style>
+</head>
+
+<body>
+ <!-- This file lives in public/404.html -->
+ <div class="dialog">
+ <h1>404: ERROR</h1>
+<h1>WHAT 'CHU LOOKIN' FOR!?</h1>
+ <p>Check yourself before you wreck yourself.</p>
+ </div>
+</body>
+</html>
View
7 app/views/static_pages/about.html
@@ -0,0 +1,7 @@
+<head>
+ <link rel="stylsheet" type="text/css" href="/stylesheet.css" />
+</head>
+
+<h1> BECAUSE WE ARE SO AWESOME </h1>
+
+<p>...now <a href="/"> take me back to XXCombinator </a></p
View
1  config/routes.rb
@@ -19,6 +19,7 @@
match '/signup', to: 'users#new'
match '/signin', to: 'sessions#new'
match '/signout', to: 'sessions#destroy'
+ get '/:page', to: 'static_pages#show'
View
BIN  public/assets/application-28459baf3436d7d86fbe9d8261e12227.css.gz
Binary file not shown
View
BIN  public/assets/application-7ea18deb78a3b2828f035b338dcbe15f.js.gz
Binary file not shown
View
8,147 public/assets/application.css
1 addition, 8,146 deletions not shown
View
BIN  public/assets/application.css.gz
Binary file not shown
View
11,685 public/assets/application.js
4 additions, 11,681 deletions not shown
View
BIN  public/assets/application.js.gz
Binary file not shown
View
18 public/assets/manifest.yml
@@ -1,10 +1,10 @@
---
-rails.png: rails.png
-application.js: application.js
-application.css: application.css
-fontawesome-webfont.eot: fontawesome-webfont.eot
-fontawesome-webfont.svg: fontawesome-webfont.svg
-fontawesome-webfont.ttf: fontawesome-webfont.ttf
-fontawesome-webfont.woff: fontawesome-webfont.woff
-twitter/bootstrap/glyphicons-halflings-white.png: twitter/bootstrap/glyphicons-halflings-white.png
-twitter/bootstrap/glyphicons-halflings.png: twitter/bootstrap/glyphicons-halflings.png
+rails.png: rails-be8732dac73d845ac5b142c8fb5f9fb0.png
+application.js: application-7ea18deb78a3b2828f035b338dcbe15f.js
+application.css: application-28459baf3436d7d86fbe9d8261e12227.css
+fontawesome-webfont.eot: fontawesome-webfont-7cf1b0de49e2f8672c9ad6d9e382115f.eot
+fontawesome-webfont.svg: fontawesome-webfont-4d19fdd70a080778557b652cb4868557.svg
+fontawesome-webfont.ttf: fontawesome-webfont-1e29be0bb354c9f664cbca7df9a966d8.ttf
+fontawesome-webfont.woff: fontawesome-webfont-9c0e35b95bf9cea29c77678ebf71a29d.woff
+twitter/bootstrap/glyphicons-halflings-white.png: twitter/bootstrap/glyphicons-halflings-white-13553a5bf21ae3cc374006592488ec64.png
+twitter/bootstrap/glyphicons-halflings.png: twitter/bootstrap/glyphicons-halflings-f6675c325532ec11a984d58e172b8e2a.png
Please sign in to comment.
Something went wrong with that request. Please try again.