Module: Teamster::Core::GeneralHelper
- Defined in:
- lib/teamster/general_helper.rb
Constant Summary collapse
- CORE_JS =
['bootstrap.min.js', 'jquery-2.1.0.min.js', 'site.js']
Instance Method Summary collapse
- #add_other_js_files ⇒ Object
- #all_adapters(shuffle = false) ⇒ Object
- #available_adapters(shuffle = false) ⇒ Object
- #current_user ⇒ Object
- #developing_adapters ⇒ Object
- #find_template(views, *args, &block) ⇒ Object
- #footer ⇒ Object
- #include_bootstrap_css ⇒ Object
- #include_bootstrap_js ⇒ Object
- #logged_in? ⇒ Boolean
- #login_required ⇒ Object
- #navbar ⇒ Object
- #title ⇒ Object
- #use_included_bootstrap_css? ⇒ Boolean
- #use_included_bootstrap_js? ⇒ Boolean
Instance Method Details
#add_other_js_files ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/teamster/general_helper.rb', line 40 def add_other_js_files all_js = Dir.glob('public/js/*.js') other_js = all_js.delete_if {|js| CORE_JS.include?(File.basename(js))} other_js.map {|js| js.gsub('public', '')} [].tap do |arr| other_js.each do |js| arr << "<script src=\"#{js}\"></script>" end end.join('\n') end |
#all_adapters(shuffle = false) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/teamster/general_helper.rb', line 78 def all_adapters(shuffle = false) all_adapters = [].tap do |arr| App.adapters.each do |mod| adapter_name = mod.to_s.split("::").last arr << ['/' + adapter_name.downcase, adapter_name] end end shuffle ? all_adapters.shuffle : all_adapters end |
#available_adapters(shuffle = false) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/teamster/general_helper.rb', line 59 def available_adapters(shuffle = false) available_adapters = [].tap do |arr| App.adapters.each do |mod| adapter_name = mod.to_s.split("::").last arr << ['/' + adapter_name.downcase, adapter_name] unless mod.under_development? end end shuffle ? available_adapters.shuffle : available_adapters end |
#current_user ⇒ Object
8 9 10 |
# File 'lib/teamster/general_helper.rb', line 8 def current_user session[:current_user] end |
#developing_adapters ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/teamster/general_helper.rb', line 69 def developing_adapters [].tap do |arr| App.adapters.each do |mod| adapter_name = mod.to_s.split("::").last arr << ['/' + adapter_name.downcase, adapter_name] if mod.under_development? end end end |
#find_template(views, *args, &block) ⇒ Object
88 89 90 |
# File 'lib/teamster/general_helper.rb', line 88 def find_template(views, *args, &block) App.views.each {|v| super(v, *args, &block)} end |
#footer ⇒ Object
55 56 57 |
# File 'lib/teamster/general_helper.rb', line 55 def erb :footer end |
#include_bootstrap_css ⇒ Object
28 29 30 31 |
# File 'lib/teamster/general_helper.rb', line 28 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 |
#include_bootstrap_js ⇒ Object
33 34 35 36 |
# File 'lib/teamster/general_helper.rb', line 33 def include_bootstrap_js %q~<script src="/js/jquery-2.1.0.min.js"></script> <script src="/js/bootstrap.min.js"></script>~ end |
#logged_in? ⇒ Boolean
12 13 14 |
# File 'lib/teamster/general_helper.rb', line 12 def logged_in? !!current_user end |
#login_required ⇒ Object
24 25 26 |
# File 'lib/teamster/general_helper.rb', line 24 def login_required halt(403, erb(:login_required)) unless session[:current_user] end |
#navbar ⇒ Object
51 52 53 |
# File 'lib/teamster/general_helper.rb', line 51 def erb :navbar end |
#title ⇒ Object
4 5 6 |
# File 'lib/teamster/general_helper.rb', line 4 def title App.title end |
#use_included_bootstrap_css? ⇒ Boolean
16 17 18 |
# File 'lib/teamster/general_helper.rb', line 16 def use_included_bootstrap_css? true end |
#use_included_bootstrap_js? ⇒ Boolean
20 21 22 |
# File 'lib/teamster/general_helper.rb', line 20 def use_included_bootstrap_js? true end |