redde_seo 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aab502b4441399a9a16afb66cd4702e9e7a8547
4
- data.tar.gz: e2b0ba29a2b38eec17fd6f77581148f001ec664d
3
+ metadata.gz: 7bc51bdeafb5c59c2002a266a50954333479ac7a
4
+ data.tar.gz: 2a0f94f206f07d133c0a939cc7557e4597ac41ce
5
5
  SHA512:
6
- metadata.gz: ccfa6b0fbc6a8e9068a0951c15e67604259d20e4052929ef487f964ce088eb9ed8eb9a727b2a60f03d0ea2f7d9bafbde4c2f17f1eee747e1c370f8fd77098d2d
7
- data.tar.gz: 313a971c1ffd79f13e2d3dc0fcd30b33cab86a5045b0dfd6abd9116f72a8c5e209388b80b7aad6c8b236b164e93d8c019d044d36c271b4b3277de5a5687e6bfa
6
+ metadata.gz: 411fa7bf5f7b05860c9e1ebc57cf45c6df452815ff7728d529b7782e1ff8580004f6a8385f9cf8521e565db43fc4f5915284a2466115a4a5651876d83280773f
7
+ data.tar.gz: bb31a361cea476eb6faa06019a6e08534eb211aa308326d6e753137338a8cee3e929584a7c03703bf344275bf9e69caf456719513bdc11d79d8076d21e7a675a
@@ -1,7 +1,8 @@
1
1
  # coding: utf-8
2
2
  class Admin::SeosController < Admin::BaseController
3
+ before_action :set_categories
3
4
  def index
4
- @seos = Redde::Seo.empty
5
+ @seos = Redde::Seo.for_empty(params[:empty]).for_type(params[:seoable_type]).page(params[:page])
5
6
  end
6
7
 
7
8
  def all
@@ -50,6 +51,10 @@ class Admin::SeosController < Admin::BaseController
50
51
  end
51
52
  end
52
53
 
54
+ def set_categories
55
+ @categories = Redde::Seo.categories
56
+ end
57
+
53
58
  def notice_for(obj)
54
59
  "#{obj.class.model_name.human} сохранен."
55
60
  end
@@ -1,4 +1,16 @@
1
+ # coding: utf-8
2
+
1
3
  module Redde::Seo::SeosHelper
4
+ def seo_empty_link(name, key)
5
+ content_tag :p do
6
+ link_to name, params.merge(empty: key), class: ['phead-side__link', ('_active' if params[:empty] == key.to_s)]
7
+ end
8
+ end
9
+
10
+ def seo_type_link(name, key)
11
+ link_to name, url_for(params.merge(seoable_type: key)), class: ['phead-tabs__link', ('_active' if params[:seoable_type] == key)]
12
+ end
13
+
2
14
  def seo_link_for_url(seo)
3
15
  link_to seo_url_for(seo), [:edit, :admin, seo], alt: seo.url, title: seo.url
4
16
  end
@@ -1,6 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  class Redde::Seo < ActiveRecord::Base
4
+ paginates_per 50
4
5
  attr_accessor :skip_basic_validation
5
6
 
6
7
  belongs_to :seoable, polymorphic: true
@@ -8,6 +9,8 @@ class Redde::Seo < ActiveRecord::Base
8
9
  scope :for_url, ->(u) { where(url: u) }
9
10
  scope :for_object, ->(o) { where(seoable_type: o.class.name, seoable_id: o.id) }
10
11
  scope :empty, -> { where("title is null or title = '' or keywords is null or keywords = '' or description is null or description = ''") }
12
+ scope :full, -> { where("char_length(title) > 0 AND char_length(keywords) > 0 AND char_length(description) > 0") }
13
+ scope :for_type, ->(u) { where(seoable_type: u) }
11
14
 
12
15
  validates :title, :keywords, :description, length: { minimum: 5 }, allow_blank: true, unless: :skip_basic_validation
13
16
 
@@ -22,4 +25,22 @@ class Redde::Seo < ActiveRecord::Base
22
25
  def self.model_name
23
26
  ActiveModel::Name.new(self, nil, 'Seo')
24
27
  end
28
+
29
+ def self.categories
30
+ self.select('seos.seoable_type, COUNT(*) AS type_count').group('seos.seoable_type')
31
+ .inject({}) do |res, t|
32
+ if t.seoable_type
33
+ name = "#{t.seoable_type.constantize.model_name.human} (#{t.type_count})"
34
+ else
35
+ name = "Без привязки (#{t.type_count})"
36
+ end
37
+ res.merge(name => t.seoable_type)
38
+ end
39
+ end
40
+
41
+ def self.for_empty(empty = nil)
42
+ return self.all if empty.nil?
43
+ return self.empty if empty == 'true'
44
+ self.full
45
+ end
25
46
  end
@@ -1,8 +1,11 @@
1
1
  - content_for(:page_header) do
2
2
  %h1 SEO
3
- %p= link_to 'Все', [:all, :admin, :seos] if action_name != 'all'
4
- %p= link_to 'Пустые', [:admin, :seos] if action_name != 'index'
5
-
3
+ = seo_empty_link('Все', nil)
4
+ = seo_empty_link('Пустые', true)
5
+ = seo_empty_link('Полные', false)
6
+ %nav.phead-tabs
7
+ - @categories.each do |name, key|
8
+ = seo_type_link(name, key)
6
9
  - unless @seos.empty?
7
10
  %table.list
8
11
  %colgroup
@@ -25,4 +28,5 @@
25
28
  %td= seo_title_for(seo)
26
29
  %td= seo_empty_for(seo)
27
30
  %td= link_to 'Удалить', [:admin, seo], method: :delete, data: { confirm: 'Удалить?' }, class: :del
31
+ = paginate @seos
28
32
 
@@ -1,3 +1,3 @@
1
1
  module ReddeSeo
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redde_seo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Bovykin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-25 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: quiet_assets
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement