transit 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +19 -11
- data/app/assets/images/transit/icon24x24.png +0 -0
- data/app/assets/images/transit/icon24x24_files.png +0 -0
- data/app/assets/images/transit/jplayer.swf +0 -0
- data/app/assets/images/transit/uploadify.swf +0 -0
- data/app/assets/images/transit/video_player.swf +0 -0
- data/app/assets/javascripts/jqtools/expose.js +224 -0
- data/app/assets/javascripts/jqtools/flashembed.js +300 -0
- data/app/assets/javascripts/jqtools/overlay.js +294 -0
- data/app/assets/javascripts/jqtools/scrollable.js +3 -0
- data/app/assets/javascripts/jqtools/scrollable/autoscroll.js +81 -0
- data/app/assets/javascripts/jqtools/scrollable/base.js +335 -0
- data/app/assets/javascripts/jqtools/scrollable/navigator.js +139 -0
- data/app/assets/javascripts/jqtools/validator.js +590 -0
- data/app/assets/javascripts/jqueryui/accordion.js +611 -0
- data/app/assets/javascripts/jqueryui/autocomplete.js +612 -0
- data/app/assets/javascripts/jqueryui/button.js +388 -0
- data/app/assets/javascripts/jqueryui/core.js +312 -0
- data/app/assets/javascripts/jqueryui/datepicker.js +1791 -0
- data/app/assets/javascripts/jqueryui/dialog.js +878 -0
- data/app/assets/javascripts/jqueryui/draggable.js +815 -0
- data/app/assets/javascripts/jqueryui/droppable.js +285 -0
- data/app/assets/javascripts/jqueryui/effects/blind.js +49 -0
- data/app/assets/javascripts/jqueryui/effects/bounce.js +78 -0
- data/app/assets/javascripts/jqueryui/effects/clip.js +54 -0
- data/app/assets/javascripts/jqueryui/effects/core.js +746 -0
- data/app/assets/javascripts/jqueryui/effects/drop.js +50 -0
- data/app/assets/javascripts/jqueryui/effects/explode.js +79 -0
- data/app/assets/javascripts/jqueryui/effects/fade.js +32 -0
- data/app/assets/javascripts/jqueryui/effects/fold.js +56 -0
- data/app/assets/javascripts/jqueryui/effects/highlight.js +50 -0
- data/app/assets/javascripts/jqueryui/effects/pulsate.js +51 -0
- data/app/assets/javascripts/jqueryui/effects/scale.js +178 -0
- data/app/assets/javascripts/jqueryui/effects/shake.js +57 -0
- data/app/assets/javascripts/jqueryui/effects/slide.js +50 -0
- data/app/assets/javascripts/jqueryui/effects/transfer.js +45 -0
- data/app/assets/javascripts/jqueryui/mouse.js +160 -0
- data/app/assets/javascripts/jqueryui/position.js +252 -0
- data/app/assets/javascripts/jqueryui/progressbar.js +109 -0
- data/app/assets/javascripts/jqueryui/resizable.js +814 -0
- data/app/assets/javascripts/jqueryui/selectable.js +266 -0
- data/app/assets/javascripts/jqueryui/slider.js +666 -0
- data/app/assets/javascripts/jqueryui/sortable.js +1077 -0
- data/app/assets/javascripts/jqueryui/tabs.js +758 -0
- data/app/assets/javascripts/jqueryui/widget.js +262 -0
- data/app/assets/javascripts/libs/backbone.js +1152 -0
- data/app/assets/javascripts/libs/cookie.js +89 -0
- data/app/assets/javascripts/libs/fileinput.js +130 -0
- data/app/assets/javascripts/libs/jplayer.js +1768 -0
- data/app/assets/javascripts/libs/proper.js +541 -0
- data/app/assets/javascripts/libs/sanitize.js +282 -0
- data/app/assets/javascripts/libs/selecttolist.js +75 -0
- data/app/assets/javascripts/libs/underscore.js +807 -0
- data/app/assets/javascripts/libs/uploadify.js +677 -0
- data/app/assets/javascripts/libs/wymeditor.js +9538 -0
- data/app/assets/javascripts/transit.js +4 -0
- data/app/assets/javascripts/transit/admin.js +22 -0
- data/app/assets/javascripts/transit/admin/contexts.js +52 -0
- data/app/assets/javascripts/transit/admin/fields.js +36 -0
- data/app/assets/javascripts/transit/admin/upload.js +109 -0
- data/app/assets/javascripts/transit/config.js.erb +101 -0
- data/app/assets/javascripts/transit/contexts/audio.js +39 -0
- data/app/assets/javascripts/transit/contexts/video.js +79 -0
- data/app/assets/javascripts/transit/core.js +171 -0
- data/app/assets/javascripts/transit/frontend.js +3 -0
- data/app/assets/javascripts/transit/lib/base64.js +120 -0
- data/app/assets/javascripts/transit/lib/editor.js +177 -0
- data/app/assets/javascripts/transit/views/audio_player.jst +22 -0
- data/app/assets/javascripts/transit/views/editor_toolbar.jst +12 -0
- data/app/assets/javascripts/transit/views/file_upload.jst +5 -0
- data/app/assets/javascripts/transit/views/video_player.jst +20 -0
- data/app/assets/javascripts/transit/views/wym_box.jst +4 -0
- data/app/assets/javascripts/transit/views/wym_iframe.jst +3 -0
- data/app/assets/stylesheets/transit.css.scss.erb +42 -0
- data/app/assets/stylesheets/transit/forms.css.scss +66 -0
- data/app/assets/stylesheets/transit/media/audio.css.scss +65 -0
- data/app/assets/stylesheets/transit/media/video.css.scss +30 -0
- data/app/assets/stylesheets/transit/panel.css.scss +100 -0
- data/app/assets/stylesheets/transit/ui.css.scss +507 -0
- data/app/controllers/pages_controller.rb +3 -0
- data/app/controllers/posts_controller.rb +3 -0
- data/app/controllers/transit/assets_controller.rb +38 -0
- data/app/controllers/transit/contexts_controller.rb +12 -9
- data/app/controllers/transit/pages_controller.rb +26 -0
- data/app/controllers/transit/posts_controller.rb +31 -0
- data/app/controllers/transit/topics_controller.rb +5 -0
- data/app/controllers/transit_controller.rb +16 -0
- data/app/helpers/transit/admin_helper.rb +43 -0
- data/app/helpers/transit/form_helper.rb +17 -0
- data/app/helpers/transit/package_helper.rb +41 -0
- data/app/helpers/transit/pagination_helper.rb +58 -0
- data/app/helpers/transit_helper.rb +42 -0
- data/app/models/comment.rb +37 -0
- data/app/models/contexts/audio.rb +12 -0
- data/app/models/{text.rb → contexts/text.rb} +0 -0
- data/app/models/contexts/video.rb +24 -0
- data/app/models/topic.rb +19 -0
- data/app/models/transit/asset.rb +68 -0
- data/{lib → app/models}/transit/context.rb +29 -0
- data/app/views/contexts/_text.html.erb +1 -1
- data/app/views/posts/index.rss.builder +18 -0
- data/app/views/transit/assets/_file.html.erb +4 -0
- data/app/views/transit/assets/_image.html.erb +13 -0
- data/app/views/transit/assets/create.js.erb +8 -0
- data/app/views/transit/assets/destroy.js.erb +3 -0
- data/app/views/transit/assets/manage.html.erb +20 -0
- data/app/views/transit/contexts/_audio.html.erb +18 -0
- data/app/views/transit/contexts/_text.html.erb +6 -0
- data/app/views/transit/contexts/_video.html.erb +13 -0
- data/app/views/transit/contexts/destroy.js.erb +1 -0
- data/app/views/transit/contexts/index.html.erb +5 -0
- data/app/views/transit/contexts/new.js.erb +7 -0
- data/app/views/transit/contexts/show.html.erb +8 -0
- data/app/views/transit/index.html.erb +26 -0
- data/app/views/transit/index.js.erb +1 -0
- data/app/views/transit/interface/post_panel.html.erb +96 -0
- data/app/views/transit/pages/_table.html.erb +7 -0
- data/app/views/transit/pages/edit.html.erb +17 -0
- data/app/views/transit/pages/index.html.erb +17 -0
- data/app/views/transit/pages/update.js.erb +1 -0
- data/app/views/transit/posts/_form.html.erb +49 -0
- data/app/views/transit/posts/edit.html.erb +14 -0
- data/app/views/transit/posts/new.html.erb +21 -0
- data/app/views/transit/table.html.erb +13 -0
- data/app/views/transit/table.js.erb +8 -0
- data/app/views/transit/topics/manage.html.erb +28 -0
- data/config/locales/en.yml +22 -0
- data/config/routes.rb +3 -3
- data/lib/transit.rb +51 -17
- data/lib/transit/admin.rb +85 -0
- data/lib/transit/builders/form_builder.rb +319 -0
- data/lib/transit/builders/jst_builder.rb +38 -0
- data/lib/transit/builders/package_builder.rb +45 -0
- data/lib/transit/config.rb +20 -0
- data/lib/transit/controller/generator.rb +42 -0
- data/lib/transit/controller/responder.rb +34 -0
- data/lib/transit/core_ext.rb +18 -0
- data/lib/transit/errors/resource_not_found.rb +6 -0
- data/lib/transit/model/assets.rb +14 -0
- data/lib/transit/model/attachments.rb +55 -0
- data/lib/transit/model/auto_increment.rb +22 -0
- data/lib/transit/model/base.rb +56 -0
- data/lib/transit/model/comments.rb +19 -0
- data/lib/transit/model/hooks.rb +38 -0
- data/lib/transit/model/owners.rb +14 -0
- data/lib/transit/model/paginator.rb +92 -0
- data/lib/transit/model/topics.rb +14 -0
- data/lib/transit/package/page.rb +20 -12
- data/lib/transit/package/post.rb +87 -33
- data/lib/transit/package/post/validations.rb +14 -0
- data/lib/transit/rails/engine.rb +29 -13
- data/lib/transit/rails/railtie.rb +31 -0
- data/lib/transit/rails/routing.rb +11 -6
- data/lib/transit/services.rb +13 -0
- data/lib/transit/services/base.rb +14 -0
- data/lib/transit/services/facebook.rb +13 -0
- data/lib/transit/services/ted.rb +10 -0
- data/lib/transit/services/twitter.rb +13 -0
- data/lib/transit/services/vimeo.rb +10 -0
- data/lib/transit/services/you_tube.rb +12 -0
- data/lib/transit/version.rb +1 -1
- metadata +178 -31
- data/app/assets/stylesheets/includes/_compat.scss +0 -24
- data/app/assets/stylesheets/includes/_defaults.scss +0 -99
- data/app/assets/stylesheets/includes/_global.scss +0 -16
- data/app/assets/stylesheets/includes/_imports.scss +0 -27
- data/app/assets/stylesheets/includes/_mixins.scss +0 -38
- data/app/assets/stylesheets/includes/_setup.scss +0 -85
- data/app/assets/stylesheets/layout.css.scss +0 -29
- data/app/assets/stylesheets/transit.css +0 -3
- data/app/controllers/application_controller.rb +0 -5
- data/app/controllers/transit/index_controller.rb +0 -7
- data/app/controllers/transit/packages_controller.rb +0 -64
- data/app/controllers/transit/transit_controller.rb +0 -4
- data/app/helpers/routing_helpers.rb +0 -7
- data/app/models/audio.rb +0 -4
- data/app/models/package_asset.rb +0 -11
- data/app/models/video.rb +0 -8
- data/app/views/contexts/_audio.html.erb +0 -1
- data/app/views/contexts/_video.html.erb +0 -1
- data/app/views/layouts/transit.html.erb +0 -31
- data/app/views/transit/index/index.html.erb +0 -0
- data/lib/transit/helpers/controller_helpers.rb +0 -40
- data/lib/transit/helpers/model_helpers.rb +0 -26
- data/lib/transit/package.rb +0 -25
- data/lib/transit/package/base.rb +0 -49
@@ -0,0 +1,92 @@
|
|
1
|
+
module Transit::Model
|
2
|
+
module Paginator
|
3
|
+
|
4
|
+
module Criteria
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
def page(*args)
|
8
|
+
self.klass.page(*args).criteria.merge(self)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
|
15
|
+
##
|
16
|
+
# Sets the default number of items per-page. Allows setting the option for
|
17
|
+
# both "admin" / management pages as well as a default for front-end pages.
|
18
|
+
#
|
19
|
+
# @example Set a default of 10, with a default of 20 for admin pages
|
20
|
+
# per_page 10, admin: 20
|
21
|
+
#
|
22
|
+
# @example Set a global default of 10
|
23
|
+
# per_page 10
|
24
|
+
#
|
25
|
+
def deliver_per_page(*opts)
|
26
|
+
options = opts.extract_options!
|
27
|
+
if options.empty?
|
28
|
+
pagination_options.merge!(default: opts.first, admin: opts.first)
|
29
|
+
else
|
30
|
+
pagination_options.merge!(options)
|
31
|
+
end
|
32
|
+
unless opts.empty?
|
33
|
+
pagination_options.merge!(default: opts.first) unless opts.first.nil?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def pagination_options
|
38
|
+
@_pagination_options ||= { default: 10, admin: 20 }
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
module Document
|
44
|
+
extend ActiveSupport::Concern
|
45
|
+
|
46
|
+
included do
|
47
|
+
##
|
48
|
+
# Retrieve a page of items, with an optional `per` value representing the number of items per page.
|
49
|
+
#
|
50
|
+
# @example Retrieve Posts 11-20
|
51
|
+
# Post.page(2, per: 10)
|
52
|
+
#
|
53
|
+
scope :page, Proc.new { |*opts|
|
54
|
+
options = opts.extract_options!
|
55
|
+
show_per_page = options.delete(:per) || pagination_options[:default]
|
56
|
+
current_index = (opts.first.to_i || 1)
|
57
|
+
limit(show_per_page).offset(show_per_page * ([current_index.to_i, 1].max - 1))
|
58
|
+
} do
|
59
|
+
include Transit::Model::Paginator::Scoping
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add an 'admin' scope method for convenience.
|
63
|
+
#
|
64
|
+
scope :admin_page, lambda{ |pg| page(pg, pagination_options[:admin]) }
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
module Scoping
|
70
|
+
def total_count #:nodoc:
|
71
|
+
count
|
72
|
+
end
|
73
|
+
# Total number of pages
|
74
|
+
def total_pages
|
75
|
+
(total_count.to_f / options[:limit]).ceil
|
76
|
+
end
|
77
|
+
# Current page number
|
78
|
+
def current_page
|
79
|
+
(options[:skip] / options[:limit]) + 1
|
80
|
+
end
|
81
|
+
# First page of the collection ?
|
82
|
+
def first_page?
|
83
|
+
current_page == 1
|
84
|
+
end
|
85
|
+
# Last page of the collection?
|
86
|
+
def last_page?
|
87
|
+
current_page >= num_pages
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Transit
|
2
|
+
module Model
|
3
|
+
|
4
|
+
module Topics
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
has_and_belongs_to_many :topics, inverse_of: :posts, autosave: true
|
9
|
+
Topic.send(:has_and_belongs_to_many, :"#{self.name.pluralize.underscore}", inverse_of: :topics)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/lib/transit/package/page.rb
CHANGED
@@ -1,18 +1,26 @@
|
|
1
|
-
module Transit
|
2
|
-
module
|
1
|
+
module Transit::Package
|
2
|
+
module Page
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
class_attribute :delivery_template, instance_writer: false
|
8
|
+
self.delivery_template = :page
|
9
|
+
|
10
|
+
include Transit::Model::Base
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
scope :published, where(:published => true)
|
14
|
-
end
|
12
|
+
field :name, :type => String
|
13
|
+
field :url, :type => String
|
14
|
+
field :keywords, :type => Array
|
15
|
+
field :description, :type => String
|
16
|
+
|
17
|
+
embeds_many :contexts, :as => :package, :class_name => 'Transit::Context'
|
15
18
|
end
|
16
19
|
|
20
|
+
def timestamp
|
21
|
+
return "" if self.post_date.nil?
|
22
|
+
self.post_date.strftime("%B %d, %Y")
|
23
|
+
end
|
24
|
+
|
17
25
|
end
|
18
26
|
end
|
data/lib/transit/package/post.rb
CHANGED
@@ -1,43 +1,97 @@
|
|
1
|
-
module Transit
|
2
|
-
module
|
1
|
+
module Transit::Package
|
2
|
+
module Post
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
autoload :Validations, 'transit/package/post/validations'
|
5
|
+
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
class_attribute :delivery_template, instance_writer: false
|
10
|
+
self.delivery_template = :post
|
6
11
|
|
7
|
-
|
8
|
-
|
9
|
-
field :title, :type => String
|
10
|
-
field :post_date, :type => Date
|
11
|
-
field :slug, :type => String
|
12
|
-
field :teaser, :type => String
|
13
|
-
|
14
|
-
validates :title, :presence => true
|
15
|
-
validates :slug, :presence => { :allow_blank => false },
|
16
|
-
:uniqueness => { :scope => :_type, :message => "A post already exists with this exact title." }
|
17
|
-
|
18
|
-
scope :published, where(:published => true, :post_date.lte => Date.today)
|
19
|
-
modded_with :sluggable, :fields => :title, :as => :slug
|
20
|
-
alias :timestamp_method :post_date
|
21
|
-
end
|
12
|
+
include Transit::Model::Base
|
22
13
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
14
|
+
field :title, :type => String
|
15
|
+
field :post_date, :type => Date
|
16
|
+
field :slug, :type => String, :default => nil
|
17
|
+
field :teaser, :type => String
|
18
|
+
field :default_teaser, :type => String, :default => ''
|
19
|
+
field :published, :type => Boolean, :default => false
|
28
20
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
field :display_image, :type => Boolean, :default => true
|
22
|
+
|
23
|
+
scope :published, where(:published => true, :post_date.lte => Date.today.to_time.midnight)
|
24
|
+
before_validation :make_slugged_title, :if => lambda{ |p| p.published? }
|
25
|
+
before_save :make_slugged_title, :if => lambda{ |p| p.published? }
|
26
|
+
before_save :force_post_date_to_midnight
|
27
|
+
after_save :set_default_teaser
|
34
28
|
|
35
|
-
|
36
|
-
return "" if self.post_date.nil?
|
37
|
-
self.post_date.strftime("%B %d, %Y")
|
38
|
-
end
|
29
|
+
include Validations
|
39
30
|
|
40
31
|
end
|
41
32
|
|
33
|
+
# Grab the post "previous" to this one, ordered by post date
|
34
|
+
# @example
|
35
|
+
# @post.previous_post
|
36
|
+
#
|
37
|
+
def previous_post
|
38
|
+
@previous_post ||= self.class.only(:title, :slug).where(:post_date.lt => self.post_date).descending(:post_date).first
|
39
|
+
end
|
40
|
+
|
41
|
+
# Grab the post "next" to this one, ordered by post date
|
42
|
+
# @example
|
43
|
+
# @post.next_post
|
44
|
+
#
|
45
|
+
def next_post
|
46
|
+
@next_post ||= self.class.only(:title, :slug).where(:post_date.gt => self.post_date).ascending(:post_date).first
|
47
|
+
end
|
48
|
+
|
49
|
+
# Returns a timestamp formatted to a normal "post date"
|
50
|
+
#
|
51
|
+
def timestamp
|
52
|
+
return "" if self.post_date.nil?
|
53
|
+
self.post_date.to_time.midnight.strftime("%B %d, %Y")
|
54
|
+
end
|
55
|
+
|
56
|
+
# The "teaser" is a shortened version of a post used to display on "index" pages.
|
57
|
+
# Post models include a "teaser" and a "default teaser" allowing teasers to be
|
58
|
+
# automatically generated from the first paragraph of the html body. It is assumed that
|
59
|
+
# all posts will include at least one Text context containing the body of the post
|
60
|
+
#
|
61
|
+
def teaser
|
62
|
+
return self.attributes['teaser'] unless self.attributes['teaser'].to_s.blank?
|
63
|
+
default_teaser.to_s
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
# Generate a URL-friendly slug from the title of this post
|
69
|
+
#
|
70
|
+
def make_slugged_title
|
71
|
+
return true unless self.published?
|
72
|
+
return true unless self.slug.to_s.blank?
|
73
|
+
self.slug = self.title.to_slug
|
74
|
+
end
|
75
|
+
|
76
|
+
# Generate the default teaser copy from the post's first html paragraph
|
77
|
+
#
|
78
|
+
def set_default_teaser
|
79
|
+
return true unless self.default_teaser.blank?
|
80
|
+
textfield = self.contexts.ascending(:position).detect{ |c| c._type.to_s == 'Text' }
|
81
|
+
return true unless textfield
|
82
|
+
doc = ::Nokogiri::HTML::DocumentFragment.parse(textfield.body)
|
83
|
+
self.update_attribute(:default_teaser, doc.xpath('.//p').first.try(:text).to_s)
|
84
|
+
doc = nil
|
85
|
+
true
|
86
|
+
end
|
87
|
+
|
88
|
+
# Since mongo uses Time objects, make sure date is set to midnight so that it
|
89
|
+
# always shows up on that date.
|
90
|
+
#
|
91
|
+
def force_post_date_to_midnight
|
92
|
+
return true if self.post_date.nil?
|
93
|
+
self.post_date = self.post_date.to_time.midnight
|
94
|
+
end
|
95
|
+
|
42
96
|
end
|
43
97
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Transit
|
2
|
+
module Package
|
3
|
+
module Post::Validations
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
validates :title, presence: true
|
8
|
+
validates :slug, presence: { if: lambda{ |p| p.published? }, allow_blank: false }
|
9
|
+
validates :slug, uniqueness: { if: lambda{ |p| p.published? }, scope: :_type, message: "A post already exists with this exact title." }
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/transit/rails/engine.rb
CHANGED
@@ -1,22 +1,38 @@
|
|
1
1
|
require 'rails'
|
2
|
-
require '
|
2
|
+
require 'paperclip'
|
3
3
|
|
4
4
|
module Transit
|
5
5
|
class Engine < Rails::Engine
|
6
|
+
|
6
7
|
isolate_namespace Transit
|
8
|
+
paths['app/models'] << 'app/models/contexts'
|
9
|
+
paths['app/helpers'] << 'app/helpers/transit'
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
|
12
|
+
##
|
13
|
+
# After initialization, dynamically create controllers for models
|
14
|
+
# that have been defined in application routes.
|
15
|
+
#
|
16
|
+
initializer 'transit.generate_controllers', :after => :eager_load! do
|
17
|
+
gen = Transit::Controller::Generator.new(:page, :post)
|
18
|
+
gen.generate!
|
15
19
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
|
21
|
+
initializer 'transit.paperclip' do
|
22
|
+
def Paperclip.logger
|
23
|
+
Rails.logger
|
24
|
+
end
|
25
|
+
::Paperclip.interpolates(:uid) do |attachment, style|
|
26
|
+
"#{attachment.instance.uid}"
|
27
|
+
end
|
28
|
+
::Paperclip.interpolates(:normalize_name) do |attachment, style|
|
29
|
+
"#{attachment.instance.normalize_name(attachment, style)}"
|
30
|
+
end
|
19
31
|
end
|
20
|
-
|
32
|
+
|
21
33
|
end
|
22
|
-
end
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'transit/rails/railtie'
|
37
|
+
Sprockets::Engines
|
38
|
+
Sprockets.register_engine '.jst', Transit::Builders::JstBuilder
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'transit/rails/routing'
|
2
|
+
|
3
|
+
module Transit
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
|
6
|
+
initializer 'transit.integration' do |app|
|
7
|
+
app.config.responders.flash_keys = [ :success, :error ]
|
8
|
+
app.config.assets.precompile << 'transit.css'
|
9
|
+
app.config.assets.precompile << 'transit.js'
|
10
|
+
app.config.action_view.default_form_builder = Transit::Builders::FormBuilder
|
11
|
+
app.config.action_controller.responder = Transit::Controller::Responder
|
12
|
+
app.config.responders.flash_keys = [ :success, :failure ]
|
13
|
+
end
|
14
|
+
|
15
|
+
ActiveSupport.on_load(:action_controller) do
|
16
|
+
self.responder = Transit::Controller::Responder
|
17
|
+
InheritedResources.flash_keys = [ :success, :error ]
|
18
|
+
end
|
19
|
+
|
20
|
+
initializer 'transit.action_view' do
|
21
|
+
ActionView::Base.default_form_builder = Transit::Builders::FormBuilder
|
22
|
+
ActionView::Base.field_error_proc = lambda{ |html_tag, instance_tag| html_tag }
|
23
|
+
end
|
24
|
+
|
25
|
+
ActiveSupport.on_load(:action_view) do
|
26
|
+
include TransitHelper
|
27
|
+
include Transit::FormHelper
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -1,12 +1,17 @@
|
|
1
1
|
module ActionDispatch::Routing
|
2
2
|
class Mapper
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
|
4
|
+
def transit(*args)
|
5
|
+
options = args.extract_options!
|
6
|
+
|
7
|
+
Transit::Engine.routes.draw do
|
8
|
+
args.map(&:to_s).map(&:pluralize).each do |mod|
|
9
|
+
Transit.add_mapping(mod)
|
10
|
+
resources mod do
|
11
|
+
resources :contexts
|
12
|
+
end
|
8
13
|
end
|
9
|
-
end
|
14
|
+
end
|
10
15
|
mount Transit::Engine => (options[:mount_on] || "/transit")
|
11
16
|
end
|
12
17
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Transit
|
2
|
+
module Services
|
3
|
+
|
4
|
+
autoload :Base, 'transit/services/base'
|
5
|
+
autoload :YouTube, 'transit/services/you_tube'
|
6
|
+
autoload :Ted, 'transit/services/ted'
|
7
|
+
autoload :Vimeo, 'transit/services/vimeo'
|
8
|
+
autoload :Twitter, 'transit/services/twitter'
|
9
|
+
autoload :Facebook, 'transit/services/facebook'
|
10
|
+
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|