amalgam 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,16 +2,16 @@ en:
2
2
  helpers:
3
3
  submit:
4
4
  page:
5
- create: "add %{model}"
6
- update: "update %{model}"
5
+ create: "Add %{model}"
6
+ update: "Update %{model}"
7
7
  group:
8
- create: "add %{model}"
9
- update: "update %{model}"
8
+ create: "Add %{model}"
9
+ update: "Update %{model}"
10
10
  label:
11
11
  page:
12
- slug: 'slug:'
13
- path: 'path:'
14
- parent_id: 'parent page:'
12
+ slug: 'Slug:'
13
+ path: 'Path:'
14
+ parent_id: 'Parent Page:'
15
15
  activerecord:
16
16
  errors:
17
17
  models:
@@ -19,73 +19,73 @@ en:
19
19
  taken: "%{attribute} has been taken"
20
20
  blank: "%{attribute} can not be blank"
21
21
  models:
22
- page: "page"
23
- amalgam/models/group: 'group'
22
+ page: "Page"
23
+ amalgam/models/group: 'Group'
24
24
  attributes:
25
25
  amalgam/models/group:
26
- name: 'name'
26
+ name: 'Name'
27
27
  page:
28
- slug: 'slug'
29
- path: 'path'
30
- parent_id: 'parent page'
31
- group_ids: "groups"
28
+ slug: 'Slug'
29
+ path: 'Path'
30
+ parent_id: 'Parent Page'
31
+ group_ids: "Groups"
32
32
  amalgam:
33
- file_download: 'file download'
34
- file_pre: 'file pre'
35
- file_upload: 'file upload'
36
- attachment_list: 'attachment list'
37
- attachment: 'attachment'
38
- description: 'description'
39
- name: 'name'
33
+ file_download: 'File Download'
34
+ file_pre: 'File Preview'
35
+ file_upload: 'File Upload'
36
+ attachment_list: 'Attachment List'
37
+ attachment: 'Attachment'
38
+ description: 'Description'
39
+ name: 'Name'
40
40
  locales:
41
41
  zh-CN: '中文(简体)'
42
42
  zh-cn: '中文(简体)'
43
43
  en: 'English'
44
44
  registrations:
45
- currentpassword: 'we need your current password to confirm your changes'
46
- leaveblank: "leave it blank if you don't want to change it"
45
+ currentpassword: 'We need your current password to confirm your changes'
46
+ leaveblank: "Leave it blank if you don't want to change it"
47
47
  fail:
48
- password_confirmation_not_match: "password and password_confirmation are not match"
49
- current_password_not_match: "current_password not match"
48
+ password_confirmation_not_match: "Password and password_confirmation are not match"
49
+ current_password_not_match: "Current_password not match"
50
50
  sessions:
51
51
  actions:
52
- sign_in: 'sign in'
53
- sign_out: 'sign out'
54
- edit_info: 'edit info'
52
+ sign_in: 'Sign In'
53
+ sign_out: 'Sign Out'
54
+ edit_info: 'Edit Info'
55
55
  success:
56
- sign_in: 'sign in successfully'
57
- sign_out: 'sign out successfully'
56
+ sign_in: 'Sign in successfully'
57
+ sign_out: 'Sign out successfully'
58
58
  fail:
59
- invalid_name_or_password: 'invalid username or password'
60
- need_to_be_admin: 'you need to be an admin,please sign in as a admin'
61
- need_to_be_user: 'you need to be an user,please sign in as a user'
62
- not_enough_authority: 'you do not have enough authority,please sign in'
59
+ invalid_name_or_password: 'Invalid username or password'
60
+ need_to_be_admin: 'You need to be an admin,please sign in as a admin'
61
+ need_to_be_user: 'You need to be an user,please sign in as a user'
62
+ not_enough_authority: 'You do not have enough authority,please sign in'
63
63
  admin:
64
64
  actions:
65
- edit: 'edit'
66
- update: 'update'
67
- apply: 'apply'
68
- cancel: 'cancel'
69
- index: 'index'
70
- new: 'new'
71
- show: "show"
72
- destroy: 'destroy'
73
- preview: 'preview'
74
- new_child: 'new child'
75
- edit_content: 'edit content'
65
+ edit: 'Edit'
66
+ update: 'Update'
67
+ apply: 'Apply'
68
+ cancel: 'Cancel'
69
+ index: 'Index'
70
+ new: 'New'
71
+ show: "Show"
72
+ destroy: 'Destroy'
73
+ preview: 'Preview'
74
+ new_child: 'New child'
75
+ edit_content: 'Edit content'
76
76
  a:
