From dd1a2fc4a8b218771428340b04186907bd0d2852 Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Wed, 20 Jun 2012 16:50:10 +0100 Subject: [PATCH] Improved add feed usability on the home page --- app/assets/stylesheets/scaffolds.css.scss | 9 +- app/controllers/feeds_controller.rb | 5 +- app/models/feed.rb | 2 +- app/views/feeds/_form.html.haml | 9 +- app/views/feeds/index.html.haml | 5 +- app/views/feeds/show.html.haml | 2 - app/views/layouts/application.html.haml | 3 + config/routes.rb | 2 +- public/index.html | 241 ---------------------- 9 files changed, 22 insertions(+), 256 deletions(-) delete mode 100644 public/index.html diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss index 60af154..0eb3159 100644 --- a/app/assets/stylesheets/scaffolds.css.scss +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -1,7 +1,7 @@ body { background-color: #fff; color: #333; - font-family: verdana, arial, helvetica, sans-serif; + font-family: "Helvetica Neue", arial, helvetica, sans-serif; font-size: 13px; line-height: 18px; width: 800px; @@ -9,7 +9,6 @@ body { } p, ol, ul, td { - font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; line-height: 18px; } @@ -69,4 +68,10 @@ div { a.button, a.button:visited { color: #fff; text-decoration: none; +} + +#new_feed { + background-color: beige; + padding: 5px 10px; + margin: 10px 0; } \ No newline at end of file diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb index e2c2d51..dbcb4eb 100644 --- a/app/controllers/feeds_controller.rb +++ b/app/controllers/feeds_controller.rb @@ -2,10 +2,9 @@ class FeedsController < ApplicationController # GET /feeds # GET /feeds.json def index + @feed = Feed.new @feeds = Feed.all -# render :template => '/feeds/index.html.haml' - respond_to do |format| format.html # index.html.erb format.json { render json: @feeds } @@ -46,7 +45,7 @@ class FeedsController < ApplicationController respond_to do |format| if @feed.save - format.html { redirect_to @feed, notice: 'Feed was successfully created.' } + format.html { redirect_to'/', notice: 'Feed was successfully created.' } format.json { render json: @feed, status: :created, location: @feed } else format.html { render action: "new" } diff --git a/app/models/feed.rb b/app/models/feed.rb index 371d394..5f1b565 100644 --- a/app/models/feed.rb +++ b/app/models/feed.rb @@ -1,7 +1,7 @@ class Feed include MongoMapper::Document - key :title, String + key :title, String, :default => "[New feed - hasn't been fetched yet]" key :link, String key :last_fetched, Time, :default => nil timestamps! diff --git a/app/views/feeds/_form.html.haml b/app/views/feeds/_form.html.haml index eb4b934..073b795 100644 --- a/app/views/feeds/_form.html.haml +++ b/app/views/feeds/_form.html.haml @@ -1,4 +1,6 @@ = form_for @feed do |f| + %h2 Add a feed + -if @feed.errors.any? #error_explanation %h2= "#{pluralize(@feed.errors.count, "error")} prohibited this feed from being saved:" @@ -7,14 +9,15 @@ %li= msg .field + -# = f.label :title = f.text_field :title .field - = f.label :link - = f.text_field :link + = f.label "URL" + = f.text_field :link, :size => 120 + = f.submit 'Save' -# .field = f.label :last_fetched = f.datetime_select :last_fetched .actions - = f.submit 'Save' diff --git a/app/views/feeds/index.html.haml b/app/views/feeds/index.html.haml index 0dbaca3..243d466 100644 --- a/app/views/feeds/index.html.haml +++ b/app/views/feeds/index.html.haml @@ -1,8 +1,5 @@ %h1 Feeds -%p= link_to 'Add a feed', new_feed_path, :class => 'button' - - %table %tr %th Title @@ -25,3 +22,5 @@ %td= link_to 'Edit', edit_feed_path(feed) %td= link_to 'Destroy', feed, :confirm => 'Are you sure?', :method => :delete +#new_feed + = render 'form' diff --git a/app/views/feeds/show.html.haml b/app/views/feeds/show.html.haml index be1adde..553d95c 100644 --- a/app/views/feeds/show.html.haml +++ b/app/views/feeds/show.html.haml @@ -1,5 +1,3 @@ -%p#notice= notice - %p %b Title: = @feed.title diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0ee253e..005f439 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -9,6 +9,9 @@ %body = image_tag "TAL_logo_blue-h100.png", :size => "275x100", :alt => "Talk About Local logo" + + %p#notice= notice + = yield diff --git a/config/routes.rb b/config/routes.rb index ef611b0..1f1df65 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -50,7 +50,7 @@ Apollo::Application.routes.draw do # You can have the root of your site routed with "root" # just remember to delete public/index.html. - # root :to => 'welcome#index' + root :to => 'feeds#index' # See how all your routes lay out with "rake routes" diff --git a/public/index.html b/public/index.html deleted file mode 100644 index a1d5099..0000000 --- a/public/index.html +++ /dev/null @@ -1,241 +0,0 @@ - - - - Ruby on Rails: Welcome aboard - - - - -
- - -
- - - - -
-

Getting started

-

Here’s how to get rolling:

- -
    -
  1. -

    Use rails generate to create your models and controllers

    -

    To see all available options, run it without parameters.

    -
  2. - -
  3. -

    Set up a default route and remove public/index.html

    -

    Routes are set up in config/routes.rb.

    -
  4. - -
  5. -

    Create your database

    -

    Run rake db:create to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    -
  6. -
-
-
- - -
- -