grandstand 0.2.4 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.markdown +43 -0
  3. data/README.txt +0 -0
  4. data/Rakefile +7 -1
  5. data/VERSION +1 -1
  6. data/app/controllers/galleries_controller.rb +2 -2
  7. data/app/controllers/{admin → grandstand}/galleries_controller.rb +9 -13
  8. data/app/controllers/{admin → grandstand}/images_controller.rb +6 -9
  9. data/app/controllers/{admin → grandstand}/main_controller.rb +8 -8
  10. data/app/controllers/{admin → grandstand}/pages_controller.rb +9 -9
  11. data/app/controllers/grandstand/posts_controller.rb +64 -0
  12. data/app/controllers/{admin → grandstand}/sessions_controller.rb +8 -8
  13. data/app/controllers/grandstand/templates_controller.rb +8 -0
  14. data/app/controllers/{admin → grandstand}/users_controller.rb +10 -10
  15. data/app/controllers/posts_controller.rb +1 -1
  16. data/app/helpers/galleries_helper.rb +2 -0
  17. data/app/helpers/grandstand/galleries_helper.rb +2 -0
  18. data/app/helpers/grandstand/images_helpers.rb +2 -0
  19. data/app/helpers/grandstand/main_helper.rb +74 -0
  20. data/app/helpers/grandstand/pages_helper.rb +2 -0
  21. data/app/helpers/grandstand/posts_helper.rb +2 -0
  22. data/app/helpers/grandstand/sessions_helper.rb +2 -0
  23. data/app/helpers/grandstand/templates_helper.rb +2 -0
  24. data/app/helpers/grandstand/users_helper.rb +2 -0
  25. data/app/models/{gallery.rb → grandstand/gallery.rb} +2 -2
  26. data/app/models/{image.rb → grandstand/image.rb} +10 -9
  27. data/app/models/{page.rb → grandstand/page.rb} +1 -1
  28. data/app/models/grandstand/page_section.rb +6 -0
  29. data/app/models/{post.rb → grandstand/post.rb} +14 -2
  30. data/app/models/{template.rb → grandstand/template.rb} +2 -2
  31. data/app/models/{user.rb → grandstand/user.rb} +1 -1
  32. data/app/stylesheets/application.less +103 -10
  33. data/app/stylesheets/global.less +47 -30
  34. data/app/stylesheets/login.less +1 -1
  35. data/app/stylesheets/wysiwyg.less +77 -65
  36. data/app/views/{admin → grandstand}/galleries/_form.html.erb +2 -2
  37. data/app/views/grandstand/galleries/_gallery.html.erb +16 -0
  38. data/app/views/grandstand/galleries/_list.html.erb +17 -0
  39. data/app/views/grandstand/galleries/delete.html.erb +8 -0
  40. data/app/views/grandstand/galleries/edit.html.erb +8 -0
  41. data/app/views/grandstand/galleries/editor.html.erb +33 -0
  42. data/app/views/grandstand/galleries/index.html.erb +14 -0
  43. data/app/views/grandstand/galleries/new.html.erb +8 -0
  44. data/app/views/grandstand/galleries/show.html.erb +19 -0
  45. data/app/views/{admin → grandstand}/images/_form.html.erb +2 -2
  46. data/app/views/grandstand/images/delete.html.erb +8 -0
  47. data/app/views/grandstand/images/edit.html.erb +8 -0
  48. data/app/views/grandstand/images/new.html.erb +8 -0
  49. data/app/views/grandstand/images/show.html.erb +33 -0
  50. data/app/views/{admin → grandstand}/images/upload.html.erb +2 -2
  51. data/app/views/grandstand/main/index.html.erb +10 -0
  52. data/app/views/{admin → grandstand}/pages/_form.html.erb +2 -2
  53. data/app/views/grandstand/pages/_left.html.erb +3 -0
  54. data/app/views/{admin → grandstand}/pages/_row.html.erb +3 -3
  55. data/app/views/{admin → grandstand}/pages/delete.html.erb +2 -2
  56. data/app/views/{admin → grandstand}/pages/edit.html.erb +2 -2
  57. data/app/views/{admin → grandstand}/pages/index.html.erb +1 -1
  58. data/app/views/{admin → grandstand}/pages/new.html.erb +2 -2
  59. data/app/views/{admin → grandstand}/pages/show.html.erb +1 -1
  60. data/app/views/grandstand/posts/_form.html.erb +15 -0
  61. data/app/views/grandstand/posts/_left.html.erb +3 -0
  62. data/app/views/grandstand/posts/_list.html.erb +26 -0
  63. data/app/views/{admin → grandstand}/posts/delete.html.erb +2 -2
  64. data/app/views/grandstand/posts/edit.html.erb +8 -0
  65. data/app/views/{admin → grandstand}/posts/index.html.erb +1 -1
  66. data/app/views/grandstand/posts/new.html.erb +8 -0
  67. data/app/views/grandstand/posts/preview.html.erb +9 -0
  68. data/app/views/grandstand/posts/show.html.erb +8 -0
  69. data/app/views/{admin → grandstand}/sessions/forgot.html.erb +2 -2
  70. data/app/views/{admin → grandstand}/sessions/show.html.erb +2 -2
  71. data/app/views/grandstand/shared/_flash.html.erb +3 -0
  72. data/app/views/{admin → grandstand}/users/_form.html.erb +2 -2
  73. data/app/views/grandstand/users/_left.html.erb +3 -0
  74. data/app/views/{admin → grandstand}/users/delete.html.erb +2 -2
  75. data/app/views/grandstand/users/edit.html.erb +8 -0
  76. data/app/views/{admin → grandstand}/users/index.html.erb +3 -3
  77. data/app/views/grandstand/users/new.html.erb +8 -0
  78. data/app/views/grandstand/users/show.html.erb +12 -0
  79. data/app/views/layouts/grandstand.html.erb +76 -0
  80. data/app/views/layouts/grandstand_login.html.erb +17 -0
  81. data/app/views/layouts/{admin_xhr.html.erb → grandstand_xhr.html.erb} +0 -0
  82. data/app/views/posts/show.html.erb +2 -2
  83. data/{lib/grandstand → config}/routes.rb +9 -7
  84. data/grandstand.gemspec +139 -122
  85. data/lib/grandstand.rb +50 -19
  86. data/lib/grandstand/application.rb +27 -35
  87. data/lib/grandstand/controller.rb +4 -6
  88. data/lib/grandstand/form_builder.rb +19 -0
  89. data/lib/grandstand/helper.rb +1 -47
  90. data/lib/grandstand/session.rb +2 -11
  91. data/lib/grandstand/stylesheets_controller.rb +14 -0
  92. data/public/{admin → grandstand}/images/background-input.gif +0 -0
  93. data/public/{admin → grandstand}/images/background-progress-bar.png +0 -0
  94. data/public/{admin → grandstand}/images/background-progress-complete.gif +0 -0
  95. data/public/{admin → grandstand}/images/background-progress.gif +0 -0
  96. data/public/grandstand/images/galleries-empty.png +0 -0
  97. data/public/{admin → grandstand}/images/icons/add.png +0 -0
  98. data/public/{admin → grandstand}/images/icons/collapse.png +0 -0
  99. data/public/{admin → grandstand}/images/icons/delete.png +0 -0
  100. data/public/{admin → grandstand}/images/icons/edit.png +0 -0
  101. data/public/{admin → grandstand}/images/icons/editor/bold.png +0 -0
  102. data/public/{admin → grandstand}/images/icons/editor/gallery.png +0 -0
  103. data/public/{admin → grandstand}/images/icons/editor/image-center.png +0 -0
  104. data/public/{admin → grandstand}/images/icons/editor/image-left.png +0 -0
  105. data/public/{admin → grandstand}/images/icons/editor/image-right.png +0 -0
  106. data/public/{admin → grandstand}/images/icons/editor/image.png +0 -0
  107. data/public/{admin → grandstand}/images/icons/editor/italic.png +0 -0
  108. data/public/{admin → grandstand}/images/icons/editor/ordered-list.png +0 -0
  109. data/public/{admin → grandstand}/images/icons/editor/quote.png +0 -0
  110. data/public/{admin → grandstand}/images/icons/editor/source.png +0 -0
  111. data/public/{admin → grandstand}/images/icons/editor/strikethrough.png +0 -0
  112. data/public/{admin → grandstand}/images/icons/editor/underline.png +0 -0
  113. data/public/{admin → grandstand}/images/icons/editor/unordered-list.png +0 -0
  114. data/public/{admin → grandstand}/images/icons/error.png +0 -0
  115. data/public/{admin → grandstand}/images/icons/expand.png +0 -0
  116. data/public/{admin → grandstand}/images/icons/galleries.png +0 -0
  117. data/public/{admin → grandstand}/images/icons/gallery.png +0 -0
  118. data/public/{admin → grandstand}/images/icons/image.png +0 -0
  119. data/public/{admin → grandstand}/images/icons/okay.png +0 -0
  120. data/public/{admin → grandstand}/images/icons/pages.png +0 -0
  121. data/public/{admin → grandstand}/images/icons/posts.png +0 -0
  122. data/public/grandstand/images/icons/processing.gif +0 -0
  123. data/public/{admin → grandstand}/images/icons/upload.png +0 -0
  124. data/public/{admin → grandstand}/images/icons/users.png +0 -0
  125. data/public/{admin → grandstand}/images/logo.png +0 -0
  126. data/public/{admin → grandstand}/images/spinner-dark.gif +0 -0
  127. data/public/{admin → grandstand}/images/uploader.swf +0 -0
  128. data/public/{admin → grandstand}/javascripts/application.js +139 -54
  129. data/public/grandstand/javascripts/jquery.js +414 -0
  130. data/public/{admin → grandstand}/javascripts/mustache.js +0 -0
  131. data/public/grandstand/javascripts/preview.js +9 -0
  132. data/public/{admin → grandstand}/javascripts/selection.js +77 -57
  133. data/public/{admin → grandstand}/javascripts/string.js +7 -6
  134. data/public/grandstand/javascripts/wysiwyg.js +311 -0
  135. data/public/{admin → grandstand}/stylesheets/wysiwyg-content.css +15 -2
  136. metadata +207 -126
  137. data/README +0 -7
  138. data/app/controllers/admin/posts_controller.rb +0 -48
  139. data/app/controllers/admin/templates_controller.rb +0 -6
  140. data/app/helpers/admin/main_helper.rb +0 -31
  141. data/app/helpers/admin/pages_helper.rb +0 -2
  142. data/app/helpers/admin/posts_helper.rb +0 -2
  143. data/app/helpers/admin/sessions_helper.rb +0 -2
  144. data/app/helpers/admin/templates_helper.rb +0 -2
  145. data/app/helpers/admin/users_helper.rb +0 -2
  146. data/app/models/page_section.rb +0 -6
  147. data/app/stylesheets/_dialogs.less +0 -85
  148. data/app/views/admin/galleries/_gallery.html.erb +0 -16
  149. data/app/views/admin/galleries/_list.html.erb +0 -17
  150. data/app/views/admin/galleries/delete.html.erb +0 -8
  151. data/app/views/admin/galleries/edit.html.erb +0 -8
  152. data/app/views/admin/galleries/editor.html.erb +0 -13
  153. data/app/views/admin/galleries/editor_with_images.html.erb +0 -19
  154. data/app/views/admin/galleries/index.html.erb +0 -13
  155. data/app/views/admin/galleries/new.html.erb +0 -8
  156. data/app/views/admin/galleries/show.html.erb +0 -15
  157. data/app/views/admin/images/delete.html.erb +0 -8
  158. data/app/views/admin/images/edit.html.erb +0 -8
  159. data/app/views/admin/images/new.html.erb +0 -8
  160. data/app/views/admin/main/index.html.erb +0 -10
  161. data/app/views/admin/pages/_left.html.erb +0 -3
  162. data/app/views/admin/posts/_form.html.erb +0 -29
  163. data/app/views/admin/posts/_left.html.erb +0 -3
  164. data/app/views/admin/posts/_list.html.erb +0 -22
  165. data/app/views/admin/posts/edit.html.erb +0 -10
  166. data/app/views/admin/posts/new.html.erb +0 -10
  167. data/app/views/admin/posts/show.html.erb +0 -4
  168. data/app/views/admin/shared/_flash.html.erb +0 -3
  169. data/app/views/admin/users/_left.html.erb +0 -3
  170. data/app/views/admin/users/edit.html.erb +0 -8
  171. data/app/views/admin/users/new.html.erb +0 -8
  172. data/app/views/admin/users/show.html.erb +0 -12
  173. data/app/views/layouts/admin.html.erb +0 -80
  174. data/app/views/layouts/admin_login.html.erb +0 -17
  175. data/lib/grandstand/controller/development.rb +0 -15
  176. data/public/admin/javascripts/jquery.js +0 -404
  177. data/public/admin/javascripts/wysiwyg.js +0 -335
  178. data/public/admin/stylesheets/application.css +0 -1
  179. data/public/admin/stylesheets/global.css +0 -1
  180. data/public/admin/stylesheets/login.css +0 -1
  181. data/public/admin/stylesheets/wysiwyg.css +0 -1
