Permalink
Browse files

Adding Twitter Bootstrap and adapting the structure of the site

  • Loading branch information...
1 parent bec2f21 commit 615e285b6254ec15ebaa7fa4b9a5bf959e8f0371 @akitaonrails committed Jul 14, 2012
View
@@ -16,9 +16,12 @@ group :assets do
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
- # gem 'therubyracer', :platforms => :ruby
+ gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
+
+ gem 'less-rails'
+ gem 'twitter-bootstrap-rails'
end
gem 'jquery-rails'
@@ -29,6 +32,7 @@ gem 'rdiscount'
gem 'activeadmin'
gem 'ActiveAdmin-Globalize3-inputs'
+
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
View
@@ -55,6 +55,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.3.3)
+ commonjs (0.2.6)
devise (2.1.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
@@ -97,6 +98,12 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
+ less (2.2.1)
+ commonjs (~> 0.2.6)
+ less-rails (2.2.3)
+ actionpack (>= 3.1)
+ less (~> 2.2.0)
+ libv8 (3.3.10.4)
listen (0.4.7)
rb-fchange (~> 0.0.5)
rb-fsevent (~> 0.9.1)
@@ -185,11 +192,18 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
+ therubyracer (0.10.1)
+ libv8 (~> 3.3.10)
thor (0.15.4)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
+ twitter-bootstrap-rails (2.1.0)
+ actionpack (>= 3.1)
+ less-rails (~> 2.2.2)
+ railties (>= 3.1)
+ therubyracer (~> 0.10.1)
tzinfo (0.3.33)
uglifier (1.2.6)
execjs (>= 0.3.0)
@@ -212,11 +226,14 @@ DEPENDENCIES
guard-rspec
jquery-rails
jquery-ui-rails
+ less-rails
pry-rails
rails (= 3.2.6)
rails-translate-routes
rdiscount
rspec-rails
sass-rails (~> 3.2.3)
sqlite3
+ therubyracer
+ twitter-bootstrap-rails
uglifier (>= 1.0.3)
@@ -12,3 +12,4 @@
//
//= require jquery
//= require jquery_ujs
+//= require twitter/bootstrap
@@ -0,0 +1,4 @@
+jQuery ->
+ $("a[rel=popover]").popover()
+ $(".tooltip").tooltip()
+ $("a[rel=tooltip]").tooltip()
@@ -9,4 +9,5 @@
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
+ *= require bootstrap_and_overrides
*/
@@ -0,0 +1,28 @@
+@import "twitter/bootstrap/bootstrap";
+@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;
@@ -1,4 +1,8 @@
class ArticlesController < ApplicationController
+ def index
+ @articles = Article.all
+ end
+
def show
@article = Article.find(params[:id])
end
@@ -4,11 +4,11 @@ def language_links
I18n.available_locales.each do |locale|
locale_key = "translation.#{locale}"
if locale == I18n.locale
- links << I18n.t(locale_key)
+ links << link_to(I18n.t(locale_key), "#", class: "btn disabled")
else
- links << link_to(I18n.t(locale_key), url_for(locale: locale.to_s))
+ links << link_to(I18n.t(locale_key), url_for(locale: locale.to_s), class: "btn")
end
end
- content_tag(:p, links.join(" | ").html_safe)
+ links.join("\n").html_safe
end
end
@@ -0,0 +1,25 @@
+<%- model_class = Article.new.class -%>
+<h1><%=t '.title', :default => model_class.model_name.human.pluralize %></h1>
+<table class="table table-striped">
+ <thead>
+ <tr>
+ <th><%= model_class.human_attribute_name(:id) %></th>
+ <th><%= model_class.human_attribute_name(:title) %></th>
+ <th><%= model_class.human_attribute_name(:created_at) %></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @articles.each do |article| %>
+ <tr>
+ <td><%= link_to article.id, article_path(article) %></td>
+ <td><%= link_to article.title, article_path(article) %></td>
+ <td><%=l article.created_at %></td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
+
+<% content_for :footer_buttons do %>
+ <%= link_to t('.back', :default => t("helpers.links.back")),
+ root_path, :class => 'btn' %>
+<% end %>
@@ -1,5 +1,12 @@
-<h1><%= @article.title %></h1>
+<div class="row">
+ <h2><%= @article.title %></h2>
+</div>
-<%= raw @article.body_html %>
+<div class="row">
+ <%=raw @article.body_html %>
+</div>
-<%= language_links %>
+<% content_for :footer_buttons do %>
+ <%= link_to t('.back', :default => t("helpers.links.back")),
+ articles_path, :class => 'btn' %>
+<% end %>
@@ -1,14 +1,32 @@
<!DOCTYPE html>
<html>
<head>
- <title>I18nDemo</title>
+ <title><%= t("site_name") %></title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
-<%= yield %>
+<div class="navbar">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="brand" href="#">
+ <%= t("site_name") %>
+ </a>
+ </div>
+ </div>
+</div>
+
+<div class="container">
+ <%= yield %>
+</div>
+
+<div class="form-actions">
+ <%= language_links %>
+ |
+ <%= yield :footer_buttons %>
+</div>
</body>
</html>
@@ -1,7 +1,23 @@
-<h1>Articles</h1>
+<dl>
+ <dt>Number to Currency</dt>
+ <dd><%= number_to_currency(123.56) %></dd>
-<ul>
- <% Article.all.each do |article| %>
- <li><%= link_to article.title, article_path(article.slug) %></li>
- <% end %>
-</ul>
+ <dt>Number to Human</dt>
+ <dd><%= number_to_human(100_555_123.15) %></dd>
+
+ <dt>Date</dt>
+ <dd><%=l Time.current, format: :long %></dd>
+
+ <dt>Time</dt>
+ <dd><%= distance_of_time_in_words(1.hour + 20.minutes) %></dd>
+
+ <dt>Article attributes</dt>
+ <dd><%= [:title, :body, :body_html].map { |attr| Article.human_attribute_name(attr) }.join(", ") %></dd>
+</dl>
+
+<% content_for :footer_buttons do %>
+ <%= link_to t("admin.title"),
+ admin_dashboard_path, :class => 'btn' %>
+ <%= link_to t("articles.title"),
+ articles_path, :class => 'btn' %>
+<% end %>
View
@@ -3,6 +3,11 @@
en:
hello: "Hello world"
+ site_name: "I18n Demonstration"
translation:
en: English
pt-BR: Portuguese
+ admin:
+ title: "Administration"
+ articles:
+ title: "Articles"
View
@@ -1,5 +1,10 @@
pt-BR:
hello: Olá Mundo
+ site_name: "Demonstração I18n"
translation:
en: Inglês
pt-BR: Português
+ admin:
+ title: "Administração"
+ articles:
+ title: "Artigos"

0 comments on commit 615e285

Please sign in to comment.