Skip to content

Commit

Permalink
seo helper
Browse files Browse the repository at this point in the history
  • Loading branch information
xdite committed Oct 20, 2011
0 parents commit e1bb2be
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
@@ -0,0 +1,17 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
4 changes: 4 additions & 0 deletions Gemfile
@@ -0,0 +1,4 @@
source 'http://rubygems.org'

# Specify your gem's dependencies in seo_helper.gemspec
gemspec
2 changes: 2 additions & 0 deletions Rakefile
@@ -0,0 +1,2 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
42 changes: 42 additions & 0 deletions lib/seo_helper.rb
@@ -0,0 +1,42 @@
require "seo_helper/version"
require 'seo_helper/railtie' if defined?(Rails)
module SeoHelper

def meta_title(title)
return nil if title.blank?
title = title + " | " + (SITE_NAME rescue "SITE_NAME")
tag(:meta, {:name => "title", :content => title})
end

def meta_description(content, site_name = false)
return nil if content.blank?
content = content + " | " + (SITE_NAME rescue "SITE_NAME") if site_name
tag(:meta, { :name => "description", :content => strip_tags(content) }, true)
end

def meta_keywords(word)
return nil if word.blank?
# word = word + (SITE_NAME rescue "SITE_NAME")
tag(:meta, {:name => "keywords", :content => word})
end

def render_rel_image(image_url)
return nil if image_url.blank?
tag(:link, {:rel => "image_src", :href => image_url})
end

def link_image(image_url)
return nil if image_url.blank?
tag(:link, { :rel => "image_src", :href => image_url }, true)
end

def link_favicon(ico_url = "/favicon.ico")
tag(:link, { :rel => "shortcut icon", :href => ico_url }, true)
end


def meta_robots(content = "INDEX,FOLLOW")
tag(:meta, { :name => "robots", :content => content }, true)
end

end
9 changes: 9 additions & 0 deletions lib/seo_helper/railtie.rb
@@ -0,0 +1,9 @@
require "seo_helper"

module SeoImageHelper
class Railtie < Rails::Railtie
initializer "seo_helper.view_helpers" do
ActionView::Base.send :include, SeoHelper
end
end
end
3 changes: 3 additions & 0 deletions lib/seo_helper/version.rb
@@ -0,0 +1,3 @@
module SeoHelper
VERSION = "0.0.1"
end
17 changes: 17 additions & 0 deletions seo_helper.gemspec
@@ -0,0 +1,17 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/seo_helper/version', __FILE__)

Gem::Specification.new do |gem|
gem.authors = ["xdite"]
gem.email = ["xdite@techbang.com.tw"]
gem.description = %q{SEO helper of Techbang}
gem.summary = %q{SEO helper of Techbang}
gem.homepage = ""

gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = "seo_helper"
gem.require_paths = ["lib"]
gem.version = SeoHelper::VERSION
end

0 comments on commit e1bb2be

Please sign in to comment.