From a0f3225dad97c66f43d41283b42ef823dfbde84e Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Sun, 30 Mar 2014 11:45:52 +0600 Subject: [PATCH] [#369] top menu & footer --- .../controllers/projects_controller.js | 5 +++ app/assets/javascripts/new_application.js | 3 ++ app/assets/stylesheets/custom_bootstrap.scss | 38 ++++++++++++++++++ .../stylesheets/new_application.css.scss | 9 +++++ app/controllers/home_controller.rb | 1 + app/models/activity_feed.rb | 2 +- app/views/layouts/bootstrap.html.haml | 17 ++++++++ app/views/layouts/menu/_new_bottom.html.haml | 20 ++++++++++ app/views/layouts/menu/_new_top.html.haml | 40 +++++++++++++++++++ config/environments/production.rb | 2 +- .../{bootstrap.scss => old-bootstrap.scss} | 0 vendor/assets/stylesheets/vendor.scss | 2 +- 12 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 app/assets/javascripts/angularjs/controllers/projects_controller.js create mode 100644 app/assets/javascripts/new_application.js create mode 100644 app/assets/stylesheets/custom_bootstrap.scss create mode 100644 app/assets/stylesheets/new_application.css.scss create mode 100644 app/views/layouts/bootstrap.html.haml create mode 100644 app/views/layouts/menu/_new_bottom.html.haml create mode 100644 app/views/layouts/menu/_new_top.html.haml rename vendor/assets/stylesheets/{bootstrap.scss => old-bootstrap.scss} (100%) diff --git a/app/assets/javascripts/angularjs/controllers/projects_controller.js b/app/assets/javascripts/angularjs/controllers/projects_controller.js new file mode 100644 index 000000000..6d7a79922 --- /dev/null +++ b/app/assets/javascripts/angularjs/controllers/projects_controller.js @@ -0,0 +1,5 @@ +RosaABF.controller('ProjectsController', ['$scope', 'Projects', function($scope, Projects) { + + $scope.projects = Projects.query(); + $scope.public = true; +}]); diff --git a/app/assets/javascripts/new_application.js b/app/assets/javascripts/new_application.js new file mode 100644 index 000000000..ef7d6a302 --- /dev/null +++ b/app/assets/javascripts/new_application.js @@ -0,0 +1,3 @@ +//= require jquery +// Loads all Bootstrap javascripts +//= require bootstrap \ No newline at end of file diff --git a/app/assets/stylesheets/custom_bootstrap.scss b/app/assets/stylesheets/custom_bootstrap.scss new file mode 100644 index 000000000..eda333c9a --- /dev/null +++ b/app/assets/stylesheets/custom_bootstrap.scss @@ -0,0 +1,38 @@ +body { + background: $body-bg image-url("bg.png") repeat-x; +} + +.top_menu { + margin-bottom: 0; +} + +article.container-fluid { + background: #FFF; +} + +$logo-mini-height: 32px; + +a.navbar-brand, .navbar .navbar-right .avatar { + padding-top: ($navbar-height - $logo-mini-height) / 2; +} + +footer { + padding-top: 20px; + padding-bottom: 20px; + text-align: center; + + ul li { + display: inline; + padding: 0; + font-size: 12px; + color: $navbar-default-link-color; + + a { + color: $navbar-default-link-color; + } + + a:hover, a:focus { + color: $navbar-default-link-hover-color; + } + } +} diff --git a/app/assets/stylesheets/new_application.css.scss b/app/assets/stylesheets/new_application.css.scss new file mode 100644 index 000000000..fd92f43ff --- /dev/null +++ b/app/assets/stylesheets/new_application.css.scss @@ -0,0 +1,9 @@ +$body-bg: #1F60A1; +$navbar-default-bg: #3E73A2; +$navbar-default-link-color: #FFF; +$navbar-default-link-active-color: #FFF; +$navbar-height: 51px; +$navbar-default-link-hover-color: #CEE7FF; + +@import "bootstrap"; +@import "custom_bootstrap" diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 40fbdbb04..889066b4b 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,4 +1,5 @@ class HomeController < ApplicationController + layout 'bootstrap' before_filter :authenticate_user!, only: [:activity, :issues, :pull_requests] def root diff --git a/app/models/activity_feed.rb b/app/models/activity_feed.rb index 0cc809782..8e4b39ccc 100644 --- a/app/models/activity_feed.rb +++ b/app/models/activity_feed.rb @@ -13,7 +13,7 @@ class ActivityFeed < ActiveRecord::Base default_scope { order created_at: :desc } scope :outdated, -> { offset(100) } - self.per_page = 10 + self.per_page = 4 def partial 'home/partials/' + self.kind diff --git a/app/views/layouts/bootstrap.html.haml b/app/views/layouts/bootstrap.html.haml new file mode 100644 index 000000000..9ff2728db --- /dev/null +++ b/app/views/layouts/bootstrap.html.haml @@ -0,0 +1,17 @@ +!!! +%html + %head + %meta{content: "text/html; charset=utf-8", "http-equiv" => "Content-Type"} + = csrf_meta_tag + = display_meta_tags site: APP_CONFIG['project_name'], reverse: true, separator: '-' + - if user_signed_in? + = auto_discovery_link_tag :atom, atom_activity_feeds_path(format: 'atom', token: current_user.authentication_token), title: t("layout.atom_link_tag_title", nickname: current_user.uname, app_name: APP_CONFIG['project_name']) + + %body + = render 'layouts/menu/new_top' + %article.container-fluid + .row= yield + = render 'layouts/menu/new_bottom' + = stylesheet_link_tag 'new_application' + = javascript_include_tag 'new_application' + =# javascript_include_tag 'moment/ru.js' if I18n.locale == :ru diff --git a/app/views/layouts/menu/_new_bottom.html.haml b/app/views/layouts/menu/_new_bottom.html.haml new file mode 100644 index 000000000..4981f3249 --- /dev/null +++ b/app/views/layouts/menu/_new_bottom.html.haml @@ -0,0 +1,20 @@ +%footer + %ul + %li= t('bottom_menu.copyright', year: Date.today.year) + %li · + %li= image_tag 'flag.png', alt: 'flag' + %li · + %li= link_to t('bottom_menu.about'), t('bottom_menu.about_url') + %li · + %li= link_to t('bottom_menu.contacts'), t('bottom_menu.contacts_url') + %li · + %li= link_to t('bottom_menu.tos'), tos_url + %li · + %li= link_to t('bottom_menu.support'), contact_url + %li · + %li= link_to t('bottom_menu.developer_api'), t('bottom_menu.developer_api_url') + -if pr = Project.find_by_owner_and_name('abf/abf-ideas') + %li · + %li= link_to t('bottom_menu.abf_ideas'), project_issues_url(pr) + %li · + %li= link_to t('bottom_menu.abf_blog'), t('bottom_menu.abf_blog_url') diff --git a/app/views/layouts/menu/_new_top.html.haml b/app/views/layouts/menu/_new_top.html.haml new file mode 100644 index 000000000..737d729af --- /dev/null +++ b/app/views/layouts/menu/_new_top.html.haml @@ -0,0 +1,40 @@ +%nav.navbar.navbar-default.top_menu{ role: "navigation" } + .container-fluid + / Brand and toggle get grouped for better mobile display + .navbar-header + %button.navbar-toggle{ "data-target" => "#bs-example-navbar-collapse-1", "data-toggle" => "collapse", type: "button" } + %span.sr-only Toggle navigation + %span.icon-bar + %span.icon-bar + %span.icon-bar + = link_to image_tag('logo-mini.png', alt: 'ABF'), root_path, class: 'navbar-brand' + / Collect the nav links, forms, and other content for toggling + #bs-example-navbar-collapse-1.collapse.navbar-collapse + %ul.nav.navbar-nav + - (collection = t 'top_menu').each do |base, title| + - if can? :index, base.to_s.classify.constantize + %li{ class: top_menu_class(base) }= link_to title, send("#{base}_path") + - if current_user.try(:admin?) + %li{ class: top_menu_class('admin') }= link_to t('admins_menu_header'), admin_users_path + = form_tag search_index_path, method: 'get', class: 'navbar-form navbar-left', role: 'search' do + .form-group + = text_field_tag 'query', @query, placeholder: t('layout.search.header'), class: 'form-control' + %ul.nav.navbar-nav.navbar-right + %li + .avatar= image_tag avatar_url(current_user), alt: 'avatar', height: "32" + - if current_user + %li.dropdown + %a.dropdown-toggle{ "data-toggle" => "dropdown", href: "#" } + = current_user.uname + %b.caret + %ul.dropdown-menu + %li= link_to current_user.uname, current_user + %li= link_to t('layout.settings.label'), profile_settings_path + %li.divider + %li= link_to t('layout.logout'), destroy_user_session_path, method: :delete + - else + %ul.nav.navbar-nav + %li= link_to t('layout.devise.shared_links.sign_up'), new_register_request_path + %li= link_to t('layout.devise.shared_links.sign_in'), new_user_session_path + / /.navbar-collapse + / /.container-fluid diff --git a/config/environments/production.rb b/config/environments/production.rb index ff123a3df..828df5800 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -63,7 +63,7 @@ Rosa::Application.configure do config.assets.digest = true # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) - config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js moment/ru.js) + config.assets.precompile += %w(login.css login.js reg_session.css tour.css tour.js gollum/editor/langs/*.js moment/ru.js new_application.css new_application.js) config.eager_load = true end diff --git a/vendor/assets/stylesheets/bootstrap.scss b/vendor/assets/stylesheets/old-bootstrap.scss similarity index 100% rename from vendor/assets/stylesheets/bootstrap.scss rename to vendor/assets/stylesheets/old-bootstrap.scss diff --git a/vendor/assets/stylesheets/vendor.scss b/vendor/assets/stylesheets/vendor.scss index 0264d0a7f..5020011a8 100644 --- a/vendor/assets/stylesheets/vendor.scss +++ b/vendor/assets/stylesheets/vendor.scss @@ -13,5 +13,5 @@ @import "codemirror/modes/rpm-spec"; @import "codemirror/modes/tiddlywiki"; -@import "bootstrap"; +@import "old-bootstrap"; @import "chosen.scss"; \ No newline at end of file