quintype-seo 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +54 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/quintype/seo.rb +21 -0
- data/lib/quintype/seo/base.rb +30 -0
- data/lib/quintype/seo/home.rb +39 -0
- data/lib/quintype/seo/search.rb +22 -0
- data/lib/quintype/seo/section.rb +35 -0
- data/lib/quintype/seo/static_page.rb +18 -0
- data/lib/quintype/seo/story.rb +72 -0
- data/lib/quintype/seo/story_element.rb +24 -0
- data/lib/quintype/seo/tag.rb +22 -0
- data/lib/quintype/seo/version.rb +5 -0
- data/quintype-seo.gemspec +23 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 735ba38e315370e148fa0ac78f48f0fa99887cc5
|
4
|
+
data.tar.gz: 6c29a96c4bb81ed6e0a5bb377c056c4a32495def
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63126102f023151fc923d9b85d6ddadf203d25fc3bcd410f25ccf3e6bd865090ce42b49d60d48e81994c343bfd140b18cc232ef2f18b6158abc5fba3139cfb1b
|
7
|
+
data.tar.gz: 9df895611cfc144b733d15009bcd3d77bdca9909e830450754e960489b34fc66121485c579e6618afe549fa41d59ccfa3f7192716b46d43089b11f90fca7db6a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Quintype::SEO
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'quintype-seo'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install quintype-seo
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
### Fetching meta tag data for a page
|
22
|
+
|
23
|
+
You can fetch data for each page in the following way:
|
24
|
+
|
25
|
+
Section:
|
26
|
+
```ruby
|
27
|
+
Quintype::Seo::Section.new(config, section).to_h
|
28
|
+
```
|
29
|
+
|
30
|
+
Home:
|
31
|
+
```ruby
|
32
|
+
Quintype::Seo::Home.new(config).to_h
|
33
|
+
```
|
34
|
+
|
35
|
+
Story:
|
36
|
+
```ruby
|
37
|
+
Quintype::Seo::Story.new(config, story).to_h
|
38
|
+
```
|
39
|
+
|
40
|
+
Search and Topic:
|
41
|
+
```ruby
|
42
|
+
Quintype::Seo::Search.new(config, search_term).to_h
|
43
|
+
Quintype::Seo::Tag.new(config, search_term).to_h
|
44
|
+
```
|
45
|
+
|
46
|
+
## Development
|
47
|
+
|
48
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
49
|
+
|
50
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/quintype/quintype-seo-ruby.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "quintype/api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/quintype/seo.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "quintype/seo/version"
|
2
|
+
|
3
|
+
module Quintype
|
4
|
+
module Seo
|
5
|
+
autoload :Base, "quintype/seo/base"
|
6
|
+
|
7
|
+
def self.Base(args)
|
8
|
+
clazz = Struct.new(*args.map(&:intern))
|
9
|
+
clazz.send(:include, BaseFunctions)
|
10
|
+
clazz
|
11
|
+
end
|
12
|
+
|
13
|
+
autoload :Home, "quintype/seo/home"
|
14
|
+
autoload :Story, "quintype/seo/story"
|
15
|
+
autoload :Section, "quintype/seo/section"
|
16
|
+
autoload :StaticPage, "quintype/seo/static_page"
|
17
|
+
autoload :Search, "quintype/seo/search"
|
18
|
+
autoload :StoryElement, "quintype/seo/story_element"
|
19
|
+
autoload :Tag, "quintype/seo/tag"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Quintype::Seo
|
2
|
+
class Base
|
3
|
+
attr_reader :config, :page_type, :page_identifier, :grouped_metadata
|
4
|
+
|
5
|
+
def initialize(config, page_type, page_identifier = nil)
|
6
|
+
@config = config
|
7
|
+
@page_type = page_type
|
8
|
+
@page_identifier = page_identifier
|
9
|
+
@grouped_metadata = group_metadata(config['seo_metadata'])
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_h
|
13
|
+
tags(page_metadata)
|
14
|
+
end
|
15
|
+
|
16
|
+
def tags(metadata)
|
17
|
+
raise 'Implement this in a child class!'
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def page_metadata
|
23
|
+
Rodash.get(grouped_metadata, [[page_type, page_identifier], 0, 'data'], {})
|
24
|
+
end
|
25
|
+
|
26
|
+
def group_metadata(metadata)
|
27
|
+
metadata.group_by { |m| [m['owner_type'], m['owner_id']] }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Quintype::Seo
|
2
|
+
class Home < Quintype::Seo::Base
|
3
|
+
|
4
|
+
def initialize(config)
|
5
|
+
super(config, 'home')
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def tags(metadata)
|
11
|
+
title = get_title(metadata)
|
12
|
+
metadata.except('page_title').merge({
|
13
|
+
'title' => title,
|
14
|
+
'description' => metadata['description'],
|
15
|
+
'og' => {
|
16
|
+
'title' => metadata['title'],
|
17
|
+
'description' => metadata['description']
|
18
|
+
},
|
19
|
+
'twitter' => {
|
20
|
+
'title' => metadata['title'],
|
21
|
+
'description' => metadata['description']
|
22
|
+
},
|
23
|
+
'msvalidate.01' => Rodash.get(config, ['integrations', 'bing', 'app_id']),
|
24
|
+
'fb' => {
|
25
|
+
'app_id' => Rodash.get(config, ['facebook', 'app_id'])
|
26
|
+
},
|
27
|
+
'alternate' => [{
|
28
|
+
'href' => '/feed',
|
29
|
+
'type' => 'application/atom+xml',
|
30
|
+
'title' => "#{title} ATOM Feed"
|
31
|
+
}]
|
32
|
+
})
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_title(metadata)
|
36
|
+
metadata['page_title'].presence || config['title']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Quintype::Seo
|
2
|
+
class Search < Quintype::Seo::Base
|
3
|
+
attr_reader :term
|
4
|
+
def initialize(config, term)
|
5
|
+
super(config, 'search')
|
6
|
+
@term = term
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def tags(metadata)
|
12
|
+
title = get_title(metadata)
|
13
|
+
{
|
14
|
+
'title' => title
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_title(metadata)
|
19
|
+
term + ' - Search Results'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Quintype::Seo
|
2
|
+
class Section < Quintype::Seo::Base
|
3
|
+
attr_reader :section
|
4
|
+
def initialize(config, section)
|
5
|
+
super(config, 'section', section['id'])
|
6
|
+
@section = section
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def tags(metadata)
|
12
|
+
title = get_title(metadata)
|
13
|
+
metadata.except('page_title').merge({
|
14
|
+
'title' => title,
|
15
|
+
'description' => metadata['description'],
|
16
|
+
'og' => {
|
17
|
+
'title' => metadata['title'],
|
18
|
+
'description' => metadata['description']
|
19
|
+
},
|
20
|
+
'twitter' => {
|
21
|
+
'title' => metadata['title'],
|
22
|
+
'description' => metadata['description']
|
23
|
+
}
|
24
|
+
})
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_title(metadata)
|
28
|
+
metadata['page_title'].presence || make_hyphenated_title
|
29
|
+
end
|
30
|
+
|
31
|
+
def make_hyphenated_title
|
32
|
+
(section['display_name'] || section['name']) + " - " + (config['title'] || '')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Quintype::Seo
|
2
|
+
class StaticPage < Quintype::Seo::Base
|
3
|
+
attr_reader :name, :title
|
4
|
+
def initialize(config, name, title)
|
5
|
+
super(config, 'static_page', name)
|
6
|
+
@name = name
|
7
|
+
@title = title
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def tags(metadata)
|
13
|
+
{
|
14
|
+
'title' => title
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Quintype::Seo
|
2
|
+
class Story < Quintype::Seo::Base
|
3
|
+
attr_reader :story
|
4
|
+
def initialize(config, story)
|
5
|
+
super(config, 'story', story['slug'])
|
6
|
+
@story = story
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def tags(metadata)
|
12
|
+
title = get_title(metadata)
|
13
|
+
metadata.except('page_title').merge({
|
14
|
+
'title' => title,
|
15
|
+
'description' => story['summary'],
|
16
|
+
'og' => og_attributes,
|
17
|
+
'twitter' => twitter_attributes,
|
18
|
+
'fb' => {
|
19
|
+
'app_id' => Rodash.get(config, ['facebook', 'app_id'])
|
20
|
+
},
|
21
|
+
'article' => {
|
22
|
+
'publisher' => Rodash.get(config , ['social_links', 'facebook_url'])
|
23
|
+
},
|
24
|
+
'msvalidate.01' => Rodash.get(config, ['integrations', 'bing', 'app_id']),
|
25
|
+
'canonical' => API::URL.story_canonical(config['root_url'], story),
|
26
|
+
'al:android:package' => Rodash.get(config, ['apps_data', 'al:android:package']),
|
27
|
+
'al:android:app_name' => Rodash.get(config, ['apps_data', 'al:android:app_name']),
|
28
|
+
'al:android:url' => "quintypefb://#{config['host']}/#{story['slug']}"
|
29
|
+
})
|
30
|
+
end
|
31
|
+
|
32
|
+
def twitter_attributes
|
33
|
+
{
|
34
|
+
'title' => story['headline'],
|
35
|
+
'description' => story['summary'],
|
36
|
+
'card' => 'summary_large_image',
|
37
|
+
'site' => Rodash.get(config, ['social_app_credentials', 'twitter', 'username']),
|
38
|
+
'image' => {
|
39
|
+
'src' => hero_image_url
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def og_attributes
|
45
|
+
hash = {
|
46
|
+
'title' => story['headline'],
|
47
|
+
'type' => 'article',
|
48
|
+
'url' => API::URL.story_canonical(config['root_url'], story),
|
49
|
+
'site_name' => config['title'],
|
50
|
+
'description' => story['summary'],
|
51
|
+
'image' => (config['cdn_name'] + story['hero_image_s3_key']).gsub(" ", "%20")
|
52
|
+
}
|
53
|
+
if hero_image_metadata = story['hero_image_metadata'].presence
|
54
|
+
hash.merge!("image:width" => hero_image_metadata["width"]) if hero_image_metadata["width"]
|
55
|
+
hash.merge!("image:height" => hero_image_metadata["height"]) if hero_image_metadata["height"]
|
56
|
+
end
|
57
|
+
hash
|
58
|
+
end
|
59
|
+
|
60
|
+
def hero_image_url
|
61
|
+
(config['cdn_name'] + story['hero_image_s3_key']).gsub(" ", "%20")
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_title(metadata)
|
65
|
+
metadata['page_title'].presence || make_hyphenated_title
|
66
|
+
end
|
67
|
+
|
68
|
+
def make_hyphenated_title
|
69
|
+
story['headline'] + " - " + config['title']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Quintype::Seo
|
2
|
+
class StoryElement < Quintype::Seo::Base
|
3
|
+
attr_reader :story, :story_element
|
4
|
+
def initialize(config, story, story_element)
|
5
|
+
super(config, 'story-element')
|
6
|
+
@story = story
|
7
|
+
@story_element = story_element
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def tags(metadata)
|
13
|
+
title = get_title(metadata)
|
14
|
+
metadata.except('page_title').merge({
|
15
|
+
'title' => title,
|
16
|
+
'canonical' => API::URL.story_canonical(config['root_url'], story),
|
17
|
+
})
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_title(metadata)
|
21
|
+
story['headline'] + " - " + config['title']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Quintype::Seo
|
2
|
+
class Tag < Quintype::Seo::Base
|
3
|
+
attr_reader :tag
|
4
|
+
def initialize(config, tag)
|
5
|
+
super(config, 'tag', tag)
|
6
|
+
@tag = tag
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def tags(metadata)
|
12
|
+
title = get_title(metadata)
|
13
|
+
{
|
14
|
+
'title' => title
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_title(metadata)
|
19
|
+
tag + ' - ' + (config['title'] || '')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'quintype/seo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "quintype-seo"
|
8
|
+
spec.version = Quintype::Seo::VERSION
|
9
|
+
spec.platform = Gem::Platform::RUBY
|
10
|
+
spec.authors = ["Ramsharan"]
|
11
|
+
spec.email = ["sharangj@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{Ruby Gem to set seo meta tags for quintype}
|
14
|
+
spec.homepage = "https://github.com/quintype/quintype-seo-ruby"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quintype-seo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ramsharan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.11'
|
19
|
+
name: bundler
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '10.0'
|
33
|
+
name: rake
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- sharangj@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- bin/console
|
53
|
+
- bin/setup
|
54
|
+
- lib/quintype/seo.rb
|
55
|
+
- lib/quintype/seo/base.rb
|
56
|
+
- lib/quintype/seo/home.rb
|
57
|
+
- lib/quintype/seo/search.rb
|
58
|
+
- lib/quintype/seo/section.rb
|
59
|
+
- lib/quintype/seo/static_page.rb
|
60
|
+
- lib/quintype/seo/story.rb
|
61
|
+
- lib/quintype/seo/story_element.rb
|
62
|
+
- lib/quintype/seo/tag.rb
|
63
|
+
- lib/quintype/seo/version.rb
|
64
|
+
- quintype-seo.gemspec
|
65
|
+
homepage: https://github.com/quintype/quintype-seo-ruby
|
66
|
+
licenses: []
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.4.8
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Ruby Gem to set seo meta tags for quintype
|
88
|
+
test_files: []
|