georgia_blog 0.7.1 → 0.7.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 873c373459eba195409c2c28d6a5d607c9f53edd
4
- data.tar.gz: 950416a5d33a968cf5e5a2430f5f5b0d0eb1536f
3
+ metadata.gz: 85e8250e827054ea0ba8e0527f47fde4a09f7410
4
+ data.tar.gz: 1e4c8a783dd1a110b17797b576d8841a73f7afec
5
5
  SHA512:
6
- metadata.gz: aec5888f4b02ec3e78f5c653911d2a4059c2ec0bb37633488f5c36e4f0484b6e6e5e4f95cec12e673cf5f1dca3b7d22813ea2698905a5ed45f098dd17122b66a
7
- data.tar.gz: bbaeedb96ad023469e129ba2567f1de21dac413a0a94ff57dc4754c61205435b7aa80523f3eebfa92c98c80a9229c9763a8941fcba2f26b8143c4b8c9b970abe
6
+ metadata.gz: 5345d90113439e653d297c1f050d058811dc58488464b876cba27a3325b5b450d5f32e683ab301fb2d3aae203670da099a6199c1ac113a7ec2817c8789c43ac3
7
+ data.tar.gz: a4186fa42cd0c3cb60430cdca585036e4a0292514e18b298bb951322c1bfabf2a382f065c5baa6cd5b471b7bde703201a206f3f5ec6158673642de6d0709e703
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Georgia Blog
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -1,73 +1,16 @@
1
1
  module Georgia
2
2
  class Post < Georgia::Page
3
3
 
4
- attr_accessible :published_at
4
+ Georgia::Indexer.register_extension(:solr, Georgia::Post)
5
+ Georgia::Indexer.register_extension(:tire, Georgia::Post)
6
+ include Georgia::Indexer::Adapter
5
7
 
6
- scope :recent, order("published_at DESC")
7
- class << self
8
- alias_method :latest, :recent
9
- end
10
-
11
- def month
12
- @month ||= published_at.strftime('%B %Y') if published_at.present?
13
- end
14
-
15
- def year
16
- @year ||= published_at.year if published_at.present?
17
- end
18
-
19
- searchable do
20
- text :title, stored: true do
21
- revisions.map{|r| r.contents.map(&:title)}.flatten.uniq.join(', ')
22
- end
23
- text :excerpt, stored: true do
24
- revisions.map{|r| r.contents.map(&:excerpt)}.flatten.uniq.join(', ')
25
- end
26
- text :text do
27
- revisions.map{|r| r.contents.map(&:text)}.flatten.uniq.join(', ')
28
- end
29
- text :keywords do
30
- revisions.map{|r| r.contents.map(&:keyword_list)}.flatten.uniq.join(', ')
31
- end
32
- text :tags do
33
- tag_list.join(', ')
34
- end
35
- text :url
36
- text :template
37
- string :title
38
- string :excerpt
39
- string :text
40
- string :url
41
- string :template
42
- string :state do
43
- public? ? 'public' : 'private'
44
- end
45
- string :class_name do
46
- self.class.name
47
- end
48
- string :keywords, stored: true, multiple: true do
49
- revisions.map{|r| r.contents.map(&:keyword_list)}.flatten.uniq
50
- end
51
- string :tag_list, stored: true, multiple: true # Array for facets
52
- string :tags, stored: true do # Single list for ordering
53
- tag_list.join(', ')
54
- end
55
- string :month, stored: true
56
- string :year, stored: true
57
- time :published_at
58
- time :updated_at # default order
59
- end
8
+ has_one :post_data
9
+ delegate :published_at, :month, :year, to: :post_data, prefix: false, allow_nil: true
60
10
 
11
+ scope :recent, order("post_data.published_at DESC")
61
12
  class << self
62
-
63
- def extra_search_params
64
- Proc.new {
65
- facet :month, :tags
66
- with(:month, params[:m]) unless params[:m].blank?
67
- with(:tags, params[:c]) unless params[:t].blank?
68
- }
69
- end
70
-
13
+ alias_method :latest, :recent
71
14
  end
72
15
  end
73
16
  end
