phoenix_core 0.2.0.beta

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.
Files changed (76) hide show
  1. data/README.md +3 -0
  2. data/app/assets/images/favicon.ico +0 -0
  3. data/app/assets/images/noise.png +0 -0
  4. data/app/assets/javascripts/application.js +14 -0
  5. data/app/assets/stylesheets/application.css +8 -0
  6. data/app/assets/stylesheets/bootstrap.css +2467 -0
  7. data/app/assets/stylesheets/global.css +24 -0
  8. data/app/assets/stylesheets/landing.css +1 -0
  9. data/app/controllers/phoenix/base_controller.rb +5 -0
  10. data/app/controllers/phoenix/home_controller.rb +13 -0
  11. data/app/helpers/phoenix/base_helper.rb +4 -0
  12. data/app/mailers/phoenix/base_mailer.rb +10 -0
  13. data/app/models/phoenix/user.rb +8 -0
  14. data/app/views/phoenix/home/index.html.haml +13 -0
  15. data/app/views/phoenix/layouts/phoenix_core/application.html.erb +14 -0
  16. data/config/initializers/phoenix.rb +3 -0
  17. data/config/initializers/setup_mail.rb +19 -0
  18. data/config/initializers/simple_form.rb +93 -0
  19. data/config/locals/phoenix/en.yml +2 -0
  20. data/config/locals/simple_form/en.yml +23 -0
  21. data/config/locals/simple_form/zn-CN.yml +23 -0
  22. data/config/routes.rb +3 -0
  23. data/lib/generators/phoenix/app/app_generator.rb +209 -0
  24. data/lib/generators/phoenix/dummy/dummy_generator.rb +86 -0
  25. data/lib/generators/phoenix/dummy/templates/rails/Rakefile +7 -0
  26. data/lib/generators/phoenix/dummy/templates/rails/application.rb +14 -0
  27. data/lib/generators/phoenix/dummy/templates/rails/boot.rb +6 -0
  28. data/lib/generators/phoenix/dummy/templates/rails/mongoid.yml +0 -0
  29. data/lib/generators/phoenix/dummy/templates/rails/routes.rb +3 -0
  30. data/lib/generators/phoenix/extension/clash_keywords.yml +3 -0
  31. data/lib/generators/phoenix/extension/extension_generator.rb +137 -0
  32. data/lib/generators/phoenix/extension/templates/Gemfile +13 -0
  33. data/lib/generators/phoenix/extension/templates/README.md +21 -0
  34. data/lib/generators/phoenix/extension/templates/app/assets/javascripts/application.js +1 -0
  35. data/lib/generators/phoenix/extension/templates/app/assets/stylesheets/application.css +3 -0
  36. data/lib/generators/phoenix/extension/templates/app/controllers/phoenix/admin/plural_name_controller.rb +12 -0
  37. data/lib/generators/phoenix/extension/templates/app/controllers/phoenix/plural_name_controller.rb +32 -0
  38. data/lib/generators/phoenix/extension/templates/app/models/phoenix/plural_name/singular_name.rb +27 -0
  39. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_actions.html.erb +28 -0
  40. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_form.html.erb +68 -0
  41. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_plural_name.html.erb +2 -0
  42. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_records.html.erb +18 -0
  43. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_singular_name.html.erb +18 -0
  44. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/_sortable_list.html.erb +7 -0
  45. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/edit.html.erb +1 -0
  46. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/index.html.erb +10 -0
  47. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/admin/plural_name/new.html.erb +1 -0
  48. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/plural_name/index.html.erb +11 -0
  49. data/lib/generators/phoenix/extension/templates/app/views/phoenix/plural_name/plural_name/show.html.erb +35 -0
  50. data/lib/generators/phoenix/extension/templates/config/locales/en.yml +5 -0
  51. data/lib/generators/phoenix/extension/templates/config/routes.rb +3 -0
  52. data/lib/generators/phoenix/extension/templates/extension.gemspec +28 -0
  53. data/lib/generators/phoenix/extension/templates/gitignore +10 -0
  54. data/lib/generators/phoenix/extension/templates/lib/generators/phoenix/plural_name_generator.rb +11 -0
  55. data/lib/generators/phoenix/extension/templates/lib/phoenix/plural_name.rb +25 -0
  56. data/lib/generators/phoenix/extension/templates/lib/phoenix/plural_name/engine.rb +29 -0
  57. data/lib/generators/phoenix/extension/templates/lib/phoenix_plural_name.rb +1 -0
  58. data/lib/generators/phoenix/extension/templates/lib/tasks/plural_name.rake +13 -0
  59. data/lib/generators/phoenix/extension/templates/phoenix_plural_name.gemspec +18 -0
  60. data/lib/generators/phoenix/extension/templates/spec/models/phoenix/singular_name_spec.rb +18 -0
  61. data/lib/generators/phoenix/extension/templates/spec/requests/phoenix/admin/plural_name_spec.rb +97 -0
  62. data/lib/generators/phoenix/extension/templates/spec/support/phoenix/factories.rb +7 -0
  63. data/lib/middleware/seo_assist.rb +0 -0
  64. data/lib/phoenix/core.rb +40 -0
  65. data/lib/phoenix/core/controller_helpers.rb +47 -0
  66. data/lib/phoenix/core/development_mail_interceptor.rb +10 -0
  67. data/lib/phoenix/core/engine.rb +10 -0
  68. data/lib/phoenix/core/ssl_requirement.rb +105 -0
  69. data/lib/phoenix/core/testing_support/common_rake.rb +25 -0
  70. data/lib/phoenix/core/testing_support/env.rb +2 -0
  71. data/lib/phoenix/engine.rb +65 -0
  72. data/lib/phoenix/version.rb +16 -0
  73. data/lib/phoenix_core.rb +3 -0
  74. data/lib/tasks/assets.rake +16 -0
  75. data/lib/tasks/phoenix.rake +2 -0
  76. metadata +252 -0
