refinerycms-snippets 0.1 → 0.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.
@@ -0,0 +1,25 @@
1
+ class CreateSnippets < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :snippets do |t|
5
+ t.string :title
6
+ t.text :body
7
+ t.integer :position
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :snippets, :id
13
+
14
+ load(Rails.root.join('db', 'seeds', 'snippets.rb'))
15
+ end
16
+
17
+ def self.down
18
+ UserPlugin.destroy_all({:name => "snippets"})
19
+
20
+ # Page.delete_all({:link_url => "/snippets"})
21
+
22
+ drop_table :snippets
23
+ end
24
+
25
+ end
@@ -0,0 +1,18 @@
1
+ class CreatePageSnippets < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :snippet_pages, :id => false do |t|
5
+ t.integer :snippet_id
6
+ t.integer :page_id
7
+ t.integer :position
8
+ end
9
+
10
+ add_index :snippet_pages, :snippet_id
11
+ add_index :snippet_pages, :page_id
12
+ end
13
+
14
+ def self.down
15
+ drop_table :snippet_pages
16
+ end
17
+
18
+ end
@@ -0,0 +1,22 @@
1
+ class TranslateSnippets < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ ::Snippet.reset_column_information
5
+ unless defined?(::Snippet::Translation) && ::Snippet::Translation.table_exists?
6
+ ::Snippet.create_translation_table!({
7
+ :body => :text
8
+ }, {
9
+ :migrate_data => true
10
+ })
11
+ end
12
+
13
+ load(Rails.root.join('db', 'seeds', 'snippets.rb').to_s)
14
+ end
15
+
16
+ def self.down
17
+ ::Snippet.reset_column_information
18
+
19
+ ::Snippet.drop_translation_table!
20
+ end
21
+
22
+ end
@@ -0,0 +1,18 @@
1
+ User.all.each do |user|
2
+ if user.plugins.where(:name => 'snippets').blank?
3
+ user.plugins.create(:name => 'snippets',
4
+ :position => (user.plugins.maximum(:position) || -1) +1)
5
+ end
6
+ end
7
+
8
+ page = Page.create(
9
+ :title => 'Snippets',
10
+ :link_url => '/snippets',
11
+ :show_in_menu => false,
12
+ :deletable => false,
13
+ :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
14
+ :menu_match => '^/snippets(\/|\/.+?|)$'
15
+ )
16
+ Page.default_parts.each do |default_page_part|
17
+ page.parts.create(:title => default_page_part, :body => nil)
18
+ end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-snippets
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- version: "0.1"
8
+ - 2
9
+ version: "0.2"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Marek L.
@@ -54,6 +54,10 @@ files:
54
54
  - app/views/admin/pages/tabs/_snippets.html.erb
55
55
  - app/views/admin/pages/tabs/_snippets_bar.html.erb
56
56
  - app/views/admin/pages/tabs/_snippets_field.html.erb
57
+ - db/migrate/2_create_page_snippets.rb
58
+ - db/migrate/1_create_snippets.rb
59
+ - db/migrate/3_translate_snippets.rb
60
+ - db/seeds/snippets.rb
57
61
  has_rdoc: true
58
62
  homepage:
59
63
  licenses: []