Permalink
Browse files

Bootstrapped post views

  • Loading branch information...
1 parent b445c59 commit f30b09234ec2d429d1650e293a0bee3e9f934681 @lisovskyvlad committed Jun 16, 2012
View
1 app/assets/javascripts/application.js
@@ -12,4 +12,5 @@
//
//= require jquery
//= require jquery_ujs
+//= require twitter/bootstrap
//= require_tree .
View
4 app/assets/javascripts/bootstrap.js.coffee
@@ -0,0 +1,4 @@
+jQuery ->
+ $("a[rel=popover]").popover()
+ $(".tooltip").tooltip()
+ $("a[rel=tooltip]").tooltip()
View
33 app/assets/stylesheets/bootstrap_and_overrides.css.less
@@ -0,0 +1,33 @@
+@import "twitter/bootstrap/bootstrap";
+body {
+ padding-top: 60px;
+ padding-left: 20px;
+}
+
+@import "twitter/bootstrap/responsive";
+
+// Set the correct sprite paths
+@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png');
+@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png');
+
+// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
+// Note: If you use asset_path() here, your compiled boostrap_and_overrides.css will not
+// have the proper paths. So for now we use the absolute path.
+@fontAwesomeEotPath: '/assets/fontawesome-webfont.eot';
+@fontAwesomeWoffPath: '/assets/fontawesome-webfont.woff';
+@fontAwesomeTtfPath: '/assets/fontawesome-webfont.ttf';
+@fontAwesomeSvgPath: '/assets/fontawesome-webfont.svg';
+
+// Font Awesome
+@import "fontawesome";
+
+// Your custom LESS stylesheets goes here
+//
+// Since bootstrap was imported above you have access to its mixins which
+// you may use and inherit here
+//
+// If you'd like to override bootstrap's own variables, you can do so here as well
+// See http://twitter.github.com/bootstrap/less.html for their names and documentation
+//
+// Example:
+// @linkColor: #ff0000;
View
3 app/assets/stylesheets/posts.css.sass
@@ -1,3 +1,6 @@
// Place all the styles related to the Posts controller here.
// They will automatically be included in application.css.
// You can use Sass here: http://sass-lang.com/
+
+#post_content
+ width: 400px
View
14 app/views/layouts/application.html.erb
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Blog</title>
- <%= stylesheet_link_tag "application", :media => "all" %>
- <%= javascript_include_tag "application" %>
- <%= csrf_meta_tags %>
-</head>
-<body>
-
-<%= yield %>
-
-</body>
-</html>
View
37 app/views/layouts/application.html.haml
@@ -0,0 +1,37 @@
+!!! 5
+%html(lang='en')
+ %head
+ %meta(charset='utf-8')
+ %meta(name='viewport' content='width=device-width, initial-scale=1.0')
+ %title= 'Blog'
+ = csrf_meta_tags
+ / Le HTML5 shim, for IE6-8 support of HTML elements
+ /[if lt IE 9]
+ = javascript_include_tag 'http://html5shim.googlecode.com/svn/trunk/html5.js'
+ = stylesheet_link_tag 'application', :media => 'all'
+ %link(href='images/apple-touch-icon.png' rel='apple-touch-icon')
+ %link(href='images/apple-touch-icon-72x72.png' rel='apple-touch-icon' sizes='72x72')
+ %link(href='images/apple-touch-icon-114x114.png' rel='apple-touch-icon' sizes='114x114')
+
+ %body
+ .navbar.navbar-fixed-top
+ .navbar-inner
+ .container
+ %a.btn.btn-navbar(data-target='.nav-collapse' data-toggle='collapse')
+ %span.icon-bar
+ %span.icon-bar
+ %span.icon-bar
+ =link_to 'Blog', root_path, class: 'brand'
+ .container
+ .content
+ .row
+ .span9.offset1
+ = yield
+ .span2
+ %footer
+ %p &copy; Lisovsky Vlad
+ /
+ Javascripts
+ \==================================================
+ / Placed at the end of the document so the pages load faster
+ = javascript_include_tag 'application'
View
12 app/views/posts/_form.html.haml
@@ -1,13 +1,13 @@
-= simple_form_for @post do |f|
+= simple_form_for @post, :html => { :class => 'form-horizontal' } do |f|
- if @post.errors.any?
#errorExplanation
%h2= "#{pluralize(@post.errors.count, "error")} prohibited this #{Post.name.titleize} from being saved:"
%ul
- @post.errors.full_messages.each do |msg|
%li= msg
-
- = f.input :title, :label => 'Title'
- = f.input :content, :as => :text, :label => 'Content'
- .actions
- = f.button :submit
+ = f.input :title
+ = f.input :content, as: :text, :input_html => { :cols => 80, :rows => 15 }
+ .form-actions
+ = f.button :submit, :class => 'btn-primary'
+ = link_to t('.cancel', :default => t("helpers.links.cancel")), posts_path, :class => 'btn'
View
11 app/views/posts/edit.html.haml
@@ -1,7 +1,4 @@
-%h1 Editing post
-
-= render 'form'
-
-= link_to 'Show', @post
-\|
-= link_to 'Back', posts_path
+- model_class = @post.class
+.page-header
+ %h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}")
+= render :partial => "form"
View
36 app/views/posts/index.html.haml
@@ -1,21 +1,19 @@
-%h1 Listing posts
-
-%table
- %tr
- %th Title
- %th Content
- %th
- %th
- %th
-
- - @posts.each do |post|
+- model_class = Post.new.class
+.page-header
+ %h1=t '.title', :default => model_class.model_name.human.pluralize
+%table.table.table-striped
+ %thead
%tr
- %td= post.title
- %td= post.content
- %td= link_to 'Show', post
- %td= link_to 'Edit', edit_post_path(post)
- %td= link_to 'Destroy', post, :data => { :confirm => 'Text' }, :method => :delete
-
-%br
+ %th= model_class.human_attribute_name(:title)
+ %th= model_class.human_attribute_name(:content)
+ %th=t '.actions', :default => t('helpers.actions')
+ %tbody
+ - @posts.each do |post|
+ %tr
+ %td= link_to post.title, post_path(post)
+ %td= post.content
+ %td
+ = link_to t('.edit', :default => t('helpers.links.edit')), edit_post_path(post), :class => 'btn btn-mini'
+ = link_to t('.destroy', :default => t('helpers.links.destroy')), post_path(post), :method => :delete, :data => { :confirm => t('.confirm', :default => t('helpers.links.confirm', :default => 'Are you sure?'))} , :class => 'btn btn-mini btn-danger'
-= link_to 'New Post', new_post_path
+= link_to t('.new', :default => t('helpers.links.new')), new_post_path, :class => 'btn btn-primary'
View
9 app/views/posts/new.html.haml
@@ -1,5 +1,4 @@
-%h1 New post
-
-= render 'form'
-
-= link_to 'Back', posts_path
+- model_class = @post.class
+.page-header
+ %h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}")
+= render :partial => 'form'
View
17 app/views/posts/show.html.haml
@@ -1,12 +1,17 @@
-%p#notice= notice
+- model_class = @post.class
+.page-header
+ %h1=t '.title', :default => model_class.model_name.human
%p
- %b Title:
+ %strong= model_class.human_attribute_name(:title) + ':'
+ %br
= @post.title
%p
- %b Content:
+ %strong= model_class.human_attribute_name(:content) + ':'
+ %br
= @post.content
-= link_to 'Edit', edit_post_path(@post)
-\|
-= link_to 'Back', posts_path
+.form-actions
+ = link_to t('.back', :default => t("helpers.links.back")), posts_path, :class => 'btn'
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_post_path(@post), :class => 'btn'
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), post_path(@post), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'

0 comments on commit f30b092

Please sign in to comment.