fullstack-admin 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.11
1
+ 0.1.12
@@ -1,7 +1,7 @@
1
1
  <% if instance_variable_get("@#{controller_name.singularize}").destroyed? %>
2
2
  $("a[data-method='delete']").filter("[href='<%=j request.path %>']").closest("tr, li").remove()
3
- notify_notice('<%=j t("flash.success.delete") %>')
3
+ notify_notice('<%=j t("fullstack.admin.flash.success.delete") %>')
4
4
  <% else %>
5
- notify_error('<%=j t("flash.error.delete") %>')
5
+ notify_error('<%=j t("fullstack.admin.flash.error.delete") %>')
6
6
  <% end %>
7
7
 
@@ -0,0 +1,5 @@
1
+ if Object.const_defined?("Ckeditor")
2
+ Ckeditor.setup do |config|
3
+ require "ckeditor/orm/active_record"
4
+ end
5
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fullstack-admin"
8
- s.version = "0.1.11"
8
+ s.version = "0.1.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["mcasimir"]
12
- s.date = "2012-08-12"
12
+ s.date = "2012-08-13"
13
13
  s.description = "Administration interface framework for fullstack"
14
14
  s.email = "maurizio.cas@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -981,6 +981,7 @@ Gem::Specification.new do |s|
981
981
  "app/views/admin/base/new.html.erb",
982
982
  "app/views/admin/base/update.js.coffee",
983
983
  "app/views/layouts/admin.html.erb",
984
+ "config/initializers/ckeditor.rb",
984
985
  "config/routes.rb",
985
986
  "fullstack-admin.gemspec",
986
987
  "lib/fullstack-admin.rb",
@@ -988,14 +989,17 @@ Gem::Specification.new do |s|
988
989
  "lib/fullstack/admin/engine.rb",
989
990
  "lib/generators/fullstack/admin/install_generator.rb",
990
991
  "lib/generators/fullstack/admin/locale_generator.rb",
992
+ "lib/generators/fullstack/admin/scaffold_generator.rb",
991
993
  "lib/generators/fullstack/admin/templates/root/app/assets/javascripts/admin/admin.js.coffee",
992
994
  "lib/generators/fullstack/admin/templates/root/app/assets/stylesheets/admin/admin.css",
993
995
  "lib/generators/fullstack/admin/templates/root/app/controllers/admin/dashboard_controller.rb",
994
996
  "lib/generators/fullstack/admin/templates/root/app/models/user.rb",
997
+ "lib/generators/fullstack/admin/templates/root/app/views/admin/_nav.html.erb",
995
998
  "lib/generators/fullstack/admin/templates/root/app/views/admin/dashboard/show.html.erb",
999
+ "lib/generators/fullstack/admin/templates/root/db/migrate/20120730204729_create_ckeditor_assets.rb",
996
1000
  "lib/generators/fullstack/admin/templates/root/lib/support/user_subject.rb",
997
1001
  "locales/en.yml",
998
- "locales/fullstack.admin.it.yml",
1002
+ "locales/it.yml",
999
1003
  "vendor/assets/javascripts/ajax-chosen.js",
1000
1004
  "vendor/assets/javascripts/angular.js",
1001
1005
  "vendor/assets/javascripts/bootstrap.js",
@@ -1,9 +1,12 @@
1
1
  require 'rails'
2
+ require "ckeditor"
2
3
 
3
4
  module Fullstack
4
5
  module Admin
5
6
  class Engine < ::Rails::Engine
6
-
7
+ initializer "fullstack-admin precompile" do |app|
8
+ app.config.assets.precompile += Ckeditor.assets
9
+ end
7
10
  end
8
11
  end
9
12
  end
@@ -15,7 +15,7 @@ module Fullstack
15
15
  generate "fullstack:install --host='#{host}' --user='#{user}' --title='#{title}' --slogan='#{slogan}'"
16
16
  end
17
17
  end
18
-
18
+
19
19
  def copy_templates
20
20
  directory "root", Rails.root
21
21
  end
@@ -31,15 +31,16 @@ eos
31
31
  end
32
32
 
33
33
  def append_routes
34
- route do
35
- <<-eos
34
+ src = <<-eos
35
+
36
36
  namespace :admin do
37
37
  root :to => "dashboard#show"
38
38
  end
39
39
 
40
40
  eos
41
+ route(src)
41
42
 
