storytime 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/storytime/application_controller.rb +3 -3
- data/app/models/storytime/autosave.rb +1 -1
- data/app/models/storytime/comment.rb +1 -1
- data/app/models/storytime/media.rb +1 -1
- data/app/models/storytime/post.rb +1 -1
- data/app/models/storytime/version.rb +1 -1
- data/app/views/storytime/application/storytime/_header.html.erb +1 -1
- data/app/views/storytime/dashboard/_navigation.html.erb +1 -1
- data/lib/generators/templates/storytime.rb +10 -1
- data/lib/storytime.rb +18 -2
- data/lib/storytime/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- metadata +2 -40
- data/spec/dummy/db/migrate/20150130213631_create_storytime_posts.storytime.rb +0 -18
- data/spec/dummy/db/migrate/20150130213632_create_friendly_id_slugs.storytime.rb +0 -16
- data/spec/dummy/db/migrate/20150130213633_create_storytime_media.storytime.rb +0 -11
- data/spec/dummy/db/migrate/20150130213634_create_storytime_sites.storytime.rb +0 -14
- data/spec/dummy/db/migrate/20150130213635_create_storytime_tags.storytime.rb +0 -10
- data/spec/dummy/db/migrate/20150130213636_create_storytime_taggings.storytime.rb +0 -11
- data/spec/dummy/db/migrate/20150130213637_create_storytime_versions.storytime.rb +0 -13
- data/spec/dummy/db/migrate/20150130213638_create_storytime_roles.storytime.rb +0 -10
- data/spec/dummy/db/migrate/20150130213639_add_storytime_role_id_to_users.storytime.rb +0 -7
- data/spec/dummy/db/migrate/20150130213640_create_storytime_permissions.storytime.rb +0 -11
- data/spec/dummy/db/migrate/20150130213641_create_storytime_actions.storytime.rb +0 -11
- data/spec/dummy/db/migrate/20150130213642_create_storytime_comments.storytime.rb +0 -12
- data/spec/dummy/db/migrate/20150130213643_add_storytime_name_to_users.storytime.rb +0 -6
- data/spec/dummy/db/migrate/20150130213644_create_storytime_autosaves.storytime.rb +0 -13
- data/spec/dummy/db/migrate/20150130213645_add_secondary_media_id_to_storytime_post.storytime.rb +0 -6
- data/spec/dummy/db/migrate/20150130213646_create_storytime_snippets.storytime.rb +0 -22
- data/spec/dummy/db/migrate/20150130213647_create_storytime_subscriptions.storytime.rb +0 -15
- data/spec/dummy/db/migrate/20150130213648_add_title_and_content_index_to_storytime_post.storytime.rb +0 -57
- data/spec/dummy/db/migrate/20150130213649_add_site_id_to_storytime_subscription.storytime.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5763a623b7cbc3a4338fb7ad83ddc56a5dbb8e3
|
4
|
+
data.tar.gz: dc51e884bd9e91cf0cc466edbdc5a54ce1a74abc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0614230034de10544be38ed69510228d33c0655ed48b02bcaf9f975626aac957204ecbf5541848c6ad3fb79b7175314dfc0656b2b0d26df2e4c121e88ed1f132
|
7
|
+
data.tar.gz: ce87e3b715e67c59f8254143f4fff0a7f5baecfc026cee4f895bc409c01dcad268c8d2b66b855eeb8149dd572d8c6d8172afd54285d926e9110872c708908688
|
@@ -30,15 +30,15 @@ class Storytime::ApplicationController < ApplicationController
|
|
30
30
|
|
31
31
|
if Storytime.user_class_symbol != :user
|
32
32
|
def authenticate_user!
|
33
|
-
send("authenticate_#{Storytime.
|
33
|
+
send("authenticate_#{Storytime.user_class_underscore_all}!".to_sym)
|
34
34
|
end
|
35
35
|
|
36
36
|
def current_user
|
37
|
-
send("current_#{Storytime.
|
37
|
+
send("current_#{Storytime.user_class_underscore_all}".to_sym)
|
38
38
|
end
|
39
39
|
|
40
40
|
def user_signed_in?
|
41
|
-
send("#{Storytime.
|
41
|
+
send("#{Storytime.user_class_underscore_all}_signed_in?".to_sym)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -6,7 +6,7 @@ module Storytime
|
|
6
6
|
extend FriendlyId
|
7
7
|
friendly_id :slug_candidates, use: [:history]
|
8
8
|
|
9
|
-
belongs_to :user, class_name: Storytime.user_class
|
9
|
+
belongs_to :user, class_name: Storytime.user_class
|
10
10
|
belongs_to :featured_media, class_name: "Media"
|
11
11
|
belongs_to :secondary_media, class_name: "Media"
|
12
12
|
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<%= link_to "#{t 'layout.subscribe_to', site_name: @site.title}", "#", data: {target: "#addSubscriptionModal", toggle: "modal"} %>
|
23
23
|
</li>
|
24
24
|
<% unless user_signed_in? %>
|
25
|
-
<li><%= link_to "Sign In",
|
25
|
+
<li><%= link_to "Sign In", Storytime.login_path %></li>
|
26
26
|
<% end %>
|
27
27
|
</ul>
|
28
28
|
</div>
|
@@ -45,7 +45,7 @@
|
|
45
45
|
</a>
|
46
46
|
<ul class="dropdown-menu">
|
47
47
|
<li><%= link_to "My Account", storytime.edit_dashboard_user_path(current_user) %></li>
|
48
|
-
<li><%= link_to "Sign Out",
|
48
|
+
<li><%= link_to "Sign Out", Storytime.logout_path, method: Storytime.logout_method %></li>
|
49
49
|
</ul>
|
50
50
|
</li>
|
51
51
|
</ul>
|
@@ -15,6 +15,15 @@ Storytime.configure do |config|
|
|
15
15
|
# Storytime's mount point within the host app.
|
16
16
|
# config.home_page_path = "/"
|
17
17
|
|
18
|
+
# Path used to sign users in.
|
19
|
+
# config.login_path = '/users/sign_in'
|
20
|
+
|
21
|
+
# Path used to log users out.
|
22
|
+
# config.logout_path = '/users/sign_out'
|
23
|
+
|
24
|
+
# Method used for Storytime user logout path.
|
25
|
+
# config.logout_method = :delete
|
26
|
+
|
18
27
|
# Add custom post types to use within Storytime.
|
19
28
|
# Make sure that the custom post types inherit the
|
20
29
|
# from the Storytime::Post class.
|
@@ -41,7 +50,7 @@ Storytime.configure do |config|
|
|
41
50
|
# Post subclasses. Options for the search adapter include:
|
42
51
|
# Storytime::PostgresSearchAdapter, Storytime::MysqlSearchAdapter,
|
43
52
|
# Storytime::MysqlFulltextSearchAdapter, Storytime::Sqlite3SearchAdapter
|
44
|
-
# config.search_adapter =
|
53
|
+
# config.search_adapter = ''
|
45
54
|
|
46
55
|
# File upload options.
|
47
56
|
config.enable_file_upload = true
|
data/lib/storytime.rb
CHANGED
@@ -19,6 +19,18 @@ module Storytime
|
|
19
19
|
mattr_accessor :home_page_path
|
20
20
|
@@home_page_path = "/"
|
21
21
|
|
22
|
+
# Path used to sign users in.
|
23
|
+
mattr_accessor :login_path
|
24
|
+
@@login_path = '/users/sign_in'
|
25
|
+
|
26
|
+
# Path used to log users out.
|
27
|
+
mattr_accessor :logout_path
|
28
|
+
@@logout_path = '/users/sign_out'
|
29
|
+
|
30
|
+
# Method used for Storytime user logout path.
|
31
|
+
mattr_accessor :logout_method
|
32
|
+
@@logout_method = :delete
|
33
|
+
|
22
34
|
# Enable file uploads through Carrierwave.
|
23
35
|
mattr_accessor :enable_file_upload
|
24
36
|
@@enable_file_upload = true
|
@@ -55,7 +67,7 @@ module Storytime
|
|
55
67
|
# Storytime::PostgresSearchAdapter, Storytime::MysqlSearchAdapter,
|
56
68
|
# Storytime::MysqlFulltextSearchAdapter, Storytime::Sqlite3SearchAdapter
|
57
69
|
mattr_accessor :search_adapter
|
58
|
-
@@search_adapter =
|
70
|
+
@@search_adapter = ''
|
59
71
|
|
60
72
|
class << self
|
61
73
|
attr_accessor :layout, :media_storage, :s3_bucket, :post_types
|
@@ -71,7 +83,11 @@ module Storytime
|
|
71
83
|
end
|
72
84
|
|
73
85
|
def user_class_underscore
|
74
|
-
@@user_class.
|
86
|
+
@@user_class.underscore
|
87
|
+
end
|
88
|
+
|
89
|
+
def user_class_underscore_all
|
90
|
+
@@user_class.underscore.gsub('/', '_')
|
75
91
|
end
|
76
92
|
|
77
93
|
def user_class_symbol
|
data/lib/storytime/version.rb
CHANGED
Binary file
|
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storytime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Roesch, David Van Der Beek, Brandon Robins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -679,25 +679,6 @@ files:
|
|
679
679
|
- spec/dummy/config/secrets.yml
|
680
680
|
- spec/dummy/db/development.sqlite3
|
681
681
|
- spec/dummy/db/migrate/20140530185250_devise_create_users.rb
|
682
|
-
- spec/dummy/db/migrate/20150130213631_create_storytime_posts.storytime.rb
|
683
|
-
- spec/dummy/db/migrate/20150130213632_create_friendly_id_slugs.storytime.rb
|
684
|
-
- spec/dummy/db/migrate/20150130213633_create_storytime_media.storytime.rb
|
685
|
-
- spec/dummy/db/migrate/20150130213634_create_storytime_sites.storytime.rb
|
686
|
-
- spec/dummy/db/migrate/20150130213635_create_storytime_tags.storytime.rb
|
687
|
-
- spec/dummy/db/migrate/20150130213636_create_storytime_taggings.storytime.rb
|
688
|
-
- spec/dummy/db/migrate/20150130213637_create_storytime_versions.storytime.rb
|
689
|
-
- spec/dummy/db/migrate/20150130213638_create_storytime_roles.storytime.rb
|
690
|
-
- spec/dummy/db/migrate/20150130213639_add_storytime_role_id_to_users.storytime.rb
|
691
|
-
- spec/dummy/db/migrate/20150130213640_create_storytime_permissions.storytime.rb
|
692
|
-
- spec/dummy/db/migrate/20150130213641_create_storytime_actions.storytime.rb
|
693
|
-
- spec/dummy/db/migrate/20150130213642_create_storytime_comments.storytime.rb
|
694
|
-
- spec/dummy/db/migrate/20150130213643_add_storytime_name_to_users.storytime.rb
|
695
|
-
- spec/dummy/db/migrate/20150130213644_create_storytime_autosaves.storytime.rb
|
696
|
-
- spec/dummy/db/migrate/20150130213645_add_secondary_media_id_to_storytime_post.storytime.rb
|
697
|
-
- spec/dummy/db/migrate/20150130213646_create_storytime_snippets.storytime.rb
|
698
|
-
- spec/dummy/db/migrate/20150130213647_create_storytime_subscriptions.storytime.rb
|
699
|
-
- spec/dummy/db/migrate/20150130213648_add_title_and_content_index_to_storytime_post.storytime.rb
|
700
|
-
- spec/dummy/db/migrate/20150130213649_add_site_id_to_storytime_subscription.storytime.rb
|
701
682
|
- spec/dummy/db/schema.rb
|
702
683
|
- spec/dummy/db/test.sqlite3
|
703
684
|
- spec/dummy/public/404.html
|
@@ -819,25 +800,6 @@ test_files:
|
|
819
800
|
- spec/dummy/config.ru
|
820
801
|
- spec/dummy/db/development.sqlite3
|
821
802
|
- spec/dummy/db/migrate/20140530185250_devise_create_users.rb
|
822
|
-
- spec/dummy/db/migrate/20150130213631_create_storytime_posts.storytime.rb
|
823
|
-
- spec/dummy/db/migrate/20150130213632_create_friendly_id_slugs.storytime.rb
|
824
|
-
- spec/dummy/db/migrate/20150130213633_create_storytime_media.storytime.rb
|
825
|
-
- spec/dummy/db/migrate/20150130213634_create_storytime_sites.storytime.rb
|
826
|
-
- spec/dummy/db/migrate/20150130213635_create_storytime_tags.storytime.rb
|
827
|
-
- spec/dummy/db/migrate/20150130213636_create_storytime_taggings.storytime.rb
|
828
|
-
- spec/dummy/db/migrate/20150130213637_create_storytime_versions.storytime.rb
|
829
|
-
- spec/dummy/db/migrate/20150130213638_create_storytime_roles.storytime.rb
|
830
|
-
- spec/dummy/db/migrate/20150130213639_add_storytime_role_id_to_users.storytime.rb
|
831
|
-
- spec/dummy/db/migrate/20150130213640_create_storytime_permissions.storytime.rb
|
832
|
-
- spec/dummy/db/migrate/20150130213641_create_storytime_actions.storytime.rb
|
833
|
-
- spec/dummy/db/migrate/20150130213642_create_storytime_comments.storytime.rb
|
834
|
-
- spec/dummy/db/migrate/20150130213643_add_storytime_name_to_users.storytime.rb
|
835
|
-
- spec/dummy/db/migrate/20150130213644_create_storytime_autosaves.storytime.rb
|
836
|
-
- spec/dummy/db/migrate/20150130213645_add_secondary_media_id_to_storytime_post.storytime.rb
|
837
|
-
- spec/dummy/db/migrate/20150130213646_create_storytime_snippets.storytime.rb
|
838
|
-
- spec/dummy/db/migrate/20150130213647_create_storytime_subscriptions.storytime.rb
|
839
|
-
- spec/dummy/db/migrate/20150130213648_add_title_and_content_index_to_storytime_post.storytime.rb
|
840
|
-
- spec/dummy/db/migrate/20150130213649_add_site_id_to_storytime_subscription.storytime.rb
|
841
803
|
- spec/dummy/db/schema.rb
|
842
804
|
- spec/dummy/db/test.sqlite3
|
843
805
|
- spec/dummy/public/404.html
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140501174341)
|
2
|
-
class CreateStorytimePosts < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_posts do |t|
|
5
|
-
t.references :user, index: true
|
6
|
-
t.string :type
|
7
|
-
t.string :title
|
8
|
-
t.string :slug, index: true
|
9
|
-
t.text :content
|
10
|
-
t.text :excerpt
|
11
|
-
t.datetime :published_at
|
12
|
-
t.references :featured_media
|
13
|
-
t.boolean :featured, default: false
|
14
|
-
|
15
|
-
t.timestamps
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140509191309)
|
2
|
-
class CreateFriendlyIdSlugs < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :friendly_id_slugs do |t|
|
5
|
-
t.string :slug, :null => false
|
6
|
-
t.integer :sluggable_id, :null => false
|
7
|
-
t.string :sluggable_type, :limit => 50
|
8
|
-
t.string :scope
|
9
|
-
t.datetime :created_at
|
10
|
-
end
|
11
|
-
add_index :friendly_id_slugs, :sluggable_id
|
12
|
-
add_index :friendly_id_slugs, [:slug, :sluggable_type]
|
13
|
-
add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], :unique => true
|
14
|
-
add_index :friendly_id_slugs, :sluggable_type
|
15
|
-
end
|
16
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140511200849)
|
2
|
-
class CreateStorytimeMedia < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_media do |t|
|
5
|
-
t.string :file
|
6
|
-
t.references :user, index: true
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140513161233)
|
2
|
-
class CreateStorytimeSites < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_sites do |t|
|
5
|
-
t.string :title
|
6
|
-
t.integer :post_slug_style, default: 0
|
7
|
-
t.string :ga_tracking_id
|
8
|
-
t.integer :root_page_content, default: 0
|
9
|
-
t.references :root_post, index: true
|
10
|
-
|
11
|
-
t.timestamps
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140514200304)
|
2
|
-
class CreateStorytimeTaggings < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_taggings do |t|
|
5
|
-
t.belongs_to :tag, index: true
|
6
|
-
t.belongs_to :post, index: true
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140516141252)
|
2
|
-
class CreateStorytimeVersions < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_versions do |t|
|
5
|
-
t.text :content
|
6
|
-
t.references :user, index: true
|
7
|
-
t.references :versionable, polymorphic: true
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
add_index :storytime_versions, [:versionable_type, :versionable_id], name: "versionable_index"
|
12
|
-
end
|
13
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140521191048)
|
2
|
-
class AddStorytimeRoleIdToUsers < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
add_column Storytime.user_class.table_name.to_sym, :storytime_role_id, :integer
|
5
|
-
add_index Storytime.user_class.table_name.to_sym, :storytime_role_id
|
6
|
-
end
|
7
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140521191728)
|
2
|
-
class CreateStorytimePermissions < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_permissions do |t|
|
5
|
-
t.belongs_to :role, index: true
|
6
|
-
t.belongs_to :action, index: true
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140521191744)
|
2
|
-
class CreateStorytimeActions < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_actions do |t|
|
5
|
-
t.string :name
|
6
|
-
t.string :guid, index: true
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140813014447)
|
2
|
-
class CreateStorytimeComments < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_comments do |t|
|
5
|
-
t.text :content
|
6
|
-
t.references :user, index: true
|
7
|
-
t.references :post, index: true
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20140916183056)
|
2
|
-
class CreateStorytimeAutosaves < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_autosaves do |t|
|
5
|
-
t.text :content
|
6
|
-
t.references :autosavable, polymorphic: true
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
|
11
|
-
add_index :storytime_autosaves, [:autosavable_type, :autosavable_id], name: "autosavable_index"
|
12
|
-
end
|
13
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20141021073356)
|
2
|
-
class CreateStorytimeSnippets < ActiveRecord::Migration
|
3
|
-
def up
|
4
|
-
create_table :storytime_snippets do |t|
|
5
|
-
t.string :name, index: true
|
6
|
-
t.text :content
|
7
|
-
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
|
11
|
-
Storytime::Role.seed
|
12
|
-
Storytime::Action.seed
|
13
|
-
|
14
|
-
manage_snippets = Storytime::Action.find_by(guid: "5qg25i")
|
15
|
-
Storytime::Permission.find_or_create_by(role: Storytime::Role.find_by(name: "editor"), action: manage_snippets)
|
16
|
-
Storytime::Permission.find_or_create_by(role: Storytime::Role.find_by(name: "admin"), action: manage_snippets)
|
17
|
-
end
|
18
|
-
|
19
|
-
def down
|
20
|
-
drop_table :storytime_snippets
|
21
|
-
end
|
22
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20141111164439)
|
2
|
-
class CreateStorytimeSubscriptions < ActiveRecord::Migration
|
3
|
-
def change
|
4
|
-
create_table :storytime_subscriptions do |t|
|
5
|
-
t.string :email
|
6
|
-
t.boolean :subscribed, default: true
|
7
|
-
t.string :token, index: true
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
|
12
|
-
Storytime::Action.seed
|
13
|
-
Storytime::Permission.seed
|
14
|
-
end
|
15
|
-
end
|
data/spec/dummy/db/migrate/20150130213648_add_title_and_content_index_to_storytime_post.storytime.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
# This migration comes from storytime (originally 20150122200805)
|
2
|
-
class AddTitleAndContentIndexToStorytimePost < ActiveRecord::Migration
|
3
|
-
def up
|
4
|
-
if Storytime.search_adapter == Storytime::PostgresSearchAdapter
|
5
|
-
execute "CREATE INDEX posts_title_contentx ON storytime_posts USING gin(to_tsvector('english', coalesce(title, '') || ' ' || coalesce(content, '')));"
|
6
|
-
elsif Storytime.search_adapter == Storytime::MysqlSearchAdapter
|
7
|
-
type = get_table_type
|
8
|
-
version = get_mysql_version
|
9
|
-
|
10
|
-
if (type == "MyISAM") || (type == "InnoDB" && Gem::Version.new(version) >= Gem::Version.new("5.6.4"))
|
11
|
-
add_index :storytime_posts, [:title, :content], type: :fulltext, :length => 50
|
12
|
-
elsif type == "InnoDB"
|
13
|
-
add_index :storytime_posts, [:title, :content], :length => 50
|
14
|
-
end
|
15
|
-
elsif Storytime.search_adapter == Storytime::MysqlFulltextSearchAdapter
|
16
|
-
add_index :storytime_posts, [:title, :content], type: :fulltext, :length => 50
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def down
|
21
|
-
if Storytime.search_adapter == Storytime::PostgresSearchAdapter
|
22
|
-
execute "REMOVE INDEX posts_title_contentx ON storytime_posts"
|
23
|
-
elsif Storytime.search_adapter == Storytime::MysqlSearchAdapter
|
24
|
-
type = get_table_type
|
25
|
-
version = get_mysql_version
|
26
|
-
|
27
|
-
if (type == "MyISAM") || (type == "InnoDB" && Gem::Version.new(version) >= Gem::Version.new("5.6.4"))
|
28
|
-
remove_index :storytime_posts, [:title, :content], type: :fulltext
|
29
|
-
elsif type == "InnoDB"
|
30
|
-
remove_index :storytime_posts, [:title, :content]
|
31
|
-
end
|
32
|
-
elsif Storytime.search_adapter == Storytime::MysqlFulltextSearchAdapter
|
33
|
-
remove_index :storytime_posts, [:title, :content], type: :fulltext
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def get_table_type
|
38
|
-
config = Rails.configuration.database_configuration
|
39
|
-
database_name = config[Rails.env]["database"]
|
40
|
-
|
41
|
-
sql = "SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '#{database_name}'"
|
42
|
-
query = ActiveRecord::Base.connection.execute(sql)
|
43
|
-
|
44
|
-
query.entries.each do |k,v|
|
45
|
-
if k == "storytime_posts"
|
46
|
-
return v
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def get_mysql_version
|
52
|
-
sql = "SELECT VERSION()"
|
53
|
-
query = ActiveRecord::Base.connection.execute(sql)
|
54
|
-
|
55
|
-
query.entries[0][0]
|
56
|
-
end
|
57
|
-
end
|