Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

converted to haml

  • Loading branch information...
commit 7c9ea79e006fa2ec819d61f705c4e99e6ea5f5eb 1 parent b21a8a9
@tl1000sv authored
View
1  Gemfile
@@ -7,6 +7,7 @@ gem 'rails', '3.2.12'
gem 'sqlite3'
+gem 'haml-rails'
# Gems used only for assets and not required
# in production environments by default.
View
3  app/assets/javascripts/bookmarks.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
View
3  app/assets/stylesheets/bookmarks.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Bookmarks controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
View
69 app/assets/stylesheets/scaffolds.css.scss
@@ -0,0 +1,69 @@
+body {
+ background-color: #fff;
+ color: #333;
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a {
+ color: #000;
+ &:visited {
+ color: #666;
+ }
+ &:hover {
+ color: #fff;
+ background-color: #000;
+ }
+}
+
+div {
+ &.field, &.actions {
+ margin-bottom: 10px;
+ }
+}
+
+#notice {
+ color: green;
+}
+
+.field_with_errors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#error_explanation {
+ width: 450px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 0;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ margin-bottom: 0px;
+ background-color: #c00;
+ color: #fff;
+ }
+ ul li {
+ font-size: 12px;
+ list-style: square;
+ }
+}
View
83 app/controllers/bookmarks_controller.rb
@@ -0,0 +1,83 @@
+class BookmarksController < ApplicationController
+ # GET /bookmarks
+ # GET /bookmarks.json
+ def index
+ @bookmarks = Bookmark.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @bookmarks }
+ end
+ end
+
+ # GET /bookmarks/1
+ # GET /bookmarks/1.json
+ def show
+ @bookmark = Bookmark.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @bookmark }
+ end
+ end
+
+ # GET /bookmarks/new
+ # GET /bookmarks/new.json
+ def new
+ @bookmark = Bookmark.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @bookmark }
+ end
+ end
+
+ # GET /bookmarks/1/edit
+ def edit
+ @bookmark = Bookmark.find(params[:id])
+ end
+
+ # POST /bookmarks
+ # POST /bookmarks.json
+ def create
+ @bookmark = Bookmark.new(params[:bookmark])
+
+ respond_to do |format|
+ if @bookmark.save
+ format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }
+ format.json { render json: @bookmark, status: :created, location: @bookmark }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @bookmark.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /bookmarks/1
+ # PUT /bookmarks/1.json
+ def update
+ @bookmark = Bookmark.find(params[:id])
+
+ respond_to do |format|
+ if @bookmark.update_attributes(params[:bookmark])
+ format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @bookmark.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /bookmarks/1
+ # DELETE /bookmarks/1.json
+ def destroy
+ @bookmark = Bookmark.find(params[:id])
+ @bookmark.destroy
+
+ respond_to do |format|
+ format.html { redirect_to bookmarks_url }
+ format.json { head :no_content }
+ end
+ end
+end
View
2  app/helpers/bookmarks_helper.rb
@@ -0,0 +1,2 @@
+module BookmarksHelper
+end
View
3  app/models/bookmark.rb
@@ -0,0 +1,3 @@
+class Bookmark < ActiveRecord::Base
+ attr_accessible :name, :uri
+end
View
16 app/views/bookmarks/_form.html.haml
@@ -0,0 +1,16 @@
+= form_for @bookmark do |f|
+ - if @bookmark.errors.any?
+ #error_explanation
+ %h2= "#{pluralize(@bookmark.errors.count, "error")} prohibited this bookmark from being saved:"
+ %ul
+ - @bookmark.errors.full_messages.each do |msg|
+ %li= msg
+
+ .field
+ = f.label :name
+ = f.text_field :name
+ .field
+ = f.label :uri
+ = f.text_field :uri
+ .actions
+ = f.submit 'Save'
View
7 app/views/bookmarks/edit.html.haml
@@ -0,0 +1,7 @@
+%h1 Editing bookmark
+
+= render 'form'
+
+= link_to 'Show', @bookmark
+\|
+= link_to 'Back', bookmarks_path
View
21 app/views/bookmarks/index.html.haml
@@ -0,0 +1,21 @@
+%h1 Listing bookmarks
+
+%table
+ %tr
+ %th Name
+ %th Uri
+ %th
+ %th
+ %th
+
+ - @bookmarks.each do |bookmark|
+ %tr
+ %td= bookmark.name
+ %td= bookmark.uri
+ %td= link_to 'Show', bookmark
+ %td= link_to 'Edit', edit_bookmark_path(bookmark)
+ %td= link_to 'Destroy', bookmark, method: :delete, data: { confirm: 'Are you sure?' }
+
+%br
+
+= link_to 'New Bookmark', new_bookmark_path
View
5 app/views/bookmarks/new.html.haml
@@ -0,0 +1,5 @@
+%h1 New bookmark
+
+= render 'form'
+
+= link_to 'Back', bookmarks_path
View
12 app/views/bookmarks/show.html.haml
@@ -0,0 +1,12 @@
+%p#notice= notice
+
+%p
+ %b Name:
+ = @bookmark.name
+%p
+ %b Uri:
+ = @bookmark.uri
+
+= link_to 'Edit', edit_bookmark_path(@bookmark)
+\|
+= link_to 'Back', bookmarks_path
View
14 app/views/layouts/application.html.erb
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>BookmarkApp</title>
- <%= stylesheet_link_tag "application", :media => "all" %>
- <%= javascript_include_tag "application" %>
- <%= csrf_meta_tags %>
-</head>
-<body>
-
-<%= yield %>
-
-</body>
-</html>
View
8 app/views/layouts/application.html.haml
@@ -0,0 +1,8 @@
+%html
+ %head
+ %title BookmarkApp
+ = stylesheet_link_tag "application", :media => "all"
+ = javascript_include_tag "application"
+ = csrf_meta_tags
+ %body
+ = yield
View
3  config/routes.rb
@@ -1,4 +1,7 @@
BookmarkApp::Application.routes.draw do
+ resources :bookmarks
+
+
# The priority is based upon order of creation:
# first created -> highest priority.
View
10 db/migrate/20130214012829_create_bookmarks.rb
@@ -0,0 +1,10 @@
+class CreateBookmarks < ActiveRecord::Migration
+ def change
+ create_table :bookmarks do |t|
+ t.string :name
+ t.string :uri
+
+ t.timestamps
+ end
+ end
+end
View
9 test/fixtures/bookmarks.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ name: MyString
+ uri: MyString
+
+two:
+ name: MyString
+ uri: MyString
View
49 test/functional/bookmarks_controller_test.rb
@@ -0,0 +1,49 @@
+require 'test_helper'
+
+class BookmarksControllerTest < ActionController::TestCase
+ setup do
+ @bookmark = bookmarks(:one)
+ end
+
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:bookmarks)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create bookmark" do
+ assert_difference('Bookmark.count') do
+ post :create, bookmark: { name: @bookmark.name, uri: @bookmark.uri }
+ end
+
+ assert_redirected_to bookmark_path(assigns(:bookmark))
+ end
+
+ test "should show bookmark" do
+ get :show, id: @bookmark
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, id: @bookmark
+ assert_response :success
+ end
+
+ test "should update bookmark" do
+ put :update, id: @bookmark, bookmark: { name: @bookmark.name, uri: @bookmark.uri }
+ assert_redirected_to bookmark_path(assigns(:bookmark))
+ end
+
+ test "should destroy bookmark" do
+ assert_difference('Bookmark.count', -1) do
+ delete :destroy, id: @bookmark
+ end
+
+ assert_redirected_to bookmarks_path
+ end
+end
View
7 test/unit/bookmark_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class BookmarkTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
View
4 test/unit/helpers/bookmarks_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class BookmarksHelperTest < ActionView::TestCase
+end
Please sign in to comment.
Something went wrong with that request. Please try again.