data/lib/grandstand.rb CHANGED
@@ -1,28 +1,59 @@
1
+ # Require the Gems we need for this guy
2
+ gem 'aws-s3'
3
+ require 'aws/s3'
4
+ require 'mustache'
5
+ require 'paperclip'
6
+
1
7
  require 'grandstand/application'
2
8
 
3
9
  module Grandstand
4
- autoload(:Controller, 'grandstand/controller')
5
- autoload(:Helper, 'grandstand/helper')
6
- autoload(:Session, 'grandstand/session')
7
-
8
- def self.initialize!(config = nil)
9
- if defined?(ActionController)
10
- ActionController::Base.send :include, Grandstand::Controller
11
- if Rails.env.development? && defined?(Less) && defined?(Less::More)
12
- ActionController::Base.send :include, Grandstand::Controller::Development
13
- # Tell Less to produce the smallest stylesheets it's capable of
14
- Less::More.compression = true
15
- Less::More.header = false
16
- # Point More to our plugins' source_path and our custom admin stylesheets folder
17
- Less::More.source_path = File.join('vendor', 'plugins', 'grandstand', 'app', 'stylesheets')
18
- Less::More.destination_path = File.join('admin', 'stylesheets')
10
+ # Some basic configuration options - app name ('Grandstand'), image sizes, content areas, etc.
11
+ class << self
12
+ def routing
13
+ @routing ||= {:ssl => true}
14
+ end
15
+
16
+ def routing=(routing)
17
+ @routing = new_routing
18
+ end
19
+
20
+ def routing_options
21
+ routing_options = {}
22
+ if Grandstand.routing[:domain]
23
+ routing_options.merge!(:path => '', :constraints => {:domain => Grandstand.routing[:domain]})
19
24
  end
