forem 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +166 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +33 -0
- data/app/controllers/forem/application_controller.rb +13 -0
- data/app/controllers/forem/forums_controler.rb +11 -0
- data/app/controllers/forem/posts_controller.rb +26 -0
- data/app/controllers/forem/topics_controller.rb +35 -0
- data/app/helpers/forem/application_helper.rb +4 -0
- data/app/models/forem/forum.rb +4 -0
- data/app/models/forem/post.rb +11 -0
- data/app/models/forem/topic.rb +17 -0
- data/app/views/forem/forums/index.html.erb +13 -0
- data/app/views/forem/forums/show.html.erb +3 -0
- data/app/views/forem/posts/_form.html.erb +4 -0
- data/app/views/forem/posts/_post.html.erb +20 -0
- data/app/views/forem/posts/new.html.erb +6 -0
- data/app/views/forem/topics/_form.html.erb +9 -0
- data/app/views/forem/topics/new.html.erb +3 -0
- data/app/views/forem/topics/show.html.erb +6 -0
- data/config/locales/en.yml +23 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20110214221555_create_forums.rb +13 -0
- data/db/migrate/20110221092741_create_topics.rb +11 -0
- data/db/migrate/20110221094502_create_posts.rb +11 -0
- data/db/migrate/20110228084940_add_reply_to_to_posts.rb +5 -0
- data/forem.gemspec +16 -0
- data/lib/forem.rb +4 -0
- data/lib/forem/engine.rb +13 -0
- data/lib/rack/utils_monkey_patch.rb +9 -0
- data/lib/tasks/forem_tasks.rake +4 -0
- data/public/javascripts/application.js +2 -0
- data/public/javascripts/controls.js +965 -0
- data/public/javascripts/dragdrop.js +974 -0
- data/public/javascripts/effects.js +1123 -0
- data/public/javascripts/prototype.js +6082 -0
- data/public/javascripts/rails.js +192 -0
- data/public/stylesheets/.gitkeep +0 -0
- data/script/rails +6 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/fake_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/user.rb +6 -0
- data/spec/dummy/app/views/fake/sign_in.html.erb +7 -0
- data/spec/dummy/app/views/layouts/application.html.erb +17 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +43 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +16 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/migrate/001_create_users.rb +8 -0
- data/spec/dummy/db/schema.rb +43 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6082 -0
- data/spec/dummy/public/javascripts/rails.js +192 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/integration/forums_spec.rb +22 -0
- data/spec/integration/posts_spec.rb +36 -0
- data/spec/integration/topics_spec.rb +71 -0
- data/spec/models/post_spec.rb +16 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/capybara.rb +6 -0
- data/spec/support/capybara_ext.rb +47 -0
- data/spec/support/dummy_login.rb +33 -0
- data/spec/support/factories.rb +45 -0
- data/spec/support/factories/forums.rb +4 -0
- data/spec/support/factories/topics.rb +4 -0
- data/spec/support/routes.rb +5 -0
- metadata +221 -0
@@ -0,0 +1,192 @@
|
|
1
|
+
(function() {
|
2
|
+
// Technique from Juriy Zaytsev
|
3
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
+
function isEventSupported(eventName) {
|
5
|
+
var el = document.createElement('div');
|
6
|
+
eventName = 'on' + eventName;
|
7
|
+
var isSupported = (eventName in el);
|
8
|
+
if (!isSupported) {
|
9
|
+
el.setAttribute(eventName, 'return;');
|
10
|
+
isSupported = typeof el[eventName] == 'function';
|
11
|
+
}
|
12
|
+
el = null;
|
13
|
+
return isSupported;
|
14
|
+
}
|
15
|
+
|
16
|
+
function isForm(element) {
|
17
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM';
|
18
|
+
}
|
19
|
+
|
20
|
+
function isInput(element) {
|
21
|
+
if (Object.isElement(element)) {
|
22
|
+
var name = element.nodeName.toUpperCase();
|
23
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA';
|
24
|
+
}
|
25
|
+
else return false;
|
26
|
+
}
|
27
|
+
|
28
|
+
var submitBubbles = isEventSupported('submit'),
|
29
|
+
changeBubbles = isEventSupported('change');
|
30
|
+
|
31
|
+
if (!submitBubbles || !changeBubbles) {
|
32
|
+
// augment the Event.Handler class to observe custom events when needed
|
33
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
+
function(init, element, eventName, selector, callback) {
|
35
|
+
init(element, eventName, selector, callback);
|
36
|
+
// is the handler being attached to an element that doesn't support this event?
|
37
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
+
// "submit" => "emulated:submit"
|
40
|
+
this.eventName = 'emulated:' + this.eventName;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
);
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!submitBubbles) {
|
47
|
+
// discover forms on the page by observing focus events which always bubble
|
48
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
+
// special handler for the real "submit" event (one-time operation)
|
50
|
+
if (!form.retrieve('emulated:submit')) {
|
51
|
+
form.on('submit', function(submitEvent) {
|
52
|
+
var emulated = form.fire('emulated:submit', submitEvent, true);
|
53
|
+
// if custom event received preventDefault, cancel the real one too
|
54
|
+
if (emulated.returnValue === false) submitEvent.preventDefault();
|
55
|
+
});
|
56
|
+
form.store('emulated:submit', true);
|
57
|
+
}
|
58
|
+
});
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!changeBubbles) {
|
62
|
+
// discover form inputs on the page
|
63
|
+
document.on('focusin', 'input, select, textarea', function(focusEvent, input) {
|
64
|
+
// special handler for real "change" events
|
65
|
+
if (!input.retrieve('emulated:change')) {
|
66
|
+
input.on('change', function(changeEvent) {
|
67
|
+
input.fire('emulated:change', changeEvent, true);
|
68
|
+
});
|
69
|
+
input.store('emulated:change', true);
|
70
|
+
}
|
71
|
+
});
|
72
|
+
}
|
73
|
+
|
74
|
+
function handleRemote(element) {
|
75
|
+
var method, url, params;
|
76
|
+
|
77
|
+
var event = element.fire("ajax:before");
|
78
|
+
if (event.stopped) return false;
|
79
|
+
|
80
|
+
if (element.tagName.toLowerCase() === 'form') {
|
81
|
+
method = element.readAttribute('method') || 'post';
|
82
|
+
url = element.readAttribute('action');
|
83
|
+
// serialize the form with respect to the submit button that was pressed
|
84
|
+
params = element.serialize({ submit: element.retrieve('rails:submit-button') });
|
85
|
+
// clear the pressed submit button information
|
86
|
+
element.store('rails:submit-button', null);
|
87
|
+
} else {
|
88
|
+
method = element.readAttribute('data-method') || 'get';
|
89
|
+
url = element.readAttribute('href');
|
90
|
+
params = {};
|
91
|
+
}
|
92
|
+
|
93
|
+
new Ajax.Request(url, {
|
94
|
+
method: method,
|
95
|
+
parameters: params,
|
96
|
+
evalScripts: true,
|
97
|
+
|
98
|
+
onCreate: function(response) { element.fire("ajax:create", response); },
|
99
|
+
onComplete: function(response) { element.fire("ajax:complete", response); },
|
100
|
+
onSuccess: function(response) { element.fire("ajax:success", response); },
|
101
|
+
onFailure: function(response) { element.fire("ajax:failure", response); }
|
102
|
+
});
|
103
|
+
|
104
|
+
element.fire("ajax:after");
|
105
|
+
}
|
106
|
+
|
107
|
+
function insertHiddenField(form, name, value) {
|
108
|
+
form.insert(new Element('input', { type: 'hidden', name: name, value: value }));
|
109
|
+
}
|
110
|
+
|
111
|
+
function handleMethod(element) {
|
112
|
+
var method = element.readAttribute('data-method'),
|
113
|
+
url = element.readAttribute('href'),
|
114
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
115
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
116
|
+
|
117
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
118
|
+
$(element.parentNode).insert(form);
|
119
|
+
|
120
|
+
if (method !== 'post') {
|
121
|
+
insertHiddenField(form, '_method', method);
|
122
|
+
}
|
123
|
+
|
124
|
+
if (csrf_param) {
|
125
|
+
insertHiddenField(form, csrf_param.readAttribute('content'), csrf_token.readAttribute('content'));
|
126
|
+
}
|
127
|
+
|
128
|
+
form.submit();
|
129
|
+
}
|
130
|
+
|
131
|
+
function disableFormElements(form) {
|
132
|
+
form.select('input[type=submit][data-disable-with]').each(function(input) {
|
133
|
+
input.store('rails:original-value', input.getValue());
|
134
|
+
input.setValue(input.readAttribute('data-disable-with')).disable();
|
135
|
+
});
|
136
|
+
}
|
137
|
+
|
138
|
+
function enableFormElements(form) {
|
139
|
+
form.select('input[type=submit][data-disable-with]').each(function(input) {
|
140
|
+
input.setValue(input.retrieve('rails:original-value')).enable();
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
function allowAction(element) {
|
145
|
+
var message = element.readAttribute('data-confirm');
|
146
|
+
return !message || confirm(message);
|
147
|
+
}
|
148
|
+
|
149
|
+
document.on('click', 'a[data-confirm], a[data-remote], a[data-method]', function(event, link) {
|
150
|
+
if (!allowAction(link)) {
|
151
|
+
event.stop();
|
152
|
+
return false;
|
153
|
+
}
|
154
|
+
|
155
|
+
if (link.readAttribute('data-remote')) {
|
156
|
+
handleRemote(link);
|
157
|
+
event.stop();
|
158
|
+
} else if (link.readAttribute('data-method')) {
|
159
|
+
handleMethod(link);
|
160
|
+
event.stop();
|
161
|
+
}
|
162
|
+
});
|
163
|
+
|
164
|
+
document.on("click", "form input[type=submit], form button[type=submit], form button:not([type])", function(event, button) {
|
165
|
+
// register the pressed submit button
|
166
|
+
event.findElement('form').store('rails:submit-button', button.name || false);
|
167
|
+
});
|
168
|
+
|
169
|
+
document.on("submit", function(event) {
|
170
|
+
var form = event.findElement();
|
171
|
+
|
172
|
+
if (!allowAction(form)) {
|
173
|
+
event.stop();
|
174
|
+
return false;
|
175
|
+
}
|
176
|
+
|
177
|
+
if (form.readAttribute('data-remote')) {
|
178
|
+
handleRemote(form);
|
179
|
+
event.stop();
|
180
|
+
} else {
|
181
|
+
disableFormElements(form);
|
182
|
+
}
|
183
|
+
});
|
184
|
+
|
185
|
+
document.on('ajax:create', 'form', function(event, form) {
|
186
|
+
if (form == event.findElement()) disableFormElements(form);
|
187
|
+
});
|
188
|
+
|
189
|
+
document.on('ajax:complete', 'form', function(event, form) {
|
190
|
+
if (form == event.findElement()) enableFormElements(form);
|
191
|
+
});
|
192
|
+
})();
|
File without changes
|
data/script/rails
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
4
|
+
|
5
|
+
ENGINE_PATH = File.expand_path('../..', __FILE__)
|
6
|
+
load File.expand_path('../../spec/dummy/script/rails', __FILE__)
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag :all %>
|
6
|
+
<%= javascript_include_tag :defaults %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<% flash.each do |key, message| %>
|
11
|
+
<div id='flash_<%= key %>'><%= message %></div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= yield %>
|
15
|
+
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require
|
6
|
+
require "forem"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
15
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
16
|
+
|
17
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
18
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
19
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
20
|
+
|
21
|
+
# Activate observers that should always be running.
|
22
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
+
|
24
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
+
|
28
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
+
# config.i18n.default_locale = :de
|
31
|
+
|
32
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
33
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
34
|
+
|
35
|
+
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
37
|
+
config.encoding = "utf-8"
|
38
|
+
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
40
|
+
config.filter_parameters += [:password]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/development.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
19
|
+
|
20
|
+
# Print deprecation notices to the Rails logger
|
21
|
+
config.active_support.deprecation = :log
|
22
|
+
|
23
|
+
# Only use best-standards-support built into browsers
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
45
|
+
config.i18n.fallbacks = true
|
46
|
+
|
47
|
+
# Send deprecation notices to registered listeners
|
48
|
+
config.active_support.deprecation = :notify
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|