0.0
No commit activity in last 3 years
No release in over 3 years
A ruby gem to generate links automatically based on a text, keywords and urls is given. Useful for example to increase dinamically the internal links in your site and improve SEO metrics.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 10.0

Runtime

 Project Readme

BuilderLinks

Gem Version Build Status Test Coverage Code Climate

A ruby gem to generate links automatically based on a text, keywords and urls is given. Useful for example to increase dinamically the internal links in your site and improve SEO metrics.

Installation

Add this line to your Gemfile's application:

gem 'builder_links'

And then execute:

$ bundle

Or install it yourself as:

$ gem install builder_links

Configuration

Use an initializer builder_links.rb

# all parameters based on which allow to find keywords and build the links
# builder_links will use anchortext to find text and uri to generate the link
BuilderLinks.setup do |config|
  config.patterns = [
    {anchortext: 'google',  uri: 'http://www.google.com'},
    {anchortext: 'builder links',  uri: 'https://github.com/jsanroman/builder_links'},
    {anchortext: "I wanted to illuminate the whole earth", uri: 'https://es.wikipedia.org/wiki/Nikola_Tesla'},
  ]

  # maximum links generated to each call
  config.total_links = 5
  # maximum links generated to each pattern given
  config.links_per_pattern = 1
end

Usage

Call directly to BuilderLinks.text("", {black_uris: ['google.com']})

We can add multiple uri's for the black_uris option to not generate these links

BuilderLinks.text("<p>I wanted to illuminate the whole earth. There is enough electricity to become a second sun.</p>")
#<p><a href="https://es.wikipedia.org/wiki/Nikola_Tesla">I wanted to illuminate the whole earth</a>. There is enough electricity to become a second sun.</p>

Or you can add builder_links to your activerecord model, that will generate a method builder_links(:field)

class Card < ActiveRecord::Base
  attr_accessible :text, :user_text

  builder_links
end

# Then you can use builder_links method
Card.find(1).builder_links(:text, {black_uris: ['google.com']})
Card.find(1).builder_links(:user_text)

Contributing

  1. Fork it ( https://github.com/jsanroman/builder_links/fork )
  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 a new Pull Request