77
- back: "back"
78
- show: "show"
77
+ back: "Back"
78
+ show: "Show"
79
79
  confirmation:
80
- delete_child: 'delete this %{model} and all its children %{model}, are you sure to remove this %{model}?'
80
+ delete_child: 'Delete this %{model} and all its children %{model}, are you sure to remove this %{model}?'
81
81
  tree:
82
- moved: "moved successfully"
83
- move_error: "move error"
82
+ moved: "Moved successfully"
83
+ move_error: "Move error"
84
84
  message:
85
- create_successfully: 'created successfully'
86
- update_successfully: 'updated successfully'
87
- destroy_successfully: 'destroyed successfully'
88
- destroy_failed: 'destroy failed'
89
- error: "load error!"
90
- loading: "loading..."
91
- done: "done!"
85
+ create_successfully: 'Created successfully'
86
+ update_successfully: 'Updated successfully'
87
+ destroy_successfully: 'Destroyed successfully'
88
+ destroy_failed: 'Destroy failed'
89
+ error: "Load error!"
90
+ loading: "Loading..."
91
+ done: "Done!"
@@ -37,7 +37,7 @@ module Amalgam
37
37
 
38
38
  def extract_locale_from_subdomain
39
39
  res = request.subdomains.first
40
- res if !request.subdomains.empty? and res != request.host
40
+ res if !request.subdomains.empty? and res != request.host and available_locales.include? res
41
41
  end
42
42
  end
43
43
  end
@@ -1,3 +1,3 @@
1
1
  module Amalgam
2
- VERSION = "2.1.2"
2
+ VERSION = "2.1.3"
3
3
  end
