Last active
November 18, 2019 21:02
-
-
Save jrm/859feb52f6cbedeecbbc to your computer and use it in GitHub Desktop.
Dynamic Dashing Index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type='text/javascript'> | |
$(function() { | |
$('li').live('click', function(e){ | |
window.location = $(this).find('.widget').data('url'); | |
}); | |
}); | |
</script> | |
<% content_for :title do %>Summary<% end %> | |
<div class='gridster'> | |
<ul> | |
<% Dir.glob("./dashboards/*").reject {|f| f.match 'layout|summary' }.each_with_index do |d,i| %> | |
<% name = d.match(/\.\/dashboards\/(.*)\.erb/)[1] %> | |
<li data-row='1' data-col="<%= i+1 %>" data-sizex='1' data-sizey='1'> | |
<div data-view='Text' data-title="<%= name.upcase %>" data-url="/<%= name %>"></div> | |
</li> | |
<% end %> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There were a couple of minor syntax errors, here is a working version of the above with multiple columns. I also made it split dashboard names on "-" or "_" and convert them to title case.