Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snipp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snipp

  • 0.1.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Snipp

Gem Version Coverage Status Build Status

Search Engine Optimization (SEO) helpers for Ruby on Rails

Supported

  • HTML meta tags
  • Rich snippets and structured data

Installation

Add the "snipp" to your application's Gemfile:

gem 'snipp'

And run bundle install command.

HTML Meta Tags

Call html_meta_tags in a view template.

<!DOCTYPE html>
<html>
<head>
  <meta charset='utf-8'>
  <%= html_meta_tags %>
  <%= stylesheet_link_tag :all %>
  <%= javascript_include_tag :defaults %>
  <%= csrf_meta_tag %>
  ...

Set content attribute values

The priority of setting values

  1. Call set_html_meta
  2. Use I18n dictionary (controller action scope)
  3. Use I18n dictionary (default scope)
  4. Set Snipp.config.html_meta_tags
Use helper

Call set_html_meta in a view.

set_html_meta({
  title: "Page Title",
  description: "Page Description",
  og: {
    title: "Title for Social Media"
  },
  link: {
    canonical: "https://github.com/yulii/snipp"
  }
}, {
  arg: "Option Values for I18n",
  page: params[:page]
})
User I18n dictionary files

for each controller action

I18n.t(:title, scope: [:views, params[:controller], params[:action], :meta])

default values

I18n.t(:title, scope: [:default, :meta])

For more information

Rich Snippets

Call item_tag like content_tag

<%= item_tag :div, scope: true, type: :review do %>
  <%= item_tag :span, 'Snipp', prop: :itemreviewd %>
  Reviewed by <%= item_tag :span, '@yulii', prop: :reviewer %> on
  <%= item_tag :time, 'April 1', prop: :dtreviewd, datetime: "2013-04-01" %>.
  <%= item_tag :span, 'Review summary...', prop: :summary %>
  <%= item_tag :span, 'Review description...', prop: :description %>
  Rating: <%= item_tag :span, '4.5', prop: :rating %>
<% end %>

This would output

<div itemscope itemtype="http://data-vocabulary.org/Review">
  <span itemprop="itemreviewed">Snipp</span>
  Reviewed by <span itemprop="reviewer">@yulii</span> on
  <time itemprop="dtreviewed" datetime="2013-04-01">April 1</time>.
  <span itemprop="summary">Review summary...</span>
  <span itemprop="description">Review description...</span>
  Rating: <span itemprop="rating">4.5</span>
</div>

Breadcrumbs

  1. Define naming routes. You can specify a name for any route using the :as option in Rails Application.
  2. Setup the Rails Application for Internationalization (i18n).
  3. Call breadcrumb method.
<%= breadcrumb [:index, :foods, :fruits] %>

This would output something like Top > Foods > Fruits, if you will set labels in your Rails.root/config/locales

en:
  views:
    breadcrumb:
      # Sample
      index: "Top"
      food: "Foods"
      food_fruit: "Fruits"

Link to root_path, food_path, food_fruit_path.

Change the separator

Use the :s or :separator option.

<%= breadcrumb [:index, :foods, :fruits], s: "/" %>
Use variables and Customize labels
<%= breadcrumb [:index, :foods, :fruits, { path: fruits_color_path('Red'), label: 'Red' }, { path: food_path(color: 'Red', name: 'Apple'), label: 'Apple' }], s: "/" %>

For more information, read erb files in app/view/snipp/

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

LICENSE

(The MIT License)

Copyright © 2013 yulii. See LICENSE.txt for further details.

FAQs

Package last updated on 29 Sep 2013

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc