Skip to content

Instantly share code, notes, and snippets.

View cedricdekimpe's full-sized avatar

Cédric Dekimpe cedricdekimpe

View GitHub Profile
class Industry < ActiveResource::Base
self.site = "http://my.site.com"
self.prefix = "prefix/api/"
end
@cedricdekimpe
cedricdekimpe / pagination.liquid
Created September 13, 2013 14:23
Custom pagination with LocomotiveCMS
<nav class="pagination">
<ul>
{% if paginate.current_page > 1 %}
<li>
<a href="?page=1">first</a>
</li>
{% endif %}
{% if paginate.previous_page %}
<li>
<a href="?page={{paginate.previous_page}}" rel="prev">prev.</a>
@cedricdekimpe
cedricdekimpe / search_controller.rb
Created October 24, 2013 09:05
SearchController for LocomotiveCMS
class SearchController < ApplicationController
include Locomotive::Routing::SiteDispatcher
include Locomotive::Render
def index
@page = Locomotive::Page.where(:handle => 'search-results').first
results = Locomotive::ContentEntry.fulltext_search(params[:search])
@drops_results = Liquid::Drops::ResultsDrop.new(results)
render_locomotive_page @page, { "search_results" => @drops_results }
end
@cedricdekimpe
cedricdekimpe / Gemfile
Created October 24, 2013 09:05
Gemfile for LocomotiveCMS search
gem 'mongoid_fulltext', '0.6.1'
@cedricdekimpe
cedricdekimpe / add_full_text_to_locomotive.rb
Created October 24, 2013 09:06
LocomotiveCMS search : config/initializer/add_full_text_to_locomotive.rb
#encoding: utf-8
::STOP_WORDS = Hash[[
"alors", "au", "aucuns", "aussi", "autre", "avant", "avec", "avoir",
"bon", "car", "ce", "cela", "ces", "ceux", "chaque", "ci", "comme", "comment", "dans", "des", "du",
"dedans", "dehors", "depuis", "deux", "devrait", "doit", "donc", "dos", "droite", "début", "elle",
"elles", "en", "encore", "essai", "est", "et", "eu", "fait", "faites", "fois", "font",
"force", "haut", "hors", "ici", "il", "ils", "je juste", "la", "le", "les", "leur", "là", "ma", "maintenant",
"mais", "mes", "mine", "moins", "mon", "mot", "même", "ni", "nommés", "notre", "nous", "nouveaux", "ou", "où",
"par", "parce", "parole", "pas", "personnes", "peut", "peu", "pièce", "plupart", "pour", "pourquoi", "quand", "que",
@cedricdekimpe
cedricdekimpe / _search.html.haml
Created October 24, 2013 09:08
LocomotiveCMS search : search form
#topSearch.right
%form#searchform{:action => "/#{locale}/search", :method => "get", :role => "search"}
%label.assistive-text{:for => "search"}= I18n.t("common.header.search_label")
%input#search{:name => "search", :placeholder => I18n.t("common.header.search_placeholder"), :type => "search", :value => ""}/
%input#searchSubmit{:type => "submit", :value => "Search"}/
@cedricdekimpe
cedricdekimpe / search-results.liquid
Created October 24, 2013 09:10
LocomotiveCMS search : liquid template
{% extends 'parent' %}
<h1>{{ page.title }}</h1>
{% if search_results.size == 0 %}
<p><strong>There is no result</strong></p>
{% endif %}
{% for result in search_results %}
{% case locale %}
{% when "fr" %}
{% capture url %}/index/{{result._permalink}}{% endcapture %}
{% else %}
@cedricdekimpe
cedricdekimpe / gist:8cb64709e60fe2189714
Created August 21, 2015 08:31
assets precompile error
RAILS_ENV=staging bundle exec rake 'assets:precompile'
WARNING: Use strings for Figaro configuration. 647730745310662 was converted to "647730745310662".
WARNING: Use strings for Figaro configuration. 22225 was converted to "22225".
/Users/cedric/.rvm/rubies/ruby-2.0.0-p451/bin/ruby /Users/cedric/.rvm/gems/ruby-2.0.0-p451@apptweak/bin/rake assets:precompile:all RAILS_ENV=staging RAILS_GROUPS=assets
WARNING: Use strings for Figaro configuration. 647730745310662 was converted to "647730745310662".
WARNING: Use strings for Figaro configuration. 22225 was converted to "22225".
AssetSync: using /Users/cedric/Code/apptweak/config/initializers/asset_sync.rb
AssetSync: Syncing.
rake aborted!
Excon::Errors::SocketError: XML declaration allowed only at the start of the document (Nokogiri::XML::SyntaxError)
@cedricdekimpe
cedricdekimpe / provlux.svg
Created September 20, 2015 17:48
provlux.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<ul class="main-navigation">
<li><a href="{{ root_url }}/">Blog</a></li>
<li><a href="{{ root_url }}/blog/archives">Archives</a></li>
</ul>