From 3e96be498efaa1056c629a8113ed1d6afbbb2331 Mon Sep 17 00:00:00 2001 From: Cesidio Di Landa Date: Fri, 19 Apr 2013 19:51:23 +0200 Subject: [PATCH] Home page Layout Assets --- README.rdoc | 28 ----------- app/assets/javascripts/application.js | 16 ------- .../javascripts/application.js.coffee.erb | 32 +++++++++++++ app/assets/javascripts/bootstrap.js.coffee | 5 ++ app/assets/javascripts/i18n/translations.js | 2 + .../{application.css => application.css.less} | 3 ++ .../bootstrap_and_overrides.css.less | 25 ++++++++++ .../stubs/variables_overrides.css.less | 13 ++++++ app/controllers/pages_controller.rb | 5 ++ app/helpers/application_helper.rb | 7 +++ app/views/layouts/application.html.erb | 14 ------ app/views/layouts/application.html.haml | 37 +++++++++++++++ app/views/pages/home.html.haml | 1 + app/views/shared/_footer.html.haml | 1 + app/views/shared/_navbar.html.haml | 4 ++ config/i18n-js.yml | 26 +++++++++++ config/routes.rb | 46 +------------------ test/test_helper.rb | 15 ------ 18 files changed, 162 insertions(+), 118 deletions(-) delete mode 100644 README.rdoc delete mode 100644 app/assets/javascripts/application.js create mode 100644 app/assets/javascripts/application.js.coffee.erb create mode 100644 app/assets/javascripts/bootstrap.js.coffee create mode 100644 app/assets/javascripts/i18n/translations.js rename app/assets/stylesheets/{application.css => application.css.less} (85%) create mode 100644 app/assets/stylesheets/bootstrap_and_overrides.css.less create mode 100644 app/assets/stylesheets/stubs/variables_overrides.css.less create mode 100644 app/controllers/pages_controller.rb delete mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/layouts/application.html.haml create mode 100644 app/views/pages/home.html.haml create mode 100644 app/views/shared/_footer.html.haml create mode 100644 app/views/shared/_navbar.html.haml create mode 100644 config/i18n-js.yml delete mode 100644 test/test_helper.rb diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index dd4e97e..0000000 --- a/README.rdoc +++ /dev/null @@ -1,28 +0,0 @@ -== README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... - - -Please feel free to use a different markup language if you do not plan to run -rake doc:app. diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js deleted file mode 100644 index 9e83eb5..0000000 --- a/app/assets/javascripts/application.js +++ /dev/null @@ -1,16 +0,0 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. -// -// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD -// GO AFTER THE REQUIRES BELOW. -// -//= require jquery -//= require jquery_ujs -//= require turbolinks -//= require_tree . diff --git a/app/assets/javascripts/application.js.coffee.erb b/app/assets/javascripts/application.js.coffee.erb new file mode 100644 index 0000000..d55cdb0 --- /dev/null +++ b/app/assets/javascripts/application.js.coffee.erb @@ -0,0 +1,32 @@ +#= require jquery +#= require jquery_ujs +#= require jquery.turbolinks +#= require turbolinks + +# FRONT END +#= require twitter/bootstrap + +# JS TEMPLATES +#= require handlebars.runtime + +# I18n +#= require i18n +#= require i18n/translations + +# ALL THE REST +#= require_tree . + +'use strict' + +I18n.defaultLocale = '<%= I18n.default_locale %>' +I18n.locale = $('html').attr 'lang' + +startSpinner = -> + $('#loading-spinner').show() + +stopSpinner = -> + $('#loading-spinner').fadeOut() + +# Turbolinks Spinner +document.addEventListener 'page:fetch', startSpinner +document.addEventListener 'page:receive', stopSpinner diff --git a/app/assets/javascripts/bootstrap.js.coffee b/app/assets/javascripts/bootstrap.js.coffee new file mode 100644 index 0000000..e36c1f1 --- /dev/null +++ b/app/assets/javascripts/bootstrap.js.coffee @@ -0,0 +1,5 @@ +'use strict' + +# jQuery Turbolinks +$ -> + $('[rel~="tooltip"]').tooltip() diff --git a/app/assets/javascripts/i18n/translations.js b/app/assets/javascripts/i18n/translations.js new file mode 100644 index 0000000..fd74986 --- /dev/null +++ b/app/assets/javascripts/i18n/translations.js @@ -0,0 +1,2 @@ +var I18n = I18n || {}; +I18n.translations = {"en":{"date":{"formats":{"default":"%Y-%m-%d","short":"%b %d","long":"%B %d, %Y"},"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"month_names":[null,"January","February","March","April","May","June","July","August","September","October","November","December"],"abbr_month_names":[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"order":["year","month","day"]},"time":{"formats":{"default":"%a, %d %b %Y %H:%M:%S %z","short":"%d %b %H:%M","long":"%B %d, %Y %H:%M"},"am":"am","pm":"pm"},"datetime":{"distance_in_words":{"half_a_minute":"half a minute","less_than_x_seconds":{"one":"less than 1 second","other":"less than %{count} seconds"},"x_seconds":{"one":"1 second","other":"%{count} seconds"},"less_than_x_minutes":{"one":"less than a minute","other":"less than %{count} minutes"},"x_minutes":{"one":"1 minute","other":"%{count} minutes"},"about_x_hours":{"one":"about 1 hour","other":"about %{count} hours"},"x_days":{"one":"1 day","other":"%{count} days"},"about_x_months":{"one":"about 1 month","other":"about %{count} months"},"x_months":{"one":"1 month","other":"%{count} months"},"about_x_years":{"one":"about 1 year","other":"about %{count} years"},"over_x_years":{"one":"over 1 year","other":"over %{count} years"},"almost_x_years":{"one":"almost 1 year","other":"almost %{count} years"}},"prompts":{"year":"Year","month":"Month","day":"Day","hour":"Hour","minute":"Minute","second":"Seconds"}}}}; \ No newline at end of file diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css.less similarity index 85% rename from app/assets/stylesheets/application.css rename to app/assets/stylesheets/application.css.less index 3192ec8..8d39cc7 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css.less @@ -8,6 +8,9 @@ * You're free to add application-wide styles to this file and they'll appear at the top of the * compiled file, but it's generally better to create a new file per style scope. * + *= stub stubs/variables_overrides.css.less *= require_self *= require_tree . */ + +@import "stubs/variables_overrides.css.less"; diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less new file mode 100644 index 0000000..8172bd9 --- /dev/null +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -0,0 +1,25 @@ +/* ========================================================================== + Bootstrap and overrides + ========================================================================== */ + +@import "twitter/bootstrap/bootstrap"; + +body { + padding-top: 60px; +} + +@import "twitter/bootstrap/responsive"; + +/* Fontawesome Icons + ========================================================================== */ + +@fontAwesomeEotPath: asset-path("fontawesome-webfont.eot?v=3.0.2"); +@fontAwesomeEotPath_iefix: asset-path("fontawesome-webfont.eot?#iefix&v=3.0.2"); +@fontAwesomeWoffPath: asset-path("fontawesome-webfont.woff?v=3.0.2"); +@fontAwesomeTtfPath: asset-path("fontawesome-webfont.ttf?v=3.0.2"); +@import "fontawesome"; + +/* Overriding default variables and loading new ones + ========================================================================== */ + +@import "stubs/variables_overrides.css.less"; diff --git a/app/assets/stylesheets/stubs/variables_overrides.css.less b/app/assets/stylesheets/stubs/variables_overrides.css.less new file mode 100644 index 0000000..d8d8f89 --- /dev/null +++ b/app/assets/stylesheets/stubs/variables_overrides.css.less @@ -0,0 +1,13 @@ +@import "twitter/bootstrap/variables"; + +/* ========================================================================== + Variables and overrides + ========================================================================== */ + +/* New variables + ========================================================================== */ + +/* Bootstrap variables override + ========================================================================== */ + +@sansFontFamily: "Ubuntu", "Helvetica Neue", Helvetica, Arial, sans-serif; diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb new file mode 100644 index 0000000..19e1898 --- /dev/null +++ b/app/controllers/pages_controller.rb @@ -0,0 +1,5 @@ +class PagesController < ApplicationController + + def home + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..7c1f91e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,9 @@ module ApplicationHelper + def title(page_title) + content_for(:title) { page_title.to_s } + end + + def yield_or_default(section, default = '') + content_for?(section) ? content_for(section) : default + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb deleted file mode 100644 index 7dacbd4..0000000 --- a/app/views/layouts/application.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - - - Starterapp - <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> - <%= javascript_include_tag "application", "data-turbolinks-track" => true %> - <%= csrf_meta_tags %> - - - -<%= yield %> - - - diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml new file mode 100644 index 0000000..cf25541 --- /dev/null +++ b/app/views/layouts/application.html.haml @@ -0,0 +1,37 @@ +!!! +%html{ lang: I18n.locale.to_s } + %head + %meta{ charset: 'utf-8' } + %meta{ name: 'viewport', content: 'width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0' } + %title= yield_or_default :title, controller.action_name.titlecase + = csrf_meta_tags + = yield :head + / Le HTML5 shim, for IE6-8 support of HTML elements + /[if lt IE 9] + + + / Le styles + = stylesheet_link_tag 'http://fonts.googleapis.com/css?family=Ubuntu:400,500,700', + 'application', + media: 'all' + + / Touch icons + %link{ href: asset_path('apple-touch-icon.png'), rel: 'apple-touch-icon' } + %link{ href: asset_path('apple-touch-icon-72x72.png'), rel: 'apple-touch-icon', sizes: '72x72' } + %link{ href: asset_path('apple-touch-icon-114x114.png'), rel: 'apple-touch-icon', sizes: '114x114' } + %link{ href: asset_path('apple-touch-icon-144x144.png'), rel: 'apple-touch-icon', sizes: '144x144' } + + / + Le javascript + \================================================== + / Placed at the top of the document 'cause of turbolinks + = javascript_include_tag 'application' + + %body + = render 'shared/navbar' + + #main-container.container + .content= yield + + #footer + .container= render 'shared/footer' diff --git a/app/views/pages/home.html.haml b/app/views/pages/home.html.haml new file mode 100644 index 0000000..eb1d247 --- /dev/null +++ b/app/views/pages/home.html.haml @@ -0,0 +1 @@ +%h1= t('hello') diff --git a/app/views/shared/_footer.html.haml b/app/views/shared/_footer.html.haml new file mode 100644 index 0000000..85811d0 --- /dev/null +++ b/app/views/shared/_footer.html.haml @@ -0,0 +1 @@ +%footer.text-center diff --git a/app/views/shared/_navbar.html.haml b/app/views/shared/_navbar.html.haml new file mode 100644 index 0000000..e7a666b --- /dev/null +++ b/app/views/shared/_navbar.html.haml @@ -0,0 +1,4 @@ +.navbar.navbar-fixed-top + .navbar-inner + .container + = link_to Rails.application.class.parent_name, root_path, class: 'brand' diff --git a/config/i18n-js.yml b/config/i18n-js.yml new file mode 100644 index 0000000..121f162 --- /dev/null +++ b/config/i18n-js.yml @@ -0,0 +1,26 @@ +# Split context in several files. +# By default only one file with all translations is exported and +# no configuration is required. Your settings for asset pipeline +# are automatically recognized. +# +# If you want to split translations into several files or specify +# locale contexts that will be exported, just use this file to do +# so. +# +# If you're going to use the Rails 3.1 asset pipeline, change +# the following configuration to something like this: +# +# translations: +# - file: "app/assets/javascripts/i18n/translations.js" +# +# If you're running an old version, you can use something +# like this: +# +# translations: +# - file: "public/javascripts/translations.js" +# only: "*" +# + +translations: + - file: 'app/assets/javascripts/i18n/translations.js' + only: ['*.date', '*.time', '*.datetime'] diff --git a/config/routes.rb b/config/routes.rb index 5f17188..25d8eb7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,49 +1,5 @@ Starterapp::Application.routes.draw do - # The priority is based upon order of creation: first created -> highest priority. - # See how all your routes lay out with "rake routes". - # You can have the root of your site routed with "root" - # root to: 'welcome#index' + root to: 'pages#home' - # Example of regular route: - # get 'products/:id' => 'catalog#view' - - # Example of named route that can be invoked with purchase_url(id: product.id) - # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase - - # Example resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Example resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Example resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Example resource route with more complex sub-resources: - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', on: :collection - # end - # end - - # Example resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index f91a437..0000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -ENV["RAILS_ENV"] = "test" -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' - -class ActiveSupport::TestCase - ActiveRecord::Migration.check_pending! - - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - # - # Note: You'll currently still have to declare fixtures explicitly in integration tests - # -- they do not yet inherit this setting - fixtures :all - - # Add more helper methods to be used by all tests here... -end