refinerycms-map 0.1.0 → 0.2.0

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.
@@ -1,6 +1,6 @@
1
1
  en:
2
2
  plugins:
3
- map:
3
+ refinerycms_map:
4
4
  title: Map
5
5
  admin:
6
6
  map_locations:
@@ -1,7 +1,7 @@
1
- ActionController::Routing::Routes.draw do |map|
2
- map.resources :map_locations, :as => :map
1
+ Refinery::Application.routes.draw do
2
+ resources :map_locations, :path => '/map'
3
3
 
4
- map.namespace(:admin, :path_prefix => (defined?(REFINERY_GEM_VERSION) ? 'admin' : 'refinery')) do |admin|
5
- admin.resources :map_locations, :as => :map
4
+ scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
5
+ resources :map_locations, :path => '/map'
6
6
  end
7
7
  end
@@ -0,0 +1,25 @@
1
+ class Create<%= table_name.camelize %> < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ create_table :<%= table_name %> do |t|
5
+ <% attributes.each do |attribute| -%>
6
+ t.<%= attribute.type %> :<%= attribute.name %>
7
+ <% end -%>
8
+ t.decimal :lat, :precision => 9, :scale => 6, :default => 0.0
9
+ t.decimal :lng, :precision => 9, :scale => 6, :default => 0.0
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :<%= table_name %>, :id
14
+ load(Rails.root.join('db', 'seeds', 'refinerycms_map.rb').to_s)
15
+ end
16
+
17
+ def self.down
18
+ UserPlugin.destroy_all({:name => "refinerycms_map"})
19
+
20
+ Page.delete_all({:link_url => "/map"})
21
+
22
+ drop_table :<%= table_name %>
23
+ end
24
+
25
+ end
@@ -0,0 +1,16 @@
1
+ User.find(:all).each do |user|
2
+ user.plugins.create(:name => "refinerycms_map",
3
+ :position => (user.plugins.maximum(:position) || -1) +1)
4
+ end
5
+
6
+ page = Page.create(
7
+ :title => "Map",
8
+ :link_url => "/map",
9
+ :deletable => false,
10
+ :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
11
+ :menu_match => "^/map.*$"
12
+ )
13
+
14
+ Page.default_parts.each do |default_page_part|
15
+ page.parts.create(:title => default_page_part, :body => nil)
16
+ end
@@ -0,0 +1,56 @@
1
+ require 'rails/generators/migration'
2
+
3
+ class RefinerycmsMapGenerator < Rails::Generators::NamedBase
4
+ include Rails::Generators::Migration
5
+
6
+ source_root File.expand_path('../refinerycms_map/templates/', __FILE__)
7
+ argument :name, :type => :string, :default => 'map_locations', :banner => ''
8
+ argument :attributes, :type => :array, :default => ["title:string", "address:string", "city:string", "state:string", "zipcode:string", "phone:string", "url:string"]
9
+
10
+ def generate
11
+ # seed file
12
+ template 'db/seeds/seed.rb', Rails.root.join('db/seeds/refinerycms_map.rb')
13
+
14
+ # javascript files
15
+ template 'js/jquery.jmapping.min.js', Rails.root.join('public/javascripts/jquery.jmapping.min.js')
16
+ template 'js/jquery.metadata.js', Rails.root.join('public/javascripts/jquery.metadata.js')
17
+ template 'js/mapiconmaker.js', Rails.root.join('public/javascripts/mapiconmaker.js')
18
+ template 'js/markermanager.js', Rails.root.join('public/javascripts/markermanager.js')
19
+
20
+ next_migration_number = ActiveRecord::Generators::Base.next_migration_number(File.dirname(__FILE__))
21
+ template('db/migrate/migration_number_create_singular_name.rb',
22
+ Rails.root.join("db/migrate/#{next_migration_number}_create_#{singular_name}.rb"))
23
+
24
+ puts "------------------------"
25
+ puts "Now run:"
26
+ puts "rake db:migrate"
27
+ puts "------------------------"
28
+ end
29
+ end
30
+
31
+ # Below is a hack until this issue:
32
+ # https://rails.lighthouseapp.com/projects/8994/tickets/3820-make-railsgeneratorsmigrationnext_migration_number-method-a-class-method-so-it-possible-to-use-it-in-custom-generators
33
+ # is fixed on the Rails project.
34
+
35
+ require 'rails/generators/named_base'
36
+ require 'rails/generators/migration'
37
+ require 'rails/generators/active_model'
38
+ require 'active_record'
39
+
40
+ module ActiveRecord
41
+ module Generators
42
+ class Base < Rails::Generators::NamedBase #:nodoc:
43
+ include Rails::Generators::Migration
44
+
45
+ # Implement the required interface for Rails::Generators::Migration.
46
+ def self.next_migration_number(dirname) #:nodoc:
47
+ next_migration_number = current_migration_number(dirname) + 1
48
+ if ActiveRecord::Base.timestamped_migrations
49
+ [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
50
+ else
51
+ "%.3d" % next_migration_number
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
data/lib/map.rb CHANGED
@@ -2,7 +2,7 @@ module Refinery
2
2
  module Map
3
3
  class << self
4
4
  def version
5
- %q{0.1.0}
5
+ %q{0.2.0}
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,23 @@
1
+ require 'refinery'
2
+ require File.expand_path('../map', __FILE__)
3
+
4
+ module Refinery
5
+ module Map
6
+
7
+ class Engine < Rails::Engine
8
+ config.after_initialize do
9
+ Refinery::Plugin.register do |plugin|
10
+ plugin.name = "refinerycms_map"
11
+ plugin.menu_match = /(admin|refinery)\/map(_locations)?$/
12
+ plugin.url = {:controller => '/admin/map_locations', :action => 'index'}
13
+ plugin.activity = {
14
+ :class => MapLocation,
15
+ :title => 'title',
16
+ :url_prefix => 'edit'
17
+ }
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
data/readme.md CHANGED
@@ -15,25 +15,16 @@ To install the map plugin, you can either include the gem or install as a plugin
15
15
 
16
16
  ## Requirements
17
17
 
18
- [RefineryCMS](http://refinerycms.com) version 0.9.7 or later.
18
+ [RefineryCMS](http://refinerycms.com) version 0.9.8 or later.
19
19
 
20
20
  ### Gem Installation using Bundler
21
21
 
22
22
  Include the latest [gem](http://rubygems.org/gems/refinerycms-map) into your Refinery CMS application's Gemfile:
23
23
 
24
- gem "refinerycms-map", '~> 0.0.1', :require => "map"
24
+ gem "refinerycms-map", '~> 0.2.0'
25
25
 
26
26
  Then type the following at command line inside your Refinery CMS application's root directory:
27
27
 
28
28
  bundle install
29
- script/generate map
30
- rake db:migrate
31
-
32
- ### Rails Engine Installation
33
-
34
- If you do not want to install the engine via bundler then you can install it as an engine inside your application's vendor directory.
35
- Type the following at command line inside your Refinery CMS application's root directory:
36
-
37
- script/plugin install git://github.com/envylabs/refinerycms-map.git
38
- script/generate map
29
+ script/generate refinerycms_map
39
30
  rake db:migrate
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-map
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Envy Labs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-29 00:00:00 -04:00
18
+ date: 2010-12-06 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -44,14 +44,16 @@ files:
44
44
  - app/views/map_locations/show.html.erb
45
45
  - config/locales/en.yml
46
46
  - config/routes.rb
47
- - generators/map/map_generator.rb
48
- - generators/map/templates/jquery.jmapping.min.js
49
- - generators/map/templates/jquery.metadata.js
50
- - generators/map/templates/mapiconmaker.js
51
- - generators/map/templates/markermanager.js
52
- - generators/map/templates/migration.rb
53
47
  - lib/gemspec.rb
48
+ - lib/generators/refinerycms_map/templates/db/migrate/migration_number_create_singuar_name.rb
49
+ - lib/generators/refinerycms_map/templates/db/seeds/seed.rb
50
+ - lib/generators/refinerycms_map/templates/js/jquery.jmapping.min.js
51
+ - lib/generators/refinerycms_map/templates/js/jquery.metadata.js
52
+ - lib/generators/refinerycms_map/templates/js/mapiconmaker.js
53
+ - lib/generators/refinerycms_map/templates/js/markermanager.js
54
+ - lib/generators/refinerycms_map_generator.rb
54
55
  - lib/map.rb
56
+ - lib/refinerycms-map.rb
55
57
  - license.md
56
58
  - rails/init.rb
57
59
  - readme.md
@@ -1,37 +0,0 @@
1
- class MapGenerator < Rails::Generator::NamedBase
2
-
3
- def initialize(*runtime_args)
4
- # set first argument to the table's name so that the user doesn't have to pass it in.
5
- runtime_args[0] = ["map_locations"]
6
- super(*runtime_args)
7
- end
8
-
9
- def banner
10
- "Usage: script/generate map"
11
- end
12
-
13
- def manifest
14
- record do |m|
15
- m.migration_template 'migration.rb', 'db/migrate',
16
- :migration_file_name => "create_structure_for_map",
17
- :assigns => {
18
- :migration_name => "CreateStructureForMap",
19
- :table_name => "map_locations",
20
- :attributes => [
21
- Rails::Generator::GeneratedAttribute.new("title", "string"),
22
- Rails::Generator::GeneratedAttribute.new("address", "string"),
23
- Rails::Generator::GeneratedAttribute.new("city", "string"),
24
- Rails::Generator::GeneratedAttribute.new("state", "string"),
25
- Rails::Generator::GeneratedAttribute.new("zipcode", "string"),
26
- Rails::Generator::GeneratedAttribute.new("phone", "string"),
27
- Rails::Generator::GeneratedAttribute.new("url", "string"),
28
- ]
29
- }
30
- m.file "jquery.jmapping.min.js", "public/javascripts/jquery.jmapping.min.js"
31
- m.file "jquery.metadata.js", "public/javascripts/jquery.metadata.js"
32
- m.file "mapiconmaker.js", "public/javascripts/mapiconmaker.js"
33
- m.file "markermanager.js", "public/javascripts/markermanager.js"
34
- end
35
- end
36
-
37
- end if defined?(Rails::Generator::NamedBase)
@@ -1,44 +0,0 @@
1
- class <%= migration_name %> < ActiveRecord::Migration
2
-
3
- def self.up
4
- create_table :<%= table_name %> do |t|
5
- <% attributes.each do |attribute| -%>
6
- t.<%= attribute.type %> :<%= attribute.name %>
7
- <% end -%>
8
- t.decimal :lat, :precision => 9, :scale => 6, :default => 0.0
9
- t.decimal :lng, :precision => 9, :scale => 6, :default => 0.0
10
- t.timestamps
11
- end
12
-
13
- add_index :<%= table_name %>, :id
14
-
15
- User.find(:all).each do |user|
16
- user.plugins.create(:name => "Map", :position => (user.plugins.maximum(:position) || -1) + 1)
17
- end
18
-
19
- page = Page.create(:title => "Map",
20
- :link_url => "/map",
21
- :menu_match => "^/map.*$",
22
- :deletable => false,
23
- :position => Page.count)
24
-
25
- RefinerySetting.find_or_set(:default_page_parts, ["Body", "Side Body"]).each do |default_page_part|
26
- page.parts.create(:title => default_page_part, :body => nil)
27
- end
28
-
29
- end
30
-
31
- def self.down
32
- UserPlugin.destroy_all({:name => "Map"})
33
-
34
- Page.find_all_by_link_url("/map").each do |page|
35
- page.link_url, page.menu_match = nil
36
- page.deletable = true
37
- page.destroy
38
- end
39
- Page.destroy_all({:link_url => "/map"})
40
-
41
- drop_table :<%= table_name %>
42
- end
43
-
44
- end