diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index 31067f3a9..4a877822b 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -17,11 +17,84 @@ module LayoutHelper current_user ? current_user.name : t("application.helper.diaspora_alpha") end - def stylesheet(*args) - content_for(:head) { stylesheet_link_tag(*args) } + def set_asset_host + content_tag(:script) do + <<-JS.html_safe + app.baseImageUrl("#{ENV['ASSET_HOST']}") + JS + end end - def javascript(*args) - content_for(:head) { javascript_include_tag(*args) } + def load_javascript_locales + content_tag(:script) do + <<-JS.html_safe + Diaspora.I18n.loadLocale(#{get_javascript_strings_for(I18n.locale).to_json}, "#{I18n.locale}"); + Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}"; + JS + end + end + + def set_current_user_in_javascript + return unless current_user + + content_tag(:script) do + <<-JS.html_safe + app.user( + _.extend(#{current_user.person.as_api_response(:backbone).to_json}, { + notifications_count : #{notification_count}, + unread_messages_count : #{unread_message_count}, + admin : #{current_user.admin?} + }) + ); + JS + end + end + + def current_user_atom_tag + return unless @person.present? + content_tag(:link, '', :rel => 'alternate', :href => "#{@person.public_url}.atom", :type => "application/atom+xml", :title => t('.public_feed', :name => @person.name)) + end + + def translation_missing_warnings + return if Rails.env == "production" + + content_tag(:style) do + <<-CSS + .translation_missing { color: purple; background-color: red; } + CSS + end + end + + def include_base_css_framework + if @aspect == :getting_started || @page == :logged_out + include_stylesheets :bootstrap + else + include_stylesheets :blueprint, :media => 'screen' + end + end + + def old_browser_js_support + content_tag(:script) do + <<-JS.html_safe + if(Array.isArray === undefined) { + Array.isArray = function (arg) { + return Object.prototype.toString.call(arg) == '[object Array]'; + }; + } + if ((window.history) && (window.history.pushState === undefined)) { + window.history.pushState = function() { }; + } + JS + end + end + + def flash_messages + return if @page == :logged_out + + flash.map do |name, msg| + content_tag(:div, :id => "flash_#{name}") do + content_tag(:div, msg, :class => 'message') + end + end.join(' ').html_safe end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 0a472326f..c0388b861 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,75 +6,26 @@ %html{:lang => I18n.locale.to_s, :dir => (rtl?) ? 'rtl' : 'ltr'} %head %meta{:charset => 'utf-8'} - - %title - = page_title yield(:page_title) - %meta{'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1'} + %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"} - %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/ + %meta{:name => "description", :content => "Diaspora*"} + %meta{:name => "author", :content => "Diaspora, Inc."} %link{:rel => 'shortcut icon', :href => '/favicon.png'} %link{:rel => 'apple-touch-icon', :href => '/apple-touch-icon.png'} - :css - @-webkit-keyframes fade-in { - 0% { opacity: 0; } - 100% { opacity: 1; } - } - - @-webkit-keyframes spin { - 0% { -webkit-transform: rotate(0deg); } - 100% { -webkit-transform: rotate(360deg); } - } - - @-moz-keyframes fade-in { - 0% { opacity: 0; } - 100% { opacity: 1; } - } - - @-moz-keyframes spin { - 0% { -moz-transform: rotate(0deg); } - 100% { -moz-transform: rotate(360deg); } - } - - .loaded { - -webkit-animation: fade-in 0.16s linear; - -moz-animation: fade-in 0.16s linear; - } - - .loader { - -webkit-animation: spin 1s infinite ease-in-out, - fade-in 0.2s ease-in; - -moz-animation: spin 1s infinite ease-in-out, - fade-in 0.2s ease-in; - - } - - / bootstrap/blueprint switch - - if @aspect == :getting_started || @page == :logged_out - = include_stylesheets :bootstrap - - else - = include_stylesheets :blueprint, :media => 'screen' + %title + = page_title yield(:page_title) + = include_base_css_framework = include_stylesheets :login, :media => 'screen' - = include_stylesheets :default, :media => 'all' + - if rtl? = include_stylesheets :rtl, :media => 'all' - :javascript - // Support for older browsers - if(Array.isArray === undefined) { - Array.isArray = function (arg) { - return Object.prototype.toString.call(arg) == '[object Array]'; - }; - } - if ((window.history) && (window.history.pushState === undefined)) { - window.history.pushState = function() { }; - } - - = csrf_meta_tag + = old_browser_js_support @@ -82,55 +33,28 @@ = jquery_include_tag - unless @landing_page = include_javascripts :main, :templates - - :javascript - Diaspora.I18n.loadLocale(#{get_javascript_strings_for(I18n.locale).to_json}, "#{I18n.locale}"); - Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}"; + = load_javascript_locales - :javascript - app.baseImageUrl("#{ENV['ASSET_HOST']}") - - - if current_user - :javascript - app.user( - _.extend(#{current_user.person.as_api_response(:backbone).to_json}, { - notifications_count : #{notification_count}, - unread_messages_count : #{unread_message_count}, - admin : #{current_user.admin?} - }) - ); + = set_asset_host + = set_current_user_in_javascript + = translation_missing_warnings + = current_user_atom_tag = yield(:head) + = csrf_meta_tag - -unless Rails.env == "production" - :css - .translation_missing { - color: purple; - background-color: red; - } - - - if @person - %link{:rel => "alternate", :href => "#{@person.public_url}.atom", :type => "application/atom+xml", :title => "#{t('.public_feed', :name => @person.name)}"} - - %body{:class => "#{yield(:body_class)}"} - - - unless @page == :logged_out - - flash.each do |name, msg| - %div{:id => "flash_#{name}"} - .message - = msg - - #notifications + %body + = flash_messages - unless current_user %header = render 'layouts/header' - .container{:style=> "#{yield(:break_the_mold)}"} + .container - if @aspsect == :getting_started || @page == :logged_out = yield - else - .span-24.last{:style=> "#{yield(:break_the_mold)}"} + .span-24.last = yield - unless @landing_page diff --git a/config/assets.yml b/config/assets.yml index 5db5219a9..8bb1ea56b 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -105,6 +105,7 @@ stylesheets: - public/stylesheets/login.css default: - public/stylesheets/application.css + - public/stylesheets/loader.css - public/stylesheets/ui.css - public/stylesheets/lightbox.css - public/stylesheets/autocomplete.css diff --git a/public/stylesheets/sass/loader.scss b/public/stylesheets/sass/loader.scss new file mode 100644 index 000000000..0e062235b --- /dev/null +++ b/public/stylesheets/sass/loader.scss @@ -0,0 +1,33 @@ +@-webkit-keyframes fade-in { + 0% { opacity: 0; } + 100% { opacity: 1; } +} + +@-webkit-keyframes spin { + 0% { -webkit-transform: rotate(0deg); } + 100% { -webkit-transform: rotate(360deg); } +} + +@-moz-keyframes fade-in { + 0% { opacity: 0; } + 100% { opacity: 1; } +} + +@-moz-keyframes spin { + 0% { -moz-transform: rotate(0deg); } + 100% { -moz-transform: rotate(360deg); } +} + +.loaded { + -webkit-animation: fade-in 0.16s linear; + -moz-animation: fade-in 0.16s linear; +} + +.loader { + -webkit-animation: spin 1s infinite ease-in-out, + fade-in 0.2s ease-in; + -moz-animation: spin 1s infinite ease-in-out, + fade-in 0.2s ease-in; + +} +