diff --git a/Gemfile b/Gemfile index 502283ff..b05d5a04 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,7 @@ gem 'devise', '2.0.4' gem 'devise_simply_stored' gem 'simple_form' gem 'draper' +gem 'cmtool', github: 'bterkuile/cmtool' gem 'rqrcode' gem 'mini_magick' diff --git a/Gemfile.lock b/Gemfile.lock index c0d49527..10bcd9b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,11 +1,29 @@ +GIT + remote: git://github.com/bterkuile/cmtool.git + revision: 370aa0369e1885dacaac57c911ebd6aded808eee + specs: + cmtool (0.5.0) + bourbon + coffee-script + devise (= 2.0.4) + devise_simply_stored + email_validator + haml-rails + jquery-rails + paperclip + rails (~> 3.2.2) + sass-rails + slim-rails + tinymce-rails + GIT remote: git://github.com/bterkuile/couch_potato.git - revision: ff7505c432cabfccb55cfa732a548d9449d8250c + revision: 7712a8d12c319f2e165733800795acbb599638d2 specs: - couch_potato (0.7.0.pre.1) + couch_potato (0.7.1) activemodel couchrest (>= 1.0.1) - json (~> 1.6.0) + json (~> 1.6) GIT remote: git://github.com/bterkuile/simply_stored.git @@ -46,10 +64,10 @@ GEM activesupport (3.2.11) i18n (~> 0.6) multi_json (~> 1.0) - addressable (2.3.2) + addressable (2.3.3) arel (3.0.2) bcrypt-ruby (3.0.1) - bootstrap-sass (2.3.0.0) + bootstrap-sass (2.3.0.1) sass (~> 3.2) bourbon (3.1.1) sass (>= 3.2.0) @@ -62,17 +80,21 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 1.0.0) - childprocess (0.3.8) + childprocess (0.3.9) ffi (~> 1.0, >= 1.0.11) chunky_png (1.2.7) - coderay (1.0.8) + climate_control (0.0.3) + activesupport (>= 3.0) + cocaine (0.5.1) + climate_control (>= 0.0.3, < 1.0) + coderay (1.0.9) coffee-rails (3.2.2) coffee-script (>= 2.2.0) railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.4.0) + coffee-script-source (1.5.0) compass (0.12.2) chunky_png (~> 1.2) fssm (>= 0.2.7) @@ -91,13 +113,15 @@ GEM warden (~> 1.1.1) devise_simply_stored (0.0.3) devise - diff-lcs (1.1.3) + diff-lcs (1.2.1) draper (1.1.0) actionpack (>= 3.0) activesupport (>= 3.0) request_store (~> 1.0.3) + email_validator (1.3.0) + activemodel erubis (2.7.0) - eventmachine (1.0.0) + eventmachine (1.0.1) execjs (1.4.0) multi_json (~> 1.0) factory_girl (4.2.0) @@ -124,12 +148,12 @@ GEM haml (>= 3.1, < 4.1) railties (>= 3.1, < 4.1) hike (1.2.1) - i18n (0.6.1) + i18n (0.6.4) journey (1.0.4) jquery-rails (2.2.1) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - json (1.6.7) + json (1.7.7) kaminari (0.14.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -140,7 +164,7 @@ GEM addressable (~> 2.3) letter_opener (1.1.0) launchy (~> 2.2.0) - listen (0.7.2) + listen (0.7.3) lumberjack (1.0.2) mail (2.4.4) i18n (>= 0.4.0) @@ -150,17 +174,23 @@ GEM mime-types (1.21) mini_magick (3.5.0) subexec (~> 0.2.1) - multi_json (1.5.0) + multi_json (1.6.1) mustache (0.99.4) nokogiri (1.5.6) orm_adapter (0.0.7) + paperclip (3.4.1) + activemodel (>= 3.0.0) + activerecord (>= 3.0.0) + activesupport (>= 3.0.0) + cocaine (~> 0.5.0) + mime-types polyglot (0.3.3) pry (0.9.12) coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) - quiet_assets (1.0.1) - railties (~> 3.1) + quiet_assets (1.0.2) + railties (>= 3.1, < 5.0) rack (1.4.5) rack-cache (1.2) rack (>= 0.4) @@ -187,40 +217,40 @@ GEM thor (>= 0.14.6, < 2.0) rake (10.0.3) rb-fsevent (0.9.3) - rdoc (3.12.1) + rdoc (3.12.2) json (~> 1.4) request_store (1.0.5) rest-client (1.6.7) mime-types (>= 1.16) rqrcode (0.4.2) - rspec (2.12.0) - rspec-core (~> 2.12.0) - rspec-expectations (~> 2.12.0) - rspec-mocks (~> 2.12.0) - rspec-core (2.12.2) - rspec-expectations (2.12.1) - diff-lcs (~> 1.1.3) - rspec-mocks (2.12.2) - rspec-rails (2.12.2) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.0) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.0) + rspec-rails (2.13.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 2.12.0) - rspec-expectations (~> 2.12.0) - rspec-mocks (~> 2.12.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) ruby_gntp (0.3.4) rubyzip (0.9.9) - sass (3.2.5) + sass (3.2.6) sass-rails (3.2.6) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - selenium-webdriver (2.29.0) + selenium-webdriver (2.31.0) childprocess (>= 0.2.5) multi_json (~> 1.0) rubyzip websocket (~> 1.0.4) - simple_form (2.0.4) + simple_form (2.1.0) actionpack (~> 3.0) activemodel (~> 3.0) slim (1.3.6) @@ -248,7 +278,9 @@ GEM eventmachine (>= 0.12.6) rack (>= 1.0.0) thor (0.17.0) - tilt (1.3.3) + tilt (1.3.4) + tinymce-rails (3.5.8.1) + railties (>= 3.1.1) treetop (1.4.12) polyglot polyglot (>= 0.3.1) @@ -268,6 +300,7 @@ PLATFORMS DEPENDENCIES bootstrap-sass bourbon + cmtool! coffee-rails (~> 3.2.1) compass-rails couch_potato! diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b14c45a9..2d8adbf3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,6 +6,10 @@ class ApplicationController < ActionController::Base rescue_from SimplyStored::RecordNotFound, with: :show_404 private + def authorize_cmtool + redirect_to '/', alert: t('general.unauthorized') unless current_user.present? && current_user.admin? + end + def broadcast_user(uid, event, data = {}) message = {channel: "/user/#{uid}", data: {event: event, data: data}} uri = URI.parse(event_host) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 82edb182..0d0bd088 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,17 +1,5 @@ class DashboardController < ApplicationController layout 'theme1' - def home - render layout: 'theme1-home' - end - - def contact - end - def bars_restaurants - end - - def clients - end - def demo_both render layout: 'demo-both' @@ -47,9 +35,4 @@ class DashboardController < ApplicationController format.svg { render qrcode: code, level: :h, unit: 10, size: 7} end end - - def scan - - end - end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb new file mode 100644 index 00000000..f81ac73c --- /dev/null +++ b/app/controllers/pages_controller.rb @@ -0,0 +1,3 @@ +class PagesController < ApplicationController + include Cmtool::Includes::PagesController +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4c1cde3a..49b94e87 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -22,7 +22,7 @@ module ApplicationHelper super(*args) end - def are_you_sure? + def are_you_sure?(record) t('helpers.links.are_you_sure') end diff --git a/app/models/page.rb b/app/models/page.rb new file mode 100644 index 00000000..0d82da70 --- /dev/null +++ b/app/models/page.rb @@ -0,0 +1,6 @@ +class Page + include Cmtool::Includes::Page + def self.layouts + %w[theme1 theme1-home] + end +end diff --git a/app/models/user.rb b/app/models/user.rb index b8a486e5..bedc3829 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,6 +4,7 @@ class User property :name property :active_list_id + property :admin, type: :boolean, default: false devise :database_authenticatable, :recoverable, :rememberable, :trackable, :token_authenticatable # , :registerable diff --git a/app/views/application/_footer.html.slim b/app/views/application/_footer.html.slim index ef2a2a96..327cf6bc 100644 --- a/app/views/application/_footer.html.slim +++ b/app/views/application/_footer.html.slim @@ -1,6 +1,6 @@ = yield :footer -= link_to 'disclaimer', '#' += link_to 'disclaimer', page_path('disclaimer') ' -= link_to 'privacy', '#' += link_to 'privacy', page_path('privacy') ' -= link_to 'kernwaarden', '#' += link_to 'kernwaarden', page_path('values') diff --git a/app/views/layouts/theme1.html.slim b/app/views/layouts/theme1.html.slim index 681fde30..6ddad4d5 100644 --- a/app/views/layouts/theme1.html.slim +++ b/app/views/layouts/theme1.html.slim @@ -47,7 +47,8 @@ html lang="en" .alert.alert-success a.close data-dismiss="alert" × div= flash[:notice] - = yield :page_title + - if @page && @page.title.present? + h1.page-title= @page.title = yield #footer-wrap .footer-shadow diff --git a/app/views/theme1/_navigation.html.slim b/app/views/theme1/_navigation.html.slim index 17264f1d..7afc4054 100644 --- a/app/views/theme1/_navigation.html.slim +++ b/app/views/theme1/_navigation.html.slim @@ -5,11 +5,9 @@ span.icon-bar ul.nav - li[class=(current_page?(controller: '/dashboard', action: 'home') ? :active : nil)]= link_to t('menu.home'), root_path - li[class=(current_page?(controller: '/dashboard', action: 'about') ? :active : nil)]= link_to t('menu.about'), about_path + li[class=(current_page?(controller: '/pages', action: 'home') ? :active : nil)]= link_to t('menu.home'), root_path + li[class=(current_page?(controller: '/pages', action: 'show', name: 'about') ? :active : nil)]= link_to t('menu.about'), page_path('about') .nav-collapse.collapse ul.nav - li[class=(current_page?(controller: '/dashboard', action: 'clients') ? :active : nil)]= link_to t('menu.clients'), clients_path - li[class=(current_page?(controller: '/dashboard', action: 'bars_restaurants') ? :active : nil)]= link_to t('menu.bars_restaurants'), bars_restaurants_path - li[class=(current_page?(controller: '/dashboard', action: 'cartoon') ? :active : nil)]= link_to t('menu.cartoon'), cartoon_path - li[class=(current_page?(controller: '/dashboard', action: 'contact') ? :active : nil)]= link_to t('menu.contact'), contact_path + - Page.top_menu.each do |page| + li[class=(current_page?(controller: '/pages', action: 'show', name: page.name) ? :active : nil)]= link_to page.menu_text, page_path(page.name) diff --git a/config/application.rb b/config/application.rb index 1bd24c85..9c7eb046 100644 --- a/config/application.rb +++ b/config/application.rb @@ -16,6 +16,17 @@ if defined?(Bundler) # Bundler.require(:default, :assets, Rails.env) end +# Ugly fix for the updated json gem changes +module JSON + class << self + alias :old_parse :parse + def parse(json, args = {}) + args[:create_additions] = true + old_parse(json, args) + end + end +end + module Qwaiter class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. diff --git a/config/routes.rb b/config/routes.rb index efee1149..0b99df33 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -61,13 +61,13 @@ Qwaiter::Application.routes.draw do #match '/show_products' => 'dashboard#show_products', as: :user_products # GENERAL - get '/about' => 'dashboard#about' - get '/enquete' => 'dashboard#enquete' - get '/cartoon' => 'dashboard#cartoon' - get '/bars-restaurants' => 'dashboard#bars_restaurants', as: :bars_restaurants - get '/clients' => 'dashboard#clients' - get '/contact' => 'dashboard#contact' - get '/s' => 'dashboard#scan', as: :scan + #get '/about' => 'dashboard#about' + #get '/enquete' => 'dashboard#enquete' + #get '/cartoon' => 'dashboard#cartoon' + #get '/bars-restaurants' => 'dashboard#bars_restaurants', as: :bars_restaurants + #get '/clients' => 'dashboard#clients' + #get '/contact' => 'dashboard#contact' + get '/s' => redirect('/scan'), as: :scan # DEVELOPMENT ONLY get '/qr' => 'dashboard#qr' @@ -100,6 +100,8 @@ Qwaiter::Application.routes.draw do #DEMO & DEVELOPMENT get '/select_qrcode' => 'dashboard#select_qrcode' get '/table_qr_image' => 'dashboard#table_qr_image', as: :table_qr_image + + mount Cmtool::Engine => '/cmtool' #match "/:action", controller: 'dashboard' # The priority is based upon order of creation: @@ -151,7 +153,10 @@ Qwaiter::Application.routes.draw do # You can have the root of your site routed with "root" # just remember to delete public/index.html. - root :to => 'dashboard#home' + # + #root :to => 'dashboard#home' + root :to => 'pages#home' + get "/:name" => "pages#show", constraints: {name: /.*/}, as: :page # See how all your routes lay out with "rake routes"