25
+ routing_options
20
26
  end
21
- if defined?(ActionView)
22
- ActionView::Base.send :include, Grandstand::Helper
27
+
28
+ def app_name
29
+ @app_name ||= 'Grandstand'
30
+ end
31
+
32
+ def image_sizes
33
+ @images_sizes ||= {}
23
34
  end
24
- Paperclip.interpolates :padded_id do |attachment, style|
25
- attachment.instance.id.to_s.rjust(6, '0')
35
+
36
+ def image_sizes=(new_image_sizes)
37
+ @images_sizes = new_image_sizes
38
+ end
39
+
40
+ def page_sections
41
+ @page_sections ||= %w(left main)
42
+ end
43
+
44
+ def page_sections=(new_page_sections)
45
+ @page_sections = new_page_sections
46
+ end
47
+
48
+ def s3
49
+ @s3 ||= {
50
+ :bucket => nil,
51
+ :credentials => File.join(Rails.root, 'config', 's3.yml')
52
+ }
53
+ end
54
+
55
+ def s3=(new_s3)
56
+ @s3 = new_s3
26
57
  end
27
58
  end
28
59
  end
@@ -1,49 +1,41 @@
1
1
  require 'rails'
2
2
  require 'grandstand'
3
+ require 'grandstand/controller'
4
+ require 'grandstand/form_builder'
5
+ require 'grandstand/helper'
6
+ require 'grandstand/session'
3
7
 
