From 2f899f227414ec2e61fed3ac2b509aee2b105b93 Mon Sep 17 00:00:00 2001 From: Jared Pace Date: Wed, 4 Aug 2010 21:42:15 -0500 Subject: [PATCH] Add a project index page supplemented with a simple, hopefully temporary, theme --- app/controllers/projects_controller.rb | 7 +++++++ app/helpers/navigation_helper.rb | 37 +++++++++++++++++++++++++++++++++++++ app/models/project.rb | 1 + app/views/layouts/application.html.erb | 14 -------------- app/views/layouts/application.html.haml | 28 ++++++++++++++++++++++++++++ app/views/mailer/error_notification.text.erb | 2 +- app/views/projects/index.html.haml | 12 ++++++++++++ app/views/shared/_flash_messages.html.haml | 4 ++++ app/views/shared/_navigation.html.haml | 5 +++++ config/routes.rb | 9 +++++++-- public/stylesheets/application.css | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/stylesheets/images/icons/.DS_Store | Bin 0 -> 6148 bytes public/stylesheets/images/icons/cross.png | Bin 0 -> 473 bytes public/stylesheets/images/icons/error.png | Bin 0 -> 695 bytes public/stylesheets/images/icons/notice.png | Bin 0 -> 157 bytes public/stylesheets/images/icons/success.png | Bin 0 -> 393 bytes public/stylesheets/images/notebook.png | Bin 0 -> 133 bytes public/stylesheets/reset.css | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ spec/controllers/projects_controller_spec.rb | 14 ++++++++++++++ 19 files changed, 351 insertions(+), 17 deletions(-) create mode 100644 app/controllers/projects_controller.rb create mode 100644 app/helpers/navigation_helper.rb delete mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/layouts/application.html.haml create mode 100644 app/views/projects/index.html.haml create mode 100644 app/views/shared/_flash_messages.html.haml create mode 100644 app/views/shared/_navigation.html.haml create mode 100644 public/stylesheets/application.css create mode 100644 public/stylesheets/images/icons/.DS_Store create mode 100755 public/stylesheets/images/icons/cross.png create mode 100755 public/stylesheets/images/icons/error.png create mode 100644 public/stylesheets/images/icons/notice.png create mode 100755 public/stylesheets/images/icons/success.png create mode 100644 public/stylesheets/images/notebook.png create mode 100644 public/stylesheets/reset.css create mode 100644 spec/controllers/projects_controller_spec.rb diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb new file mode 100644 index 0000000..3292768 --- /dev/null +++ b/app/controllers/projects_controller.rb @@ -0,0 +1,7 @@ +class ProjectsController < ApplicationController + + def index + @projects = Project.all + end + +end diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb new file mode 100644 index 0000000..c817219 --- /dev/null +++ b/app/helpers/navigation_helper.rb @@ -0,0 +1,37 @@ +module NavigationHelper + + # Returns ' active' if you are on a given controller + # - active_if_here(:users) => ' active' if users controller + # Or on one of a list of controllers + # - active_if_here([:users, :blogs, :comments]) + # Or on certain action(s) in a certain controller + # - active_if_here(:users => :index, :blogs => [:create, :update], :comments) + # + # Useful for navigation elements that have a certain state when your on a given page. + # Returns nil if there are no matches so when passing: + # link_to 'link', '#', :class => active_if_here(:users) + # will not even set a class attribute if nil is passed back. + def active_if_here(matches) + current_controller = controller.controller_name.to_sym + current_action = controller.action_name.to_sym + + sections = case matches + when Hash + matches + when Array + s = {} + matches.each {|c| s[c] = :all} + s + else + {matches => :all} + end + + active = nil + sections.each do |controller, actions| + actions = ([] << actions) unless actions.kind_of?(Array) + active = ' active' if current_controller == controller && (actions.include?(:all) || actions.include?(current_action)) + end + active + end + +end \ No newline at end of file diff --git a/app/models/project.rb b/app/models/project.rb index 52ebeab..9c2e548 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -4,6 +4,7 @@ class Project field :name, :type => String field :api_key + key :name embeds_many :watchers embeds_many :deploys diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb deleted file mode 100644 index db98c67..0000000 --- a/app/views/layouts/application.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - - - Hypnotoad - <%= stylesheet_link_tag :all %> - <%= javascript_include_tag :defaults %> - <%= csrf_meta_tag %> - - - -<%= yield %> - - - diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml new file mode 100644 index 0000000..334f531 --- /dev/null +++ b/app/views/layouts/application.html.haml @@ -0,0 +1,28 @@ +!!! html +%html + %head + %title + Cartless — + = yield(:page_title).present? ? yield(:page_title) : yield(:title) + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "content-type" }/ + = javascript_include_tag :defaults + = stylesheet_link_tag 'reset', 'application' + = yield :head + %body{:id => controller.controller_name, :class => controller.action_name} + #header + = link_to 'Hypnotoad', root_path, :id => 'site-name' + + = render :partial => 'shared/navigation' + + #content-title + %h1= yield :title + %span.meta= yield :meta + - if action_bar = yield(:action_bar) + #action-bar + = action_bar + #content + = render :partial => 'shared/flash_messages' + = yield + #footer + Powered by Hypnotoad. All Glory to the Hypnotoad. + = yield :scripts \ No newline at end of file diff --git a/app/views/mailer/error_notification.text.erb b/app/views/mailer/error_notification.text.erb index 4a6d67c..4f8b253 100644 --- a/app/views/mailer/error_notification.text.erb +++ b/app/views/mailer/error_notification.text.erb @@ -2,6 +2,6 @@ An error has just occurred in <%= @notice.err.environment %>: <%= @notice.err.me This error has occurred <%= pluralize @notice.err.notices.count, 'time' %>. You should really look into it here: - <%= error_notice_url(@notice.err, @notice) %> + <%= project_err_notice_url(@project, @notice.err, @notice) %> <%= render :partial => 'signature' %> \ No newline at end of file diff --git a/app/views/projects/index.html.haml b/app/views/projects/index.html.haml new file mode 100644 index 0000000..e82ee14 --- /dev/null +++ b/app/views/projects/index.html.haml @@ -0,0 +1,12 @@ +- content_for :title, 'Projects' + +%table + %thead + %tr + %th Project Name + %th Errors + %tbody + - @projects.each do |project| + %tr + %td= link_to project.name, project_path(project) + %td= link_to project.errs.unresolved.count, project_errs_path(project) \ No newline at end of file diff --git a/app/views/shared/_flash_messages.html.haml b/app/views/shared/_flash_messages.html.haml new file mode 100644 index 0000000..3d2b902 --- /dev/null +++ b/app/views/shared/_flash_messages.html.haml @@ -0,0 +1,4 @@ +- unless flash.keys.empty? + %ul#flash-messages + - flash.each do |type, message| + %li{:class => type}= message \ No newline at end of file diff --git a/app/views/shared/_navigation.html.haml b/app/views/shared/_navigation.html.haml new file mode 100644 index 0000000..b8d840e --- /dev/null +++ b/app/views/shared/_navigation.html.haml @@ -0,0 +1,5 @@ +#nav-bar + %ul + //%li= link_to 'Dashboard', admin_dashboard_path, :class => active_if_here(:dashboards) + %li= link_to 'Projects', projects_path, :class => active_if_here(:projects) + %div.clear \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index da1054f..460369c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,8 +6,13 @@ Hypnotoad::Application.routes.draw do resources :notices, :only => [:show] resources :deploys, :only => [:show] - resources :errors do - resources :notices + + resources :projects do + resources :errs do + resources :notices + end end + root :to => 'projects#index' + end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css new file mode 100644 index 0000000..1da131c --- /dev/null +++ b/public/stylesheets/application.css @@ -0,0 +1,161 @@ +html { + margin: 0; padding: 0; + color: #585858; background-color: #E2E2E2; + font-size: 62.8%; font-family: "Lucida Grande","Lucida Sans",Arial,sans-serif; +} +body { + margin: 0 auto; padding: 0 5px; width: 900px; + font-size: 1.3em; line-height: 1.4em; +} + +/* Convenience Classes */ +.clear { clear: both; } +.clear-left { clear: left; } +.clear-right { clear: right; } +.nowrap { white-space: nowrap; } + +/* Headings */ +h1, h2, h3, h4, h5, h6 { padding: 0.2em 0; margin-bottom: 1em; border-bottom: 1px solid #E2E2E2;} +h1 { font-size: 2.0em; line-height: 1.2em; } +h2 { font-size: 1.7em; line-height: 1.2em; } +h3 { font-size: 1.5em; line-height: 1.2em; } +h4 { font-size: 1.3em; line-height: 1.2em; } +h5 { font-size: 1.1em; line-height: 1.2em; } +h6 { font-size: 0.9em; line-height: 1.2em; } + +/* General */ +p { margin-bottom: 1em; } + +/* Links */ +a { color: #BF3838; text-decoration: none;} +a:visited { color: #674646;} +a:hover { color: #BF3838; text-decoration: underline; } +a.action { float: right; font-size: 0.9em;} + +/* Header */ +#header { + height: 90px; + position: relative; +} +#header #site-name { + font-size: 2.31em; font-weight: bold; line-height: 90px; text-decoration: none; text-transform: uppercase; + color: #585858; +} +#header #session-links { + position: absolute; top: 15px; right: 0; + font-size: 0.9em; +} + +/* Navigation */ +#nav-bar { + margin-bottom: 20px; + background-color: #585858; +} +#nav-bar li { float: left; } +#nav-bar li a { + display: block; padding: 20px 30px; + color: #fff; + font-size: 1.231em; font-weight: bold; line-height: 1em; text-decoration: none; +} +#nav-bar li a:hover { background-color: #686868; } +#nav-bar li a.active { background-color: #BF3838;} + +/* Content Title */ +#content-title { + padding: 30px 20px; border: 1px solid #C6C6C6; border-bottom: none; + background-color: #FFF; +} +#content-title h1 { + padding: 0; margin: 0; border: none; + font-size: 2em; line-height: 1em; font-weight: bold; font-style: italic; font-family: georgia, times, serif; +} +#content-title .meta { font-size: 0.9em; color: #787878; } + +/* Action Bar */ +#action-bar { + padding: 5px 20px; border: 1px solid #C6C6C6; border-top:none; border-bottom: none; + color: #E2E2E2; background-color: #585858; + text-align: right; +} +#action-bar a { color: #E2E2E2; text-decoration: none; } +#action-bar a:hover { color: #FFF; text-decoration: underline;} + +/* Content */ +#content { + padding: 20px; border: 1px solid #C6C6C6; + background-color: #FFF; +} + +/* Footer */ +#footer { + padding: 20px 0; + font-size: 0.8em; text-align: center; + color: #929292; +} + +/* Flash Messages */ +#flash-messages li { + padding: 13px 45px; margin-bottom:25px; border: 1px solid #C6C6C6; + background-color: #F9F9F9; + line-height: 1em; +} +#flash-messages .notice, #flash-messages .success { background: transparent url(images/icons/success.png) 16px 50% no-repeat; } +#flash-messages .error { background: transparent url(images/icons/error.png) 16px 50% no-repeat; } + +/* Forms */ +form { + width: 620px; +} +form > div, form fieldset > div { margin: 1em 0;} +form fieldset { + padding: 0.8em; margin-bottom: 1em; + background-color: #F0F0F0; border: 1px solid #C6C6C6; border-left: none; border-right: none; +} +form fieldset legend { + font-size: 1.2em; font-weight: bold; text-transform: uppercase; + color: #555; +} +form label { + font-weight: bold; text-transform: uppercase; line-height: 1.6em; + display: block; +} +form label.inline { display: inline; } +form .required label { color: #BF3838;} +form input[type=text], form input[type=password] { + width: 96%; padding: 0.8em; + font-size: 1em; + color: #787878; border: 1px solid #C6C6C6; +} +form textarea { + width: 100%; padding: 0.8em; + font-size: inherit; font-family: inherit; + color: #787878; border: 1px solid #C6C6C6; +} +form textarea.short { height: 8em; } +form textarea.supershort { height: 4em; } +form input[type=submit] { + display:block; width: auto; padding: 0.5em; + font-size: 1.2em; line-height: 1em; text-transform: uppercase; + border: none; color: #FFF; background-color: #387fc1; +} +form > div > span { + display: block; margin-top: 0.5em; + font-size: 0.85em; + color: #787878; +} + +/* Tables */ +table { width: 100%; border: 1px solid #C6C6C6; margin-bottom: 1.5em; } +table th, table td { border-bottom: 1px solid #C6C6C6; padding: 10px 8px; text-align: left; } +table th { background-color: #E2E2E2; font-weight: bold; text-transform: uppercase; } +table tbody tr:nth-child(odd) td { background-color: #F9F9F9; } +table .main { width: 100%; } + +/* HTML Styling */ +.html { padding-left: 1em; border-left: 2px solid #C6C6C6;} +.html h1, .html h2, .html h3, .html h4, .html h5, .html h6 { + border: none; +} +.html ul, .html ol { margin-left: 2em; margin-bottom: 1em; } +.html ul li { margin-bottom: 0.5em; list-style: disc; } +.html ol li { margin-bottom: 0.5em; list-style: decimal; } diff --git a/public/stylesheets/images/icons/.DS_Store b/public/stylesheets/images/icons/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/public/stylesheets/images/icons/.DS_Store differ diff --git a/public/stylesheets/images/icons/cross.png b/public/stylesheets/images/icons/cross.png new file mode 100755 index 0000000..33a3837 Binary files /dev/null and b/public/stylesheets/images/icons/cross.png differ diff --git a/public/stylesheets/images/icons/error.png b/public/stylesheets/images/icons/error.png new file mode 100755 index 0000000..51161fd Binary files /dev/null and b/public/stylesheets/images/icons/error.png differ diff --git a/public/stylesheets/images/icons/notice.png b/public/stylesheets/images/icons/notice.png new file mode 100644 index 0000000..d3977af Binary files /dev/null and b/public/stylesheets/images/icons/notice.png differ diff --git a/public/stylesheets/images/icons/success.png b/public/stylesheets/images/icons/success.png new file mode 100755 index 0000000..36dea05 Binary files /dev/null and b/public/stylesheets/images/icons/success.png differ diff --git a/public/stylesheets/images/notebook.png b/public/stylesheets/images/notebook.png new file mode 100644 index 0000000..6ee7090 Binary files /dev/null and b/public/stylesheets/images/notebook.png differ diff --git a/public/stylesheets/reset.css b/public/stylesheets/reset.css new file mode 100644 index 0000000..f448cd8 --- /dev/null +++ b/public/stylesheets/reset.css @@ -0,0 +1,74 @@ +/* + * Reset.css - by Eric Meyer + * Modified for NewsStand + * By Jared Pace + * Codeword: Studios + */ + + html, body, div, span, applet, object, iframe, + h1, h2, h3, h4, h5, h6, p, blockquote, pre, + a, abbr, acronym, address, big, cite, code, + del, dfn, em, font, img, ins, kbd, q, s, samp, + small, strike, strong, sub, sup, tt, var, + b, u, i, center, + dl, dt, dd, ol, ul, li, + fieldset, form, label, legend, + table, caption, tbody, tfoot, thead, tr, th, td { + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: transparent; + } + body { + line-height: 1; + } + ol, ul { + list-style: none; + } + blockquote, q { + quotes: none; + } + td { + vertical-align: top; +} + + /* remember to define focus styles! */ + :focus { + outline: 0; + } + + /* remember to highlight inserts somehow! */ + ins { + text-decoration: none; + } + del { + text-decoration: line-through; + } + + /* tables still need 'cellspacing="0"' in the markup */ + table { + border-collapse: collapse; + border-spacing: 0; + } + + sup, sub { + height: 0; + line-height: 1; + vertical-align: baseline; + _vertical-align: bottom; + position: relative; + font-size: 0.8em; + } + + sup { + bottom: 1ex; + } + + sub { + top: .5ex; + } + +p { margin-bottom: 1em; } \ No newline at end of file diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb new file mode 100644 index 0000000..01c86f3 --- /dev/null +++ b/spec/controllers/projects_controller_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe ProjectsController do + + describe "GET /projects" do + it 'finds all projects' do + 3.times { Factory(:project) } + projects = Project.all + get :index + assigns(:projects).should == projects + end + end + +end -- libgit2 0.21.2