@@ -0,0 +1,2 @@
1
+ <%%= will_paginate @<%= plural_name %> %>
2
+ <%%= render :partial => "sortable_list" %>
@@ -0,0 +1,18 @@
1
+ <%% if searching? %>
2
+ <h2><%%= t('results_for', :scope => 'refinery.admin.search', :query => params[:search]) %></h2>
3
+ <%% end %>
4
+ <%% if @<%= plural_name %>.any? %>
5
+ <div class='pagination_container'>
6
+ <%%= render :partial => '<%= plural_name %>' %>
7
+ </div>
8
+ <%% else %>
9
+ <p>
10
+ <%% unless searching? %>
11
+ <strong>
12
+ <%%= t('.no_items_yet') %>
13
+ </strong>
14
+ <%% else %>
15
+ <%%= t('no_results', :scope => 'refinery.admin.search') %>
16
+ <%% end %>
17
+ </p>
18
+ <%% end %>
@@ -0,0 +1,18 @@
1
+ <li class='clearfix record <%%= cycle("on", "on-hover") %>' id="<%%= dom_id(<%= singular_name %>) -%>">
2
+ <span class='title'>
3
+ <%%= <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? -%>.<%= title.name %><% else %>.title<%end %> %>
4
+ <span class="preview">&nbsp;</span>
5
+ </span>
6
+ <span class='actions'>
7
+ <%%= link_to refinery_icon_tag("application_go.png"), main_app.refinery_<%= singular_name %>_path(<%= singular_name %>),
8
+ :title => t('.view_live_html'),
9
+ :target => "_blank" %>
10
+ <%%= link_to refinery_icon_tag("application_edit.png"), main_app.edit_refinery_admin_<%= singular_name %>_path(<%= singular_name %>),
11
+ :title => t('.edit') %>
12
+ <%%= link_to refinery_icon_tag("delete.png"), main_app.refinery_admin_<%= singular_name %>_path(<%= singular_name %>),
13
+ :class => "cancel confirm-delete",
14
+ :title => t('.delete'),
15
+ :confirm => t('message', :scope => 'refinery.admin.delete', :title => <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>.<%= title.name %><% else %>.title<% end %>),
16
+ :method => :delete %>
17
+ </span>
18
+ </li>
@@ -0,0 +1,7 @@
1
+ <ul id='sortable_list'>
2
+ <%%= render :partial => '<%= singular_name %>', :collection => @<%= plural_name %> %>
3
+ </ul>
4
+ <%%= render :partial => "/refinery/admin/sortable_list",
5
+ :locals => {
6
+ :continue_reordering => (local_assigns.keys.include?(:continue_reordering)) ? continue_reordering : true
7
+ } %>
@@ -0,0 +1,10 @@
1
+ <section id='records'>
2
+ <%%= render :partial => 'records' %>
3
+ </section>
4
+ <aside id='actions'>
5
+ <%%= render :partial => 'actions' %>
6
+ </aside>
7
+ <%%= render :partial => '/refinery/admin/make_sortable',
8
+ :locals => {
9
+ :tree => false
10
+ } if !searching? and ::Phoenix::Admin::<%= class_name.pluralize %>Controller.sortable? and ::Phoenix::<%= class_name.pluralize %>::<%= class_name %>.count > 1 %>
@@ -0,0 +1,11 @@
1
+ <%% content_for :body_content_left do %>
2
+ <ul id="<%= plural_name %>">
3
+ <%% @<%= "all_" if plural_name == singular_name%><%= plural_name %>.each do |<%= singular_name %>| %>
4
+ <li>
5
+ <%%= link_to <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>.<%= title.name %><% end %>, main_app.refinery_<%= singular_name %>_path(<%= singular_name %>) %>
6
+ </li>
7
+ <%% end %>
8
+ </ul>
9
+ <%% end %>
10
+
11
+ <%%= render :partial => "/refinery/content_page" %>
@@ -0,0 +1,35 @@
1
+ <%% content_for :body_content_title do %>
2
+ <%%= @<%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>.<%= title.name %><% else %>.title<% end %> %>
3
+ <%% end %>
4
+
5
+ <%% content_for :body_content_left do %>
6
+ <% attributes.each do |attribute| -%>
7
+ <section>
8
+ <h1><%= attribute.name.titleize %></h1>
9
+ <p>
10
+ <% if attribute.type.to_s == 'image' -%>
11
+ <%%= image_fu @<%= singular_name %>.<%= attribute.name %>, nil %>
12
+ <% elsif attribute.type.to_s == 'resource' -%>
13
+ <%%= link_to <%= "'#{attribute.name}'" %>, @<%= singular_name %>.<%= attribute.name %>.url %>
14
+ <% else -%>
15
+ <%%=raw @<%= singular_name %>.<%= attribute.name %> %>
16
+ <% end -%>
17
+ </p>
18
+ </section>
19
+ <% end -%>
20
+ <%% end %>
21
+
22
+ <%% content_for :body_content_right do %>
23
+ <aside>
24
+ <h2><%%= t('.other') %></h2>
25
+ <ul id="<%= plural_name %>">
26
+ <%% @<%= "all_" if plural_name == singular_name%><%= plural_name %>.each do |<%= singular_name %>| %>
27
+ <li>
28
+ <%%= link_to <%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>.<%= title.name %><% else %>.title<% end %>, main_app.refinery_<%= singular_name %>_path(<%= singular_name %>) %>
29
+ </li>
30
+ <%% end %>
31
+ </ul>
32
+ </aside>
33
+ <%% end %>
34
+
35
+ <%%= render :partial => "/refinery/content_page" %>
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ <%= class_name %>::Engine.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.platform = Gem::Platform::RUBY
5
+ s.required_ruby_version = '>= 1.9.2'
6
+
7
+ s.name = '<%= file_name %>'
8
+ s.version = '<%= Phoenix.version %>'
9
+ s.summary = 'TODO: Add gem summary here'
10
+ s.description = 'TODO: Add (optional) gem description here'
11
+
12
+ s.author = 'Lanvige Jiang'
13
+ s.email = 'lanvige@gmail.com'
14
+ s.homepage = 'http://lanvige.com'
15
+
16
+ #s.files = `git ls-files`.split("\n")
17
+ #s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+
19
+ s.require_path = 'lib'
20
+ s.requirements << 'none'
21
+
22
+ s.add_dependency 'phoenix_core'
23
+
24
+ s.add_development_dependency 'capybara', '1.0.1'
25
+ s.add_development_dependency 'factory_girl'
26
+ s.add_development_dependency 'ffaker'
27
+ s.add_development_dependency 'rspec-rails', '~> 2.7'
28
+ end
@@ -0,0 +1,10 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ tmp
8
+ nbproject
9
+ *.swp
10
+ spec/dummy
@@ -0,0 +1,11 @@
1
+ module Phoenix
2
+ class <%= class_name.pluralize %>Generator < Rails::Generators::Base
3
+
4
+ source_root File.expand_path('../../../../', __FILE__)
5
+
6
+ def rake_db
7
+ rake("refinery_<%= plural_name %>:install:migrations")
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ require 'refinerycms-core'
2
+
3
+ module Phoenix
4
+ autoload :<%= class_name.pluralize %>Generator, 'generators/refinery/<%= plural_name %>_generator'
5
+
6
+ module <%= class_name.pluralize %><%= 'Engine' if plural_name == singular_name %>
7
+ require 'refinery/<%= plural_name %>/engine' if defined?(Rails)
8
+
9
+ class << self
10
+ def table_name_prefix
11
+ 'refinery_'
12
+ end
13
+
14
+ attr_writer :root
15
+
16
+ def root
17
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
18
+ end
19
+
20
+ def factory_paths
21
+ @factory_paths ||= [ root.join("spec/factories").to_s ]
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ require 'refinerycms-<%= plural_name %>'
2
+
3
+ module Phoenix
4
+ module <%= class_name.pluralize %>
5
+ class Engine < Rails::Engine
6
+ include Phoenix::Engine
7
+ isolate_namespace Phoenix
8
+ engine_name :refinery_<%= plural_name %>
9
+
10
+ initializer "register refinerycms_<%= plural_name %> plugin" do |app|
11
+ Phoenix::Plugin.register do |plugin|
12
+ plugin.name = "<%= class_name.pluralize.underscore.downcase %>"
13
+ plugin.url = {:controller => '/refinery/<%= plural_name %>'}
14
+ plugin.pathname = root
15
+ plugin.name = '<%= class_name.pluralize.underscore.downcase %>'
16
+ plugin.url = '/refinery/<%= plural_name %>'
17
+
18
+ plugin.activity = {
19
+ :class_name => :'refinery/<%= singular_name %>'
20
+ }
21
+ end
22
+ end
23
+
24
+ config.after_initialize do
25
+ Phoenix.register_engine(Phoenix::<%= class_name.pluralize %>)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1 @@
1
+ require 'refinery/<%= plural_name %>'
@@ -0,0 +1,13 @@
1
+ namespace :phoenix do
2
+
3
+ namespace :<%= plural_name %> do
4
+
5
+ # call this task by running: rake phoenix:<%= plural_name %>:my_task
6
+ # desc "Description of my task below"
7
+ # task :my_task => :environment do
8
+ # # add your logic here
9
+ # end
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,18 @@
1
+ # Encoding: UTF-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.platform = Gem::Platform::RUBY
5
+ s.name = 'phoenix_<%= plural_name %>'
6
+ s.version = '1.0'
7
+ s.description = 'Ruby on Rails <%= plural_name.titleize %> engine for Phoenix CMS'
8
+ s.date = '<%= Time.now.strftime('%Y-%m-%d') %>'
9
+ s.summary = '<%= plural_name.titleize %> engine for Phoenix CMS'
10
+ s.require_paths = %w(lib)
11
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["readme.md"]
12
+
13
+ # Runtime dependencies
14
+ s.add_dependency 'phoenix_core', '~> <%= Phoenix::Version %>'
15
+
16
+ # Development dependencies (usually used for testing)
17
+ s.add_development_dependency 'phoenix_testing', '~> <%= Phoenix::Version %>'
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module Phoenix
4
+ describe <%= class_name %> do
5
+ describe "validations" do
6
+ subject do
7
+ FactoryGirl.create(:<%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? -%>,
8
+ :<%= title.name %> => "Phoenix CMS"<% end %>)
9
+ end
10
+
11
+ it { should be_valid }
12
+ its(:errors) { should be_empty }
13
+ <% if title -%>
14
+ its(:<%= title.name %>) { should == "Phoenix CMS" }
15
+ <% end -%>
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,97 @@
1
+ require "spec_helper"
2
+
3
+ describe Phoenix do
4
+ describe "Admin" do
5
+ describe "<%= plural_name %>" do
6
+ login_refinery_user
7
+ <% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>
8
+ describe "<%= plural_name %> list" do
9
+ before(:each) do
10
+ FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne")
11
+ FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleTwo")
12
+ end
13
+
14
+ it "shows two items" do
15
+ visit refinery_admin_<%= plural_name %>_path
16
+ page.should have_content("UniqueTitleOne")
17
+ page.should have_content("UniqueTitleTwo")
18
+ end
19
+ end
20
+
21
+ describe "create" do
22
+ before(:each) do
23
+ visit refinery_admin_<%= plural_name %>_path
24
+
25
+ click_link "Add New <%= singular_name.titleize %>"
26
+ end
27
+
28
+ context "valid data" do
29
+ it "should succeed" do
30
+ fill_in "<%= title.name.titleize %>", :with => "This is a test of the first string field"
31
+ click_button "Save"
32
+
33
+ page.should have_content("'This is a test of the first string field' was successfully added.")
34
+ Phoenix::<%= class_name.pluralize %>::<%= class_name %>.count.should == 1
35
+ end
36
+ end
37
+
38
+ context "invalid data" do
39
+ it "should fail" do
40
+ click_button "Save"
41
+
42
+ page.should have_content("<%= title.name.titleize %> can't be blank")
43
+ Phoenix::<%= class_name.pluralize %>::<%= class_name %>.count.should == 0
44
+ end
45
+ end
46
+
47
+ context "duplicate" do
48
+ before(:each) { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitle") }
49
+
50
+ it "should fail" do
51
+ visit refinery_admin_<%= plural_name %>_path
52
+
53
+ click_link "Add New <%= singular_name.titleize %>"
54
+
55
+ fill_in "<%= title.name.titleize %>", :with => "UniqueTitle"
56
+ click_button "Save"
57
+
58
+ page.should have_content("There were problems")
59
+ Phoenix::<%= class_name.pluralize %>::<%= class_name %>.count.should == 1
60
+ end
61
+ end
62
+ end
63
+
64
+ describe "edit" do
65
+ before(:each) { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "A <%= title.name %>") }
66
+
67
+ it "should succeed" do
68
+ visit refinery_admin_<%= plural_name %>_path
69
+
70
+ within ".actions" do
71
+ click_link "Edit this <%= singular_name.titleize.downcase %>"
72
+ end
73
+
74
+ fill_in "<%= title.name.titleize %>", :with => "A different <%= title.name %>"
75
+ click_button "Save"
76
+
77
+ page.should have_content("'A different <%= title.name %>' was successfully updated.")
78
+ page.should have_no_content("A <%= title.name %>")
79
+ end
80
+ end
81
+
82
+ describe "destroy" do
83
+ before(:each) { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne") }
84
+
85
+ it "should succeed" do
86
+ visit refinery_admin_<%= plural_name %>_path
87
+
88
+ click_link "Remove this <%= singular_name.titleize.downcase %> forever"
89
+
90
+ page.should have_content("'UniqueTitleOne' was successfully removed.")
91
+ Phoenix::<%= class_name.pluralize %>::<%= class_name %>.count.should == 0
92
+ end
93
+ end
94
+ <% end %>
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,7 @@
1
+ <% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %>
2
+ FactoryGirl.define do
3
+ factory :<%= singular_name %>, :class => Phoenix::<%= class_name.pluralize %>::<%= class_name %> do
4
+ sequence(:<%= title.name %>) { |n| "phoenix#{n}" }
5
+ end
6
+ end
7
+ <% end %>
File without changes
@@ -0,0 +1,40 @@
1
+ require "action_controller/railtie"
2
+ require "active_resource/railtie"
3
+ require "active_support/railtie"
4
+ require 'rails/generators'
5
+
6
+ require 'rbconfig'
7
+
8
+ require 'haml'
9
+ require 'jquery-rails'
10
+ require 'simple_form'
11
+
12
+ module Phoenix
13
+
14
+ # Different between require and autoload.
15
+ # Require will be specified after the autoload.
16
+ autoload :Engine, 'phoenix/engine'
17
+ autoload :Version, 'phoenix/version'
18
+
19
+ autoload :DummyGenerator, 'generators/phoenix/dummy/dummy_generator'
20
+ autoload :ExtensionGenerator, 'generators/phoenix/extension/extension_generator'
21
+
22
+ require 'generators/phoenix/dummy/dummy_generator'
23
+ require 'generators/phoenix/extension/extension_generator'
24
+
25
+ module Core
26
+ require 'phoenix/core/engine' if defined?(Rails)
27
+
28
+ require 'phoenix/core/controller_helpers'
29
+ require 'phoenix/core/ssl_requirement'
30
+ require 'phoenix/core/development_mail_interceptor'
31
+
32
+ class << self
33
+ def root
34
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+