hobo 1.3.3 → 1.4.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGES.txt → CHANGES-1.3.txt} +0 -0
- data/CHANGES-1.4.txt +678 -0
- data/Rakefile +13 -3
- data/TODO-1.4.txt +69 -0
- data/VERSION +1 -1
- data/app/helpers/hobo_debug_helper.rb +16 -0
- data/app/helpers/hobo_deprecated_helper.rb +45 -0
- data/app/helpers/hobo_helper_base.rb +8 -0
- data/app/helpers/hobo_permissions_helper.rb +136 -0
- data/app/helpers/hobo_route_helper.rb +196 -0
- data/{lib/hobo/helper/translations.rb → app/helpers/hobo_translations_helper.rb} +4 -7
- data/{lib/hobo/helper/translations/normalizer.rb → app/helpers/hobo_translations_normalizer_helper.rb} +3 -10
- data/app/helpers/hobo_type_helper.rb +24 -0
- data/app/helpers/hobo_view_hint_helper.rb +13 -0
- data/hobo.gemspec +3 -3
- data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +0 -9
- data/lib/generators/hobo/admin_subsite/templates/application.dryml +2 -0
- data/lib/generators/hobo/admin_subsite/templates/gitkeep +0 -0
- data/lib/generators/hobo/admin_subsite/templates/site.css.erb +9 -0
- data/lib/generators/hobo/admin_subsite/templates/site.js.erb +10 -0
- data/lib/generators/hobo/assets/assets_generator.rb +16 -2
- data/lib/generators/hobo/assets/templates/application.css +9 -0
- data/lib/generators/hobo/assets/templates/application.dryml.erb +0 -5
- data/lib/generators/hobo/assets/templates/application.js +11 -0
- data/lib/generators/hobo/assets/templates/front.css +10 -0
- data/lib/generators/hobo/assets/templates/front.js +11 -0
- data/lib/generators/hobo/assets/templates/front_site.dryml.erb +6 -0
- data/lib/generators/hobo/assets/templates/gitkeep +0 -0
- data/lib/generators/hobo/dev_tweaks/dev_tweaks_generator.rb +31 -0
- data/lib/generators/hobo/i18n/templates/hobo.en.yml +1 -1
- data/lib/generators/hobo/install_plugin/USAGE +3 -0
- data/lib/generators/hobo/install_plugin/install_plugin_generator.rb +36 -0
- data/lib/generators/hobo/plugin.rb +112 -0
- data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +31 -14
- data/lib/generators/hobo/subsite.rb +16 -2
- data/lib/generators/hobo/subsite/templates/gitkeep +0 -0
- data/lib/generators/hobo/subsite/templates/site.css.erb +9 -0
- data/lib/generators/hobo/subsite/templates/site.js.erb +10 -0
- data/lib/generators/hobo/subsite_taglib/templates/taglib.dryml.erb +0 -17
- data/lib/generators/hobo/test_framework/test_framework_generator.rb +1 -1
- data/lib/hobo.rb +3 -2
- data/lib/hobo/controller.rb +43 -24
- data/lib/hobo/controller/model.rb +63 -42
- data/lib/hobo/controller/user_base.rb +1 -3
- data/lib/hobo/engine.rb +1 -1
- data/lib/hobo/extensions/active_record/associations/association.rb +36 -0
- data/lib/hobo/extensions/active_record/associations/collection.rb +10 -19
- data/lib/hobo/extensions/active_record/associations/proxy.rb +3 -15
- data/lib/hobo/extensions/active_record/associations/scope.rb +2 -2
- data/lib/hobo/extensions/active_record/permissions.rb +32 -38
- data/lib/hobo/extensions/active_record/relation_with_origin.rb +5 -5
- data/lib/hobo/model.rb +12 -7
- data/lib/hobo/model/accessible_associations.rb +8 -15
- data/lib/hobo/model/lifecycles/creator.rb +1 -1
- data/lib/hobo/model/lifecycles/transition.rb +1 -1
- data/lib/hobo/model/permissions.rb +4 -4
- data/lib/hobo/model/scopes.rb +4 -17
- data/lib/hobo/model/scopes/automatic_scopes.rb +5 -13
- data/lib/hobo/rapid/helper.rb +1 -161
- data/lib/hobo/rapid/taglibs/rapid.dryml +3 -17
- data/test/doctest/hobo/hobo_helper.rdoctest +8 -44
- data/{doctests → test/doctest}/hobo/lifecycles.rdoctest +0 -0
- data/{doctests → test/doctest}/hobo/model.rdoctest +2 -4
- data/{doctests → test/doctest}/hobo/multi_model_forms.rdoctest +3 -24
- data/{doctests → test/doctest}/hobo/scopes.rdoctest +3 -53
- data/test/doctest/prepare_testapp.rb +11 -0
- data/test/irt/generators/admin_subsite.irt +1 -19
- data/test/irt/generators/assets.irt +4 -9
- data/test/irt/generators/controller.irt +0 -3
- data/test/irt/generators/front_controller.irt +0 -5
- data/test/irt/generators/{helper.rb → irt_helper.rb} +2 -2
- data/test/irt/generators/model.irt +1 -12
- data/test/irt/generators/partials/_account_user_model_tests.rb +0 -8
- data/test/irt/generators/partials/_accounts_users_controller_tests.rb +0 -2
- data/test/irt/generators/partials/_default_user_model_tests.rb +0 -8
- data/test/irt/generators/partials/_default_users_controller_tests.rb +0 -2
- data/test/irt/generators/partials/_house_controller_tests.rb +0 -2
- data/test/irt/generators/partials/_house_model_tests.rb +1 -9
- data/test/irt/generators/partials/_subsite_taglib_admin.rb +5 -2
- data/test/irt/generators/partials/_subsite_taglib_admin_invite_only.rb +1 -1
- data/test/irt/generators/partials/_subsite_taglib_noopt.rb +2 -2
- data/test/irt/generators/partials/_subsite_taglib_variables.rb +0 -15
- data/test/irt/generators/partials/_user_mailer_tests.rb +1 -3
- data/test/irt/generators/resource.irt +0 -3
- data/test/irt/generators/subsite.irt +6 -22
- data/test/irt/generators/subsite_taglib.irt +0 -18
- data/test/irt/generators/test_framework.irt +2 -5
- data/test/irt/generators/user_controller.irt +0 -3
- data/test/irt/generators/user_mailer.irt +0 -3
- data/test/irt/generators/user_model.irt +0 -3
- data/test/irt/generators/user_resource.irt +0 -3
- data/test/irt/readme.txt +6 -3
- metadata +116 -159
- data/app/controllers/dev_controller.rb +0 -25
- data/app/views/dev/summary.dryml +0 -102
- data/doctests/prepare_testapp.rb +0 -8
- data/lib/generators/hobo/admin_subsite/templates/admin.css +0 -20
- data/lib/generators/hobo/rapid/USAGE +0 -3
- data/lib/generators/hobo/rapid/rapid_generator.rb +0 -24
- data/lib/generators/hobo/rapid/templates/IE7.js +0 -2
- data/lib/generators/hobo/rapid/templates/blank.gif +0 -0
- data/lib/generators/hobo/rapid/templates/hobo-rapid.css +0 -94
- data/lib/generators/hobo/rapid/templates/hobo-rapid.js +0 -1015
- data/lib/generators/hobo/rapid/templates/ie7-recalc.js +0 -166
- data/lib/generators/hobo/rapid/templates/lowpro.js +0 -339
- data/lib/generators/hobo/rapid/templates/reset.css +0 -95
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/101-3B5F87-ACD3E6.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/30-3E547A-242E42.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/30-DBE1E5-FCFEF5.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/300-ACD3E6-fff.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/50-ACD3E6-fff.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/fieldbg.gif +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/pencil.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/small_close.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/spinner.gif +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/clean.css +0 -327
- data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +0 -102
- data/lib/generators/hobo/rapid/templates/themes/clean/views/clean.dryml +0 -10
- data/lib/hobo/helper.rb +0 -460
- data/lib/hobo/rapid/taglibs/rapid_core.dryml +0 -808
- data/lib/hobo/rapid/taglibs/rapid_document_tags.dryml +0 -56
- data/lib/hobo/rapid/taglibs/rapid_editing.dryml +0 -287
- data/lib/hobo/rapid/taglibs/rapid_forms.dryml +0 -1156
- data/lib/hobo/rapid/taglibs/rapid_generics.dryml +0 -48
- data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +0 -173
- data/lib/hobo/rapid/taglibs/rapid_lifecycles.dryml +0 -96
- data/lib/hobo/rapid/taglibs/rapid_navigation.dryml +0 -108
- data/lib/hobo/rapid/taglibs/rapid_pages.dryml +0 -259
- data/lib/hobo/rapid/taglibs/rapid_plus.dryml +0 -247
- data/lib/hobo/rapid/taglibs/rapid_summary.dryml +0 -283
- data/lib/hobo/rapid/taglibs/rapid_support.dryml +0 -102
- data/lib/hobo/rapid/taglibs/rapid_user_pages.dryml +0 -182
- data/test/irt/generators/rapid.irt +0 -29
@@ -1,10 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
module Translations
|
5
|
-
module Normalizer
|
6
|
-
|
7
|
-
private
|
1
|
+
module HoboTranslationsNormalizerHelper
|
2
|
+
extend HoboHelperBase
|
3
|
+
private
|
8
4
|
|
9
5
|
def normalize_args(key, options={})
|
10
6
|
if (key.class == Hash) # called as a tag
|
@@ -33,7 +29,4 @@ module Hobo
|
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
32
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module HoboTypeHelper
|
2
|
+
extend HoboHelperBase
|
3
|
+
protected
|
4
|
+
def type_id(type=nil)
|
5
|
+
type ||= (this.is_a?(Class) && this) || this_type || this.class
|
6
|
+
HoboFields.to_name(type) || type.name.to_s.underscore.gsub("/", "__")
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def type_and_field(*args)
|
11
|
+
type, field = args.empty? ? [this_parent.class, this_field] : args
|
12
|
+
"#{type.typed_id}_#{field}" if type.respond_to?(:typed_id)
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def model_id_class(object=this, attribute=nil)
|
17
|
+
object.respond_to?(:typed_id) ? "model::#{typed_id(object, attribute).to_s.dasherize}" : ""
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def css_data(name, *args)
|
22
|
+
"#{name.to_s.dasherize}::#{args * '::'}"
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module HoboViewHintHelper
|
2
|
+
extend HoboHelperBase
|
3
|
+
protected
|
4
|
+
# --- ViewHint Helpers --- #
|
5
|
+
|
6
|
+
def this_field_name
|
7
|
+
this_parent.class.try.human_attribute_name(this_field) || this_field
|
8
|
+
end
|
9
|
+
|
10
|
+
def this_field_help
|
11
|
+
this_parent.class.try.attribute_help(this_field.to_sym) || ""
|
12
|
+
end
|
13
|
+
end
|
data/hobo.gemspec
CHANGED
@@ -14,11 +14,11 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.add_runtime_dependency('hobo_support', ["= #{version}"])
|
15
15
|
s.add_runtime_dependency('hobo_fields', ["= #{version}"])
|
16
16
|
s.add_runtime_dependency('dryml', ["= #{version}"])
|
17
|
-
s.add_runtime_dependency('will_paginate', ["
|
17
|
+
s.add_runtime_dependency('will_paginate', ["~> 3.0.0"])
|
18
18
|
|
19
|
-
s.add_development_dependency('rubydoctest', [">=
|
19
|
+
s.add_development_dependency('rubydoctest', [">= 1.1.3"])
|
20
20
|
s.add_development_dependency('shoulda', [">= 0"])
|
21
|
-
s.add_development_dependency('irt', [">=
|
21
|
+
s.add_development_dependency('irt', [">= 1.2.10"])
|
22
22
|
|
23
23
|
s.executables = ["hobo"]
|
24
24
|
s.files = `git ls-files -x #{name}/* -z`.split("\0")
|
@@ -12,10 +12,6 @@ module Hobo
|
|
12
12
|
"rails generate hobo:admin_subsite [NAME=admin] [options]"
|
13
13
|
end
|
14
14
|
|
15
|
-
def generate_admin_css
|
16
|
-
template "admin.css", File.join("public/stylesheets/#{file_name}.css")
|
17
|
-
end
|
18
|
-
|
19
15
|
def generate_admin_user_controller
|
20
16
|
invoke "hobo:controller", ["#{file_name}/#{options[:user_resource_name].pluralize.underscore}"], options
|
21
17
|
template "users_index.dryml", "app/views/#{file_name}/#{options[:user_resource_name].pluralize.underscore}/index.dryml"
|
@@ -25,11 +21,6 @@ module Hobo
|
|
25
21
|
invoke 'hobo:subsite_taglib', [name], options.merge(:admin => true)
|
26
22
|
end
|
27
23
|
|
28
|
-
def append_admin_tag_into_application_taglib
|
29
|
-
destination = File.join(Rails.root, "app/views/taglibs/application.dryml")
|
30
|
-
append_file(destination) { eval_template('admin_tag_injection.erb') }
|
31
|
-
end
|
32
|
-
|
33
24
|
include Generators::Hobo::Subsite
|
34
25
|
|
35
26
|
end
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
// This is a manifest file for the <%= name %> subsite. It will be
|
2
|
+
// compiled into including all the files listed below. Add new
|
3
|
+
// JavaScript/Coffee code in separate files in the <%= name %>
|
4
|
+
// directory and they'll automatically be included in the compiled
|
5
|
+
// file accessible from http://example.com/assets/<%= name %>.js It's
|
6
|
+
// not advisable to add code directly here, but if you do, it'll
|
7
|
+
// appear at the bottom of the the compiled file.
|
8
|
+
//
|
9
|
+
//= require application
|
10
|
+
//= require_tree ./<%= name %>
|
@@ -8,10 +8,24 @@ module Hobo
|
|
8
8
|
|
9
9
|
def copy_rapid_files
|
10
10
|
template 'application.dryml.erb', 'app/views/taglibs/application.dryml'
|
11
|
-
|
12
|
-
copy_file 'dryml-support.js', 'public/javascripts/dryml-support.js'
|
11
|
+
template 'front_site.dryml.erb', 'app/views/taglibs/front_site.dryml'
|
12
|
+
#copy_file 'dryml-support.js', 'public/javascripts/dryml-support.js'
|
13
13
|
copy_file 'dryml_taglibs_initializer.rb', 'config/initializers/dryml_taglibs.rb'
|
14
14
|
copy_file 'guest.rb', 'app/models/guest.rb'
|
15
|
+
|
16
|
+
FileUtils.mv 'app/assets/stylesheets/application.css', 'app/assets/stylesheets/application.css.orig'
|
17
|
+
copy_file 'application.css', 'app/assets/stylesheets/application.css'
|
18
|
+
copy_file 'gitkeep', 'app/assets/stylesheets/application/.gitkeep'
|
19
|
+
copy_file 'front.css', 'app/assets/stylesheets/front.css'
|
20
|
+
copy_file 'gitkeep', 'app/assets/stylesheets/front/.gitkeep'
|
21
|
+
|
22
|
+
FileUtils.mv 'app/assets/javascripts/application.js', 'app/assets/javascripts/application.js.orig'
|
23
|
+
copy_file 'application.js', 'app/assets/javascripts/application.js'
|
24
|
+
copy_file 'gitkeep', 'app/assets/javascripts/application/.gitkeep'
|
25
|
+
copy_file 'front.js', 'app/assets/javascripts/front.js'
|
26
|
+
copy_file 'gitkeep', 'app/assets/javascripts/front/.gitkeep'
|
27
|
+
|
28
|
+
application "config.assets.precompile += %w(front.css front.js)"
|
15
29
|
end
|
16
30
|
|
17
31
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/*
|
2
|
+
* This is the global stylesheet manifest file. Files or plugins
|
3
|
+
* referenced from here or placed in the application/ directory will be
|
4
|
+
* included in all subsites. This file is included by front.css and all
|
5
|
+
* subsites.
|
6
|
+
*
|
7
|
+
*= require_self
|
8
|
+
*= require_tree ./application
|
9
|
+
*/
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// This file is included in all sites and subsites. This is a
|
2
|
+
// manifest file that'll be compiled into including all the files
|
3
|
+
// listed below. Add new JavaScript/Coffee code in separate files in
|
4
|
+
// the application directory and they'll automatically be included.
|
5
|
+
// It's not advisable to add code directly here, but if you do, it'll
|
6
|
+
// appear at the bottom of the the compiled file.
|
7
|
+
//
|
8
|
+
//= require jquery
|
9
|
+
//= require jquery_ujs
|
10
|
+
//= require jquery-ui
|
11
|
+
//= require_tree ./application
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/*
|
2
|
+
* This is the stylesheet manifest file for the front subsite (which
|
3
|
+
* is your whole application if you don't have any subsites). Files
|
4
|
+
* or plugins referenced from here or placed in the front/ directory
|
5
|
+
* will be included.
|
6
|
+
*
|
7
|
+
*= require_self
|
8
|
+
*= require application
|
9
|
+
*= require_tree ./front
|
10
|
+
*/
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// This is a manifest file for the front subsite (which is your whole
|
2
|
+
// application if you don't have any subsites). It will be compiled
|
3
|
+
// into including all the files listed below. Add new
|
4
|
+
// JavaScript/Coffee code in separate files in the front directory and
|
5
|
+
// they'll automatically be included in the compiled file accessible
|
6
|
+
// from http://example.com/assets/front.js It's not advisable to add
|
7
|
+
// code directly here, but if you do, it'll appear at the bottom of
|
8
|
+
// the the compiled file.
|
9
|
+
//
|
10
|
+
//= require application
|
11
|
+
//= require_tree ./front
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'bundler/cli'
|
2
|
+
module Hobo
|
3
|
+
class DevTweaksGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
include Generators::Hobo::Plugin
|
6
|
+
|
7
|
+
desc "install the rails-dev-tweaks plugin & configure it"
|
8
|
+
def add_dev_tweaks
|
9
|
+
say "Adding rails-dev-tweaks gem"
|
10
|
+
gem_with_comments('rails-dev-tweaks', :version => "~> 0.6.1", :comments => "\n# The asset pipeline in Rails is really slow in development mode.\n# Hobo has a lot of assets, so speed it up with rails-dev-tweaks", :group => :development)
|
11
|
+
Bundler.with_clean_env do
|
12
|
+
run "bundle install"
|
13
|
+
end
|
14
|
+
|
15
|
+
# environment :env => :development action is broken
|
16
|
+
inject_into_file "config/environments/development.rb", :before => /end(?!.*end)/m do
|
17
|
+
"""
|
18
|
+
# By default, rails-dev-tweaks also applies to XHR, but that's not a great default for Hobo
|
19
|
+
config.dev_tweaks.autoload_rules do
|
20
|
+
keep :all
|
21
|
+
|
22
|
+
skip '/favicon.ico'
|
23
|
+
skip :assets
|
24
|
+
keep :xhr
|
25
|
+
keep :forced
|
26
|
+
end
|
27
|
+
"""
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -114,7 +114,7 @@ en:
|
|
114
114
|
update:
|
115
115
|
no_attribute_error: "No update specified in params"
|
116
116
|
success: "Changes to the %{model} were saved"
|
117
|
-
error: "There was a problem with that change
|
117
|
+
error: "There was a problem with that change.\\n%{errors}"
|
118
118
|
destroy:
|
119
119
|
success: "The %{model} was deleted"
|
120
120
|
signup:
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'bundler/cli'
|
2
|
+
module Hobo
|
3
|
+
class InstallPluginGenerator < Rails::Generators::NamedBase
|
4
|
+
|
5
|
+
include Generators::Hobo::Plugin
|
6
|
+
|
7
|
+
desc """This generator installs a hobo plugin.
|
8
|
+
|
9
|
+
The first argument is the name of the plugin, and the second is where
|
10
|
+
to get it. If the second argument is not supplied, it is installed
|
11
|
+
from rubygems.org or any other gem source listed in your Gemfile. If
|
12
|
+
the second argument contains a colon (:), it is assumed to be a git
|
13
|
+
URL. Otherwise it is considered to be a path.
|
14
|
+
|
15
|
+
If you are installing a Hobo theme, you probably want to use the options
|
16
|
+
`--subsite=front --css-top`.
|
17
|
+
"""
|
18
|
+
|
19
|
+
argument :name, :desc => "the plugin name"
|
20
|
+
argument :git_path, :required => false, :desc => "if supplied, is passed to the :git or :path option in the gemfile"
|
21
|
+
class_option :skip_gem, :type => :boolean, :aliases => '-M', :desc => "don't add plugin to Gemfile"
|
22
|
+
class_option :skip_js, :type => :boolean, :aliases => '-J', :desc => "don't add require to application.js"
|
23
|
+
class_option :skip_css, :type => :boolean, :aliases => '-C', :desc => "doesn't add require to application.css"
|
24
|
+
class_option :version, :type => :string, :aliases => '-v', :desc => "Gemspec version string"
|
25
|
+
class_option :comments, :type => :string, :desc => "comments to add before require/include"
|
26
|
+
class_option :subsite, :type => :string, :aliases => '-e', :default => "application", :desc => "Subsite name (without '_site') or 'all' or 'application'"
|
27
|
+
class_option :css_top, :type => :boolean, :desc => "add the require statement to the top of the CSS file rather tahn the bottom."
|
28
|
+
|
29
|
+
def install_plugin
|
30
|
+
if install_plugin_helper(name, git_path, options)
|
31
|
+
invoke(Bundler::CLI, :update, [], {})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module Generators
|
2
|
+
module Hobo
|
3
|
+
Plugin = classy_module do
|
4
|
+
|
5
|
+
protected
|
6
|
+
def gem_with_comments(*args)
|
7
|
+
options = args.extract_options!
|
8
|
+
name = args[0]
|
9
|
+
|
10
|
+
unless File.read("Gemfile") =~ /^gem ("|')#{name}/
|
11
|
+
if (comments = options.delete(:comments))
|
12
|
+
append_file "Gemfile", "#{comments}\n", :verbose => false
|
13
|
+
end
|
14
|
+
|
15
|
+
gem(args[0], args[1], options)
|
16
|
+
true
|
17
|
+
else
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def install_plugin_helper(name, git_path, options)
|
23
|
+
plugin = name.dup
|
24
|
+
unless options[:skip_gem]
|
25
|
+
gem_options = {}
|
26
|
+
if git_path
|
27
|
+
if git_path =~ /:/
|
28
|
+
gem_options[:git] = git_path
|
29
|
+
else
|
30
|
+
gem_options[:path] = git_path
|
31
|
+
end
|
32
|
+
end
|
33
|
+
gem_options[:comments] = "# #{options[:comments]}" if options[:comments]
|
34
|
+
need_update = gem_with_comments(plugin, gem_options[:version], gem_options)
|
35
|
+
end
|
36
|
+
|
37
|
+
if options[:subsite] == "all"
|
38
|
+
if Hobo.subsites.blank?
|
39
|
+
subsites = ['application']
|
40
|
+
else
|
41
|
+
subsites = ['front'] + Hobo.subsites
|
42
|
+
end
|
43
|
+
else
|
44
|
+
subsites = [options[:subsite] || 'application']
|
45
|
+
end
|
46
|
+
|
47
|
+
subsites.each do |subsite|
|
48
|
+
inject_js_require(name, subsite, options[:comments]) unless options[:skip_js]
|
49
|
+
inject_css_require(name, subsite, options[:comments], options[:css_top]) unless options[:skip_css]
|
50
|
+
inject_dryml_include(name, subsite, options[:comments])
|
51
|
+
end
|
52
|
+
|
53
|
+
return need_update
|
54
|
+
end
|
55
|
+
|
56
|
+
def inject_js_require(name, subsite, comments)
|
57
|
+
application_file = "app/assets/javascripts/#{subsite}.js"
|
58
|
+
pattern = /\/\/=(?!.*\/\/=).*?$/m
|
59
|
+
|
60
|
+
unless exists?(application_file)
|
61
|
+
application_file = "#{application_file}.coffee"
|
62
|
+
pattern = /#=(?!.*#=).*?$/m
|
63
|
+
end
|
64
|
+
|
65
|
+
raise Thor::Error, "Couldn't find either #{subsite}.js or #{subsite}.js.coffee files!" unless exists?(application_file)
|
66
|
+
|
67
|
+
inject_into_file application_file, :before=>pattern do
|
68
|
+
line = "//= require #{name}\n"
|
69
|
+
line = "//\n// #{comments}\n#{line}" if comments
|
70
|
+
line
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def inject_css_require(name, subsite, comments, css_top)
|
75
|
+
application_file = "app/assets/stylesheets/#{subsite}.css"
|
76
|
+
if css_top
|
77
|
+
opts = {:after => /^\/\*.*?\*=.*?\n /m}
|
78
|
+
else
|
79
|
+
opts = {:before => /\*=(?!.*\*=).*?$/m}
|
80
|
+
end
|
81
|
+
|
82
|
+
raise Thor::Error, "Couldn't find #{subsite}.css!" unless exists?(application_file)
|
83
|
+
|
84
|
+
inject_into_file application_file, opts do
|
85
|
+
line = "*= require #{name}\n "
|
86
|
+
line = "*\n * #{comments}\n #{line}" if comments
|
87
|
+
line
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def inject_dryml_include(name, subsite, comments)
|
92
|
+
subsite = "#{subsite}_site" unless subsite=="application"
|
93
|
+
application_file = "app/views/taglibs/#{subsite}.dryml"
|
94
|
+
pattern = /\<include.*?\>(?!.*\<include.*?\>).*?\n/m
|
95
|
+
|
96
|
+
raise Thor::Error, "Couldn't find #{subsite}.dryml!" unless exists?(application_file)
|
97
|
+
|
98
|
+
inject_into_file application_file, :after=>pattern do
|
99
|
+
line = "\n<include gem='#{name}'/>\n"
|
100
|
+
line = "\n<%# #{comments} %>#{line}" if comments
|
101
|
+
line
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
def exists?(file)
|
107
|
+
File.exist?(File.join(destination_root, file))
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|