@@ -0,0 +1,210 @@
1
+ module Amalgam
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
5
+ class_option :i18n, :type => :boolean, :default => false, :description => "Include the globalize module"
6
+
7
+ source_root File.expand_path("../../templates", __FILE__)
8
+
9
+ desc "Creates a Amalgam initializer and copy locale files to your application and init the basic model page."
10
+
11
+ def copy_initializer
12
+ template "amalgam.rb", "config/initializers/amalgam.rb"
13
+ end
14
+
15
+ def copy_locale
16
+ copy_file "../../../config/locales/en.yml", "config/locales/amalgam.en.yml"
17
+ copy_file "../../../config/locales/zh-CN.yml", "config/locales/amalgam.zh-CN.yml"
18
+ end
19
+
20
+ def init_page
21
+ create_file "app/models/page.rb" do
22
+ <<-RUBY
23
+ class Page < ActiveRecord::Base
24
+ include Amalgam::Models::Page
25
+ attr_accessible :parent_id, :prev_id ,:next_id ,:title ,:slug
26
+ end
27
+ RUBY
28
+ end
29
+ end
30
+
31
+ def init_admin_user
32
+ create_file "app/models/admin_user.rb" do
33
+ <<-RUBY
34
+ class AdminUser < Amalgam::Authorities::Models::ActiveRecord
35
+ attr_accessible :email, :username
36
+ end
37
+ RUBY
38
+ end
39
+ end
40
+
41
+ def inti_attachments
42
+ create_file "app/models/attachment.rb" do
43
+ <<-RUBY
44
+ class Attachment < ActiveRecord::Base
45
+ attr_accessible :attachable_id, :file, :name, :description, :position
46
+
47
+ mount_uploader :file , AttachmentUploader
48
+ validates_presence_of :file, :on => :create
49
+
50
+ belongs_to :attachable, :polymorphic => true
51
+
52
+
53
+ delegate :url, :to => :file
54
+
55
+ def serializable_hash(options = nil)
56
+ options ||= {}
57
+ options[:methods] ||= []
58
+ options[:methods] << :url
59
+ super(options)
60
+ end
61
+
62
+ protected
63
+
64
+ before_save :update_file_attributes
65
+ def update_file_attributes
66
+ if file.present? && file_changed?
67
+ self.content_type = file.file.content_type
68
+ self.file_size = file.file.size
69
+ self.original_filename = file.file.original_filename
70
+ end
71
+ end
72
+ end
73
+ RUBY
74
+ end
75
+ end
76
+
77
+ def create_migration_files
78
+ time = Time.now.strftime('%Y%m%d%H%M%S').to_i
79
+ create_file "db/migrate/#{time}_create_pages.rb" do
80
+ <<-RUBY
81
+ class CreatePages < ActiveRecord::Migration
82
+ def change
83
+ create_table :pages do |t|
84
+ t.string :title, :null => false
85
+ t.string :path
86
+ t.string :slug, :null => false
87
+ t.integer :lft
88
+ t.integer :rgt
89
+ t.integer :parent_id
90
+
91
+ t.timestamps
92
+ end
93
+ end
94
+ end
95
+ RUBY
96
+ end
97
+
98
+ time += 1
99
+ create_file "db/migrate/#{time}_create_admin_users.rb" do
100
+ <<-RUBY
101
+ class CreateAdminUsers < ActiveRecord::Migration
102
+ def change
103
+ create_table :admin_users do |t|
104
+
105
+ t.string :username
106
+ t.string :email
107
+ t.string :password_digest
108
+
109
+ t.timestamps
110
+ end
111
+ end
112
+ end
113
+ RUBY
114
+ end
115
+
116
+ time += 1
117
+ create_file "db/migrate/#{time}_create_attachments.rb" do
118
+ <<-RUBY
119
+ class CreateAttachments < ActiveRecord::Migration
120
+ create_table :attachments do |t|
121
+ t.references :attachable ,:polymorphic => {:default => 'Page'}
122
+ t.string :name
123
+ t.string :file
124
+ t.string :content_type
125
+ t.string :original_filename
126
+ t.string :description
127
+ t.string :secure_token
128
+ t.integer :file_size
129
+ t.integer :position
130
+
131
+ t.timestamps
132
+ end
133
+ end
134
+ RUBY
135
+ end
136
+
137
+ time += 1
138
+ create_file "db/migrate/#{time}_create_groups.rb" do
139
+ <<-RUBY
140
+ class CreateGroups < ActiveRecord::Migration
141
+ def change
142
+ create_table :groups do |t|
143
+
144
+ t.string :name
145
+
146
+ t.timestamps
147
+ end
148
+ end
149
+ end
150
+ RUBY
151
+ end
152
+
153
+ time += 1
154
+ create_file "db/migrate/#{time}_create_base_groups.rb" do
155
+ <<-RUBY
156
+ class CreateBaseGroups < ActiveRecord::Migration
157
+ def change
158
+ create_table :base_groups do |t|
159
+
160
+ t.integer :group_id
161
+ t.string :groupable_type
162
+ t.integer :groupable_id
163
+
164
+ t.timestamps
165
+ end
166
+ end
167
+ end
168
+ RUBY
169
+ end
170
+ end
171
+
172
+ def extra
173
+ inject_into_file 'app/controllers/application_controller.rb', :before => 'protect_from_forgery' do
174
+ <<-RUBY
175
+ include Amalgam::Authorities::Controllers::Helpers
176
+ RUBY
177
+ end
178
+
179
+ create_file "app/controllers/pages_controller.rb" do
180
+ <<-RUBY
181
+ class PagesController < ApplicationController
182
+ include Amalgam::TemplateFinder
183
+ include Amalgam::Editable
184
+
185
+ def show
186
+ @page = Page.where(:slug => params[:slug]).first
187
+ raise ActiveRecord::RecordNotFound , "Couldn't find page with PATH=\#\{params[:slug]\}" if @page.blank?
188
+ render template_for(@page)
189
+ end
190
+ end
191
+ RUBY
192
+ end
193
+
194
+ inject_into_file 'config/routes.rb', :after => "Application.routes.draw do\n" do
195
+ <<-RUBY
196
+ hierarchical_resource :pages
197
+ mount Amalgam::Engine => "/"
198
+ root :to => 'pages#show' , :defaults => {:slug => 'home'}
199
+ RUBY
200
+ end
201
+
202
+ append_file 'db/seeds.rb' do
203
+ <<-RUBY
204
+ AdminUser.create(:username => 'admin', :email => 'admin@example.com',:password => 'admin1234', :password_confirmation => 'admin1234')
205
+ RUBY
206
+ end
207
+ end
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,50 @@
1
+ #encoding: utf-8
2
+ Amalgam.setup do |config|
3
+ # type_whitelist 允许mercury编辑器编辑更新的模型列表,不在这个列表内的模型无法通过mercury编辑器编辑更新,
4
+ # 里面应该填写对应的模型的类名字符串,是个数组,可以填多个模型。例如
5
+ #
6
+ #config.type_whitelist = ['Page']
7
+ #config.type_whitelist = ['Page', 'Post']
8
+ #
9
+ config.type_whitelist = ['Page']
10
+
11
+ # models_with_templates 采用新模板匹配方式查询模板的控制器列表,
12
+ # 里面应该填写对应的模型的控制器名字符串,是个数组,可以填多个模型。例如
13
+ #
14
+ #config.models_with_templates = ['pages']
15
+ #config.models_with_templates = ['pages', 'posts']
16
+ #
17
+ config.models_with_templates = ['pages']
18
+
19
+
20
+ # authority_model 内置的权限系统,内部会根据这里的设置生成routes, 默认是后台管理员 admin_user。
21
+ # 例如
22
+ # config.authority_model :user
23
+ # 如果要给这个用户以管理员权限,则加入一个:as => :admin选项
24
+ # 例如
25
+ # config.authority_model :admin_user, :as => :admin
26
+ # 可以加入多个用户,目前管理员只能有一个
27
+ #
28
+ config.authority_model :admin_user, :as => :admin
29
+
30
+ # admin_routes 后台的routes, 在block里填写后台需要编辑的模型的routes, 后台会根据对应的routes生成顶栏
31
+ # 链接
32
+ # 例如
33
+ # config.admin_routes do
34
+ # resources :pages, :except => [:show]
35
+ # # resources :posts, :except => [:show]
36
+ # resources :appointments, :except => [:edit,:update,:create,:new]
37
+ # end
38
+ config.admin_routes do
39
+ resources :pages, :except => [:show]
40
+ end
41
+
42
+ # i18n 支持多语言的选项,默认是nil,是不支持多语言,使用默认语言
43
+ # 如果
44
+ # config.i18n = params
45
+ # 是说明采用参数传递语言种类
46
+ # 如果
47
+ # config.i18n = subdomain
48
+ # 是说明用子域名的方式传递语言种类
49
+ config.i18n = nil
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amalgam
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
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: 2013-01-21 00:00:00.000000000 Z
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -379,7 +379,7 @@ dependencies:
379
379
  - - ! '>='
