From e5a37b4ed76df8aec6131789e7361ed6efa3394b Mon Sep 17 00:00:00 2001 From: elijah Date: Sun, 23 Jun 2013 22:18:28 -0700 Subject: new home page --- core/app/helpers/navigation_helper.rb | 82 +++++++++++++++++++++++++++++++++++ core/app/helpers/snippet_helper.rb | 11 +++++ 2 files changed, 93 insertions(+) create mode 100644 core/app/helpers/navigation_helper.rb create mode 100644 core/app/helpers/snippet_helper.rb (limited to 'core/app/helpers') diff --git a/core/app/helpers/navigation_helper.rb b/core/app/helpers/navigation_helper.rb new file mode 100644 index 0000000..19cb934 --- /dev/null +++ b/core/app/helpers/navigation_helper.rb @@ -0,0 +1,82 @@ +module NavigationHelper + + # + # used to create a side navigation link. + # + # Signature is the same as link_to, except it accepts an :active value in the html_options + # + def link_to_navigation(*args) + if args.last.is_a? Hash + html_options = args.pop.dup + active_class = html_options.delete(:active) ? 'active' : nil + html_options[:class] = [html_options[:class], active_class].join(' ') + args << html_options + else + active_class = nil + end + content_tag :li, :class => active_class do + link_to(*args) + end + end + + # + # returns true if params[:action] matches one of the args. + # + def action?(*actions) + actions.detect do |action| + if action.is_a? String + action == action_string + elsif action.is_a? Symbol + if action == :none + action_string == nil + else + action == action_symbol + end + end + end + end + + # + # returns true if params[:controller] matches one of the args. + # + # for example: + # controller?(:me, :home) + # controller?('groups/') <-- matches any controller in namespace 'groups' + # + def controller?(*controllers) + controllers.each do |cntr| + if cntr.is_a? String + if cntr.ends_with?('/') + return true if controller_string.starts_with?(cntr.chop) + end + return true if cntr == controller_string + elsif cntr.is_a? Symbol + return true if cntr == controller_symbol + end + end + return false + end + + private + + def controller_string + @controller_string ||= params[:controller].to_s.gsub(/^\//, '') + end + + def controller_symbol + @controller_symbol ||= params[:controller].gsub(/^\//,'').gsub('/','_').to_sym + end + + def action_string + params[:action] + end + + def action_symbol + @action_symbol ||= if params[:action].present? + params[:action].to_sym + else + nil + end + end + +end diff --git a/core/app/helpers/snippet_helper.rb b/core/app/helpers/snippet_helper.rb new file mode 100644 index 0000000..6fee454 --- /dev/null +++ b/core/app/helpers/snippet_helper.rb @@ -0,0 +1,11 @@ +# +# various html snippets we use throughout. +# + +module SnippetHelper + + def home_page_buttons + render 'common/home_page_buttons' + end + +end \ No newline at end of file -- cgit v1.2.3 From 40830b4b1fa33b9e26dbd500fc08b4b76b58011b Mon Sep 17 00:00:00 2001 From: elijah Date: Thu, 4 Jul 2013 01:36:08 -0700 Subject: minor changes to css and home page. --- core/app/helpers/core_helper.rb | 13 +++++++++++++ core/app/helpers/snippet_helper.rb | 11 ----------- 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 core/app/helpers/core_helper.rb delete mode 100644 core/app/helpers/snippet_helper.rb (limited to 'core/app/helpers') diff --git a/core/app/helpers/core_helper.rb b/core/app/helpers/core_helper.rb new file mode 100644 index 0000000..a496144 --- /dev/null +++ b/core/app/helpers/core_helper.rb @@ -0,0 +1,13 @@ +# +# Misc. helpers needed throughout. +# +module CoreHelper + + # + # insert common buttons (download, login, etc) + # + def home_page_buttons + render 'common/home_page_buttons' + end + +end \ No newline at end of file diff --git a/core/app/helpers/snippet_helper.rb b/core/app/helpers/snippet_helper.rb deleted file mode 100644 index 6fee454..0000000 --- a/core/app/helpers/snippet_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -# -# various html snippets we use throughout. -# - -module SnippetHelper - - def home_page_buttons - render 'common/home_page_buttons' - end - -end \ No newline at end of file -- cgit v1.2.3