Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
pivotal-honkster-jelly
Advanced tools
If you haven't already, add GitHub to your gem sources:
gem sources -a http://gems.github.com
Then run:
sudo gem install pivotal-jelly
In your environment.rb
in the Rails::Initializer.run
block, be sure to require jelly:
config.gem "jelly"
Then install the required JavaScript files by running this command in your Rails project:
script/generate jelly
Then, in your layout, add the following:
<%= javascript_include_tag :jelly, *application_jelly_files %>
<%= spread_jelly %>
This will include the required JavaScripts for jelly and activate the current page. The :jelly
javascript expansion
includes jQuery. If you already have jQuery included in the page, use the :only_jelly
expansion instead.
Assuming you have controller named fun
with an action called index
and that you have a layout called fun.html.erb
that is already setup as described above. In your fun index view (index.html.erb
), put:
<h1>Your page's 'index' function did not run. Jelly is not configured correctly.</h1>
<span class="all">Your page's 'all' function did not run. Jelly is not configured correctly.</span>
Then, in public/javascripts/pages/fun.js
, put:
Jelly.add("Fun", {
all: function() {
$('span.all').text("I am displayed on every action in this controller.");
},
index: function() {
$('h1').text("Welcome to the index page.");
}
});
Now goto /fun/index
and see Jelly in action!
You can trigger callbacks on the page object from Rails with the jelly_callback
method.
Adding to the index.html.erb
file from above:
<a href="#" id="jelly_ajax_link">Click me for Jelly Ajax Action</a>
<span id="jelly_callback_element">This gets filled in by the Jelly Ajax callback</span>
And update your controller:
class FunController < ApplicationController
def index
end
def ajax_action
jelly_callback do
[
render(:partial => 'fun_partial'),
"second_parameter"
]
end
end
end
Update your page object in fun.js
:
Jelly.add("Fun", {
all: function() {
$('title').text("Hello! Isn't this fun?");
},
index: function() {
$('h1').text("Welcome to the index page.");
$("#jelly_ajax_link").click(function() {
$.ajaxWithJelly({
type: "GET",
url: "/fun/ajax_action"
});
});
},
on_ajax_action: function(html, second_parameter) {
$('#jelly_callback_element').html(html);
}
});
And finally, make the partial _fun_partial.html.erb
and just put "Hello from the server!" in it, then visit your page
and watch the ajax callbacks in action.
The jelly_callback
method takes an optional parameter for the name of the callback, and the provided block can return
either one parameter, or an array of parameters.
To run ruby tests, run rake spec
.
To run JavaScript tests, open jelly/spec/jasmine_runner.html
in a web browser.
FAQs
Unknown package
We found that pivotal-honkster-jelly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.