42
- end
43
+ route("\n devise_for :users\n")
43
44
  end
44
45
 
45
46
  def english_localizations
@@ -1,7 +1,7 @@
1
1
  module Fullstack
2
2
  module Admin
3
3
  class LocaleGenerator < Rails::Generators::NamedBase
4
- source_root File.expand_path('../../../../locales', __FILE__)
4
+ source_root File.expand_path('../../../../../locales', __FILE__)
5
5
 
6
6
  def install
7
7
  copy_file "#{name}.yml", Rails.root.join("config", "locales", "fullstack.admin.#{name}.yml")
@@ -0,0 +1,118 @@
1
+ module Fullstack
2
+ module Admin
3
+ class ScaffoldGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates/scaffold', __FILE__)
5
+
6
+ argument :name, :required => true
7
+ class_option :views, :type => :boolean, :default => true
8
+
9
+
10
+
11
+ def create_controller_files
12
+ template 'controller.rb', File.join("app/controllers/", scope, "#{file_name.pluralize}_controller.rb")
13
+ end
14
+
15
+ def add_routes
16
+ routes_rb = Rails.root.join('config', 'routes.rb')
17
+
18
+ altered_lines = []
19
+ File.open(routes_rb) do |file|
20
+ lines = file.read.split("\n")
21
+ lines.each do |line|
22
+ if line =~ /^ \s* namespace \s+ :#{scope} \s+ do /x
23
+ leading_space = line.match(/^(\s*)/)[1] + " "
24
+ line = [line, "#{leading_space}resources :#{plural_name}, :except => [:show]"].join("\n")
25
+ end
26
+ altered_lines << line
27
+ end
28
+ end
29
+
30
+ File.open(routes_rb, 'w') do |file|
31
+ file.write(altered_lines.join("\n"))
32
+ end
33
+
34
+ say("addedd 'resources :#{plural_name}, :except => [:show]' to namespace ':#{scope}' in routes.rb")
35
+ end
36
+
37
+ def create_views
38
+ if options[:views]
39
+ directory('views', Rails.root.join('app', 'views', scope, plural_name))
40
+ end
41
+ end
42
+
43
+ # def generate_inputs
44
+ # generate("inputs #{name.singularize} --scope #{scope}")
45
+ # end
46
+
47
+ def append_to_menu
48
+ gsub_file(Rails.root.join('app', 'views', scope, "shared", "_nav.html.erb"), /\<\!-- items placeholder --\>\n/) do
49
+ <<-str
50
+ <%= nav_item _("#{controller_class_name}"), #{scope}_#{plural_name}_path %>
51
+ <!-- items placeholder -->
52
+
53
+ str
54
+ end
55
+ end
56
+
57
+ protected
58
+
59
+ def scope
60
+ @scope ||= "admin"
61
+ end
62
+
63
+ def plural_name
64
+ name.pluralize
65
+ end
66
+
67
+ def singular_name
68
+ name.singularize
69
+ end
70
+
71
+ def scope_class
72
+ scope.camelize
73
+ end
74
+
75
+ # def inputs
76
+ # exclude_attributes = model.protected_attributes.to_a + %W(created_at updated_at slug)
77
+ # columns = model.columns_hash.map {|k, v| [k, v.type]}.delete_if {|k, t| exclude_attributes.include?(k)}
78
+ # end
79
+
80
+ def has_timestamps?
81
+ model.columns_hash["created_at"]
82
+ end
83
+
84
+ def title_column
85
+ ( model.column_names & %W(title name label claim) ).first
86
+ end
87
+
88
+ def controller_class_name
89
+ class_name.pluralize
90
+ end
91
+
92
+ def resource_class_name
93
+ class_name.singularize
94
+ end
95
+
96
+ def resource_name
97
+ file_name.singularize
98
+ end
99
+
100
+ def collection_name
101
+ file_name.pluralize
102
+ end
103
+
104
+ def file_name
105
+ name
106
+ end
107
+
108
+ def model
109
+ class_name.constantize
110
+ end
111
+
112
+ def content?
113
+ options[:content]
114
+ end
115
+
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,34 @@
1
+ <% content_for :menu do -%>
2
+
3
+ <%= nav do %>
4
+ <%= nav_item _("Dashboard"), admin_root_path, :icon => "cog" , :icon_color => :white %>
5
+ <% end %>
6
+
7
+ <%= nav(:class => 'float right') do %>
8
+ <%= nav_item _("Homepage"), "/", :icon => "home" , :icon_color => :white %>
9
+ <%= dropdown_nav_item _("Account"), :icon => "user" , :icon_color => :white do %>
10
+ <%= nav_item _('Logout'), destroy_user_session_path, :method => :delete %>
11
+ <% end %>
12
+ <% end %>
13
+
14
+ <% end -%>
15
+
16
+ <% content_for :nav do -%>
17
+
18
+ <div class="well">
19
+ <%= nav_list do %>
20
+ <%= nav_header _("Contents") %>
21
+ <!-- FULLSTACK_PLACEHOLDER -->
22
+
23
+ <!-- Please do not delete the comment above.
24
+ It is a placeholder used by fullstack generators
25
+ to attach new menu items
26
+ -->
27
+
28
+ <%= nav_header _("Users") %>
29
+ <%= nav_item _("Users"), admin_users_path %>
30
+ <% end -%>
31
+ </div>
32
+
33
+
34
+ <% end -%>
@@ -0,0 +1,26 @@
1
+ class CreateCkeditorAssets < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :ckeditor_assets do |t|
4
+ t.string :data_file_name, :null => false
5
+ t.string :data_content_type
6
+ t.integer :data_file_size
7
+
8
+ t.integer :assetable_id
9
+ t.string :assetable_type, :limit => 30
10
+ t.string :type, :limit => 30
11
+
12
+ # Uncomment it to save images dimensions, if your need it
13
+ t.integer :width
14
+ t.integer :height
15
+
16
+ t.timestamps
17
+ end
18
+
19
+ add_index "ckeditor_assets", ["assetable_type", "type", "assetable_id"], :name => "idx_ckeditor_assetable_type"
20
+ add_index "ckeditor_assets", ["assetable_type", "assetable_id"], :name => "idx_ckeditor_assetable"
21
+ end
22
+
23
+ def self.down
24
+ drop_table :ckeditor_assets
25
+ end
26
+ end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fullstack-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-12 00:00:00.000000000 Z
12
+ date: 2012-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -1207,6 +1207,7 @@ files:
1207
1207
  - app/views/admin/base/new.html.erb
