simple_forum 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +18 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +49 -0
- data/Rakefile +27 -0
- data/app/controllers/simple_forum/application_controller.rb +27 -0
- data/app/controllers/simple_forum/forums_controller.rb +29 -0
- data/app/controllers/simple_forum/posts_controller.rb +114 -0
- data/app/controllers/simple_forum/topics_controller.rb +116 -0
- data/app/models/simple_forum.rb +6 -0
- data/app/models/simple_forum/category.rb +28 -0
- data/app/models/simple_forum/forum.rb +69 -0
- data/app/models/simple_forum/moderatorship.rb +18 -0
- data/app/models/simple_forum/post.rb +105 -0
- data/app/models/simple_forum/topic.rb +134 -0
- data/app/models/simple_forum/user_activity.rb +80 -0
- data/app/views/layouts/simple_forum.html.erb +50 -0
- data/app/views/simple_forum/forums/index.html.erb +76 -0
- data/app/views/simple_forum/forums/show.html.erb +92 -0
- data/app/views/simple_forum/posts/edit.html.erb +41 -0
- data/app/views/simple_forum/topics/_post.html.erb +73 -0
- data/app/views/simple_forum/topics/new.html.erb +23 -0
- data/app/views/simple_forum/topics/show.html.erb +68 -0
- data/config/locales/simple_forum.pl.yml +121 -0
- data/config/routes.rb +44 -0
- data/lib/bb-ruby/bb-ruby.rb +57 -0
- data/lib/generators/simple_forum/install_generator.rb +19 -0
- data/lib/generators/templates/simple_forum.rb +34 -0
- data/lib/simple_forum.rb +52 -0
- data/lib/simple_forum/engine.rb +15 -0
- data/lib/simple_forum/tasks/railties.rake +66 -0
- data/lib/simple_forum/version.rb +4 -0
- metadata +114 -0
data/config/routes.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#SimpleForum::Engine.routes.draw do
|
2
|
+
#
|
3
|
+
# root :to => "simple_forum/forums#index"
|
4
|
+
# match '/asd2' => "simple_forum/forums#index", :as => :aaaa
|
5
|
+
#
|
6
|
+
# # - Make sure our route names are namespaced under regulate_
|
7
|
+
# scope 'forum', :module => :simple_forum, :as => :simple_forum do
|
8
|
+
# match '/asd2' => "simple_forum/forums#index", :as => :bbbb
|
9
|
+
#
|
10
|
+
# resources :forums, :only => [:index, :show] do
|
11
|
+
# resources :topics, :only => [:show], :controller => 'simple_forum/topics' do
|
12
|
+
# resources :posts, :only => [:show, :new, :create], :controller => 'simple_forum/posts' do
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
#
|
19
|
+
#end
|
20
|
+
#
|
21
|
+
|
22
|
+
Rails.application.routes.draw do
|
23
|
+
|
24
|
+
scope SimpleForum.route_namespace, :module => :simple_forum, :as => :simple_forum do
|
25
|
+
|
26
|
+
root :to => 'forums#index', :via => :get
|
27
|
+
|
28
|
+
resources :forums, :only => [:index, :show], :path => 'f' do
|
29
|
+
resources :topics, :only => [:index, :show, :new, :create], :path => 't' do
|
30
|
+
member do
|
31
|
+
post :open
|
32
|
+
post :close
|
33
|
+
end
|
34
|
+
|
35
|
+
resources :posts, :except => [:destroy], :path => 'p' do
|
36
|
+
delete :delete, :on => :member
|
37
|
+
get :preview, :on => :collection
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#overwrite process_tags method, because original one doesn't work with nested tags(like citation)'
|
2
|
+
# also mark returned string as html_safe
|
3
|
+
module BBRuby
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def process_tags(text, tags_alternative_definition={}, escape_html=true, method=:disable, *tags)
|
7
|
+
text = text.dup
|
8
|
+
|
9
|
+
# escape "<, >, &" to remove any html
|
10
|
+
if escape_html
|
11
|
+
text.gsub!('&', '&')
|
12
|
+
text.gsub!('<', '<')
|
13
|
+
text.gsub!('>', '>')
|
14
|
+
end
|
15
|
+
|
16
|
+
tags_definition = @@tags.merge(tags_alternative_definition)
|
17
|
+
|
18
|
+
# parse bbcode tags
|
19
|
+
case method
|
20
|
+
when :enable
|
21
|
+
tags_definition.each_value do |t|
|
22
|
+
if tags.include?(t[4])
|
23
|
+
while text.gsub!(t[0], t[1]) do
|
24
|
+
#nothing
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
when :disable
|
29
|
+
# this works nicely because the default is disable and the default set of tags is [] (so none disabled) :)
|
30
|
+
tags_definition.each_value do |t|
|
31
|
+
unless tags.include?(t[4])
|
32
|
+
while text.gsub!(t[0], t[1]) do
|
33
|
+
#nothing
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
text
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_html_with_html_safe(text, tags_alternative_definition={}, escape_html=true, method=:disable, *tags)
|
43
|
+
text = to_html_without_html_safe(text, tags_alternative_definition, escape_html, method, *tags)
|
44
|
+
text.respond_to?(:html_safe) ? text.html_safe : text
|
45
|
+
end
|
46
|
+
|
47
|
+
alias_method_chain :to_html, :html_safe
|
48
|
+
|
49
|
+
def to_html_with_formatting_with_html_safe(text, tags_alternative_definition={}, escape_html=true, method=:disable, *tags)
|
50
|
+
text = to_html_with_formatting_without_html_safe(text, tags_alternative_definition, escape_html, method, *tags)
|
51
|
+
text.respond_to?(:html_safe) ? text.html_safe : text
|
52
|
+
end
|
53
|
+
|
54
|
+
alias_method_chain :to_html_with_formatting, :html_safe
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SimpleForum
|
2
|
+
|
3
|
+
module Generators
|
4
|
+
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
source_root File.expand_path("../../templates", __FILE__)
|
8
|
+
|
9
|
+
desc "Copies the simple_forum initializer."
|
10
|
+
|
11
|
+
def copy_initializer
|
12
|
+
template "simple_forum.rb", "config/initializers/simple_forum.rb"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
SimpleForum.setup do |config|
|
2
|
+
# The namespace that you would like to use for the routes. The default is 'forum'.
|
3
|
+
# config.route_namespace = 'my_custom_route_namespace'
|
4
|
+
|
5
|
+
# The layout for simple forum views. The default is 'simple_forum'.
|
6
|
+
# config.layout = "application"
|
7
|
+
|
8
|
+
# The name of yours application. It will be shown as root in forum breadcrumbs. The default is ''My application'.
|
9
|
+
# config.root_application_name = "My application name"
|
10
|
+
|
11
|
+
# How long users can edit theirs posts. You can set 0 if users should not edit theirs posts. The default is '15.
|
12
|
+
# config.minutes_for_edit_post = 5
|
13
|
+
|
14
|
+
# How long users can delete theirs posts. You can set 0 if users should not delete theirs posts. The default is '15.
|
15
|
+
# config.minutes_for_delete_post = 5
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
# AbstractAuth Implementations
|
20
|
+
|
21
|
+
#aktualnie zalogowany użytkownik. Default: current_user
|
22
|
+
#AbstractAuth.implement :authenticated_user do
|
23
|
+
# current_user
|
24
|
+
#end
|
25
|
+
|
26
|
+
#Czy użytkownik jest zalogowany. Default: user_signed_in?
|
27
|
+
#AbstractAuth.implement :user_authenticated? do
|
28
|
+
# user_signed_in?
|
29
|
+
#end
|
30
|
+
|
31
|
+
#Model użytkownika. Default: User"
|
32
|
+
#AbstractAuth.implement :user_class do
|
33
|
+
# User
|
34
|
+
#end
|
data/lib/simple_forum.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'abstract_auth'
|
2
|
+
require 'bb-ruby'
|
3
|
+
require 'bb-ruby/bb-ruby'
|
4
|
+
|
5
|
+
module SimpleForum
|
6
|
+
|
7
|
+
AbstractAuth.setup do |config|
|
8
|
+
config.requires :user_class
|
9
|
+
|
10
|
+
#default authenticated_user implementation
|
11
|
+
config.implement :user_class do
|
12
|
+
User
|
13
|
+
end
|
14
|
+
|
15
|
+
config.requires :authenticated_user
|
16
|
+
|
17
|
+
#default authenticated_user implementation
|
18
|
+
config.implement :authenticated_user do
|
19
|
+
current_user
|
20
|
+
end
|
21
|
+
|
22
|
+
config.requires :user_authenticated?
|
23
|
+
|
24
|
+
#default authenticated_user implementation
|
25
|
+
config.implement :user_authenticated? do
|
26
|
+
user_signed_in?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
mattr_accessor :route_namespace
|
31
|
+
@@route_namespace = "forum"
|
32
|
+
|
33
|
+
mattr_accessor :layout
|
34
|
+
@@layout = "simple_forum"
|
35
|
+
|
36
|
+
mattr_accessor :root_application_name
|
37
|
+
@@root_application_name = "My Application"
|
38
|
+
|
39
|
+
mattr_accessor :minutes_for_edit_post
|
40
|
+
@@minutes_for_edit_post = 15
|
41
|
+
|
42
|
+
mattr_accessor :minutes_for_delete_post
|
43
|
+
@@minutes_for_delete_post = 15
|
44
|
+
|
45
|
+
# Yield self on setup for nice config blocks
|
46
|
+
def self.setup
|
47
|
+
yield self
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
require 'simple_forum/engine' if defined?(Rails)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "simple_forum"
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
module SimpleForum
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
# isolate_namespace SimpleForum
|
7
|
+
initializer "static assets" do |app|
|
8
|
+
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
|
9
|
+
end
|
10
|
+
|
11
|
+
rake_tasks do
|
12
|
+
load "simple_forum/tasks/railties.rake"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#TODO delete this file when Rails 3.1 will be released!
|
2
|
+
require 'active_record/migration'
|
3
|
+
|
4
|
+
namespace :simple_forum do
|
5
|
+
namespace :install do
|
6
|
+
desc "-"
|
7
|
+
task :assets => :rails_env do
|
8
|
+
require 'rails/generators/base'
|
9
|
+
Rails.application.initialize!
|
10
|
+
|
11
|
+
app_public_path = Rails.application.paths["public"].first
|
12
|
+
|
13
|
+
|
14
|
+
railtie = Rails.application.railties.all.detect { |r| r.respond_to?(:railtie_name) ? r.railtie_name == 'simple_forum_engine' : r.class == SimpleForum::Engine }
|
15
|
+
|
16
|
+
path = railtie.paths["public"].first
|
17
|
+
Rails::Generators::Base.source_root(path)
|
18
|
+
copier = Rails::Generators::Base.new
|
19
|
+
Dir[File.join(path, "**/*")].each do |file|
|
20
|
+
relative = file.gsub(/^#{path}\//, '')
|
21
|
+
if File.file?(file)
|
22
|
+
copier.copy_file relative, File.join(app_public_path, 'simple_forum_engine', relative)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "-"
|
28
|
+
task :migrations => :"db:load_config" do
|
29
|
+
to_load = ['simple_forum_engine']
|
30
|
+
railties = {}
|
31
|
+
railtie = Rails.application.railties.all.detect { |r| r.respond_to?(:railtie_name) ? r.railtie_name == 'simple_forum_engine' : r.class == SimpleForum::Engine }
|
32
|
+
|
33
|
+
if railtie.respond_to?(:paths) && (path = railtie.paths["db/migrate"].first)
|
34
|
+
railties['simple_forum_engine'] = path
|
35
|
+
end
|
36
|
+
|
37
|
+
on_copy = Proc.new do |name, file, old_path|
|
38
|
+
puts "Copied migration #{file} from #{name}"
|
39
|
+
end
|
40
|
+
|
41
|
+
destination = 'db/migrate'
|
42
|
+
|
43
|
+
FileUtils.mkdir_p(destination) unless File.exists?(destination)
|
44
|
+
|
45
|
+
railties.each do |name, path|
|
46
|
+
source_files = Dir["#{path}/[0-9]*_*.rb"]
|
47
|
+
|
48
|
+
|
49
|
+
source_files.each do |file|
|
50
|
+
new_path = File.join(destination, File.basename(file))
|
51
|
+
old_path = file
|
52
|
+
|
53
|
+
FileUtils.cp(old_path, new_path)
|
54
|
+
on_copy.call(name, file, old_path)
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "-"
|
62
|
+
task :install do
|
63
|
+
Rake::Task["simple_forum:install:migrations"].invoke
|
64
|
+
Rake::Task["simple_forum:install:assets"].invoke
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: simple_forum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Galdomedia
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-20 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: abstract_auth
|
16
|
+
requirement: &18978680 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *18978680
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: will_paginate
|
27
|
+
requirement: &18978180 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.pre2
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *18978180
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: bb-ruby
|
38
|
+
requirement: &18977760 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *18977760
|
47
|
+
description: Insert SimpleForum description.
|
48
|
+
email:
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- app/models/simple_forum.rb
|
54
|
+
- app/models/simple_forum/forum.rb
|
55
|
+
- app/models/simple_forum/post.rb
|
56
|
+
- app/models/simple_forum/moderatorship.rb
|
57
|
+
- app/models/simple_forum/user_activity.rb
|
58
|
+
- app/models/simple_forum/topic.rb
|
59
|
+
- app/models/simple_forum/category.rb
|
60
|
+
- app/controllers/simple_forum/application_controller.rb
|
61
|
+
- app/controllers/simple_forum/topics_controller.rb
|
62
|
+
- app/controllers/simple_forum/forums_controller.rb
|
63
|
+
- app/controllers/simple_forum/posts_controller.rb
|
64
|
+
- app/views/layouts/simple_forum.html.erb
|
65
|
+
- app/views/simple_forum/forums/show.html.erb
|
66
|
+
- app/views/simple_forum/forums/index.html.erb
|
67
|
+
- app/views/simple_forum/topics/show.html.erb
|
68
|
+
- app/views/simple_forum/topics/new.html.erb
|
69
|
+
- app/views/simple_forum/topics/_post.html.erb
|
70
|
+
- app/views/simple_forum/posts/edit.html.erb
|
71
|
+
- lib/simple_forum.rb
|
72
|
+
- lib/bb-ruby/bb-ruby.rb
|
73
|
+
- lib/generators/templates/simple_forum.rb
|
74
|
+
- lib/generators/simple_forum/install_generator.rb
|
75
|
+
- lib/simple_forum/version.rb
|
76
|
+
- lib/simple_forum/tasks/railties.rake
|
77
|
+
- lib/simple_forum/engine.rb
|
78
|
+
- config/routes.rb
|
79
|
+
- config/locales/simple_forum.pl.yml
|
80
|
+
- MIT-LICENSE
|
81
|
+
- Rakefile
|
82
|
+
- Gemfile
|
83
|
+
- README.rdoc
|
84
|
+
homepage:
|
85
|
+
licenses: []
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
hash: -1789205060122559928
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
hash: -1789205060122559928
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 1.8.15
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: Insert SimpleForum summary.
|
114
|
+
test_files: []
|