Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
© 2011-2013 Ryan Graham, Dennis Taylor
Easy collection display grid with column sorting and pagination.
MagicGrid Live Demo (it's not very pretty. Help?)
Displays a collection (ActiveRelation or Array) wrapped in an html table with server side column sorting, filtering hooks, and search bar. Large collections can be paginated with either the will_paginate gem or kaminari gem if you use them, or a naive Enumerable based paginator (without pager links) if neither is present.
Tables are styled using Themeroller compatible classes, which also don't look too bad with Bootstrap.
In your Gemfile
:
gem 'magic_grid'
In your controller:
@posts = Post.where(:published => true)
In your view:
<%= magic_grid(@posts, [:title, :author]) %>
What you'll get is an table with 2 sortable columns. You'll also get pagination if you have eitehr Keminari or WillPaginate loaded.
You can also do your own row rendering by passing a block:
<%= magic_grid(@posts, [:title, :author, "Actions"]) do |post| %>
<tr>
<td><%= link_to(post.title, post) %></td>
<td><%= link_to(post.author, post.author) %></td>
<td>
<%= link_to("Edit", edit_post_path(post)) %> |
<%= link_to("Delete", post, method: :delete,
data: {confirm: "Are you sure?"}) %>
</td>
</tr>
<% end %>
There are a bunch of extra options that can be passed to the magic_grid
helper:
An array of columns to try to generate a search query for. Providing this
list tells magic_grid to render a search box in the header of the html table
it generates. Make sure to include magic_grid.js
in your view or application wide via your application.js or search won't work.
Sets the number of rows per page in the paginator.
Sets a text string to include in the top of the grid's thead
to display as a title for the grid.
There's a.. ahem slight lack of documentation at the moment. Pull requests welcome?
Testing was originally done UnitTest style, with some tarantula to force a bunch of random page renderings. I've since added some RSpec goodness.
To run all the tests, just run rake
.
Distributed under the MIT license. See MIT-LICENSE for detail.
FAQs
Unknown package
We found that magic_grid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.