somatics3 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +91 -0
- data/Rakefile +72 -0
- data/VERSION +1 -0
- data/bin/somatics +23 -0
- data/bin/somatify +21 -0
- data/lib/generators/somatics.rb +37 -0
- data/lib/generators/somatics/associated/associated_generator.rb +184 -0
- data/lib/generators/somatics/associated/templates/migration.rb +11 -0
- data/lib/generators/somatics/attributes/attributes_generator.rb +115 -0
- data/lib/generators/somatics/attributes/templates/migration.rb +11 -0
- data/lib/generators/somatics/authenticated/authenticated_generator.rb +65 -0
- data/lib/generators/somatics/authenticated/templates/partial_form.html.erb +23 -0
- data/lib/generators/somatics/authenticated_controller/authenticated_controller_generator.rb +38 -0
- data/lib/generators/somatics/authenticated_controller/templates/locales_en.yml +6 -0
- data/lib/generators/somatics/authenticated_controller/templates/locales_zh-TW.yml +6 -0
- data/lib/generators/somatics/authenticated_controller/templates/login.html.erb +31 -0
- data/lib/generators/somatics/authenticated_controller/templates/sessions_controller.rb +11 -0
- data/lib/generators/somatics/helper/helper_generator.rb +16 -0
- data/lib/generators/somatics/install/install_generator.rb +101 -0
- data/lib/generators/somatics/install/templates/config/locales/devise_zh-TW.yml +39 -0
- data/lib/generators/somatics/install/templates/config/locales/somatics_en.yml +35 -0
- data/lib/generators/somatics/install/templates/config/locales/somatics_zh-TW.yml +35 -0
- data/lib/generators/somatics/install/templates/controller_admin.rb +17 -0
- data/lib/generators/somatics/install/templates/controller_home.rb +4 -0
- data/lib/generators/somatics/install/templates/helper_admin.rb +99 -0
- data/lib/generators/somatics/install/templates/initializer_paper_trail.rb +2 -0
- data/lib/generators/somatics/install/templates/layout_admin.html.erb +87 -0
- data/lib/generators/somatics/install/templates/lib/active_record/diff.rb +61 -0
- data/lib/generators/somatics/install/templates/lib/somatic_link_renderer.rb +24 -0
- data/lib/generators/somatics/install/templates/lib/tasks/heroku.rake +30 -0
- data/lib/generators/somatics/install/templates/lib/tasks/svn.rake +47 -0
- data/lib/generators/somatics/install/templates/partial_menu.html.erb +1 -0
- data/lib/generators/somatics/install/templates/partial_versions.html.erb +56 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/add.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/arrow_collapsed.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/arrow_expanded.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/attachment.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/bullet_arrow_left.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/bullet_arrow_right.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/bullet_diamond.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/bullet_end.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/bullet_go.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/bullet_toggle_minus.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/bullet_toggle_plus.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/c.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/cancel.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/changeset.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/comment.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/comments.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/content-left.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/content-right.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/copy.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/csharp.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/database_key.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/default.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/delete.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/document.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/draft.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/duplicate.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/edit.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/exclamation.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/external.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/fav.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/fav_off.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/feed.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/folder.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/folder_open.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/footer-bg.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/footer-left.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/footer-right.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/group.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/help.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/history.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/image.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/lightning.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/link.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/loading.gif +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/locked.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/message.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/milestone.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/move.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/news.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/openid-bg.gif +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/package.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/pdf.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/php.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/plugin.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/projects.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/rails.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/reload.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/report.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/ruby.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/save.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/sort_asc.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/sort_desc.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/stats.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/table_multiple.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/task_done.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/task_late.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/task_parent_end.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/task_todo.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/text.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/text_list_bullets.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/textfield.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/ticket.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/ticket_checked.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/ticket_edit.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/ticket_go.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/ticket_note.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/time.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/time_add.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/toggle_check.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/true.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/unlock.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/user.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/warning.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/wiki_edit.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/xml.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/zip.png +0 -0
- data/lib/generators/somatics/install/templates/public/images/somatics/zoom_in.png +0 -0
- data/lib/generators/somatics/install/templates/public/javascripts/somatics/base.js +237 -0
- data/lib/generators/somatics/install/templates/public/javascripts/somatics/context_menu.js +237 -0
- data/lib/generators/somatics/install/templates/public/javascripts/somatics/controls.js +965 -0
- data/lib/generators/somatics/install/templates/public/javascripts/somatics/dragdrop.js +974 -0
- data/lib/generators/somatics/install/templates/public/javascripts/somatics/effects.js +1123 -0
- data/lib/generators/somatics/install/templates/public/javascripts/somatics/prototype.js +6001 -0
- data/lib/generators/somatics/install/templates/public/javascripts/somatics/rails.js +175 -0
- data/lib/generators/somatics/install/templates/public/javascripts/somatics/select_list_move.js +82 -0
- data/lib/generators/somatics/install/templates/public/stylesheets/application.css +863 -0
- data/lib/generators/somatics/install/templates/public/stylesheets/somatics/base.css +951 -0
- data/lib/generators/somatics/install/templates/public/stylesheets/somatics/context_menu.css +52 -0
- data/lib/generators/somatics/install/templates/public/stylesheets/somatics/csshover.htc +122 -0
- data/lib/generators/somatics/install/templates/public/stylesheets/somatics/jstoolbar.css +95 -0
- data/lib/generators/somatics/install/templates/public/themes/default/stylesheets/application.css +951 -0
- data/lib/generators/somatics/install/templates/view_index.html.erb +46 -0
- data/lib/generators/somatics/relationship/relationship_generator.rb +173 -0
- data/lib/generators/somatics/relationship/templates/migration.rb +11 -0
- data/lib/generators/somatics/scaffold/scaffold_generator.rb +24 -0
- data/lib/generators/somatics/scaffold/templates/_form.html.erb +23 -0
- data/lib/generators/somatics/scaffold/templates/edit.html.erb +6 -0
- data/lib/generators/somatics/scaffold/templates/index.html.erb +27 -0
- data/lib/generators/somatics/scaffold/templates/new.html.erb +5 -0
- data/lib/generators/somatics/scaffold/templates/show.html.erb +12 -0
- data/lib/generators/somatics/scaffold_controller/USAGE +20 -0
- data/lib/generators/somatics/scaffold_controller/scaffold_controller_generator.rb +108 -0
- data/lib/generators/somatics/scaffold_controller/templates/builder_index.xls.builder +24 -0
- data/lib/generators/somatics/scaffold_controller/templates/builder_index.xml.builder +10 -0
- data/lib/generators/somatics/scaffold_controller/templates/controller.rb +123 -0
- data/lib/generators/somatics/scaffold_controller/templates/locales_en.yml +17 -0
- data/lib/generators/somatics/scaffold_controller/templates/locales_zh-TW.yml +20 -0
- data/lib/generators/somatics/scaffold_controller/templates/partial_bulk.html.erb +12 -0
- data/lib/generators/somatics/scaffold_controller/templates/partial_edit.html.erb +7 -0
- data/lib/generators/somatics/scaffold_controller/templates/partial_form.html.erb +13 -0
- data/lib/generators/somatics/scaffold_controller/templates/partial_list.html.erb +30 -0
- data/lib/generators/somatics/scaffold_controller/templates/partial_menu.html.erb +1 -0
- data/lib/generators/somatics/scaffold_controller/templates/partial_show.html.erb +31 -0
- data/lib/generators/somatics/scaffold_controller/templates/view_edit.html.erb +24 -0
- data/lib/generators/somatics/scaffold_controller/templates/view_index.html.erb +27 -0
- data/lib/generators/somatics/scaffold_controller/templates/view_new.html.erb +14 -0
- data/lib/generators/somatics/scaffold_controller/templates/view_show.html.erb +26 -0
- data/lib/generators/somatics/settings/settings_generator.rb +86 -0
- data/lib/generators/somatics/settings_controller/USAGE +20 -0
- data/lib/generators/somatics/settings_controller/settings_controller_generator.rb +11 -0
- data/lib/generators/somatics/settings_controller/templates/builder_index.xls.builder +24 -0
- data/lib/generators/somatics/settings_controller/templates/builder_index.xml.builder +10 -0
- data/lib/generators/somatics/settings_controller/templates/controller.rb +64 -0
- data/lib/generators/somatics/settings_controller/templates/helper.rb +2 -0
- data/lib/generators/somatics/settings_controller/templates/locales_en.yml +9 -0
- data/lib/generators/somatics/settings_controller/templates/locales_zh-TW.yml +28 -0
- data/lib/generators/somatics/settings_controller/templates/migration.rb +17 -0
- data/lib/generators/somatics/settings_controller/templates/partial_bulk.html.erb +12 -0
- data/lib/generators/somatics/settings_controller/templates/partial_edit.html.erb +7 -0
- data/lib/generators/somatics/settings_controller/templates/partial_form.html.erb +15 -0
- data/lib/generators/somatics/settings_controller/templates/partial_list.html.erb +28 -0
- data/lib/generators/somatics/settings_controller/templates/partial_menu.html.erb +1 -0
- data/lib/generators/somatics/settings_controller/templates/partial_show.html.erb +13 -0
- data/lib/generators/somatics/settings_controller/templates/view_edit.html.erb +23 -0
- data/lib/generators/somatics/settings_controller/templates/view_index.html.erb +22 -0
- data/lib/generators/somatics/settings_controller/templates/view_new.html.erb +14 -0
- data/lib/generators/somatics/settings_controller/templates/view_show.html.erb +23 -0
- data/lib/somatics.rb +9 -0
- data/somatics.gemspec +249 -0
- data/somatics3.gemspec +248 -0
- data/templates/somatics.rb +106 -0
- data/test/helper.rb +10 -0
- data/test/test_somatics3-generators.rb +7 -0
- metadata +398 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 tkwong
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
=== Welcome to Somatics3
|
2
|
+
|
3
|
+
Somatics3 is next generation open source scaffolding template that kick-starts your next Rails project.
|
4
|
+
Active development has started in July 2010; new features, enhancements, and updates appear
|
5
|
+
on daily basis.
|
6
|
+
|
7
|
+
Here are the steps to get Somatics up and running on your system.
|
8
|
+
|
9
|
+
Somatics3 Support Rails 3 Now!
|
10
|
+
|
11
|
+
|
12
|
+
=== System Requirements
|
13
|
+
|
14
|
+
* Ruby v1.8.7 or v1.9.2
|
15
|
+
* Ruby on Rails v3.0+
|
16
|
+
* MySQL v4.1.1 or later (v5+ is recommended) or SQLite v3.4 or later
|
17
|
+
|
18
|
+
|
19
|
+
== Getting Started
|
20
|
+
|
21
|
+
1. Install \Somatics at the command prompt if you haven't yet:
|
22
|
+
|
23
|
+
gem install somatics3-generators
|
24
|
+
|
25
|
+
2. At the command prompt, create a new \Somatics application:
|
26
|
+
|
27
|
+
somatics new myapp
|
28
|
+
|
29
|
+
where "myapp" is the application name.
|
30
|
+
|
31
|
+
3. Change directory to +myapp+ and start the web server:
|
32
|
+
|
33
|
+
cd myapp; rails server
|
34
|
+
|
35
|
+
Run with <tt>--help</tt> for options.
|
36
|
+
|
37
|
+
4. Open up http://localhost:3000/admin and login with username ‘admin’ and password ‘somatics’.
|
38
|
+
|
39
|
+
=== Downloads
|
40
|
+
|
41
|
+
* Git source code repository: git://github.com/inspiresynergy/somatics3-generators.git
|
42
|
+
* .zip or .tgz archives: http://github.com/inspiresynergy/somatics3-generators/downloads
|
43
|
+
|
44
|
+
=== Resources
|
45
|
+
|
46
|
+
* Home page: http://www.somaticsapp.com
|
47
|
+
* Project page: http://github.com/inspiresynergy/somatics3-generators/tree/master
|
48
|
+
* Features and bugs: http://somatics.lighthouseapp.com
|
49
|
+
* Twitter commit updates: http://twitter.com/somaticsapp
|
50
|
+
* Discussion group for developers: http://groups.google.com/group/somaticsapp
|
51
|
+
* IRC channel: #somaticsapp on irc.freenode.net
|
52
|
+
|
53
|
+
=== Generate the Admin Model
|
54
|
+
|
55
|
+
You can test drive Somatics by generating models.
|
56
|
+
|
57
|
+
$ rails generate somatics:scaffold products title:string description:text
|
58
|
+
|
59
|
+
Among other things the generator creates admin user records and administration panels.
|
60
|
+
You can log in the admin panel using the default login and password.(+admin+/+password+)
|
61
|
+
The admin site is at http://localhost:3000/admin .
|
62
|
+
|
63
|
+
=== Deploying The App
|
64
|
+
|
65
|
+
TODO
|
66
|
+
|
67
|
+
=== For Developers
|
68
|
+
|
69
|
+
TODO
|
70
|
+
|
71
|
+
=== Features
|
72
|
+
|
73
|
+
Somatic is open source software and relies on your contributions to grow!
|
74
|
+
|
75
|
+
http://github.com/inspiresynergy/somatics3-generators
|
76
|
+
|
77
|
+
GitHub always contains the latest BaseApp code. Fork your own development branch here if you wish to contribute code.
|
78
|
+
|
79
|
+
Pull requests should be send to ‘inspiresynergy’ to include them in the main Somatics code base.
|
80
|
+
|
81
|
+
http://inspiresynergy.lighthouseapp.com/projects/53315-somatics/overview
|
82
|
+
|
83
|
+
Bug reports and feature requests should be posted in LightHouse.
|
84
|
+
|
85
|
+
Bugs always have priority over new features! But, you’re free to help out with whatever you want.
|
86
|
+
|
87
|
+
=== Credits
|
88
|
+
|
89
|
+
Somatics is developed by Inspire Synergy – Benjamin Wong, Gary Or and a whole bunch of cool contributors.
|
90
|
+
|
91
|
+
Somatics is released to the public under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'jeweler'
|
4
|
+
|
5
|
+
begin
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "somatics3"
|
8
|
+
gem.version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
9
|
+
gem.summary = %Q{Somatics3 - Admin Panel for Rails 3 Resources}
|
10
|
+
gem.description = %Q{Somatics3 is a collection of generators and extensions which reduces the effort of building admin panel for rails 3 resources.}
|
11
|
+
gem.email = "inspiresynergy@somaticsapp.com"
|
12
|
+
gem.homepage = "http://github.com/inspiresynergy/somatics3"
|
13
|
+
gem.authors = ["Benjamin Wong", "Gary Or"]
|
14
|
+
gem.rdoc_options += FileList['lib/**/templates/*'].to_a.collect {|f| "--exclude=#{f}" }
|
15
|
+
# gem.files = FileList[
|
16
|
+
# "README.rdoc"
|
17
|
+
# ]
|
18
|
+
# raise FileList['lib/**/templates/*'].to_a.collect{|f| "--exclude=#{f}" }.inspect
|
19
|
+
# gem.rdoc_options << "--exclude='lib/**/templates/*'"
|
20
|
+
# gem.rubyforge_project = 'somatics3'
|
21
|
+
# gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
22
|
+
|
23
|
+
gem.add_dependency 'will_paginate', "~> 3.0.pre2"
|
24
|
+
gem.add_dependency 'json'
|
25
|
+
gem.add_dependency 'meta_search'
|
26
|
+
gem.add_dependency 'paper_trail'
|
27
|
+
gem.add_dependency 'tiny_mce'
|
28
|
+
gem.add_dependency 'devise'
|
29
|
+
gem.executables = ['somatics', 'somatify']
|
30
|
+
end
|
31
|
+
# Jeweler::RubyforgeTasks.new do |rubyforge|
|
32
|
+
# rubyforge.doc_task = "rdoc"
|
33
|
+
# end
|
34
|
+
Jeweler::GemcutterTasks.new
|
35
|
+
rescue LoadError
|
36
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'rake/testtask'
|
40
|
+
Rake::TestTask.new(:test) do |test|
|
41
|
+
test.libs << 'lib' << 'test'
|
42
|
+
test.pattern = 'test/**/test_*.rb'
|
43
|
+
test.verbose = true
|
44
|
+
end
|
45
|
+
|
46
|
+
begin
|
47
|
+
require 'rcov/rcovtask'
|
48
|
+
Rcov::RcovTask.new do |test|
|
49
|
+
test.libs << 'test'
|
50
|
+
test.pattern = 'test/**/test_*.rb'
|
51
|
+
test.verbose = true
|
52
|
+
end
|
53
|
+
rescue LoadError
|
54
|
+
task :rcov do
|
55
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
task :test => :check_dependencies
|
60
|
+
|
61
|
+
task :default => :test
|
62
|
+
|
63
|
+
require 'rake/rdoctask'
|
64
|
+
Rake::RDocTask.new do |rdoc|
|
65
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
66
|
+
|
67
|
+
rdoc.rdoc_dir = 'rdoc'
|
68
|
+
rdoc.title = "somatics3 #{version}"
|
69
|
+
rdoc.rdoc_files.include('README*')
|
70
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
71
|
+
rdoc.rdoc_files.exclude('lib/**/templates/*')
|
72
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.10
|
data/bin/somatics
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
template_path = File.expand_path(File.dirname(__FILE__) + '/../templates')
|
7
|
+
|
8
|
+
|
9
|
+
# require 'somatics'
|
10
|
+
|
11
|
+
args = ARGV.dup
|
12
|
+
ARGV.clear
|
13
|
+
args.unshift('new') if args[0] != 'new'
|
14
|
+
# path = args.shift.strip rescue '.'
|
15
|
+
|
16
|
+
# a = File.expand_path(path)
|
17
|
+
template = File.join(template_path,'somatics.rb')
|
18
|
+
|
19
|
+
# puts "#{path} #{a} #{args.join(',')} #{template}"
|
20
|
+
puts "rails #{args.join(' ')} -m #{template}"
|
21
|
+
system "rails #{args.join(' ')} -m #{template}"
|
22
|
+
|
23
|
+
exit
|
data/bin/somatify
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
template_path = File.expand_path(File.dirname(__FILE__) + '/../templates')
|
7
|
+
|
8
|
+
|
9
|
+
# require 'somatics'
|
10
|
+
|
11
|
+
args = ARGV.dup
|
12
|
+
ARGV.clear
|
13
|
+
path = args.shift.strip rescue '.'
|
14
|
+
|
15
|
+
# a = File.expand_path(path)
|
16
|
+
template = File.join(template_path,'somatics.rb')
|
17
|
+
|
18
|
+
puts "rake rails:template LOCATION=#{template}"
|
19
|
+
system "rake rails:template LOCATION=#{template}"
|
20
|
+
|
21
|
+
exit
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rails/generators/named_base'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Somatics
|
5
|
+
module Generators
|
6
|
+
module Helper
|
7
|
+
def self.included(base)
|
8
|
+
base.send(:extend, ClassMethods)
|
9
|
+
base.send(:include, InstanceMethods)
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
private
|
14
|
+
|
15
|
+
def uses_local_templates
|
16
|
+
extend Somatics::Generators::TemplatePath
|
17
|
+
end
|
18
|
+
|
19
|
+
def namespaced
|
20
|
+
class_option :namespace, :banner => "NAME", :type => :string, :required => false, :default => "admin", :desc => "namespace for the controller"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module InstanceMethods
|
25
|
+
private
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module TemplatePath
|
30
|
+
def source_root
|
31
|
+
@_somaitcs_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'somatics', generator_name, 'templates'))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Rails::Generators::NamedBase.send(:include, Somatics::Generators::Helper)
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'generators/somatics'
|
2
|
+
require 'rails/generators/named_base'
|
3
|
+
require 'rails/generators/migration'
|
4
|
+
|
5
|
+
require 'net/http'
|
6
|
+
require 'uri'
|
7
|
+
require 'json'
|
8
|
+
class GoogleTranslate
|
9
|
+
def self.t(text,to_lang = 'zh-TW')
|
10
|
+
uri = URI.parse('http://ajax.googleapis.com/ajax/services/language/translate')
|
11
|
+
JSON.parse(Net::HTTP.post_form(uri, {"q" => text, "langpair" => "en|#{to_lang}", "v" => '1.0'}).body)['responseData']['translatedText'] rescue text.humanize
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
module Somatics
|
17
|
+
module Generators
|
18
|
+
class AssociatedGenerator < Rails::Generators::NamedBase
|
19
|
+
extend TemplatePath
|
20
|
+
include Rails::Generators::Migration
|
21
|
+
include Rails::Generators::ResourceHelpers
|
22
|
+
|
23
|
+
argument :associated_field, :type => :string, :banner => 'associated_field_name'
|
24
|
+
argument :attribute, :type => :hash, :default => {"name" => "string"}, :banner => "field:type"
|
25
|
+
# argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
26
|
+
class_option :namespace, :banner => "NAME", :type => :string, :default => 'admin'
|
27
|
+
class_option :skip_migration, :type => :boolean, :desc => "Don't generate a migration file for this model."
|
28
|
+
class_option :locales, :type => :array, :banner => "LOCALE LOCALE", :default => %w( en zh-TW ),
|
29
|
+
:desc => "Supported Locales"
|
30
|
+
|
31
|
+
|
32
|
+
def dump_generator_attribute_names
|
33
|
+
generator_attribute_names = [
|
34
|
+
:name,
|
35
|
+
:singular_name,
|
36
|
+
:human_name,
|
37
|
+
:plural_name,
|
38
|
+
:table_name,
|
39
|
+
:class_name,
|
40
|
+
:controller_class_path,
|
41
|
+
:controller_file_name,
|
42
|
+
:attribute_name,
|
43
|
+
:attribute_type,
|
44
|
+
:associated_name,
|
45
|
+
:associated_singular_name,
|
46
|
+
:associated_human_name,
|
47
|
+
:associated_plural_name,
|
48
|
+
:associated_table_name,
|
49
|
+
:associated_class_name,
|
50
|
+
]
|
51
|
+
|
52
|
+
generator_attribute_names.each do |attr|
|
53
|
+
# puts "%-40s %s" % ["#{attr}:", self.send(attr.to_s)] # instance_variable_get("@#{attr.to_s}"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate_associated_scaffold
|
59
|
+
invoke 'somatics:scaffold', [associated_class_name, "#{attribute_name}:#{attribute_type}"], {:namespace => options[:namespace], :header => false }
|
60
|
+
end
|
61
|
+
|
62
|
+
def update_menu
|
63
|
+
# add attributes type to submenu
|
64
|
+
# look_for = /<li ><%= link_to 'Product', '\/admin\/products', :class => (match_controller?('products')) \? 'selected' : ''%>.*<ul>/
|
65
|
+
look_for = /<%=.*\/#{options.namespace}\/#{plural_name}.*%>[^<]*<ul[^>]*>/
|
66
|
+
inject_into_file File.join('app/views/',options.namespace, 'shared/_menu.html.erb'), :after => look_for do
|
67
|
+
<<-RUBY
|
68
|
+
|
69
|
+
<li><%=link_to #{class_name}.human_attribute_name(:#{associated_name}), '/#{options.namespace}/#{associated_plural_name}' %></li>
|
70
|
+
RUBY
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def update_show_partial
|
76
|
+
look_for = "</tbody>\n</table>"
|
77
|
+
inject_into_file File.join('app/views/',options.namespace, controller_class_path, controller_file_name, '_show.html.erb'), :before => look_for do
|
78
|
+
" <tr>\n <td><b><%= #{class_name}.human_attribute_name(:#{associated_name}) %></b></td>\n <td><%=h #{singular_name}.#{associated_name}_#{attribute_name}%></td>\n </tr>\n"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def update_form_partial
|
83
|
+
look_for = "</tbody>\n</table>"
|
84
|
+
inject_into_file File.join('app/views/',options.namespace, controller_class_path, controller_file_name, '_form.html.erb'), :before => look_for do
|
85
|
+
" <tr>\n <td><b><%= #{class_name}.human_attribute_name(:#{associated_name}) %></b></td>\n <td><%= f.collection_select :#{associated_name}_id, #{associated_class_name}.all, :id, :#{attribute_name}, :prompt => true %></td>\n </tr>\n"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def update_list_partial
|
90
|
+
# look_for = " <!-- More Sort Link Helper -->"
|
91
|
+
# inject_into_file File.join('app/views/',options.namespace, controller_class_path, controller_file_name, '_list.html.erb'), :after => look_for do
|
92
|
+
# " <th title=\"Sort by "#{attribute.name.humanize}"\"><%= sort_link_helper #{class_name}.human_attribute_name(:#{attribute.name}), '#{singular_name}', '#{attribute.name}' %></th>\n"
|
93
|
+
# end
|
94
|
+
# look_for = " <!-- More Fields -->"
|
95
|
+
# inject_into_file File.join('app/views/',options.namespace, controller_class_path, controller_file_name, '_list.html.erb'), :after => look_for do
|
96
|
+
# " <td onclick=\"link_to(<%= \"'\#{admin_#{singular_name}_path(#{singular_name})}'\" %>);\" class=\"#{attribute.name}\"><%=h #{singular_name}.#{attribute.name} %></td>\n"
|
97
|
+
# end
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_attribute_to_locales
|
101
|
+
options[:locales].each do |locale|
|
102
|
+
append_file File.join('config/locales', "#{controller_file_name}_#{locale}.yml") do
|
103
|
+
" #{associated_name}: #{GoogleTranslate.t associated_human_name, locale}\n"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_association_to_model
|
109
|
+
inject_into_class "app/models/#{name}.rb", class_name do
|
110
|
+
<<-RUBY
|
111
|
+
belongs_to :#{associated_name}
|
112
|
+
def #{associated_name}_#{attribute_name}
|
113
|
+
self.#{associated_name}.#{attribute_name} unless self.#{associated_name}.blank?
|
114
|
+
end
|
115
|
+
|
116
|
+
def #{associated_name}_#{attribute_name}=(#{associated_name}_#{attribute_name})
|
117
|
+
self.#{associated_name} = #{associated_class_name}.find_by_#{attribute_name}(#{associated_name}_#{attribute_name}) || #{associated_class_name}.new(:#{attribute_name} => #{associated_name}_#{attribute_name})
|
118
|
+
end
|
119
|
+
RUBY
|
120
|
+
end
|
121
|
+
|
122
|
+
inject_into_class "app/models/#{associated_name}.rb", associated_class_name do
|
123
|
+
<<-RUBY
|
124
|
+
has_many :#{class_name}
|
125
|
+
RUBY
|
126
|
+
end rescue nil
|
127
|
+
end
|
128
|
+
|
129
|
+
def migrate_attributes
|
130
|
+
unless options[:skip_migration]
|
131
|
+
invoke "migration", [%(add_#{associated_singular_name}_to_#{table_name}), "#{associated_singular_name}_id:integer"]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
protected
|
136
|
+
|
137
|
+
#
|
138
|
+
# Implement the required interface for Rails::Generators::Migration.
|
139
|
+
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
140
|
+
#
|
141
|
+
def self.next_migration_number(dirname) #:nodoc:
|
142
|
+
if ActiveRecord::Base.timestamped_migrations
|
143
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
144
|
+
else
|
145
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
private
|
150
|
+
def attribute_name
|
151
|
+
attribute.keys.first
|
152
|
+
end
|
153
|
+
|
154
|
+
def attribute_type
|
155
|
+
attribute.values.first
|
156
|
+
end
|
157
|
+
|
158
|
+
def associated_name
|
159
|
+
name + '_' + associated_field
|
160
|
+
end
|
161
|
+
|
162
|
+
def associated_singular_name
|
163
|
+
associated_name.singularize
|
164
|
+
end
|
165
|
+
|
166
|
+
def associated_human_name
|
167
|
+
associated_name.humanize
|
168
|
+
end
|
169
|
+
|
170
|
+
def associated_plural_name
|
171
|
+
associated_name.pluralize
|
172
|
+
end
|
173
|
+
|
174
|
+
def associated_table_name
|
175
|
+
associated_name.tableize
|
176
|
+
end
|
177
|
+
|
178
|
+
def associated_class_name
|
179
|
+
associated_name.classify
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|