New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zen_seo

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zen_seo

  • 0.0.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

#ZEN_SEO is a clean way of managing your meta tags for resources

Install

Hope all of us are at least on Rails3 and moving to upcoming Rails4(unsupported for now)

    # Gemfile
    gem 'zen_seo'

Then run the install generator, that will create migration(MongoDB is on the routemap) for the SEO model.

    rails generate zen_seo:install

Usage

Pick up a resource to grant a promotable behavior

Model

   #app/models/post.rb
   has_seo

This will try to call title, description, keywords on your model to fill in seo fields, optionally you can supply a hash, that redefines the methods to be called

   #app/models/post.rb
   class Post < ActiveRecord::Base
     attr_accessible :body, :tags, :title
     has_seo :description=>:body, :keywords=>:make_keywords

     private
     def make_keywords
       self.tags.gsub(/:/, ', ')
     end
   end
Excessive options

Note that you can pass excessive options that meta_tags support through :options key like so:

   #app/models/post.rb
   class Post < ActiveRecord::Base
     attr_accessible :body, :tags, :title
     has_seo :description=>:body,
                :options=>{
                    :og => {
                      :title    => :title,
                      :type     => 'website',
                      :image    => 'http://now.com/you_rock.jpg'
                    }
                }
   end

###Controller

ZEN_SEO heavily based on meta_tags gem, so set it up as normal.

When your layout contains

    #application.html.erb
    <head>
      <%= display_meta_tags default_meta_tags %>
    </head>

now in controller you can use meta_tags_for helper

    #posts_controller.rb
    # GET /posts/1
    # GET /posts/1.json
    def show
      @post = Post.find(params[:id])
      meta_tags_for @post
      respond_to do |format|
        format.html # show.html.erb
        format.json { render json: @post }
      end
    end

###Form To set meta tags for your resource just put fields_for :seo in your form. Like this:

  <h3>Make yout post seo-friendly</h3>
  <%= f.fields_for :seo do |seo| %>
    <div class="field">
      <%= seo.label :title %><br />
      <%= seo.text_field :title %>
    </div>
    <div class="field">
      <%= seo.label :keywords %><br />
      <%= seo.text_field :keywords %>
    </div>
    <div class="field">
      <%= seo.label :description %><br />
      <%= seo.text_area :description %>
    </div>
  <% end %>

Note on Patches/Pull Requests

  • Any help on issues-fighting(or finding) and testing is highly appreciated

Developed by Sergey Prikhodko Copyright (c) 2013. See LICENSE for details.

FAQs

Package last updated on 25 Jun 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