@@ -0,0 +1,17 @@
1
+ module Georgia
2
+ class PostData < ActiveRecord::Base
3
+
4
+ belongs_to :post
5
+
6
+ attr_accessible :published_at
7
+
8
+ def month
9
+ @month ||= published_at.strftime('%B %Y') if published_at.present?
10
+ end
11
+
12
+ def year
13
+ @year ||= published_at.year if published_at.present?
14
+ end
15
+
16
+ end
17
+ end
@@ -1,5 +1,3 @@
1
- <% if can? :manage, Georgia::Post %>
2
- <li class="<%= 'active' if controller_name == 'posts' %>">
3
- <%= link_to 'Blog', georgia.search_posts_url %>
4
- </li>
5
- <% end -%>
1
+ <% if can? :index, Georgia::Post %>
2
+ <%= sidebar_navigation_link 'Blog', georgia.search_posts_url, controller: 'posts', icon: 'coffee' %>
3
+ <% end -%>
@@ -0,0 +1,73 @@
1
+ require 'active_support/concern'
2
+
3
+ module Georgia
4
+ module Indexer
5
+ module SolrAdapter
6
+ module GeorgiaPostExtension
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ searchable do
11
+ text :title, stored: true do
12
+ revisions.map{|r| r.contents.map(&:title)}.flatten.uniq.join(', ')
13
+ end
14
+ text :excerpt, stored: true do
15
+ revisions.map{|r| r.contents.map(&:excerpt)}.flatten.uniq.join(', ')
16
+ end
17
+ text :text do
18
+ revisions.map{|r| r.contents.map(&:text)}.flatten.uniq.join(', ')
19
+ end
20
+ text :keywords do
21
+ revisions.map{|r| r.contents.map(&:keyword_list)}.flatten.uniq.join(', ')
22
+ end
23
+ text :tags do
24
+ tag_list.join(', ')
25
+ end
26
+ text :url
27
+ text :template
28
+ string :title
29
+ string :excerpt
30
+ string :text
31
+ string :url
32
+ string :template
33
+ string :state do
34
+ public? ? 'public' : 'private'
35
+ end
36
+ string :class_name do
37
+ self.class.name
38
+ end
39
+ string :keywords, stored: true, multiple: true do
40
+ revisions.map{|r| r.contents.map(&:keyword_list)}.flatten.uniq
41
+ end
42
+ string :tag_list, stored: true, multiple: true # Array for facets
43
+ string :tags, stored: true do # Single list for ordering
44
+ tag_list.join(', ')
45
+ end
46
+ string :month, stored: true
47
+ string :year, stored: true
48
+ time :published_at
49
+ time :updated_at # default order
50
+ end
51
+
52
+ def self.search_index model, params
53
+ @search = model.search do
54
+ fulltext params[:query] do
55
+ fields(:title, :excerpt, :text, :keywords, :tags, :url, :template)
56
+ end
57
+ facet :state, :template, :tag_list, :month, :tags
58
+ with(:class_name, model.to_s)
59
+ with(:state, params[:s]) unless params[:s].blank?
60
+ with(:template, params[:t]) unless params[:t].blank?
61
+ with(:tag_list).all_of(params[:tg]) unless params[:tg].blank?
62
+ order_by (params[:o] || :updated_at), (params[:dir] || :desc)
63
+ paginate(page: params[:page], per_page: (params[:per] || 25))
64
+ with(:month, params[:m]) unless params[:m].blank?
65
+ with(:tags, params[:c]) unless params[:t].blank?
66
+ end.results
67
+ end
68
+
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,57 @@
1
+ require 'active_support/concern'
2
+
3
+ module Georgia
4
+ module Indexer
5
+ module TireAdapter
6
+ module GeorgiaPostExtension
7
+
8
+ extend ActiveSupport::Concern
9
+
10
+ included do
11
+
12
+ include ::Tire::Model::Search
13
+ include ::Tire::Model::Callbacks
14
+
15
+ def to_indexed_json
16
+ keywords = current_revision.present? ? current_revision.contents.map(&:keyword_list).flatten.uniq.join(', ') : ""
17
+ tags = tag_list.join(', ')
18
+ class_name = self.class.name
19
+
20
+ indexed_hash = {
21
+ title: title,
22
+ text: text,
23
+ excerpt: excerpt,
24
+ keywords: keywords,
25
+ url: url,
26
+ template: template,
27
+ tags: tags,
28
+ tag_list: tag_list,
29
+ publish_state: publish_state,
30
+ class_name: class_name,
31
+ updated_at: updated_at.strftime('%F'),
32
+ revision_id: revision_id,
33
+ month: month,
34
+ year: year
35
+ }
36
+ indexed_hash.to_json
37
+ end
38
+
39
+ def self.search_index params
40
+ search(page: (params[:page] || 1), per_page: (params[:per] || 25)) do
41
+ if params[:query].present?
42
+ query do
43
+ boolean do
44
+ must { string params[:query], default_operator: "AND" }
45
+ end
46
+ end
47
+ sort { by (params[:o] || :updated_at), (params[:dir] || :desc) }
48
+ end
49
+ end.results
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
@@ -2,7 +2,5 @@ module GeorgiaBlog
2
2
  class Engine < ::Rails::Engine
3
3
  require 'rubygems'
4
4
  require 'georgia'
5
-
6
- extend Georgia::Paths
7
5
  end
8
6
  end
@@ -1,3 +1,3 @@
1
1
  module GeorgiaBlog
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
data/lib/georgia_blog.rb CHANGED
@@ -1 +1,8 @@
1
- require "georgia_blog/engine"
1
+ require "georgia_blog/engine"
2
+
3
+ module GeorgiaBlog
4
+
5
+ # Add to Georgia by default
6
+ Georgia.navigation += %w(blog)
7
+
8
+ end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: georgia_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathieu Gagné
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
11
+ date: 2014-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 3.2.13
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 3.2.13
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: georgia
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -47,17 +33,19 @@ extensions: []
47
33
  extra_rdoc_files: []
48
34
  files:
49
35
  - MIT-LICENSE
50
- - README.rdoc
36
+ - README.md
51
37
  - Rakefile
52
38
  - app/controllers/georgia/posts_controller.rb
53
39
  - app/decorators/georgia/post_decorator.rb
54
40
  - app/decorators/georgia/posts_decorator.rb
55
41
  - app/models/georgia/post.rb
42
+ - app/models/georgia/post_data.rb
56
43
  - app/views/georgia/header/_blog.html.erb
57
44
  - app/views/georgia/posts/fields/_extra-fields.html.erb
58
- - config/initializers/georgia.rb
59
45
  - config/routes.rb
60
46
  - db/migrate/001_create_georgia_post_data.rb
47
+ - lib/georgia/indexer/extensions/solr_adapter/georgia/post.rb
48
+ - lib/georgia/indexer/extensions/tire_adapter/georgia/post.rb
61
49
  - lib/georgia_blog.rb
62
50
  - lib/georgia_blog/engine.rb
63
51
  - lib/georgia_blog/version.rb
data/README.rdoc DELETED
@@ -1,3 +0,0 @@
1
- = Georgia Blog
2
-
3
- This project rocks and uses MIT-LICENSE.
@@ -1,3 +0,0 @@
1
- Georgia.setup do |config|
2
- config.navigation += %w(blog)
3
- end