4
8
  module Grandstand
5
9
  class Application < Rails::Engine
6
- paths.config.routes = 'lib/routes.rb'
7
-
8
- initializer 'grandstand.add_session_extension', :after => :load_application_initializers do |app|
9
- # puts "Adding middleware (#{app.config.session_options.inspect})"
10
+ initializer 'grandstand.initialize', :after => :load_application_initializers do |app|
11
+ # Add sessions for Flash file uploads - but this is *not* very secure!
10
12
  app.middleware.insert_before(ActionDispatch::ShowExceptions, Grandstand::Session, app.config.session_options[:key] || app.config.session_options['key'])
11
- Grandstand.initialize!
12
- end
13
-
14
- initializer 'grandstand.symlink_public_files' do |app|
15
- Dir[File.join(File.dirname(__FILE__), '..', 'public', '*')].each do |gem_path|
16
- user_path = File.join(app.root, 'public', File.basename(gem_path))
17
- # puts "Copying #{gem_path} to #{user_path}"
18
- if File.file?(gem_path) && !File.file?(user_path)
19
- FileUtils.cp_r(gem_path, user_path)
20
- elsif File.directory?(gem_path) && !File.directory?(user_path)
21
- FileUtils.cp_r(gem_path, user_path)
22
- end
23
- end
24
- end
25
13
 
26
- class << self
27
- def app_name
28
- @app_name ||= 'Portfoliawesome'
29
- end
14
+ # Extend ActionController and ActionView to have the Grandstand defaults (current_user and its friends)
15
+ ActionController::Base.send :include, Grandstand::Controller
30
16
 
31
- def image_sizes
32
- {
33
- :icon => '75x75#',
34
- :page => '541x'
35
- }
36
- end
17
+ # Include Grandstand view helpers (page content and its friends)
18
+ ActionView::Base.send :include, Grandstand::Helper
19
+ ActionView::Helpers::FormBuilder.send :include, Grandstand::FormBuilder
37
20
 