380
380
  - !ruby/object:Gem::Version
381
381
  version: '0'
382
- description: Amalgam is a WYSIWYG gem for CMS
382
+ description: CMS based on Mercury Editor
383
383
  email:
384
384
  - andrew@xtunes.cn
385
385
  executables: []
@@ -472,6 +472,8 @@ files:
472
472
  - lib/amalgam/validators/slug.rb
473
473
  - lib/amalgam/version.rb
474
474
  - lib/amalgam.rb
475
+ - lib/generators/amalgam/install_generator.rb
476
+ - lib/generators/templates/amalgam.rb
475
477
  - lib/page_routes.rb
476
478
  - lib/tasks/amalgam_tasks.rake
477
479
  - lib/tasks/dump.rake
@@ -898,18 +900,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
898
900
  - - ! '>='
899
901
  - !ruby/object:Gem::Version
900
902
  version: '0'
901
- segments:
902
- - 0
903
- hash: -10239737494206678
904
903
  required_rubygems_version: !ruby/object:Gem::Requirement
905
904
  none: false
906
905
  requirements:
907
906
  - - ! '>='
908
907
  - !ruby/object:Gem::Version
909
908
  version: '0'
910
- segments:
911
- - 0
912
- hash: -10239737494206678
913
909
  requirements: []
914
910
  rubyforge_project:
915
911
  rubygems_version: 1.8.24
@@ -917,3 +913,4 @@ signing_key:
917
913
  specification_version: 3
918
914
  summary: Amalgam is a gem for cms building
919
915
  test_files: []
916
+ has_rdoc: