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.
locomotivecms-search
Advanced tools
Open your Gemfile and add locomotive-cms search to it:
gem 'locomotivecms-search', require: 'locomotive/search/mongoid'
Check out the Activesearch gem to know which backends are available and how to configure them.
Run bundle install
[New way]
{% search_for params.query, per_page: 10, page: params.page %}
<p>{{ search.total_entries }} elements found.</p>
<ul>
{% for result in search.results %}
<li><a href="/{{result.slug}}">{{ result.title }}</a></li>
{% endfor %}
</ul>
{% if search.total_pages > params.page %}
<p>
<a href="?page={{ params.page | plus: 1 }}&query={{ params.query }}">Next page</a>
</p>
{% endif %}
{% endsearch_for %}
[Old way]
Create a new page that will display your search results. Its code might be something like this:
{% for result in site.search %}
<li><a href="/{{result.slug}}">{{ result.title }}</a></li>
{% endfor %}
As you can see, when a search string is passed in the URL, you can fetch the results by using site.search
.
Choose a good slug, like "search".
Anywhere on your site you can add a simple form to fire a search. This could be done on the homepage, on a page you are inheriting from, on even on a snippet. Just add this code:
<form action="/{{ locale }}/search" method="GET">
<label for="search">Search</label>
<input type="text" name="search" id="search">
<input type="submit" value="Search">
</form>
The important part is the action parameter, since it must point to the slug of your search results page. Also, the name of the search input must be "search".
From the 0.3.0 version, this gem includes a search bar for your LocomotiveCMS back-office. This search bar uses the typeahead javascript plugin.
The only requirement is to have the LocomotiveCMS 2.5.x version installed.
In your LocomotiveCMS main application (the one embedding LocomotiveCMS), you need to add 2 files (or edit them if they already exist).
In the app/views/locomotive/shared/_main_app_head.html.haml file, add these 2 lines:
= javascript_include_tag 'locomotive/search_bar'
= stylesheet_link_tag 'locomotive/search_bar'
In the app/views/locomotive/shared/_main_app_header.html.haml file, add this line:
= render 'locomotive/shared/search_bar'
If you are using the mongoid engine and still on 2.x, you must use locomotivecms-search version ~> 0.0.5
This project rocks and uses MIT-LICENSE.
FAQs
Unknown package
We found that locomotivecms-search 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.
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.