38
- def page_sections
39
- %w(left main)
21
+ # Add Paperclip padded_id and dimensions interpolations
22
+ Paperclip.interpolates :dimensions do |attachment, style|
23
+ attachment.options[:styles][style].gsub(/[^\dx]/, '')
24
+ end
25
+ Paperclip.interpolates :gallery_id do |attachment, style|
26
+ attachment.instance.gallery_id.to_s.rjust(6, '0')
40
27
  end
28
+ Paperclip.interpolates :padded_id do |attachment, style|
29
+ attachment.instance.id.to_s.rjust(6, '0')
30
+ end
31
+ end
41
32
 
42
- def s3
43
- @s3 ||= {
44
- :bucket => nil,
45
- :credentials => File.join(Rails.root, 'config', 's3.yml')
46
- }
33
+ if Rails.env.development?
34
+ # In development mode, Grandstand will serve static assets. Be sure to move them to your app's
35
+ # actual public directory when you're ready to deploy using rake something something
36
+ # TODO: Find actual rake task
37
+ initializer 'grandstand.development_mode', :after => :load_application_initializers do |app|
38
+ # app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
47
39
  end
48
40
  end
49
41
  end
@@ -1,7 +1,5 @@
1
1
  module Grandstand
2
2
  module Controller
3
- autoload(:Development, 'grandstand/controller/development')
4
-
5
3
  def self.included(base)
6
4
  base.helper_method :current_page, :current_user, :return_path
7
5
  end
@@ -11,14 +9,14 @@ module Grandstand
11
9
  # the current requests' URL. Very frequently nil!
12
10
  def current_page
13
11
  return @_current_page if defined? @_current_page
14
- @_current_page = Page.where(:url => request.path.reverse.chomp('/').reverse).first
12
+ @_current_page = Grandstand::Page.where(:url => request.path.reverse.chomp('/').reverse).first
15
13
  end
16
14
  protected :current_page
17
15
 
18
16
  # Predictably, `current_user` will return the currently logged-in user.
19
17
  def current_user
20
18
  # Ask Rack for a model first - this makes it easy to add SSO middleware
21
- @_user ||= request.env['user'] || User.first(:conditions => {:id => session[:user_id]}) if session[:user_id]
19
+ @_user ||= request.env['user'] || Grandstand::User.first(:conditions => {:id => session[:user_id]}) if session[:user_id]
22
20
  end
23
21
  protected :current_user
24
22
 
@@ -57,7 +55,7 @@ module Grandstand
57
55
  # Remember any post variables the user may have sent between logout and now.
58
56
  # session[:post_params] = params.except(:controller, :action, :id).merge({:_method => request.method}) unless request.get?
59
57
  # Send them off to the correct login path
60
- redirect_to(admin_session_path) and return false
58
+ redirect_to(grandstand_session_path) and return false
61
59
  end
62
60
  end
63
61
 
@@ -95,7 +93,7 @@ module Grandstand
95
93
  # end
96
94
  #
97
95
  # It's also a quick way to return a user to previous action post-login - see
98
- # Admin::SessionController#create for more details and an example
96
+ # Grandstand::SessionController#create for more details and an example
99
97
  def set_return_path(path = nil)
100
98
  session[:return_path] = path || request.fullpath
101
99
  end
