grandstand 0.2.1
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.
- data/.gitignore +2 -0
- data/MIT-LICENSE +20 -0
- data/README +7 -0
- data/Rakefile +44 -0
- data/VERSION +1 -0
- data/app/controllers/admin/galleries_controller.rb +52 -0
- data/app/controllers/admin/images_controller.rb +68 -0
- data/app/controllers/admin/main_controller.rb +36 -0
- data/app/controllers/admin/pages_controller.rb +51 -0
- data/app/controllers/admin/posts_controller.rb +48 -0
- data/app/controllers/admin/sessions_controller.rb +41 -0
- data/app/controllers/admin/templates_controller.rb +6 -0
- data/app/controllers/admin/users_controller.rb +48 -0
- data/app/controllers/galleries_controller.rb +5 -0
- data/app/controllers/pages_controller.rb +5 -0
- data/app/controllers/posts_controller.rb +5 -0
- data/app/helpers/admin/main_helper.rb +31 -0
- data/app/helpers/admin/pages_helper.rb +2 -0
- data/app/helpers/admin/posts_helper.rb +2 -0
- data/app/helpers/admin/sessions_helper.rb +2 -0
- data/app/helpers/admin/templates_helper.rb +2 -0
- data/app/helpers/admin/users_helper.rb +2 -0
- data/app/helpers/pages_helper.rb +2 -0
- data/app/helpers/posts_helper.rb +2 -0
- data/app/helpers/site_helper.rb +2 -0
- data/app/models/gallery.rb +22 -0
- data/app/models/image.rb +61 -0
- data/app/models/page.rb +45 -0
- data/app/models/page_section.rb +6 -0
- data/app/models/post.rb +27 -0
- data/app/models/template.rb +33 -0
- data/app/models/user.rb +68 -0
- data/app/stylesheets/_buttons.less +76 -0
- data/app/stylesheets/_dialogs.less +85 -0
- data/app/stylesheets/application.less +238 -0
- data/app/stylesheets/global.less +435 -0
- data/app/stylesheets/login.less +30 -0
- data/app/stylesheets/wysiwyg.less +96 -0
- data/app/views/admin/galleries/_form.html.erb +11 -0
- data/app/views/admin/galleries/_gallery.html.erb +16 -0
- data/app/views/admin/galleries/_list.html.erb +17 -0
- data/app/views/admin/galleries/delete.html.erb +8 -0
- data/app/views/admin/galleries/edit.html.erb +8 -0
- data/app/views/admin/galleries/editor.html.erb +13 -0
- data/app/views/admin/galleries/editor_with_images.html.erb +19 -0
- data/app/views/admin/galleries/index.html.erb +13 -0
- data/app/views/admin/galleries/new.html.erb +8 -0
- data/app/views/admin/galleries/show.html.erb +15 -0
- data/app/views/admin/images/_form.html.erb +11 -0
- data/app/views/admin/images/delete.html.erb +8 -0
- data/app/views/admin/images/edit.html.erb +8 -0
- data/app/views/admin/images/new.html.erb +8 -0
- data/app/views/admin/images/upload.html.erb +11 -0
- data/app/views/admin/main/index.html.erb +10 -0
- data/app/views/admin/pages/_form.html.erb +33 -0
- data/app/views/admin/pages/_left.html.erb +3 -0
- data/app/views/admin/pages/_row.html.erb +9 -0
- data/app/views/admin/pages/delete.html.erb +8 -0
- data/app/views/admin/pages/edit.html.erb +8 -0
- data/app/views/admin/pages/index.html.erb +20 -0
- data/app/views/admin/pages/new.html.erb +8 -0
- data/app/views/admin/pages/show.html.erb +3 -0
- data/app/views/admin/posts/_form.html.erb +29 -0
- data/app/views/admin/posts/_left.html.erb +3 -0
- data/app/views/admin/posts/_list.html.erb +22 -0
- data/app/views/admin/posts/delete.html.erb +9 -0
- data/app/views/admin/posts/edit.html.erb +10 -0
- data/app/views/admin/posts/index.html.erb +10 -0
- data/app/views/admin/posts/new.html.erb +10 -0
- data/app/views/admin/posts/show.html.erb +4 -0
- data/app/views/admin/sessions/forgot.html.erb +8 -0
- data/app/views/admin/sessions/show.html.erb +12 -0
- data/app/views/admin/shared/_flash.html.erb +3 -0
- data/app/views/admin/users/_form.html.erb +16 -0
- data/app/views/admin/users/_left.html.erb +3 -0
- data/app/views/admin/users/delete.html.erb +10 -0
- data/app/views/admin/users/edit.html.erb +8 -0
- data/app/views/admin/users/index.html.erb +22 -0
- data/app/views/admin/users/new.html.erb +8 -0
- data/app/views/admin/users/show.html.erb +12 -0
- data/app/views/galleries/index.html.erb +0 -0
- data/app/views/galleries/show.html.erb +12 -0
- data/app/views/layouts/admin.html.erb +80 -0
- data/app/views/layouts/admin_login.html.erb +17 -0
- data/app/views/layouts/admin_xhr.html.erb +3 -0
- data/app/views/pages/show.html.erb +8 -0
- data/app/views/posts/show.html.erb +3 -0
- data/app/views/shared/404.html.erb +5 -0
- data/app/views/shared/gallery.html +14 -0
- data/app/views/shared/image.html +1 -0
- data/app/views/shared/page.html +0 -0
- data/app/views/shared/post.html +3 -0
- data/grandstand.gemspec +189 -0
- data/lib/grandstand/application.rb +50 -0
- data/lib/grandstand/controller/development.rb +15 -0
- data/lib/grandstand/controller.rb +104 -0
- data/lib/grandstand/helper.rb +117 -0
- data/lib/grandstand/routes.rb +59 -0
- data/lib/grandstand/session.rb +25 -0
- data/lib/grandstand.rb +27 -0
- data/public/.DS_Store +0 -0
- data/public/admin/.DS_Store +0 -0
- data/public/admin/images/.DS_Store +0 -0
- data/public/admin/images/background-input.gif +0 -0
- data/public/admin/images/background-progress-bar.png +0 -0
- data/public/admin/images/background-progress-complete.gif +0 -0
- data/public/admin/images/background-progress.gif +0 -0
- data/public/admin/images/icons/.DS_Store +0 -0
- data/public/admin/images/icons/add.png +0 -0
- data/public/admin/images/icons/collapse.png +0 -0
- data/public/admin/images/icons/delete.png +0 -0
- data/public/admin/images/icons/edit.png +0 -0
- data/public/admin/images/icons/editor/bold.png +0 -0
- data/public/admin/images/icons/editor/gallery.png +0 -0
- data/public/admin/images/icons/editor/image-center.png +0 -0
- data/public/admin/images/icons/editor/image-left.png +0 -0
- data/public/admin/images/icons/editor/image-right.png +0 -0
- data/public/admin/images/icons/editor/image.png +0 -0
- data/public/admin/images/icons/editor/italic.png +0 -0
- data/public/admin/images/icons/editor/ordered-list.png +0 -0
- data/public/admin/images/icons/editor/quote.png +0 -0
- data/public/admin/images/icons/editor/source.png +0 -0
- data/public/admin/images/icons/editor/strikethrough.png +0 -0
- data/public/admin/images/icons/editor/underline.png +0 -0
- data/public/admin/images/icons/editor/unordered-list.png +0 -0
- data/public/admin/images/icons/error.png +0 -0
- data/public/admin/images/icons/expand.png +0 -0
- data/public/admin/images/icons/galleries.png +0 -0
- data/public/admin/images/icons/gallery.png +0 -0
- data/public/admin/images/icons/image.png +0 -0
- data/public/admin/images/icons/okay.png +0 -0
- data/public/admin/images/icons/pages.png +0 -0
- data/public/admin/images/icons/posts.png +0 -0
- data/public/admin/images/icons/upload.png +0 -0
- data/public/admin/images/icons/users.png +0 -0
- data/public/admin/images/logo.png +0 -0
- data/public/admin/images/spinner-dark.gif +0 -0
- data/public/admin/images/uploader.swf +0 -0
- data/public/admin/javascripts/application.js +231 -0
- data/public/admin/javascripts/jquery.js +404 -0
- data/public/admin/javascripts/mustache.js +324 -0
- data/public/admin/javascripts/selection.js +280 -0
- data/public/admin/javascripts/string.js +264 -0
- data/public/admin/javascripts/wysiwyg.js +335 -0
- data/public/admin/stylesheets/application.css +1 -0
- data/public/admin/stylesheets/global.css +1 -0
- data/public/admin/stylesheets/login.css +1 -0
- data/public/admin/stylesheets/wysiwyg-content.css +20 -0
- data/public/admin/stylesheets/wysiwyg.css +1 -0
- data/vendor/cache/more-0.1.1.gem +0 -0
- metadata +216 -0
data/grandstand.gemspec
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{grandstand}
|
|
8
|
+
s.version = "0.2.1"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Flip Sasser"]
|
|
12
|
+
s.date = %q{2010-07-29}
|
|
13
|
+
s.description = %q{
|
|
14
|
+
Grandstand is a simple blog and photo gallery application. It takes a minimal amount of configuration and can
|
|
15
|
+
be built installed as a gem and used like any other thingymagig. It's totally cool.
|
|
16
|
+
}
|
|
17
|
+
s.email = %q{flip@x451.com}
|
|
18
|
+
s.extra_rdoc_files = [
|
|
19
|
+
"README"
|
|
20
|
+
]
|
|
21
|
+
s.files = [
|
|
22
|
+
".gitignore",
|
|
23
|
+
"MIT-LICENSE",
|
|
24
|
+
"README",
|
|
25
|
+
"Rakefile",
|
|
26
|
+
"VERSION",
|
|
27
|
+
"app/controllers/admin/galleries_controller.rb",
|
|
28
|
+
"app/controllers/admin/images_controller.rb",
|
|
29
|
+
"app/controllers/admin/main_controller.rb",
|
|
30
|
+
"app/controllers/admin/pages_controller.rb",
|
|
31
|
+
"app/controllers/admin/posts_controller.rb",
|
|
32
|
+
"app/controllers/admin/sessions_controller.rb",
|
|
33
|
+
"app/controllers/admin/templates_controller.rb",
|
|
34
|
+
"app/controllers/admin/users_controller.rb",
|
|
35
|
+
"app/controllers/galleries_controller.rb",
|
|
36
|
+
"app/controllers/pages_controller.rb",
|
|
37
|
+
"app/controllers/posts_controller.rb",
|
|
38
|
+
"app/helpers/admin/main_helper.rb",
|
|
39
|
+
"app/helpers/admin/pages_helper.rb",
|
|
40
|
+
"app/helpers/admin/posts_helper.rb",
|
|
41
|
+
"app/helpers/admin/sessions_helper.rb",
|
|
42
|
+
"app/helpers/admin/templates_helper.rb",
|
|
43
|
+
"app/helpers/admin/users_helper.rb",
|
|
44
|
+
"app/helpers/pages_helper.rb",
|
|
45
|
+
"app/helpers/posts_helper.rb",
|
|
46
|
+
"app/helpers/site_helper.rb",
|
|
47
|
+
"app/models/gallery.rb",
|
|
48
|
+
"app/models/image.rb",
|
|
49
|
+
"app/models/page.rb",
|
|
50
|
+
"app/models/page_section.rb",
|
|
51
|
+
"app/models/post.rb",
|
|
52
|
+
"app/models/template.rb",
|
|
53
|
+
"app/models/user.rb",
|
|
54
|
+
"app/stylesheets/_buttons.less",
|
|
55
|
+
"app/stylesheets/_dialogs.less",
|
|
56
|
+
"app/stylesheets/application.less",
|
|
57
|
+
"app/stylesheets/global.less",
|
|
58
|
+
"app/stylesheets/login.less",
|
|
59
|
+
"app/stylesheets/wysiwyg.less",
|
|
60
|
+
"app/views/admin/galleries/_form.html.erb",
|
|
61
|
+
"app/views/admin/galleries/_gallery.html.erb",
|
|
62
|
+
"app/views/admin/galleries/_list.html.erb",
|
|
63
|
+
"app/views/admin/galleries/delete.html.erb",
|
|
64
|
+
"app/views/admin/galleries/edit.html.erb",
|
|
65
|
+
"app/views/admin/galleries/editor.html.erb",
|
|
66
|
+
"app/views/admin/galleries/editor_with_images.html.erb",
|
|
67
|
+
"app/views/admin/galleries/index.html.erb",
|
|
68
|
+
"app/views/admin/galleries/new.html.erb",
|
|
69
|
+
"app/views/admin/galleries/show.html.erb",
|
|
70
|
+
"app/views/admin/images/_form.html.erb",
|
|
71
|
+
"app/views/admin/images/delete.html.erb",
|
|
72
|
+
"app/views/admin/images/edit.html.erb",
|
|
73
|
+
"app/views/admin/images/new.html.erb",
|
|
74
|
+
"app/views/admin/images/upload.html.erb",
|
|
75
|
+
"app/views/admin/main/index.html.erb",
|
|
76
|
+
"app/views/admin/pages/_form.html.erb",
|
|
77
|
+
"app/views/admin/pages/_left.html.erb",
|
|
78
|
+
"app/views/admin/pages/_row.html.erb",
|
|
79
|
+
"app/views/admin/pages/delete.html.erb",
|
|
80
|
+
"app/views/admin/pages/edit.html.erb",
|
|
81
|
+
"app/views/admin/pages/index.html.erb",
|
|
82
|
+
"app/views/admin/pages/new.html.erb",
|
|
83
|
+
"app/views/admin/pages/show.html.erb",
|
|
84
|
+
"app/views/admin/posts/_form.html.erb",
|
|
85
|
+
"app/views/admin/posts/_left.html.erb",
|
|
86
|
+
"app/views/admin/posts/_list.html.erb",
|
|
87
|
+
"app/views/admin/posts/delete.html.erb",
|
|
88
|
+
"app/views/admin/posts/edit.html.erb",
|
|
89
|
+
"app/views/admin/posts/index.html.erb",
|
|
90
|
+
"app/views/admin/posts/new.html.erb",
|
|
91
|
+
"app/views/admin/posts/show.html.erb",
|
|
92
|
+
"app/views/admin/sessions/forgot.html.erb",
|
|
93
|
+
"app/views/admin/sessions/show.html.erb",
|
|
94
|
+
"app/views/admin/shared/_flash.html.erb",
|
|
95
|
+
"app/views/admin/users/_form.html.erb",
|
|
96
|
+
"app/views/admin/users/_left.html.erb",
|
|
97
|
+
"app/views/admin/users/delete.html.erb",
|
|
98
|
+
"app/views/admin/users/edit.html.erb",
|
|
99
|
+
"app/views/admin/users/index.html.erb",
|
|
100
|
+
"app/views/admin/users/new.html.erb",
|
|
101
|
+
"app/views/admin/users/show.html.erb",
|
|
102
|
+
"app/views/galleries/index.html.erb",
|
|
103
|
+
"app/views/galleries/show.html.erb",
|
|
104
|
+
"app/views/layouts/admin.html.erb",
|
|
105
|
+
"app/views/layouts/admin_login.html.erb",
|
|
106
|
+
"app/views/layouts/admin_xhr.html.erb",
|
|
107
|
+
"app/views/pages/show.html.erb",
|
|
108
|
+
"app/views/posts/show.html.erb",
|
|
109
|
+
"app/views/shared/404.html.erb",
|
|
110
|
+
"app/views/shared/gallery.html",
|
|
111
|
+
"app/views/shared/image.html",
|
|
112
|
+
"app/views/shared/page.html",
|
|
113
|
+
"app/views/shared/post.html",
|
|
114
|
+
"grandstand.gemspec",
|
|
115
|
+
"lib/grandstand.rb",
|
|
116
|
+
"lib/grandstand/application.rb",
|
|
117
|
+
"lib/grandstand/controller.rb",
|
|
118
|
+
"lib/grandstand/controller/development.rb",
|
|
119
|
+
"lib/grandstand/helper.rb",
|
|
120
|
+
"lib/grandstand/routes.rb",
|
|
121
|
+
"lib/grandstand/session.rb",
|
|
122
|
+
"public/.DS_Store",
|
|
123
|
+
"public/admin/.DS_Store",
|
|
124
|
+
"public/admin/images/.DS_Store",
|
|
125
|
+
"public/admin/images/background-input.gif",
|
|
126
|
+
"public/admin/images/background-progress-bar.png",
|
|
127
|
+
"public/admin/images/background-progress-complete.gif",
|
|
128
|
+
"public/admin/images/background-progress.gif",
|
|
129
|
+
"public/admin/images/icons/.DS_Store",
|
|
130
|
+
"public/admin/images/icons/add.png",
|
|
131
|
+
"public/admin/images/icons/collapse.png",
|
|
132
|
+
"public/admin/images/icons/delete.png",
|
|
133
|
+
"public/admin/images/icons/edit.png",
|
|
134
|
+
"public/admin/images/icons/editor/bold.png",
|
|
135
|
+
"public/admin/images/icons/editor/gallery.png",
|
|
136
|
+
"public/admin/images/icons/editor/image-center.png",
|
|
137
|
+
"public/admin/images/icons/editor/image-left.png",
|
|
138
|
+
"public/admin/images/icons/editor/image-right.png",
|
|
139
|
+
"public/admin/images/icons/editor/image.png",
|
|
140
|
+
"public/admin/images/icons/editor/italic.png",
|
|
141
|
+
"public/admin/images/icons/editor/ordered-list.png",
|
|
142
|
+
"public/admin/images/icons/editor/quote.png",
|
|
143
|
+
"public/admin/images/icons/editor/source.png",
|
|
144
|
+
"public/admin/images/icons/editor/strikethrough.png",
|
|
145
|
+
"public/admin/images/icons/editor/underline.png",
|
|
146
|
+
"public/admin/images/icons/editor/unordered-list.png",
|
|
147
|
+
"public/admin/images/icons/error.png",
|
|
148
|
+
"public/admin/images/icons/expand.png",
|
|
149
|
+
"public/admin/images/icons/galleries.png",
|
|
150
|
+
"public/admin/images/icons/gallery.png",
|
|
151
|
+
"public/admin/images/icons/image.png",
|
|
152
|
+
"public/admin/images/icons/okay.png",
|
|
153
|
+
"public/admin/images/icons/pages.png",
|
|
154
|
+
"public/admin/images/icons/posts.png",
|
|
155
|
+
"public/admin/images/icons/upload.png",
|
|
156
|
+
"public/admin/images/icons/users.png",
|
|
157
|
+
"public/admin/images/logo.png",
|
|
158
|
+
"public/admin/images/spinner-dark.gif",
|
|
159
|
+
"public/admin/images/uploader.swf",
|
|
160
|
+
"public/admin/javascripts/application.js",
|
|
161
|
+
"public/admin/javascripts/jquery.js",
|
|
162
|
+
"public/admin/javascripts/mustache.js",
|
|
163
|
+
"public/admin/javascripts/selection.js",
|
|
164
|
+
"public/admin/javascripts/string.js",
|
|
165
|
+
"public/admin/javascripts/wysiwyg.js",
|
|
166
|
+
"public/admin/stylesheets/application.css",
|
|
167
|
+
"public/admin/stylesheets/global.css",
|
|
168
|
+
"public/admin/stylesheets/login.css",
|
|
169
|
+
"public/admin/stylesheets/wysiwyg-content.css",
|
|
170
|
+
"public/admin/stylesheets/wysiwyg.css",
|
|
171
|
+
"vendor/cache/more-0.1.1.gem"
|
|
172
|
+
]
|
|
173
|
+
s.homepage = %q{http://github.com/flipsasser/grandstand}
|
|
174
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
|
175
|
+
s.require_paths = ["lib"]
|
|
176
|
+
s.rubygems_version = %q{1.3.7}
|
|
177
|
+
s.summary = %q{A blog / gallery gem for Rails 3 that's dead-simple to configure, override, and rebuild}
|
|
178
|
+
|
|
179
|
+
if s.respond_to? :specification_version then
|
|
180
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
181
|
+
s.specification_version = 3
|
|
182
|
+
|
|
183
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
184
|
+
else
|
|
185
|
+
end
|
|
186
|
+
else
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'rails'
|
|
2
|
+
require 'grandstand'
|
|
3
|
+
|
|
4
|
+
module Grandstand
|
|
5
|
+
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
|
+
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
|
+
|
|
26
|
+
class << self
|
|
27
|
+
def app_name
|
|
28
|
+
@app_name ||= 'Portfoliawesome'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def image_sizes
|
|
32
|
+
{
|
|
33
|
+
:icon => '75x75#',
|
|
34
|
+
:page => '541x'
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def page_sections
|
|
39
|
+
%w(left main)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def s3
|
|
43
|
+
@s3 ||= {
|
|
44
|
+
:bucket => nil,
|
|
45
|
+
:credentials => File.join(Rails.root, 'config', 's3.yml')
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Grandstand
|
|
2
|
+
module Controller
|
|
3
|
+
module Development
|
|
4
|
+
def self.included(base)
|
|
5
|
+
base.before_filter :generate_css_from_less
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
protected
|
|
9
|
+
def generate_css_from_less
|
|
10
|
+
Less::More.generate_all
|
|
11
|
+
end
|
|
12
|
+
protected :generate_css_from_less
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
module Grandstand
|
|
2
|
+
module Controller
|
|
3
|
+
autoload(:Development, 'grandstand/controller/development')
|
|
4
|
+
|
|
5
|
+
def self.included(base)
|
|
6
|
+
base.helper_method :current_page, :current_user, :return_path
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
protected
|
|
10
|
+
# current_page returns a Page instance for any page that exists for the
|
|
11
|
+
# the current requests' URL. Very frequently nil!
|
|
12
|
+
def current_page
|
|
13
|
+
return @_current_page if defined? @_current_page
|
|
14
|
+
@_current_page = Page.where(:url => request.path.reverse.chomp('/').reverse).first
|
|
15
|
+
end
|
|
16
|
+
protected :current_page
|
|
17
|
+
|
|
18
|
+
# Predictably, `current_user` will return the currently logged-in user.
|
|
19
|
+
def current_user
|
|
20
|
+
# 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]
|
|
22
|
+
end
|
|
23
|
+
protected :current_user
|
|
24
|
+
|
|
25
|
+
# not_found is a quick and easy way to render a 404 error page without much overhead.
|
|
26
|
+
# You can pass it options which are just render options that get merged on top of the
|
|
27
|
+
# defaults, which are to render the application layout, with a 404 status, and the
|
|
28
|
+
# shared/404 template. That's it!
|
|
29
|
+
#
|
|
30
|
+
# Also of note, it returns false so you can very easily integrate it into before_filter
|
|
31
|
+
# and do stuff like:
|
|
32
|
+
#
|
|
33
|
+
# class PostsController < ApplicationController
|
|
34
|
+
# before_filter :find_post, :except => :index
|
|
35
|
+
#
|
|
36
|
+
# ...
|
|
37
|
+
#
|
|
38
|
+
# protected
|
|
39
|
+
# def find_post
|
|
40
|
+
# not_found unless @post = Post.first(:conditions => {:id => params[:id]})
|
|
41
|
+
# end
|
|
42
|
+
# end
|
|
43
|
+
#
|
|
44
|
+
def not_found(options = {})
|
|
45
|
+
options = {:layout => 'application', :status => 404, :template => 'shared/404'}.merge(options)
|
|
46
|
+
render options
|
|
47
|
+
false
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Require a user for this action - use as a before filter, as in:
|
|
51
|
+
# before_filter :require_user, :only => [:show]
|
|
52
|
+
def require_user
|
|
53
|
+
# Require a logged in model
|
|
54
|
+
unless current_user
|
|
55
|
+
# Remember where we started
|
|
56
|
+
set_return_path
|
|
57
|
+
# Remember any post variables the user may have sent between logout and now.
|
|
58
|
+
# session[:post_params] = params.except(:controller, :action, :id).merge({:_method => request.method}) unless request.get?
|
|
59
|
+
# Send them off to the correct login path
|
|
60
|
+
redirect_to(admin_session_path) and return false
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# return_path gives you the current return_path as set by set_return_path. Use them
|
|
65
|
+
# together to ensure users are returned to a contextually correct location whenever
|
|
66
|
+
# possible. Also used as a helper method so you can point cancel buttons to the
|
|
67
|
+
# contextually correct resource, e.g.:
|
|
68
|
+
#
|
|
69
|
+
# <% form_for(@post) do |form| %>
|
|
70
|
+
# ...
|
|
71
|
+
# <%= form.submit "Save Post" %> or <%= link_to 'cancel', return_path || posts_path %>
|
|
72
|
+
# <% end %>
|
|
73
|
+
#
|
|
74
|
+
# See set_return_path for more information.
|
|
75
|
+
def return_path
|
|
76
|
+
session[:return_path]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Sets a return path for redirecting users to later on. For example, on a basic CRUD controller,
|
|
80
|
+
# if your user goes straight to "edit" from the index action, chances are they want to return
|
|
81
|
+
# to index when they're done, and likewise for the show action. So:
|
|
82
|
+
#
|
|
83
|
+
# class PostsController < ApplicationController
|
|
84
|
+
# before_filter :set_return_path, :only => [:index, :show]
|
|
85
|
+
#
|
|
86
|
+
# ...
|
|
87
|
+
#
|
|
88
|
+
# def update
|
|
89
|
+
# if @post.update_attributes(params[:post])
|
|
90
|
+
# redirect_to return_path || post_path(@post)
|
|
91
|
+
# else
|
|
92
|
+
# ...
|
|
93
|
+
# end
|
|
94
|
+
# end
|
|
95
|
+
# end
|
|
96
|
+
#
|
|
97
|
+
# 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
|
|
99
|
+
def set_return_path(path = nil)
|
|
100
|
+
session[:return_path] = path || request.fullpath
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
module Grandstand
|
|
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
|
+
# Adds section-oriented class names if a current_page exists. Useful for styling your site to account for the presence
|
|
50
|
+
# 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
|
+
# content in the "right" column, you can add:
|
|
52
|
+
#
|
|
53
|
+
# <body<%= page_class_name %>>
|
|
54
|
+
#
|
|
55
|
+
# and end up with:
|
|
56
|
+
#
|
|
57
|
+
# <body class="has-left">
|
|
58
|
+
#
|
|
59
|
+
# Likewise, you can add your own classes to the page_class_name method if you want to add other classes to the BODY tag, like so:
|
|
60
|
+
#
|
|
61
|
+
# <body<%= page_class_name :simple, 'another-class-name' %>>
|
|
62
|
+
#
|
|
63
|
+
# Which might produce something like:
|
|
64
|
+
#
|
|
65
|
+
# <body class="simple another-class-name has-left has-right">
|
|
66
|
+
#
|
|
67
|
+
# Using this, you can really dig deep into your stylesheets to hide empty columns and more
|
|
68
|
+
def page_class_name(*extras)
|
|
69
|
+
class_names = (extras.map(&:to_s) + Array(current_page.try(:class_names))).reject(&:blank?)
|
|
70
|
+
unless class_names.empty?
|
|
71
|
+
%( class="#{class_names.join(' ')}")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Displays formatted content for a page section based on its 'filter' attribute. Useful for rendering individual
|
|
76
|
+
# page sections (if you're feeling so bold). It's probably easier to user page_section instead.
|
|
77
|
+
def page_content(page_section)
|
|
78
|
+
case page_section.filter
|
|
79
|
+
when 'markdown'
|
|
80
|
+
markdown(page_section.content)
|
|
81
|
+
when 'textfile'
|
|
82
|
+
textile(page_section.content)
|
|
83
|
+
else
|
|
84
|
+
simple_format(page_section.content)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# page_section can be used to check for content in a certain area of your layout, and to render it as well. It will
|
|
89
|
+
# return nil if there is no content for that section - so use it to quickly scope out sections and add them to your
|
|
90
|
+
# layout when present, e.g.:
|
|
91
|
+
#
|
|
92
|
+
# <% if page_section(:left) -%>
|
|
93
|
+
# <div id="left">
|
|
94
|
+
# <%= page_section(:left) %>
|
|
95
|
+
# <!-- Add other content that might go here -->
|
|
96
|
+
# </div>
|
|
97
|
+
# <% end -%>
|
|
98
|
+
#
|
|
99
|
+
def page_section(section_name)
|
|
100
|
+
return nil unless current_page
|
|
101
|
+
section_name = section_name.to_sym
|
|
102
|
+
@_page_sections ||= {}
|
|
103
|
+
return @_page_sections[section_name] if @_page_sections.has_key?(section_name)
|
|
104
|
+
if current_page.page_sections.respond_to?(section_name) && !current_page.page_sections.send(section_name).empty?
|
|
105
|
+
@_page_sections[section_name] = current_page.page_sections.send(section_name).map {|page_section| page_content(page_section) }.join("\n\n")
|
|
106
|
+
else
|
|
107
|
+
@_page_sections[section_name] = nil
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def page_title(separator = '|')
|
|
112
|
+
if object = @post || @_page
|
|
113
|
+
"#{object.name} #{separator}"
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Grandstand::Application.routes.draw do |map|
|
|
2
|
+
resources :galleries, :only => [:index, :show]
|
|
3
|
+
match ':year/:month/:id', :to => 'posts#show', :as => 'post', :constraints => {:year => /\d\d\d\d/, :month => /\d{1,2}/}
|
|
4
|
+
|
|
5
|
+
namespace :admin do
|
|
6
|
+
resource :session do
|
|
7
|
+
member do
|
|
8
|
+
get :forgot
|
|
9
|
+
post :reset
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
root :to => 'main#index'
|
|
14
|
+
get 'expand', :to => 'main#expand'
|
|
15
|
+
|
|
16
|
+
resources :galleries do
|
|
17
|
+
collection do
|
|
18
|
+
post :reorder
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
member do
|
|
22
|
+
get :delete
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
resources :images, :except => [:show] do
|
|
26
|
+
collection do
|
|
27
|
+
post :reorder
|
|
28
|
+
get :upload
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
member do
|
|
32
|
+
get :delete
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
resources :pages do
|
|
38
|
+
member do
|
|
39
|
+
get :delete
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
resources :posts do
|
|
44
|
+
member do
|
|
45
|
+
get :delete
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
resources :templates
|
|
50
|
+
|
|
51
|
+
resources :users do
|
|
52
|
+
member do
|
|
53
|
+
get :delete
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
match '*url', :to => 'pages#show', :as => 'page'
|
|
59
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'rack/utils'
|
|
2
|
+
|
|
3
|
+
module Grandstand
|
|
4
|
+
class Session
|
|
5
|
+
def initialize(app, session_key = '_session_id')
|
|
6
|
+
@app = app
|
|
7
|
+
@session_key = session_key
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def call(env)
|
|
11
|
+
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/ && env['PATH_INFO'] =~ /^\/admin\/galleries\/\d+\/images$/
|
|
12
|
+
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"
|
|
21
|
+
end
|
|
22
|
+
@app.call(env)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/grandstand.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'grandstand/application'
|
|
2
|
+
|
|
3
|
+
module Grandstand
|
|
4
|
+
autoload(:Controller, 'grandstand/controller')
|
|
5
|
+
autoload(:Helper, 'grandstand/helper')
|
|
6
|
+
|
|
7
|
+
def self.initialize!(config = nil)
|
|
8
|
+
if defined?(ActionController)
|
|
9
|
+
ActionController::Base.send :include, Grandstand::Controller
|
|
10
|
+
if Rails.env.development?
|
|
11
|
+
ActionController::Base.send :include, Grandstand::Controller::Development
|
|
12
|
+
# Tell Less to produce the smallest stylesheets it's capable of
|
|
13
|
+
Less::More.compression = true
|
|
14
|
+
Less::More.header = false
|
|
15
|
+
# Point More to our plugins' source_path and our custom admin stylesheets folder
|
|
16
|
+
Less::More.source_path = File.join('vendor', 'plugins', 'grandstand', 'app', 'stylesheets')
|
|
17
|
+
Less::More.destination_path = File.join('admin', 'stylesheets')
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
if defined?(ActionView)
|
|
21
|
+
ActionView::Base.send :include, Grandstand::Helper
|
|
22
|
+
end
|
|
23
|
+
Paperclip.interpolates :padded_id do |attachment, style|
|
|
24
|
+
attachment.instance.id.to_s.rjust(6, '0')
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/public/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|