devape_cms 0.0.2 → 0.0.3

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.
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Rails.application.routes.draw do
2
+ #resources :categories
3
+ #resources :posts
4
+ match '/:title' => 'categories#cms'
5
+ match '/:id' => 'posts#cms'
6
+ root :to => 'index#index'
7
+ end
@@ -3,73 +3,9 @@ require 'rails/generators/migration'
3
3
 
4
4
  class DevapeCmsGenerator < Rails::Generators::Base
5
5
  include Rails::Generators::Migration
6
-
7
- def self.source_root
8
- File.join(File.dirname(__FILE__), 'templates')
9
- end
10
-
11
- def self.next_migration_number(dirname) #:nodoc:
12
- if ActiveRecord::Base.timestamped_migrations
13
- Time.now.utc.strftime("%Y%m%d%H%M%S")
14
- else
15
- "%.3d" % (current_migration_number(dirname) + 1)
16
- end
17
- end
18
-
19
-
20
- # Every method that is declared below will be automatically executed when the generator is run
21
-
22
- def create_migration_file
23
- f = File.open File.join(File.dirname(__FILE__), 'templates', 'schema.rb')
24
- schema = f.read; f.close
25
-
26
- schema.gsub!(/ActiveRecord::Schema.*\n/, '')
27
- schema.gsub!(/^end\n*$/, '')
28
-
29
- f = File.open File.join(File.dirname(__FILE__), 'templates', 'migration.rb')
30
- migration = f.read; f.close
31
- migration.gsub!(/SCHEMA_AUTO_INSERTED_HERE/, schema)
32
-
33
- tmp = File.open "~/migration_ready.rb", "w"
34
- tmp.write migration
35
- tmp.close
36
-
37
- migration_template '../../../tmp/~migration_ready.rb',
38
- 'db/migrate/create_cheese_tables.rb'
39
- remove_file 'tmp/~migration_ready.rb'
40
- end
41
-
6
+ source_root File.expand_path("../templates", __FILE__)
42
7
  def copy_initializer_file
43
- copy_file 'initializer.rb', 'config/initializers/cheese.rb'
8
+ copy_file "migration.rb", "db/migrate/0000000001_migrate_devape_cms.rb"
44
9
  end
45
10
 
46
- def update_application_template
47
- f = File.open "app/views/layouts/application.html.erb"
48
- layout = f.read; f.close
49
-
50
- if layout =~ /<%=[ ]+yield[ ]+%>/
51
- print " \e[1m\e[34mquestion\e[0m Your layouts/application.html.erb layout currently has the line <%= yield %>. This gem needs to change this line to <%= content_for?(:content) ? yield(:content) : yield %> to support its nested layouts. This change should not affect any of your existing layouts or views. Is this okay? [y/n] "
52
- begin
53
- answer = gets.chomp
54
- end while not answer =~ /[yn]/i
55
-
56
- if answer =~ /y/i
57
-
58
- layout.gsub!(/<%=[ ]+yield[ ]+%>/, '<%= content_for?(:content) ? yield(:content) : yield %>')
59
-
60
- tmp = File.open "tmp/~application.html.erb", "w"
61
- tmp.write layout; tmp.close
62
-
63
- remove_file 'app/views/layouts/application.html.erb'
64
- copy_file '../../../tmp/~application.html.erb',
65
- 'app/views/layouts/application.html.erb'
66
- remove_file 'tmp/~application.html.erb'
67
- end
68
- elsif layout =~ /<%=[ ]+content_for\?\(:content\) \? yield\(:content\) : yield[ ]+%>/
69
- puts " \e[1m\e[33mskipping\e[0m layouts/application.html.erb modification is already done."
70
- else
71
- puts " \e[1m\e[31mconflict\e[0m The gem is confused by your layouts/application.html.erb. It does not contain the default line <%= yield %>, you may need to make manual changes to get this gem's nested layouts working. Visit ###### for details."
72
- end
73
- end
74
-
75
11
  end
@@ -1,7 +1,7 @@
1
- module Cheese
1
+ module DevapeCms
2
2
  class Engine < Rails::Engine
3
3
 
4
- config.mount_at = '/cheese'
4
+ config.mount_at = '/devape_cms'
5
5
  config.widget_factory_name = 'Factory Name'
6
6
 
7
7
  end
@@ -1,9 +1,34 @@
1
- class CreateCheeseTables < ActiveRecord::Migration
1
+ class MigrateDevapeCms < ActiveRecord::Migration
2
2
  def self.up
3
- SCHEMA_AUTO_INSERTED_HERE
3
+ create_table :devape_cms_categories_posts, :id => false do |t|
4
+ t.integer :post_id
5
+ t.integer :category_id
6
+ t.timestamps
7
+ end
8
+ create_table :devape_cms_categories do |t|
9
+ t.string :title
10
+ t.text :description
11
+ t.integer :parent_id
12
+ t.timestamps
13
+ end
14
+ create_table :devape_cms_posts do |t|
15
+ t.integer :admin_id
16
+ t.string :title
17
+ t.text :content
18
+ t.integer :parent_id
19
+ t.string :slug
20
+ t.timestamps
21
+ end
22
+ add_index(:devape_cms_categories_posts, :post_id)
23
+ add_index(:devape_cms_categories_posts, :category_id)
24
+ add_index(:devape_cms_categories, :parent_id)
25
+ add_index(:devape_cms_posts, :parent_id)
26
+ add_index(:devape_cms_posts, :slug)
4
27
  end
5
28
 
6
29
  def self.down
7
- drop_table :cheese_widgets
30
+ drop_table :devape_cms_posts
31
+ drop_table :devape_cms_categories
32
+ drop_table :devape_cms_categories_posts
8
33
  end
9
34
  end
@@ -1,11 +1,11 @@
1
1
  ActiveRecord::Schema.define(:version => 0) do
2
2
 
3
- create_table :cheese_widgets, :force => true do |t|
4
- t.string :title
5
- t.datetime :created_at
6
- t.datetime :updated_at
7
- end
3
+ #create_table :cheese_widgets, :force => true do |t|
4
+ # t.string :title
5
+ # t.datetime :created_at
6
+ # t.datetime :updated_at
7
+ #end
8
8
 
9
- add_index :cheese_widgets, [:title]
9
+ #add_index :cheese_widgets, [:title]
10
10
 
11
- end
11
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: devape_cms
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Kealy
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-23 00:00:00 Z
13
+ date: 2011-07-24 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -55,6 +55,7 @@ files:
55
55
  - MIT-LICENSE
56
56
  - Rakefile
57
57
  - README.rdoc
58
+ - config/routes.rb
58
59
  homepage:
59
60
  licenses: []
60
61