Skip to content

Commit

Permalink
Building out Common Layout elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jcnetdev committed Jun 12, 2008
1 parent 897137d commit 1543481
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 14 deletions.
15 changes: 15 additions & 0 deletions app/controllers/categories_controller.rb
@@ -0,0 +1,15 @@
class CategoriesController < ApplicationController
def index
@categories = Category.find :all, :order => "position"
end

def show
@category = current_category
end

protected
def current_category
@current_category ||= Category.find_by_value(params[:id])
return @current_category
end
end
15 changes: 15 additions & 0 deletions app/helpers/categories_helper.rb
@@ -0,0 +1,15 @@
module CategoriesHelper
def category_nav_item(category)

li_options = {}

# see if we are displaying the currently selected category
if category == @category
li_options[:class] = "selected"
end

link = link_to "<span>#{category.name}</span><span class='cnr'>&nbsp;</span>", category_url(category), :title => category.name

return content_tag(:li, link, li_options)
end
end
8 changes: 8 additions & 0 deletions app/helpers/jobs_helper.rb
@@ -1,2 +1,10 @@
module JobsHelper
# list last viewed jobs (from session)
def last_viewed_jobs
unless @last_viewed_jobs
@last_viewed_jobs = []
end

return @last_viewed_jobs
end
end
10 changes: 10 additions & 0 deletions app/models/category.rb
@@ -1,2 +1,12 @@
class Category < ActiveRecord::Base
has_many :jobs

def self.list
find :all, :order => "position"
end

def to_param
self.value
end

end
5 changes: 5 additions & 0 deletions app/views/categories/_list.html.haml
@@ -0,0 +1,5 @@
#categories
%ul
- Category.list.each do |category|
= category_nav_item(category)
= clear
25 changes: 25 additions & 0 deletions app/views/layouts/_sidebar.html.haml
@@ -0,0 +1,25 @@
#sidebar
-# display home link (if not already there)
- unless current_page?(root_url)
= link_to "Home", root_url
= br

-# display list of last viewed jobs
- unless last_viewed_jobs.empty?
%h4 Seen Recently
%ul
- last_viewed_jobs.each do |job|
%li= link_to "&raquo; #{job.title}", job_url(job)


-# show stats
- if current_page?(root_url)
= br
#stats
%strong== #{Job.count} total jobs
= br
- Category.list.each do |category|
%strong= category.jobs.size
for
= link_to category.name, category_url(category)
= br
7 changes: 6 additions & 1 deletion app/views/search/_searchbox.html.haml
Expand Up @@ -5,4 +5,9 @@
= text_field_tag :keywords, params[:keywords], :id => "keywords", :class => "example", :maxlength => 30 , :title => "search for a job"
%span#indicator.hidden= image_tag "ajax-loader.gif", :alt => ""
%label.suggestionTop= AppConfig.search_suggestions


.addJob
= link_to "Post a New Job", new_job_url(:cat_id => @category), :class => "add", :title => "Post a New Job"



1 change: 1 addition & 0 deletions config/routes.rb
@@ -1,6 +1,7 @@
ActionController::Routing::Routes.draw do |map|

map.resources :jobs
map.resources :categories
map.resource :search

# map.namespace :admin do |admin|
Expand Down
7 changes: 5 additions & 2 deletions public/javascripts/application.js
@@ -1,2 +1,5 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$j(document).ready(function() {
$j(".example").each(function(index) {
$j(this).example(this.title);
});
});
22 changes: 11 additions & 11 deletions public/stylesheets/styles.css
Expand Up @@ -75,7 +75,7 @@ em {
div#skip { display:none;}
div#container { width:950px; text-align:left; font-size:1.2em; min-height: 100%; height: auto !important; height: 100%; margin: 0 auto 0em; }
div#header { height:120px; width:950px; position:relative;}
div#header h1#logo { width:347px; height:80px; position:absolute; top:25px; left:10px; }
div#header h1#logo { width:347px; height:80px; position:absolute; top:25px; left:20px; }
div#header h1#logo a { width:347px; height:80px; outline:0; background: url(/images/logo.png) 0 0 no-repeat; text-indent:-1000em; float:left; }
div#header ul#top {position:absolute; top:20px; right:20px;}
div#header ul#top li{display:inline; margin-left:2px; background-color:transparent; color:#0099CC;}
Expand Down Expand Up @@ -106,16 +106,16 @@ div#promo a:hover { background: #fff; }
#content ol { margin: 0 0 0 17px;}
#content ul { list-style-type: disc; margin-left: 17px;}

div#categs-nav {background: #0099cc; float: left; width:950px; padding-bottom: 6px; margin-top:25px; font-size: 11px;}
div#categs-nav ul{background: #fff; float: left; width:950px; list-style-type: none; margin:0; padding:0;}
div#categs-nav ul li {background: white; float: left; padding-right: 6px; }
div#categs-nav ul li a{display: block; background: #eee url(/images/sd_left.gif) no-repeat 0 0; background-position: 0 -75px; padding: 4px 0px 4px 6px; float: left; text-decoration: none; color: #333 !important; position: relative; outline: none;}
div#categs-nav ul li a:hover{ background-position: 0 0px; color: #fff !important;}
div#categs-nav ul li.selected a{ background-position: 0 0px; color: #fff !important;}
div#categs-nav ul li a span{display: block; float: left; padding-left: 12px;cursor: pointer; font-size:14px; padding-top:4px; }
div#categs-nav ul li a span.cnr{display: block; background: url(/images/sd_right.gif) no-repeat right 0; background-position: right -75px; float: left; position: relative; top:-4px;}
div#categs-nav ul li a:hover span.cnr{ background-position: right 0px; cursor: pointer; }
div#categs-nav ul li.selected a span.cnr{ background-position: right 0px; cursor: pointer; }
div#categories {background: #0099cc; float: left; width:950px; padding-bottom: 6px; margin-top:25px; font-size: 11px;}
div#categories ul{background: #fff; float: left; width:950px; list-style-type: none; margin:0; padding:0;}
div#categories ul li {background: white; float: left; padding-right: 6px; }
div#categories ul li a{display: block; background: #eee url(/images/sd_left.gif) no-repeat 0 0; background-position: 0 -75px; padding: 4px 0px 4px 6px; float: left; text-decoration: none; color: #333 !important; position: relative; outline: none;}
div#categories ul li a:hover{ background-position: 0 0px; color: #fff !important;}
div#categories ul li.selected a{ background-position: 0 0px; color: #fff !important;}
div#categories ul li a span{display: block; float: left; padding-left: 12px;cursor: pointer; font-size:14px; padding-top:4px; }
div#categories ul li a span.cnr{display: block; background: url(/images/sd_right.gif) no-repeat right 0; background-position: right -75px; float: left; position: relative; top:-4px;}
div#categories ul li a:hover span.cnr{ background-position: right 0px; cursor: pointer; }
div#categories ul li.selected a span.cnr{ background-position: right 0px; cursor: pointer; }

#sitemap-1 {float: left; display: inline; width: 200px;}
#sitemap-2 {float: left; display: inline; width: 200px; margin-left: 30px;}
Expand Down
8 changes: 8 additions & 0 deletions test/functional/categories_controller_test.rb
@@ -0,0 +1,8 @@
require 'test_helper'

class CategoriesControllerTest < ActionController::TestCase
# Replace this with your real tests.
def test_truth
assert true
end
end

0 comments on commit 1543481

Please sign in to comment.