diff options
Diffstat (limited to 'lib')
10 files changed, 44 insertions, 12 deletions
diff --git a/lib/bootstrap_breadcrumbs_builder.rb b/lib/bootstrap_breadcrumbs_builder.rb new file mode 100644 index 0000000..1d6326b --- /dev/null +++ b/lib/bootstrap_breadcrumbs_builder.rb @@ -0,0 +1,32 @@ +# The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder. +# It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions. +# +# BootstrapBreadcrumbsBuilder accepts a limited set of options: +# * separator: what should be displayed as a separator between elements +# +# You can use it with the :builder option on render_breadcrumbs: +# <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder, :separator => "»" %> +# +# Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class: +# config.autoload_paths += Dir["#{config.root}/lib/"] +# +class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder + def render + @context.content_tag(:ul, class: 'breadcrumb') do + @elements.collect do |element| + render_element(element) + end.join.html_safe + end + end + + def render_element(element) + current = @context.current_page?(compute_path(element)) + + @context.content_tag(:li, :class => ('active' if current)) do + link_or_text = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options) + divider = @context.content_tag(:span, (@options[:separator] || '/').html_safe, :class => 'divider') unless current + + link_or_text + (divider || '') + end + end +end
\ No newline at end of file diff --git a/lib/generators/nifty/authentication/templates/views/haml/edit.html.haml b/lib/generators/nifty/authentication/templates/views/haml/edit.html.haml index 4b43a3b..7f21ea3 100644 --- a/lib/generators/nifty/authentication/templates/views/haml/edit.html.haml +++ b/lib/generators/nifty/authentication/templates/views/haml/edit.html.haml @@ -1,3 +1,3 @@ -- title "Sign up" +- content_for :title, "Sign up" = render "form" diff --git a/lib/generators/nifty/authentication/templates/views/haml/login.html.haml b/lib/generators/nifty/authentication/templates/views/haml/login.html.haml index 22fc95b..3aebb44 100644 --- a/lib/generators/nifty/authentication/templates/views/haml/login.html.haml +++ b/lib/generators/nifty/authentication/templates/views/haml/login.html.haml @@ -1,4 +1,4 @@ -- title "Log in" +- content_for :title, "Log in" %p== Don't have an account? #{link_to "Sign up!", signup_path} diff --git a/lib/generators/nifty/authentication/templates/views/haml/signup.html.haml b/lib/generators/nifty/authentication/templates/views/haml/signup.html.haml index dc75c13..8557204 100644 --- a/lib/generators/nifty/authentication/templates/views/haml/signup.html.haml +++ b/lib/generators/nifty/authentication/templates/views/haml/signup.html.haml @@ -1,4 +1,4 @@ -- title "Sign up" +- content_for :title, "Sign up" %p== Already have an account? #{link_to "Log in", login_path}. diff --git a/lib/generators/nifty/scaffold/templates/views/haml/_index_core.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/_index_core.html.haml index 9cbea63..a523d32 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/_index_core.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/_index_core.html.haml @@ -1,12 +1,12 @@ -%table +%table{:class => 'table table-striped'} %tr <%- for attribute in model_attributes -%> %th= t('<%= plural_name %>.index.<%= attribute.name %>') <%- end -%> - - reset_cycle + - for <%= instance_name %> in <%= instances_name %> - %tr{:class => cycle('odd', 'even')} + %tr <%- for attribute in model_attributes -%> %td= <%= instance_name %>.<%= attribute.name %> <%- end -%> diff --git a/lib/generators/nifty/scaffold/templates/views/haml/edit.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/edit.html.haml index dc7de62..381fba0 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/edit.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/edit.html.haml @@ -1,3 +1,3 @@ -- title t("<%= plural_name %>.edit.page_title") +- content_for :title, t("<%= plural_name %>.edit.page_title") <%= render_form %>
\ No newline at end of file diff --git a/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml index 86c6b9e..b6642ad 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml @@ -1,4 +1,4 @@ -- title t("<%= plural_name %>.index.page_title") +- content_for :title, t("<%= plural_name %>.index.page_title") - if @<%= instances_name %> && @<%= instances_name %>.count > 0 = render "index_core", :<%= instances_name %> => @<%= instances_name %> diff --git a/lib/generators/nifty/scaffold/templates/views/haml/new.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/new.html.haml index 4e7f871..d9a6bb5 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/new.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/new.html.haml @@ -1,3 +1,3 @@ -- title t("<%= plural_name %>.new.page_title") +- content_for :title, t("<%= plural_name %>.new.page_title") <%= render_form %>
\ No newline at end of file diff --git a/lib/generators/nifty/scaffold/templates/views/haml/show.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/show.html.haml index 3d01340..bd73c52 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/show.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/show.html.haml @@ -1,4 +1,4 @@ -- title t("<%= plural_name %>.show.page_title") +- content_for :title, t("<%= plural_name %>.show.page_title") <%- for attribute in model_attributes -%> %p diff --git a/lib/templates/erb/scaffold/_form.html.erb b/lib/templates/erb/scaffold/_form.html.erb index 24a1768..201a069 100644 --- a/lib/templates/erb/scaffold/_form.html.erb +++ b/lib/templates/erb/scaffold/_form.html.erb @@ -1,13 +1,13 @@ <%%= simple_form_for(@<%= singular_table_name %>) do |f| %> <%%= f.error_notification %> - <div class="inputs"> + <div class="form-inputs"> <%- attributes.each do |attribute| -%> <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %> <%- end -%> </div> - <div class="actions"> + <div class="form-actions"> <%%= f.button :submit %> </div> <%% end %> |