Skip to content

Using active_link_to if defined (falling back to link_to) #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

johanandre
Copy link
Member

@johanandre johanandre commented Feb 17, 2017

  • Cleaning up concat of html (no longer need html_safe on generated output)
  • Removing inline html (except the icon chevron)
  • When a block is passed to sidebar_item (for generating a dropdown), an random id is created

closes #10

- Cleaning up concat of html (no longer need html_safe on generated output)
- Removing inline html (except the icon chevron)
- When a block is passed to sidebar_item (for generating a dropdown), an random id is created
@johanandre johanandre requested a review from AnteWall February 17, 2017 18:55
html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: {toggle: 'collapse'}))
concat(content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [84/80]

content_tag :li do
html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: {toggle: 'collapse'}))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [116/80]
Space inside { missing.
Space inside } missing.

if block_given?
url = "##{(0...20).map { ('a'..'z').to_a[rand(26)] }.join}" unless url.present?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [87/80]

@@ -13,17 +13,29 @@ def sidebar(*args, &block)
end
end

def sidebar_item(title, url, &block)
def sidebar_item(title, url = nil, &block)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment Branch Condition size for sidebar_item is too high. [16.16/15]
Method has too many lines. [13/10]
Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.

content_tag :li do
html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(link_to("#{title} #{dropdown_arrow_icon}".html_safe, url, data: { toggle: 'collapse' }))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [105/80]

if block_given?
url = "##{(0...20).map { ('a'..'z').to_a.sample }.join }" unless url.present?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside string interpolation detected.
Line is too long. [85/80]

html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(link_to("#{title} #{dropdown_arrow_icon}".html_safe, url, data: {toggle: 'collapse'}))
concat(content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [84/80]

content_tag :li do
html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(link_to("#{title} #{dropdown_arrow_icon}".html_safe, url, data: {toggle: 'collapse'}))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [103/80]
Space inside { missing.
Space inside } missing.

@@ -13,17 +13,36 @@ def sidebar(*args, &block)
end
end

def sidebar_item(title, url, &block)
def sidebar_item(title, url = nil, &block)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method has too many lines. [11/10]
Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.

content_tag :li do
html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(link_to("#{ title } #{ dropdown_arrow_icon }".html_safe, url, data: { toggle: 'collapse' }))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside string interpolation detected.
Line is too long. [109/80]

concat(
link_to("#{ title } #{ dropdown_arrow_icon }".html_safe, url, data: {toggle: 'collapse'})
)
concat(content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [84/80]

html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(
link_to("#{ title } #{ dropdown_arrow_icon }".html_safe, url, data: {toggle: 'collapse'})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the first parameter one step more than the start of the previous line.
Space inside string interpolation detected.
Line is too long. [103/80]
Space inside { missing.
Space inside } missing.

html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(
link_to("#{ title } #{ dropdown_arrow_icon }".html_safe, url, data: {toggle: 'collapse'})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside string interpolation detected.
Line is too long. [101/80]
Space inside { missing.
Space inside } missing.

html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(
link_to("#{ title } #{ arrow_icon }".html_safe, url, data: {toggle: 'collapse'})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside string interpolation detected.
Space inside { missing.
Line is too long. [92/80]
Space inside } missing.

link_to("#{ title } #{ arrow_icon }".html_safe,
url, data: { toggle: 'collapse' })
)
concat(content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [84/80]

@@ -13,17 +13,39 @@ def sidebar(*args, &block)
end
end

def sidebar_item(title, url, &block)
def sidebar_item(title, url = nil, &block)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method has too many lines. [14/10]
Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.

)
concat(
content_tag(:ul, class: 'submenu collapse',
id: url.delete('#')) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the elements of a hash literal if they span more than one line.

end
html.html_safe
concat(
link_to("#{ title } #{ arrow_icon }".html_safe,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside string interpolation detected.

@@ -13,17 +13,42 @@ def sidebar(*args, &block)
end
end

def sidebar_item(title, url, &block)
def sidebar_item(title, url = nil, &block)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method has too many lines. [17/10]
Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.

html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(link_to("#{ title } #{ arrow_icon }".html_safe, url, data: { toggle: 'collapse' }))
concat(content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [84/80]

content_tag :li do
html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(link_to("#{ title } #{ arrow_icon }".html_safe, url, data: { toggle: 'collapse' }))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside string interpolation detected.
Line is too long. [100/80]

@@ -4,26 +4,45 @@ def sidebar(*args, &block)
options = args.extract_options!
if block_given?
content_tag :div, id: 'sidebar-wrapper' do
html = link_to '', options[:brand_url], class: 'sidebar-brand hidden-sm-down'
html << content_tag(:ul, class: 'sidebar-nav') do
concat(link_to '', options[:brand_url], class: 'sidebar-brand hidden-sm-down')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add parentheses to nested method call link_to '', options[:brand_url], class: 'sidebar-brand hidden-sm-down'.
Line is too long. [88/80]

@johanandre
Copy link
Member Author

I fiddled around to please Hound but ended up in some shitty looking code, thats why there is a bunch of commits changing stuff back and forth... :)

Copy link
Contributor

@AnteWall AnteWall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its better then it was before, however the biggest problem we had before is that we can't customize it. It would be nice if we could modify the classes that its append. (i.e the nav-link etc...)

Perhaps change them completely by sending in our own class.

@johanandre
Copy link
Member Author

Well, since it moves the sidebar helpers to a working state (from not working that great), although not adding everything, I think we should merge it anyway. Of course I'm open for solving the customization in a later pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use active_link_to in sidebar helper
3 participants