1208
1208
  - app/views/admin/base/update.js.coffee
1209
1209
  - app/views/layouts/admin.html.erb
1210
+ - config/initializers/ckeditor.rb
1210
1211
  - config/routes.rb
1211
1212
  - fullstack-admin.gemspec
1212
1213
  - lib/fullstack-admin.rb
@@ -1214,14 +1215,17 @@ files:
1214
1215
  - lib/fullstack/admin/engine.rb
1215
1216
  - lib/generators/fullstack/admin/install_generator.rb
1216
1217
  - lib/generators/fullstack/admin/locale_generator.rb
1218
+ - lib/generators/fullstack/admin/scaffold_generator.rb
1217
1219
  - lib/generators/fullstack/admin/templates/root/app/assets/javascripts/admin/admin.js.coffee
1218
1220
  - lib/generators/fullstack/admin/templates/root/app/assets/stylesheets/admin/admin.css
1219
1221
  - lib/generators/fullstack/admin/templates/root/app/controllers/admin/dashboard_controller.rb
1220
1222
  - lib/generators/fullstack/admin/templates/root/app/models/user.rb
1223
+ - lib/generators/fullstack/admin/templates/root/app/views/admin/_nav.html.erb
1221
1224
  - lib/generators/fullstack/admin/templates/root/app/views/admin/dashboard/show.html.erb
1225
+ - lib/generators/fullstack/admin/templates/root/db/migrate/20120730204729_create_ckeditor_assets.rb
1222
1226
  - lib/generators/fullstack/admin/templates/root/lib/support/user_subject.rb
1223
1227
  - locales/en.yml
1224
- - locales/fullstack.admin.it.yml
1228
+ - locales/it.yml
1225
1229
  - vendor/assets/javascripts/ajax-chosen.js
1226
1230
  - vendor/assets/javascripts/angular.js
1227
1231
  - vendor/assets/javascripts/bootstrap.js
@@ -1258,7 +1262,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1258
1262
  version: '0'
1259
1263
  segments:
1260
1264
  - 0
1261
- hash: -1397487762689386514
1265
+ hash: -2592282413072707918
1262
1266
  required_rubygems_version: !ruby/object:Gem::Requirement
1263
1267
  none: false
1264
1268
  requirements: