diff --git a/Gemfile b/Gemfile index 872327f..2be3da5 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,9 @@ gem 'mongoid-paperclip' # Stripe integration gem 'stripe' +# Render your navigation as HTML list, link list or breadcrumbs. +gem 'simple-navigation' + # To extend paperclip with locales gem 'paperclip-i18n' @@ -37,9 +40,6 @@ gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc -# Easily generate a Twitter Bootstrap navbar in your Rails app -gem 'rails_bootstrap_navbar' - # Kaminari Mongoid adapter. gem 'kaminari-mongoid' gem 'kaminari-actionview' diff --git a/Gemfile.lock b/Gemfile.lock index 0e548cc..5f4332e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -52,8 +52,6 @@ GEM benchmark-ips (2.7.2) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - bootstrap-navbar (2.5.0) - gem_config (~> 0.3) bootstrap-sass (3.3.7) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) @@ -114,7 +112,6 @@ GEM ffi (1.9.18) font-awesome-rails (4.7.0.2) railties (>= 3.2, < 5.2) - gem_config (0.3.1) geocoder (1.4.4) get_process_mem (0.2.1) globalid (0.4.0) @@ -251,9 +248,6 @@ GEM rails (>= 4.0, < 6) remotipart (~> 1.3) sass-rails (>= 4.0, < 6) - rails_bootstrap_navbar (2.0.1) - bootstrap-navbar (~> 2.0) - rails (>= 3.0.0) rails_serve_static_assets (0.0.5) rails_stdout_logging (0.0.5) railties (4.2.10) @@ -314,6 +308,8 @@ GEM sdoc (0.4.2) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) + simple-navigation (4.0.5) + activesupport (>= 2.3.2) simple_form (3.5.0) actionpack (> 4, < 5.2) activemodel (> 4, < 5.2) @@ -384,12 +380,12 @@ DEPENDENCIES rails-i18n rails_12factor rails_admin - rails_bootstrap_navbar roadie-rails (~> 1.0) route_translator rspec-rails (~> 3.0) sass-rails (~> 5.0) sdoc (~> 0.4.0) + simple-navigation simple_form slim slim-rails @@ -402,4 +398,4 @@ RUBY VERSION ruby 2.3.1p112 BUNDLED WITH - 1.14.6 + 1.16.0 diff --git a/app/assets/stylesheets/application.sass b/app/assets/stylesheets/application.sass index a227ef1..9ecf2f2 100644 --- a/app/assets/stylesheets/application.sass +++ b/app/assets/stylesheets/application.sass @@ -20,6 +20,7 @@ @import "footnotes" @import "statements" @import "donations" +@import "nav" .alert-alert @extend .alert-danger @@ -58,6 +59,12 @@ body .container padding-left: 0px + header > .row + margin-bottom: 12px + + main > h1 + margin-top: 0px + ul#topnav font-size: 1.2em diff --git a/app/assets/stylesheets/nav.sass b/app/assets/stylesheets/nav.sass new file mode 100644 index 0000000..3b3cc59 --- /dev/null +++ b/app/assets/stylesheets/nav.sass @@ -0,0 +1,25 @@ +@import "variables" + +nav#mainnav + marign-top: 12px + font-size: 16pt + + a + color: $brand-success + + a.selected + font-weight: bold + + + ul + list-style: none + + li + padding-bottom: 6px + + ul + padding-left: 20px + padding-top: 12px + + li + font-size: 12pt \ No newline at end of file diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim index 12620e2..9bf2df7 100644 --- a/app/views/layouts/application.html.slim +++ b/app/views/layouts/application.html.slim @@ -65,8 +65,11 @@ html lang="#{I18n.locale}" .container.content = render 'shared/flashes' = render 'shared/header' - = render 'shared/topnavigation' - = yield + .row + .col-xs-12.col-sm-3 + nav#mainnav = render_navigation + .col-xs-12.col-sm-9 + main= yield hr footer.row .col-xs-12.col-sm-6 diff --git a/app/views/shared/_topnavigation.slim b/app/views/shared/_topnavigation.slim deleted file mode 100644 index d9268dc..0000000 --- a/app/views/shared/_topnavigation.slim +++ /dev/null @@ -1,19 +0,0 @@ -= navbar do - = navbar_header - = navbar_collapse do - = navbar_group id: 'topnav' do - = navbar_item "Home", "/#{I18n.locale}" - = navbar_dropdown t('.initiative') do - = navbar_item t('.initiative_text'), initiative_text_path - = navbar_item t('.arguments'), arguments_path - = navbar_item t('.faq'), faq_path - = navbar_item t('.numbers'), numbers_path - = navbar_item t('.collection_concept'), collection_concept_path - = navbar_item t('.statements'), statements_path - = navbar_item t('donation'), donation_path - = navbar_item 'Blog', 'http://blog.cannabis-initiative.ch' - = navbar_item t('.sign_in'), new_supporter_session_path unless supporter_signed_in? - = navbar_item t('.sign_out'), destroy_supporter_session_path, nil, 'data-method' => :delete if supporter_signed_in? - - if supporter_signed_in? && current_supporter.admin? - = navbar_dropdown t('admin.title') do - = navbar_item t('admin.publicities.index.title'), admin_publicities_path diff --git a/app/views/supporters/registrations/edit.html.slim b/app/views/supporters/registrations/edit.html.slim index d85ef28..75a3fa5 100644 --- a/app/views/supporters/registrations/edit.html.slim +++ b/app/views/supporters/registrations/edit.html.slim @@ -21,7 +21,6 @@ = f.input :language, as: :radio_buttons, collection: t('languages').map{ |x| [x.first, raw(x.last)]}, label_method: :last, value_method: :first .form-actions = f.button :submit, t("devise.registrations.edit.update"), class: 'btn btn-primary' - p = link_to t("devise.shared.links.back"), :back hr p = link_to t("devise.registrations.edit.cancel_my_account"), registration_path(resource_name), data: { confirm: t("devise.registrations.edit.are_you_sure") }, method: :delete, class: 'btn btn-danger btn-sm pull-right' diff --git a/config/initializers/rails-bootstrap-navbar.rb b/config/initializers/rails-bootstrap-navbar.rb deleted file mode 100644 index b0816f5..0000000 --- a/config/initializers/rails-bootstrap-navbar.rb +++ /dev/null @@ -1,4 +0,0 @@ -BootstrapNavbar.configure do |config| - config.bootstrap_version = '3.3.6' - config.root_paths = ['/', '/de', '/fr', '/it'] # default: ['/'] -end \ No newline at end of file diff --git a/config/locales/de.yml b/config/locales/de.yml index e0e2884..b904e92 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -7,6 +7,8 @@ de: logo: Logo der Initiative title_html: Ja, ich will Cannabis in der Schweiz legalisieren topnavigation: + support: Unterstützen + my_account: Mein Konto sign_in: Anmelden sign_out: Abmelden initiative_text: Der Initiativtext im Wortlaut @@ -15,7 +17,7 @@ de: faq: Fragen und Antworten sponsoring: Sponsoren numbers: Zahlen - statementes: Statements + statements: Statements collection_concept: Wie macht man eine Volksinitiative? lang: Sprache @@ -80,7 +82,7 @@ de: new: title: Hallo %{name} - edit: Meine Daten bearbeiten... + edit: Meine Daten bearbeiten my_data: Meine Daten publicities: diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 43021eb..2ba13d3 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -22,6 +22,7 @@ fr: numbers: Chiffres (en allemand) statements: Déclarations collection_concept: Comment faire une initiative populaire? (en allemand) + my_account: Mon compte lang: Langue are_you_sure: Tu es sûre? @@ -77,7 +78,7 @@ fr: new: title: Salut %{name} - edit: Modifier mes données ... + edit: Modifier mes données my_data: Mes données publicities: diff --git a/config/locales/it.yml b/config/locales/it.yml index f7700ff..ae09c82 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -19,6 +19,7 @@ it: numbers: Numeri (in tedesco) statements: Dichiarazioni collection_concept: Come fare un iniziativa popolare? (in tedesco) + my_account: Il mio account counter: supporters: "Sostenitore:" @@ -81,7 +82,7 @@ it: new: title: Ciao %{name} - edit: Modifica i miei dati ... + edit: Modifica i miei dati my_data: Miei dati publicities: diff --git a/config/navigation.rb b/config/navigation.rb new file mode 100644 index 0000000..bd087ce --- /dev/null +++ b/config/navigation.rb @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +# Configures your navigation +SimpleNavigation::Configuration.run do |navigation| + # Specify a custom renderer if needed. + # The default renderer is SimpleNavigation::Renderer::List which renders HTML lists. + # The renderer can also be specified as option in the render_navigation call. + # navigation.renderer = Your::Custom::Renderer + + # Specify the class that will be applied to active navigation items. Defaults to 'selected' + #navigation.selected_class = 'selected' + + # Specify the class that will be applied to the current leaf of + # active navigation items. Defaults to 'simple-navigation-active-leaf' + #navigation.active_leaf_class = 'simple-navigation-active-leaf' + + # Specify if item keys are added to navigation items as id. Defaults to true + #navigation.autogenerate_item_ids = true + + # You can override the default logic that is used to autogenerate the item ids. + # To do this, define a Proc which takes the key of the current item as argument. + # The example below would add a prefix to each key. + #navigation.id_generator = Proc.new {|key| "my-prefix-#{key}"} + + # If you need to add custom html around item names, you can define a proc that + # will be called with the name you pass in to the navigation. + # The example below shows how to wrap items spans. + #navigation.name_generator = Proc.new {|name, item| "#{name}"} + + # Specify if the auto highlight feature is turned on (globally, for the whole navigation). Defaults to true + #navigation.auto_highlight = true + + # Specifies whether auto highlight should ignore query params and/or anchors when + # comparing the navigation items with the current URL. Defaults to true + #navigation.ignore_query_params_on_auto_highlight = true + #navigation.ignore_anchors_on_auto_highlight = true + + # If this option is set to true, all item names will be considered as safe (passed through html_safe). Defaults to false. + #navigation.consider_item_names_as_safe = false + + # Define the primary navigation + navigation.items do |primary| + # Add an item to the primary navigation. The following params apply: + # key - a symbol which uniquely defines your navigation item in the scope of the primary_navigation + # name - will be displayed in the rendered navigation. This can also be a call to your I18n-framework. + # url - the address that the generated item links to. You can also use url_helpers (named routes, restful routes helper, url_for etc.) + # options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.) + # some special options that can be set: + # :if - Specifies a proc to call to determine if the item should + # be rendered (e.g. if: -> { current_user.admin? }). The + # proc should evaluate to a true or false value and is evaluated in the context of the view. + # :unless - Specifies a proc to call to determine if the item should not + # be rendered (e.g. unless: -> { current_user.admin? }). The + # proc should evaluate to a true or false value and is evaluated in the context of the view. + # :method - Specifies the http-method for the generated link - default is :get. + # :highlights_on - if autohighlighting is turned off and/or you want to explicitly specify + # when the item should be highlighted, you can set a regexp which is matched + # against the current URI. You may also use a proc, or the symbol :subpath. + # + + unless supporter_signed_in? + primary.item :home, I18n.t('.shared.topnavigation.support'), "/#{I18n.locale}" + end + primary.item :initiative, I18n.t('.shared.topnavigation.initiative'), initiative_text_path do | initiative | + initiative.item :arguments, I18n.t('.shared.topnavigation.arguments'), arguments_path + initiative.item :faq, I18n.t('.shared.topnavigation.faq'), faq_path + initiative.item :numbers, I18n.t('.shared.topnavigation.numbers'), numbers_path + initiative.item :collection_concept, I18n.t('.shared.topnavigation.collection_concept'), collection_concept_path + end + primary.item :statements, I18n.t('.shared.topnavigation.statements'), statements_path do |statements| + statements.item :new_statement, I18n.t('.supporters.publicity.renew'), new_publicity_path + end + primary.item :donation, I18n.t('donation'), donation_path + primary.item :blog, 'Blog', 'http://blog.cannabis-initiative.ch/', link_html: { target: '_blank'} + if supporter_signed_in? + primary.item :home, I18n.t('.shared.topnavigation.my_account'), "/#{I18n.locale}" do |my_account| + my_account.item :edit_account, I18n.t('.supporters.new.edit'), edit_supporter_registration_path() + my_account.item :sign_out, I18n.t('.shared.topnavigation.sign_out'), destroy_supporter_session_path, link_html: { 'data-method' => :delete } + end + else + primary.item :home, I18n.t('.shared.topnavigation.sign_in'), new_supporter_session_path + end + end +end \ No newline at end of file