prologue 0.1.0 → 0.1.1
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/README.md +7 -0
- data/lib/prologue/version.rb +1 -1
- data/templates/admin/layout.rb +0 -2
- data/templates/admin/users.rb +5 -17
- data/templates/application_layout.rb +0 -2
- data/templates/bootstrap.rb +0 -3
- data/templates/db.rb +2 -1
- data/templates/devise.rb +4 -1
- data/templates/gemfile.rb +1 -0
- metadata +3 -4
- data/templates/sorter_lib.rb +0 -97
data/README.md
CHANGED
@@ -29,6 +29,13 @@ Everything is configured and ready to rock your next Rails 3 project. We hope i
|
|
29
29
|
prologue new my_app --no-admin
|
30
30
|
|
31
31
|
|
32
|
+
### Testing generated app
|
33
|
+
|
34
|
+
rake spec
|
35
|
+
rake cucumber
|
36
|
+
bundle exec autotest
|
37
|
+
|
38
|
+
|
32
39
|
### Issues
|
33
40
|
|
34
41
|
Please report issues to the [Prologue issue tracker](http://github.com/quickleft/prologue/issues/).
|
data/lib/prologue/version.rb
CHANGED
data/templates/admin/layout.rb
CHANGED
data/templates/admin/users.rb
CHANGED
@@ -10,8 +10,7 @@ end
|
|
10
10
|
|
11
11
|
inject_into_file 'app/controllers/admin/users_controller.rb', :after => "def index\n" do
|
12
12
|
<<-'FILE'
|
13
|
-
@
|
14
|
-
@users = User.paginate :page => params[:page], :order => @sortable.order, :per_page => 2
|
13
|
+
@users = User.paginate :page => params[:page], :per_page => 50
|
15
14
|
FILE
|
16
15
|
end
|
17
16
|
|
@@ -57,18 +56,7 @@ gsub_file 'app/controllers/admin/users_controller.rb', /ApplicationController/,
|
|
57
56
|
inject_into_file 'app/controllers/admin/users_controller.rb', :after => "class Admin::UsersController < Admin::BaseController\n" do
|
58
57
|
<<-'FILE'
|
59
58
|
before_filter :find_user, :only => [:edit, :update, :destroy]
|
60
|
-
|
61
|
-
INDEX_SORT = SortIndex::Config.new(
|
62
|
-
{'name' => 'name'},
|
63
|
-
{
|
64
|
-
'email' => 'email',
|
65
|
-
'login' => 'login',
|
66
|
-
'roles_mask' => 'roles_mask',
|
67
|
-
'last_login_at' => 'last_login_at'
|
68
|
-
}
|
69
|
-
#, optionally SortIndex::SORT_KEY_ASC
|
70
|
-
)
|
71
|
-
|
59
|
+
|
72
60
|
def find_user
|
73
61
|
@user = User.find(params[:id])
|
74
62
|
end
|
@@ -117,8 +105,8 @@ create_file 'app/views/admin/users/index.html.haml' do
|
|
117
105
|
%table
|
118
106
|
%thead
|
119
107
|
%tr
|
120
|
-
%th
|
121
|
-
%th
|
108
|
+
%th Name
|
109
|
+
%th Email
|
122
110
|
%th
|
123
111
|
%th
|
124
112
|
%tbody
|
@@ -129,7 +117,7 @@ create_file 'app/views/admin/users/index.html.haml' do
|
|
129
117
|
%td= link_to "Edit", edit_admin_user_path(user), :class => 'edit_link'
|
130
118
|
%td
|
131
119
|
- if user.id != current_user.id
|
132
|
-
= link_to "Delete", admin_user_path(user), :confirm =>
|
120
|
+
= link_to "Delete", admin_user_path(user), :confirm => 'Are you sure?', :method => :delete, :class => 'delete_link'
|
133
121
|
- else
|
134
122
|
That's you!
|
135
123
|
= will_paginate @users
|
data/templates/bootstrap.rb
CHANGED
@@ -42,9 +42,6 @@ apply File.expand_path("../friendly_id.rb", __FILE__)
|
|
42
42
|
# Apply Devise?
|
43
43
|
apply File.expand_path("../devise.rb", __FILE__) if ENV['PROLOGUE_AUTH']
|
44
44
|
|
45
|
-
# Apply sorter helper
|
46
|
-
apply File.expand_path("../sorter_lib.rb", __FILE__)
|
47
|
-
|
48
45
|
# Apply admin
|
49
46
|
apply File.expand_path("../admin.rb", __FILE__) if ENV['PROLOGUE_ADMIN']
|
50
47
|
|
data/templates/db.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
run 'rake db:migrate'
|
1
|
+
run 'rake db:migrate'
|
2
|
+
run 'rake db:test:prepare'
|
data/templates/devise.rb
CHANGED
@@ -86,7 +86,10 @@ gsub_file devise_migration, /# add_index :users, :confirmation_token, :unique
|
|
86
86
|
|
87
87
|
append_file 'db/seeds.rb' do
|
88
88
|
<<-FILE
|
89
|
-
|
89
|
+
# Setup initial user so we can get in
|
90
|
+
user = User.create! :name => '#{ENV['PROLOGUE_USER_NAME']}', :email => '#{ENV['PROLOGUE_USER_EMAIL']}', :password => '#{ENV['PROLOGUE_USER_PASSWORD']}', :password_confirmation => '#{ENV['PROLOGUE_USER_PASSWORD']}'
|
91
|
+
user.confirmed_at = user.confirmation_sent_at
|
92
|
+
user.save
|
90
93
|
FILE
|
91
94
|
end
|
92
95
|
|
data/templates/gemfile.rb
CHANGED
@@ -21,6 +21,7 @@ gem "mocha", :group => [:test]
|
|
21
21
|
gem "factory_girl_rails", :group => [:test, :cucumber]
|
22
22
|
gem "faker", :group => [:test]
|
23
23
|
gem "autotest", :group => [:test]
|
24
|
+
gem "autotest-rails", :group => [:test]
|
24
25
|
gem "thin", :group => [:test, :cucumber, :development]
|
25
26
|
gem "cucumber", :git => "git://github.com/aslakhellesoy/cucumber.git", :group => [:cucumber]
|
26
27
|
gem "database_cleaner", :git => "git://github.com/bmabey/database_cleaner.git", :group => [:test, :cucumber]
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Quick Left
|
@@ -150,7 +150,6 @@ files:
|
|
150
150
|
- templates/rails_clean.rb
|
151
151
|
- templates/rspec_clean.rb
|
152
152
|
- templates/sass.rb
|
153
|
-
- templates/sorter_lib.rb
|
154
153
|
- templates/test_suite.rb
|
155
154
|
has_rdoc: true
|
156
155
|
homepage: http://github.com/quickleft/prologue
|
@@ -185,6 +184,6 @@ rubyforge_project: prologue
|
|
185
184
|
rubygems_version: 1.3.7
|
186
185
|
signing_key:
|
187
186
|
specification_version: 3
|
188
|
-
summary: prologue-0.1.
|
187
|
+
summary: prologue-0.1.1
|
189
188
|
test_files: []
|
190
189
|
|
data/templates/sorter_lib.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
create_file 'lib/sort_index.rb' do
|
2
|
-
<<-'FILE'
|
3
|
-
module SortIndex
|
4
|
-
|
5
|
-
SORT_KEY_ASC = 'asc'
|
6
|
-
SORT_KEY_DESC = 'desc'
|
7
|
-
|
8
|
-
SORT_DIRECTION_MAP = {
|
9
|
-
SORT_KEY_DESC => 'DESC',
|
10
|
-
SORT_KEY_ASC => 'ASC'
|
11
|
-
}
|
12
|
-
|
13
|
-
class Config
|
14
|
-
attr_accessor :columns
|
15
|
-
attr_accessor :default_direction
|
16
|
-
|
17
|
-
def default
|
18
|
-
return @default
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(default, columns, default_direction = nil)
|
22
|
-
@columns = columns
|
23
|
-
@default_direction = default_direction || SORT_KEY_DESC
|
24
|
-
|
25
|
-
raise "default only supports 1 pair" if default.length != 1
|
26
|
-
default.each_pair { |key, value|
|
27
|
-
@default = value
|
28
|
-
@columns[key] = value
|
29
|
-
}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class Sortable
|
34
|
-
|
35
|
-
def initialize(params, config, index_url = nil)
|
36
|
-
@config = config
|
37
|
-
@params = params
|
38
|
-
@index_url = index_url || params[:controller]
|
39
|
-
|
40
|
-
# sets up for building the sql order by
|
41
|
-
@sort_direction = SORT_DIRECTION_MAP[@params[:sort_direction]] || @config.default_direction
|
42
|
-
@sort_by = @config.columns[@params[:sort_by]] || @config.default
|
43
|
-
end
|
44
|
-
|
45
|
-
def order
|
46
|
-
specified_sort_by || "#{@sort_by} #{@sort_direction}"
|
47
|
-
end
|
48
|
-
|
49
|
-
def header_link(sort_key, display, sortable = true, element_id = '')
|
50
|
-
|
51
|
-
if @config.columns[sort_key].nil? and sortable then
|
52
|
-
raise "Sort key of '#{sort_key}' not found. Check your controllers SortIndex::Config variable"
|
53
|
-
end
|
54
|
-
|
55
|
-
id_attr = ""
|
56
|
-
if element_id != '' then
|
57
|
-
id_attr = "id=\"#{element_id}\""
|
58
|
-
end
|
59
|
-
|
60
|
-
class_attr = ""
|
61
|
-
if @config.columns[sort_key] == @sort_by then
|
62
|
-
class_attr = " class='current-sort-#{@sort_direction.downcase}'"
|
63
|
-
end
|
64
|
-
|
65
|
-
a_href = "<a#{class_attr} href=\"/#{@index_url}?sort_by=#{sort_key}&sort_direction=#{next_direction}\" title=\"#{display}\" #{id_attr}>#{display}</a>"
|
66
|
-
if sortable == false then
|
67
|
-
a_href = "<span>#{display}</span>"
|
68
|
-
end
|
69
|
-
|
70
|
-
return "#{a_href}".html_safe
|
71
|
-
end
|
72
|
-
|
73
|
-
def next_direction
|
74
|
-
sort_direction = SORT_KEY_ASC
|
75
|
-
if (@params[:sort_direction].nil?) then
|
76
|
-
sort_direction = (@sort_direction == SORT_KEY_ASC) ? SORT_KEY_DESC : SORT_KEY_ASC
|
77
|
-
elsif (@params[:sort_direction] == SORT_KEY_ASC) then
|
78
|
-
sort_direction = SORT_KEY_DESC
|
79
|
-
end
|
80
|
-
return sort_direction
|
81
|
-
end
|
82
|
-
|
83
|
-
def specified_sort_by
|
84
|
-
sort = @config.columns[@params[:sort_by]]
|
85
|
-
return nil if sort.nil?
|
86
|
-
return sort.split(',').map {|order_criteria| "#{order_criteria} #{@sort_direction}"}.join(',')
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
FILE
|
91
|
-
end
|
92
|
-
|
93
|
-
inject_into_file 'config/application.rb', :after => "# Custom directories with classes and modules you want to be autoloadable.\n" do
|
94
|
-
<<-'FILE'
|
95
|
-
config.autoload_paths += %W(#{config.root}/lib)
|
96
|
-
FILE
|
97
|
-
end
|