Sha256: 4571a73cfb4c3b28a0c945f597293085a005dc37eb13ad1a4e306f1554cc724f

Contents?: true

Size: 1.95 KB

Versions: 1

Compression:

Stored size: 1.95 KB

Contents

module Teamster
  module Core
    module GeneralHelper
      def title
        App.title
      end

      def current_user
        session[:current_user]
      end

      def logged_in?
        !!current_user
      end

      def use_included_bootstrap_css?
        true
      end

      def use_included_bootstrap_js?
        true
      end

      def login_required
        halt(403, erb(:login_required)) unless session[:current_user]
      end

      def include_bootstrap_css
        %q~<link rel='stylesheet' href='/css/bootstrap.min.css' type='text/css'>
        <link rel='stylesheet' href='/css/bootstrap-theme.min.css' type='text/css'>~
      end

      def include_bootstrap_js
        %q~<script src="/js/jquery-2.1.0.min.js"></script>
        <script src="/js/bootstrap.min.js"></script>~
      end

      def navbar
        erb :navbar
      end

      def footer
        erb :footer
      end

      def available_modules(shuffle = false)
        available_modules = [].tap do |arr|
          App.modules.each do |mod|
            module_name = mod.to_s.split("::").last
            arr << ['/' + module_name.downcase, module_name] unless mod.under_development?
          end
        end
        shuffle ? available_modules.shuffle : available_modules
      end

      def developing_modules
        [].tap do |arr|
          App.modules.each do |mod|
            module_name = mod.to_s.split("::").last
            arr << ['/' + module_name.downcase, module_name] if mod.under_development?
          end
        end
      end

      def all_modules(shuffle = false)
        all_modules = [].tap do |arr|
          App.modules.each do |mod|
            module_name = mod.to_s.split("::").last
            arr << ['/' + module_name.downcase, module_name]
          end
        end
        shuffle ? all_modules.shuffle : all_modules
      end

      def find_template(views, name, engine, &block)
        App.views.each {|v| super(v, name, engine, &block)}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
teamster-0.3.2 lib/teamster/general_helper.rb