@@ -0,0 +1,19 @@
1
+ module Grandstand
2
+ module FormBuilder
3
+ def errors_on(*fields)
4
+ if @object
5
+ errors = []
6
+ fields.each do |field|
7
+ @object.errors[field].each do |error|
8
+ errors.push("<li>#{error[0, 1] == error[0, 1].upcase ? error : "#{field.to_s.humanize} #{error}"}</li>")
9
+ end
10
+ end
11
+ unless errors.empty?
12
+ @template.content_tag(:ul, :class => 'errors') do
13
+ errors.join("\n")
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,51 +1,5 @@
1
1
  module Grandstand
2
2
  module Helper
3
- # Renders a <button> tag. Helpful for forms and the like.
4
- #
5
- # <%= button("Save Changes", :class => "blue") %>
6
- #
7
- # ... produces
8
- #
9
- # <button class="button blue"><span class="inner"><span>Save Changes</span></span></button>
10
- def button(*args)
11
- options, icon = button_options(args.extract_options! || {})
12
- content_tag(:button, options) { content_tag(:span, :class => icon ? "#{icon} icon" : nil) { args.shift } }
13
- end
14
-
15
- # Similar to button, but generates a link instead of a button element. Useful for providing
16
- # buttons to GET actions:
17
- #
18
- # <%= button_link_to("Get Help", support_path, :icon => "help") %>
19
- #
20
- # ... produces
21
- #
22
- # <a class="button blue" href="/support"><span class="inner"><span class="help icon">Get Help</span></span></button>
23
- #
24
- # The extra spans are for any sliding door styling you may be interested in adding. Adding :icon to the options will
25
- # give the inner-most span a class of "#{options[:icon]} icon", allowing you to add extra images inside of your button.
26
- def button_link_to(*args)
27
- options, icon = button_options(args.extract_options! || {})
28
- link_to(content_tag(:span, :class => icon ? "#{icon} icon" : nil) { args.shift }, *args.push(options))
29
- end
30
-
31
- def button_options(options)
32
- classes = %w(button)
33
- if icon = options.delete(:icon)
34
- classes.push('has-icon')
35
- end
36
- classes.push(options[:class].to_s.split(' ')) if options[:class]
37
- options[:class] = classes.uniq.join(' ')
38
- [options, icon]
39
- end
40
-
41
- # Returns error_message_on ONLY IF the instance has errors on that field. Just a helpful way of conditionally rendering
42
- # errors.
43
- def errors_on(instance, method)
44
- if (instance = instance_variable_get("@#{instance}")) && !instance.errors[method].empty?
45
- error_message_on(instance, method, :css_class => 'error icon')
46
- end
47
- end
48
-
49
3
  # Adds section-oriented class names if a current_page exists. Useful for styling your site to account for the presence
50
4
  # of various content sections; e.g. if a CMS user adds a page with content in the "left" column but not a page with
51
5
  # content in the "right" column, you can add:
@@ -109,7 +63,7 @@ module Grandstand
109
63
  end
110
64
 
111
65
  def page_title(separator = '|')
112
- if object = @post || @_page
66
+ if object = @post || current_page
113
67
  "#{object.name} #{separator}"
114
68
  end
115
69
  end
@@ -1,5 +1,3 @@
1
- require 'rack/utils'
2
-
3
1
  module Grandstand
4
2
  class Session
5
3
  def initialize(app, session_key = '_session_id')
@@ -8,16 +6,9 @@ module Grandstand
8
6
  end
9
7
 
10
8
  def call(env)
11
- if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/ && env['PATH_INFO'] =~ /^\/admin\/galleries\/\d+\/images$/
9
+ if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/ && env['PATH_INFO'] =~ /^\/grandstand\/galleries\/\d+\/images$/
12
10
  params = Rack::Request.new(env).POST
13
- unless params['session_key'].nil?
14
- # This will strip out the session_key from the POST params - not entirely necessary,
15
- # but still cleaner than the alternative
16
- env['HTTP_COOKIE'] = [ @session_key, params.delete('session_key') ].join('=').freeze
17
- env['rack.input'] = StringIO.new(Rack::Utils::Multipart.build_multipart(params))
18
- env['rack.input'].rewind
19
- end
20
- puts "\n\n#{env['HTTP_COOKIE'].inspect}\n\n"
11
+ env['HTTP_COOKIE'] = [ @session_key, params.delete('session_key') ].join('=').freeze unless params['session_key'].nil?
21
12
  end
22
13
  @app.call(env)
23
14
  end
@@ -0,0 +1,14 @@
1
+ require 'less'
2
+ module Grandstand
3
+ class StylesheetsController < ApplicationController
4
+ def show
5
+ stylesheet = File.join(Grandstand::Application.root, 'app', 'stylesheets', "#{params[:name]}.less")
6
+ if File.file?(stylesheet)
7
+ engine = File.open(stylesheet) {|file| Less::Engine.new(file) }
8
+ render :content_type => 'text/css', :text => engine.to_css
9
+ else
10
+ grandstand_not_found
11
+ end
12
+ end
13
+ end
14
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- $LOAD_PATH = ['/admin/javascripts'];
1
+ $LOAD_PATH = ['/grandstand/javascripts'];
2
2
 
3
3
  $(document).ready(function() {
4
4
  $('a[data-method]').live('click', function(event) {
@@ -29,42 +29,24 @@ $(document).ready(function() {
29
29
  ul.slideDown(100);
30
30
  add = true;
31
31
  }
32
- $.get('/admin/expand?add=' + (add ? 'yup' : 'nope') + '&section=' + link.attr('rel'));
32
+ $.get('/grandstand/expand?add=' + (add ? 'yup' : 'nope') + '&section=' + link.attr('rel'));
33
33
  });
34
34
 
35
- $('#cover').click(function() {
36
- $(this).fadeOut(200);
37
- var pulldown = $('#pulldown');
38
- if (pulldown.css('display') != 'none') {
39
- pulldown.animate({top: -(pulldown.height())}, 300, function() {
40
- pulldown.hide();
41
- });
42
- }
43
- });
44
-
45
- $('#pulldown a.cancel').live('click', function(event) {
46
- event.preventDefault();
47
- $('#cover').click();
35
+ $('form').submit(function() {
36
+ $(this).find('button').attr('enabled', false);
48
37
  });
49
38
 
50
39
  $('.remote').live('click', function(event) {
51
- $('#cover').fadeIn(100);
52
40
  event.preventDefault();
53
- $.get(this.href, function(response) {
54
- var pulldown = $('#pulldown');
55
- pulldown.html(response);
56
- if (pulldown.css('display') == 'none') {
57
- pulldown.css('top', -(pulldown.height())).show().animate({top: 0}, 300);
58
- }
59
- });
41
+ Dialog.show(this.href);
60
42
  });
61
43
 
62
44
  $('.galleries.sortable').sortable({
63
45
  handle: '.float-left',
64
46
  items: '.container',
65
47
  stop: function(event, ui) {
66
- $.post('/admin/galleries/reorder', $(this).sortable('serialize'), function() {
67
- Flash.show('notice', "Your changes have been saved!");
48
+ $.post('/grandstand/galleries/reorder', $(this).sortable('serialize'), function() {
49
+ Notifications.show('notice', 'Your changes have been saved!');
68
50
  });
69
51
  }
70
52
  });
@@ -74,7 +56,7 @@ $(document).ready(function() {
74
56
  items: '.container',
75
57
  stop: function(event, ui) {
76
58
  $.post(window.location.toString() + '/images/reorder', $(this).sortable('serialize'), function() {
77
- Flash.show('notice', "Your changes have been saved!");
59
+ Notifications.show('notice', 'Your changes have been saved!');
78
60
  });
79
61
  }
80
62
  });
@@ -106,7 +88,7 @@ $(document).ready(function() {
106
88
  flashvars: {action: form.attr('action'), method: form.attr('method').toUpperCase(), data: $.param(data)},
107
89
  height: 24,
108
90
  id: 'uploads-flash',
109
- src: '/admin/images/uploader.swf',
91
+ src: '/grandstand/images/uploader.swf',
110
92
  width: 118,
111
93
  wmode: 'transparent'
112
94
  }
@@ -116,10 +98,14 @@ $(document).ready(function() {
116
98
  }
117
99
  });
118
100
 
101
+ $('#cover').click(function(event) {
102
+ Dialog.hide();
103
+ });
104
+
119
105
  $('.tabset').tabs();
120
106
 
121
107
  $('.wysiwyg').dependency('wysiwyg', function() {
122
- this.wysiwyg('post', this.attr('id') == 'post_body' ? '.post' : null);
108
+ this.wysiwyg('post', '.post');
123
109
  });
124
110
 
125
111
  $('.source a').live('click', function(event) {
@@ -137,9 +123,120 @@ $(document).ready(function() {
137
123
  $('#' + link.attr('rel')).show();
138
124
  });
139
125
 
140
- Flash.hideAll();
126
+ Notifications.hide();
127
+
141
128
  });
142
129
 
130
+ var Dialog = {
131
+ hide: function(close) {
132
+ Dialog.unbind();
133
+ if (!close) {
134
+ $('#cover').fadeOut(200);
135
+ }
136
+ var dialog = $('#dialog');
137
+ if (dialog.css('display') != 'none') {
138
+ dialog.animate({top: -(dialog.height())}, 300, function() {
139
+ if (close) {
140
+ close();
141
+ }
142
+ dialog.hide().html('');
143
+ });
144
+ } else {
145
+ close();
146
+ }
147
+ },
148
+ keydown: function(event) {
149
+ if (event.keyCode == 27) {
150
+ $('#dialog a.cancel').addClass('active');
151
+ } else if (event.keyCode == 13) {
152
+ $('#dialog .default').addClass('active');
153
+ }
154
+ },
155
+ keyup: function(event) {
156
+ if (event.keyCode == 27) {
157
+ $('#dialog a.cancel').removeClass('active');
158
+ Dialog.hide();
159
+ } else if (event.keyCode == 13) {
160
+ $('#dialog .default').removeClass('active');
161
+ if ($(event.target).parents('form').length === 0 && !$(event.target).is('form')) {
162
+ Dialog.submit();
163
+ }
164
+ }
165
+ },
166
+ show: function(content, options) {
167
+ var cover = $('#cover');
168
+ cover.fadeIn(100);
169
+ var options = options || {};
170
+ var dialog = $('#dialog');
171
+ dialog.removeClass();
172
+ if (options.style) {
173
+ dialog.addClass(options.style);
174
+ }
175
+ var process = function(content) {
176
+ dialog.html(content);
177
+ dialog.find('a.cancel').click(function(event) {
178
+ event.preventDefault();
179
+ Dialog.hide();
180
+ });
181
+ if (options.load) {
182
+ options.load(dialog);
183
+ }
184
+ $(document).keydown(Dialog.keydown).keyup(Dialog.keyup);
185
+ if (options.submit) {
186
+ dialog.find('form').submit(function(event) {
187
+ return options.submit.call(this, event);
188
+ });
189
+ }
190
+ if (dialog.css('display') == 'none') {
191
+ dialog.css('top', -(dialog.height())).show().animate({top: 0}, 300, function() {
192
+ cover.removeClass('loading');
193
+ if (options.complete) {
194
+ options.complete.call(this);
195
+ }
196
+ });
197
+ } else {
198
+ cover.removeClass('loading');
199
+ }
200
+ }
201
+ if (typeof(content) == 'string' && content.toString().match(/^http(s)*:\/\//) || content.toString().match(/^\//)) {
202
+ cover.addClass('loading');
203
+ $.get(content, function(response) {
204
+ process(response);
205
+ });
206
+ } else {
207
+ process(content);
208
+ }
209
+ },
210
+ submit: function() {
211
+ Dialog.unbind();
212
+ $('#dialog form').submit();
213
+ },
214
+ unbind: function() {
215
+ $(document).unbind('keydown', Dialog.keydown).unbind('keyup', Dialog.keyup);
216
+ }
217
+ };
218
+
219
+ var Notifications = {
220
+ hide: function() {
221
+ $('.notification').each(function() {
222
+ var notification = $(this);
223
+ setTimeout(function() {
224
+ notification.fadeOut(200);
225
+ }, 2000);
226
+ });
227
+ },
228
+ show: function(type, message) {
229
+ var notification = $('.notification.' + type);
230
+ if (notification.length === 0) {
231
+ notification = $('<div class="notification ' + type + '"><div class="inner"></div></div>').hide();
232
+ $(document.body).prepend(notification);
233
+ }
234
+ notification.find('.inner').html(message);
235
+ Notifications.hide();
236
+ return notification.fadeIn(200);
237
+ }
238
+ };
239
+
143
240
  var Upload = {
144
241
  // Every file is done; move on with our lives
145
242
  allComplete: function() {
@@ -147,7 +244,7 @@ var Upload = {
147
244
  },
148
245
  // Called when someone clicks a "cancel this event" button
149
246
  cancel: function(event) {
150
-
247
+ alert('cancelling the thingy...');
151
248
  },
152
249
  // Called AFTER we've successfully cancelled, but we initiate the cancelling.
153
250
  cancelled: function() {
@@ -183,7 +280,7 @@ var Upload = {
183
280
  fileCompleted: function(event) {
184
281
  var row = Upload.rowFor(event.target.name);
185
282
  row.find('.progress-bar').addClass('complete');
186
- row.find('.delete').removeClass('delete').addClass('okay');
283
+ row.find('.delete').removeClass('delete').removeClass('processing').addClass('okay');
187
284
  },
188
285
  fileError: function(event) {
189
286
  var row = Upload.rowFor(event.target.name)
@@ -191,8 +288,17 @@ var Upload = {
191
288
  row.find('.icon').removeClass('delete').addClass('error');
192
289
  },
193
290
  fileProgress: function(event) {
194
- var progress = Upload.rowFor(event.target.name).find('.progress');
195
- progress.animate({width: (event.bytesLoaded / event.bytesTotal * 100).toString() + '%'}, 50);
291
+ var row = Upload.rowFor(event.target.name);
292
+ var progress = row.find('.progress');
293
+ var percent = event.bytesLoaded / event.bytesTotal * 100;
294
+ progress.animate({width: percent.toString() + '%'}, 50);
295
+ if (percent == 100) {
296
+ var icon = row.find('.icon');
297
+ if (!icon.hasClass('processing')) {
298
+ progress.parent().addClass('complete');
299
+ row.find('.delete').addClass('processing');
300
+ }
301
+ }
196
302
  },
197
303
  fileStarted: function(event) {
198
304
 
@@ -208,24 +314,3 @@ var Upload = {
208
314
  Upload.list.find('tbody').find('tr:odd').addClass('odd');
209
315
  }
210
316
  };
211
-
212
- var Flash = {
213
- hideAll: function() {
214
- $('.flash').each(function() {
215
- var flash = $(this);
216
- setTimeout(function() {
217
- flash.fadeOut(200);
218
- }, 2000);
219
- });
220
- },
221
- show: function(type, message) {
222
- var flash = $('.flash.' + type);
223
- if (flash.length === 0) {
224
- flash = $('<div class="flash ' + type + '"><div class="inner"></div></div>').hide();
225
- $(document.body).prepend(flash);
226
- }
227
- flash.find('.inner').html(message);
228
- Flash.hideAll();
229
- return flash.fadeIn(200);
230
- }
231
- };