Changesets can be listed by changeset number.
The Git repository is here.
Changeset 9
Reverting to the Tarball version of RForum. The prototype RISC OS Open
Ltd web site used a HEAD revision of RForum from RForum's SVN but this
specific revision was not recorded, so the changes are unknown. I'm
going to separately apply the current HEAD as a patch to the rolled
back Tarball revision, and apply the RISC OS Open Ltd site version as
a patch, then attempt to merge the latter to the former. If this fails
I'll revert to my original strategy - take the Tarball, commit HEAD,
then commit the web site version (which will implicitly revert to a
slightly earlier RForum version).
- Comitted by: adh
- Date: Saturday July 22 19:57:27 2006 (over 18 years ago)
Affected files:
- rool/rails/rforum/trunk/attachments/
- rool/rails/rforum/trunk/public/skins/default/
- rool/rails/rforum/trunk/public/skins/ice/
- rool/rails/rforum/trunk/public/skins/mikrocontroller.net/
- rool/rails/rforum/trunk/vendor/
- rool/rails/rforum/trunk/app/controllers/attachment_controller.rb
- rool/rails/rforum/trunk/app/models/site.rb
- rool/rails/rforum/trunk/app/views/sidebar.rhtml
- rool/rails/rforum/trunk/db/migrate/005_add_site_table.rb
- rool/rails/rforum/trunk/db/migrate/006_add_readonly_field_to_forum.rb
- rool/rails/rforum/trunk/db/migrate/007_add_ml_from_address_to_forum.rb
- rool/rails/rforum/trunk/db/migrate/009_add_user_activated.rb
- rool/rails/rforum/trunk/db/migrate/010_add_created_at_to_session_table.rb
- rool/rails/rforum/trunk/db/migrate/011_capitalize_user_realnames.rb
- rool/rails/rforum/trunk/lang/cn.yaml
- rool/rails/rforum/trunk/lang/ro.yaml
- rool/rails/rforum/trunk/lib/mysql_session.rb
- rool/rails/rforum/trunk/lib/postgresql_session.rb
- rool/rails/rforum/trunk/lib/sql_session_store.rb
- rool/rails/rforum/trunk/public/images/comment_add.png
- rool/rails/rforum/trunk/public/images/email.png
- rool/rails/rforum/trunk/script/update_index
- rool/rails/rforum/trunk/test/functional/attachment_controller_test.rb
- rool/rails/rforum/trunk/app/controllers/admin_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/application.rb (diff)
- rool/rails/rforum/trunk/app/controllers/feed_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/forum_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/mailer.rb (diff)
- rool/rails/rforum/trunk/app/controllers/security_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/topic_controller.rb (diff)
- rool/rails/rforum/trunk/app/controllers/user_controller.rb (diff)
- rool/rails/rforum/trunk/app/models/attachment.rb (diff)
- rool/rails/rforum/trunk/app/models/forum.rb (diff)
- rool/rails/rforum/trunk/app/models/post.rb (diff)
- rool/rails/rforum/trunk/app/models/tag.rb (diff)
- rool/rails/rforum/trunk/app/models/user.rb (diff)
- rool/rails/rforum/trunk/app/views/forum/forum.rhtml (diff)
- rool/rails/rforum/trunk/app/views/forum/list.rhtml (diff)
- rool/rails/rforum/trunk/app/views/forum/search.rhtml (diff)
- rool/rails/rforum/trunk/app/views/layouts/default.rhtml (diff)
- rool/rails/rforum/trunk/app/views/topic/_post.rhtml (diff)
- rool/rails/rforum/trunk/app/views/topic/_postform.rhtml (diff)
- rool/rails/rforum/trunk/app/views/user/list.rhtml (diff)
- rool/rails/rforum/trunk/app/views/user/registration_complete.rhtml (diff)
- rool/rails/rforum/trunk/config/app.rb (diff)
- rool/rails/rforum/trunk/config/database.yml (diff)
- rool/rails/rforum/trunk/config/default_site.rb (diff)
- rool/rails/rforum/trunk/config/routes.rb (diff)
- rool/rails/rforum/trunk/lang/de.yaml (diff)
- rool/rails/rforum/trunk/lang/en.yaml (diff)
- rool/rails/rforum/trunk/lib/received_mail.rb (diff)
- rool/rails/rforum/trunk/public/skins/ruby-forum.com/style.css (diff)
- rool/rails/rforum/trunk/public/stylesheets/main.css (diff)
- rool/rails/rforum/trunk/public/stylesheets/print.css (diff)
- rool/rails/rforum/trunk/script/process_mails (diff)
- rool/rails/rforum/trunk/test/functional/topic_controller_test.rb (diff)
- rool/rails/rforum/trunk/test/functional/user_controller_test.rb (diff)
- rool/rails/rforum/trunk/test/test_helper.rb (diff)
- rool/rails/rforum/trunk/test/unit/attachment_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/forum_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/localization_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/post_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/search_ferret_test.rb (diff)
- rool/rails/rforum/trunk/test/unit/user_test.rb (diff)
rool/rails/rforum/trunk/app/controllers/admin_controller.rb:
prev. | current | |
1 | require 'application' | |
2 | ||
class AdminController < ApplicationController | ||
def block_ip |
rool/rails/rforum/trunk/app/controllers/application.rb:
prev. | current | |
require 'navbar' | ||
require 'post_menu' | ||
require 'url_generator' | ||
4 | require_dependency 'mod_application' | |
# The filters added to this controller will be run for all controllers in the application. | ||
# Likewise will all the methods added be available for all controllers. | ||
... | ... | |
include RForum::Localization | ||
layout 'default' | ||
16 | | |
17 | | |
18 | | |
19 | | |
20 | ||
21 | | |
22 | | |
17 | before_filter :check_block, :setup_user, :setup_url_generator, :setup_local | |
after_filter :finish_user, :remember_location | ||
# Default index action: redirect to start page | ||
... | ... | |
@headers["Content-Type"] = "text/html; charset=#{RForum::CONFIG[:web_charset]}" | ||
end | ||
105 | | |
106 | | |
107 | | |
108 | | |
109 | ||
110 | | |
111 | | |
112 | ||
113 | | |
114 | | |
115 | | |
116 | | |
117 | | |
118 | | |
119 | | |
120 | ||
121 | | |
122 | | |
123 | | |
124 | | |
125 | | |
126 | | |
127 | | |
128 | ||
129 | | |
130 | | |
131 | | |
132 | | |
133 | | |
134 | | |
135 | | |
136 | | |
end | ||
module RForum |
rool/rails/rforum/trunk/app/controllers/feed_controller.rb:
prev. | current | |
1 | require 'application' | |
2 | ||
class FeedController < ApplicationController | ||
layout nil | ||
rool/rails/rforum/trunk/app/controllers/forum_controller.rb:
prev. | current | |
1 | require 'application' | |
2 | ||
class ForumController < ApplicationController | ||
helper :forum | ||
#caches_page :index, :forum | ||
... | ... | |
def forum | ||
begin | ||
@forum = Forum.find(@params['id']) | ||
10 | | |
rescue ActiveRecord::RecordNotFound | ||
render_text "Forum not found", 404 | ||
return | ||
... | ... | |
# List all forums. | ||
def list | ||
@title = l(:forum_list_title) | ||
44 | ||
45 | ||
46 | @forums = Forum.find_all(nil, 'position ASC') | |
@forums.each{|f| f['last_post'] = f.get_last_post} | ||
end | ||
... | ... | |
redirect_to :controller => 'forum', :action => 'list' | ||
end | ||
54 | # TODO: move this to another controller? | |
def search | ||
@title = l(:search_title) | ||
57 | @search_by_forum = Post.search_handler.supports_search_by_forum? | |
59 | if RForum::CONFIG[:search] == :disabled | |
60 | # TODO: move to view | |
61 | render_text "search is disabled", 404 | |
62 | return | |
63 | end | |
64 | ||
65 | @forums = Forum.find_all | |
66 | ||
if @params['forums'] | ||
@selected_forums = @params['forums'].collect {|id| id.to_i} | ||
else | ||
@selected_forums = (@forums.collect {|f| f.id}) | ||
end | ||
60 | ||
72 | ||
if @params['query'] | ||
@query = @params['query'] | ||
@page_params = {'query' => @query} | ||
... | ... | |
redirect_to :action => 'list' | ||
end | ||
132 | ||
end |
rool/rails/rforum/trunk/app/controllers/mailer.rb:
prev. | current | |
1 | require 'action_mailer' | |
require 'url_generator' | ||
require 'digest/md5' | ||
require 'received_mail' | ||
... | ... | |
footer = "\n\n-- \nPosted via http://www.ruby-forum.com/." | ||
@body = post.text + footer | ||
55 | ||
if post.author.guest? | ||
57 | | |
58 | | |
57 | @from = (post.author.guest_name || 'Guest').dup | |
58 | @from << " <" + (post.author.guest_email || ("forumpost@" + RForum::CONFIG[:hostname])) + ">" | |
else | ||
60 | | |
61 | | |
60 | @from = "#{post.author.firstname} #{post.author.surname} <#{post.author.email}>" | |
end | ||
64 | | |
65 | | |
66 | | |
67 | | |
68 | | |
69 | | |
@subject = post.subject | ||
@recipients = post.topic.forum.list_address | ||
@sent_on = post.created_at |
rool/rails/rforum/trunk/app/controllers/security_controller.rb:
prev. | current | |
1 | require 'application' | |
2 | ||
class SecurityController < ApplicationController | ||
def access_denied | ||
# TODO log, or notify admin, or something like that |
rool/rails/rforum/trunk/app/controllers/topic_controller.rb:
prev. | current | |
1 | require 'application' | |
2 | ||
class TopicController < ApplicationController | ||
helper :forum | ||
... | ... | |
@title = @topic.subject | ||
@forum = @topic.forum | ||
15 | ||
16 | | |
raise RForum::SecurityError if @topic.hidden? && !@user.can_view_deleted_posts?(@topic) | ||
... | ... | |
else | ||
# Create reply | ||
post = prepare_post_from_params(@params['post']) | ||
36 | ||
post.parent_id = @params['post']['parent_id'] | ||
38 | | |
39 | | |
40 | | |
41 | | |
42 | | |
43 | | |
44 | | |
37 | Post.find(@params['post']['parent_id']).add_reply(post) | |
end | ||
display_post(post) | ||
... | ... | |
end | ||
# if reply_to parameter specified, prepare template inputs for a post editing form | ||
elsif @params['reply_to'] | ||
54 | ||
55 | | |
56 | | |
57 | | |
58 | | |
@no_robots = true | ||
@post = prepare_reply_for_form(@params['reply_to']) | ||
elsif @params['edit'] | ||
... | ... | |
@forum = Forum.find(@params['forum_id']) rescue Forum.find_first | ||
@title = "New post in forum '#{@forum.name}'" | ||
78 | | |
79 | | |
80 | | |
81 | | |
82 | ||
if @params['post'] | ||
# Form submitted | ||
new_post = prepare_post_from_params(@params['post']) | ||
... | ... | |
@post = e.entity | ||
end | ||
else | ||
95 | | |
@post = Post.new | ||
@post.author = @user | ||
end | ||
... | ... | |
redirect_to :action => 'show', :id => topic.id | ||
else | ||
@topic = topic | ||
96 | @forums = Forum.find_all | |
end | ||
end | ||
... | ... | |
# prepare a Post object from a form, update @user with guest_name and guest_email | ||
def prepare_post_from_params(form_attributes) | ||
new_post = Post.new | ||
198 | | |
199 | | |
200 | | |
201 | | |
202 | | |
new_post.subject = form_attributes['subject'] | ||
new_post.text = form_attributes['text'] | ||
rool/rails/rforum/trunk/app/controllers/user_controller.rb:
prev. | current | |
1 | require 'application' | |
2 | ||
class UserController < ApplicationController | ||
def login | ||
... | ... | |
if user | ||
# login successful | ||
@user = user | ||
11 | | |
12 | | |
return_to_last_remembered | ||
else | ||
# login failed |
rool/rails/rforum/trunk/app/models/attachment.rb:
prev. | current | |
def before_save | ||
self.filename.gsub!(/[^a-z_\.\-0-9]/i, '_') | ||
10 | | |
end | ||
def after_save | ||
... | ... | |
File.open(self.file_path, 'w') do |f| | ||
f.write(@data) | ||
end | ||
23 | | |
end | ||
def after_destroy | ||
... | ... | |
end | ||
def get_file_content | ||
43 | | |
File.read self.file_path | ||
end | ||
43 | ||
47 | | |
48 | | |
49 | | |
50 | ||
end |
rool/rails/rforum/trunk/app/models/forum.rb:
prev. | current | |
class Forum < ActiveRecord::Base | ||
has_many :topics, :dependent => true | ||
3 | | |
4 | | |
5 | | |
3 | acts_as_list | |
include ErrorRaising | ||
... | ... | |
# Transaction is necessary here because more than one entity is being | ||
# created if saving of post raises an error (e.g., | ||
# RForum::ValidationError), complete trx must be rolled back | ||
58 | | |
59 | | |
60 | | |
56 | ActiveRecord::Base.transaction(post) do | |
topic = Topic.create('forum_id' => self.id, 'subject' => post.subject) | ||
topic.created_at = topic.updated_at = post.created_at = post.updated_at = (post.created_at or Time.now) | ||
post.topic = topic | ||
... | ... | |
end | ||
def get_last_post | ||
117 | | |
118 | | |
119 | | |
120 | | |
121 | | |
122 | ||
123 | | |
124 | ||
125 | | |
126 | | |
127 | | |
128 | | |
129 | | |
113 | query = <<-EOL | |
114 | SELECT posts.* FROM posts,topics | |
115 | WHERE posts.topic_id = topics.id | |
116 | AND topics.forum_id = #{self.id} | |
117 | AND topics.deleted = 0 | |
118 | AND posts.deleted = 0 | |
119 | ORDER BY posts.created_at DESC | |
120 | LIMIT 1 | |
121 | EOL | |
122 | Post.find_by_sql(query)[0] | |
end | ||
end |
rool/rails/rforum/trunk/app/models/post.rb:
prev. | current | |
belongs_to :parent, :class_name => 'Post', :foreign_key => 'parent_id' | ||
has_many :children, :class_name => 'Post', :foreign_key => 'parent_id' | ||
has_many :post_votes, :dependent => true | ||
20 | has_one :search_index_item, :dependent => true | |
has_many :attachments, :dependent => true | ||
composed_of :guest, :mapping => [ %w(guest_name guest_name), %w(guest_email guest_email) ] | ||
23 | | |
24 | | |
25 | ||
26 | | |
27 | ||
28 | | |
24 | validates_length_of :text, :within => 3..50000, | |
:too_short => 'formerror_text_short', :too_long => 'formerror_text_long' | ||
validates_length_of :subject, :within => 3..60, | ||
:too_short => 'formerror_subject_short', :too_long => 'formerror_subject_long' | ||
validates_uniqueness_of :messageid | ||
31 | cattr_accessor :indexing_disabled | |
32 | @@indexing_disabled = false | |
33 | cattr_accessor :search_handler | |
34 | @@search_handler = self.const_get(RForum::CONFIG[:search_handler]).new | |
35 | ||
include ErrorRaising | ||
... | ... | |
EOL | ||
end | ||
51 | | |
52 | | |
53 | | |
52 | # Find the <tt>count</tt> latest posts. | |
53 | def self.find_latest(count) | |
54 | Post.find_all "deleted = 0", 'created_at DESC, id DESC', count | |
end | ||
# Finds post with specified id, and adds data from corresponding USERS row | ||
... | ... | |
end | ||
# Return an Array of posts matching the query string | ||
123 | | |
124 | | |
125 | | |
126 | | |
127 | | |
128 | | |
129 | | |
130 | | |
124 | def self.search(query, forums, count=1, offset=0) | |
125 | self.search_handler.search(query, forums) | |
end | ||
128 | def self.rebuild_index | |
129 | self.search_handler.rebuild_index | |
130 | end | |
131 | ||
# CALLBACKS | ||
def before_validation | ||
# Guest post | ||
... | ... | |
end | ||
def validate | ||
156 | | |
157 | | |
158 | | |
159 | | |
160 | | |
161 | | |
162 | | |
163 | | |
155 | # applications problems | |
check_mandatory_atributes(:topic_id) | ||
if self.parent_id and self.parent.topic_id != self.topic_id | ||
raise ArgumentError.new("Post ##{self.parent_id} does not belong to topic #{self.topic_id}") | ||
end | ||
169 | | |
170 | | |
171 | | |
172 | ||
errors.add('text', :formerror_text_short) if text.nil? | ||
errors.add('subject', :formerror_subject_short) if subject.nil? | ||
... | ... | |
end | ||
def after_create | ||
201 | | |
202 | | |
203 | | |
204 | | |
205 | ||
# notify users | ||
self.topic.topic_subscriptions.each do |subscription| | ||
subscription.do_notify(self) | ||
end | ||
193 | ||
194 | # send list mails | |
195 | # TODO: check whether this post originates from list | |
196 | if RForum::CONFIG[:deliver_mail] and self.topic.forum.list_address and self.post_method != 'mail' | |
197 | Mailer.deliver_ml_post(self) | |
198 | end | |
end | ||
def before_destroy | ||
... | ... | |
self.topic.update_post_counter | ||
self.topic.subject = self.subject if self.root? | ||
self.topic.save | ||
235 | | |
236 | | |
237 | | |
238 | | |
224 | Post.search_handler.update(self) unless @@indexing_disabled | |
end | ||
# OTHER METHODS | ||
243 | | |
244 | | |
245 | | |
246 | | |
247 | ||
# Add a reply to the current post, and return the saved reply | ||
def add_reply(post) | ||
250 | | |
251 | | |
252 | | |
231 | ActiveRecord::Base.transaction(post) do | |
post.parent = self | ||
post.topic = self.topic | ||
post.save | ||
... | ... | |
a = Attachment.new | ||
a.filename = filename | ||
a.data = data | ||
264 | | |
a.save | ||
244 | self.attachments << a | |
a | ||
end | ||
... | ... | |
if recursive | ||
self.children.each { |child| child.hide(:recursive) } | ||
end | ||
277 | Post.search_handler.delete(self) unless @@indexing_disabled | |
end | ||
def unhide(recursive=false) | ||
... | ... | |
if recursive | ||
self.children.each { |child| child.unhide(:recursive) } | ||
end | ||
286 | ||
287 | Post.search_handler.update(self) unless @@indexing_disabled | |
end | ||
def hidden? |
rool/rails/rforum/trunk/app/models/tag.rb:
prev. | current | |
class Tag < ActiveRecord::Base | ||
has_and_belongs_to_many :topics, :join_table => 'topics_tags' | ||
3 | ||
4 | | |
end |
rool/rails/rforum/trunk/app/models/user.rb:
prev. | current | |
self[attr] = self[attr].to_s.strip.squeeze(' ').chomp | ||
end | ||
50 | | |
51 | | |
self.name.downcase! | ||
self.email.downcase! | ||
self.role = 'User' |
rool/rails/rforum/trunk/app/views/forum/forum.rhtml:
prev. | current | |
<div class="forum"> | ||
<div class="forum"> | ||
3 | <div class="box"> | |
4 | ||
5 | | |
6 | ||
5 | <% if @topics.empty? %> | |
6 | <%=l :forum_is_empty %> | |
7 | <% end %> | |
8 | | |
9 | <table class="topics"> | |
<tr> | ||
<th class="subject">Subject</th> | ||
<th class="replies">Replies</th> | ||
<th class="last-post"><%= l(:last_post) %></th> | ||
</tr> | ||
15 | | |
16 | | |
16 | <% @topics.each do |topic| %> | |
17 | <tr class="<%= 'new-posts' if (@user.is_a? User and (topic['last_read_time'] == nil or topic['last_read_time'] < topic.last_post_created_at)) %> <%= 'deleted-topic' if (topic.hidden?) %>"> | |
<td class="subject"> | ||
<a href="<%=h url_for(:controller => 'topic', :action => 'show', :id => topic.id, :anchor => 'new') %>"><%=h topic.subject %></a><%= ' (' + l(:deleted_topic) + ')' if topic.hidden? %> | ||
</td> | ||
... | ... | |
</tr> | ||
<% end %> | ||
</table> | ||
28 | ||
29 | ||
30 | ||
29 | </div> | |
</div> | ||
</div> |
rool/rails/rforum/trunk/app/views/forum/list.rhtml:
prev. | current | |
<div class="forum"> | ||
<div class="list"> | ||
11 | <div class="box"> | |
<% if @forums.empty? %> | ||
<%=l :no_forums_available %> | ||
<% else %> | ||
15 | | |
16 | | |
17 | | |
18 | | |
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
16 | <table> | |
<% @forums.each do |forum| %> | ||
<tr> | ||
<td class="name-description"> | ||
<a href="<%=h url_for(:controller => 'forum', :action => 'forum', :id => forum.id) %>"><%=h forum.name %></a> | ||
29 | ||
30 | | |
31 | | |
32 | | |
<span class="name"> | ||
<% if @user.admin? %> | ||
... | ... | |
</td> | ||
<td class="lastpost"> | ||
<% if forum.last_post %> | ||
48 | | |
49 | | |
37 | <%= l(:last_post) %>: | |
38 | <a href="<%=h url_for(:controller => 'topic', :action => 'show', :id => forum.last_post.topic_id, :anchor => forum.last_post.id) %>"><%=h format_relative_time(forum.last_post.created_at) %></a> | |
<% end %> | ||
</td> | ||
<td class="topics_num"> | ||
53 | | |
42 | <%= l(:number_of_topics) %>: <%=h forum.get_topics_num %> | |
</td> | ||
<td class="posts_num"> | ||
56 | | |
45 | <%= l(:number_of_posts) %>: <%=h forum.get_posts_num %> | |
</td> | ||
</tr> | ||
<% end %> | ||
... | ... | |
<% end %> | ||
53 | </div> | |
</div> | ||
</div> |
rool/rails/rforum/trunk/app/views/forum/search.rhtml:
prev. | current | |
<form action="<%= url_for() %>"> | ||
<input type="text" name="query" value="<%=h @query %>" /> | ||
11 | <% if @search_by_forum %> | |
12 | <br /> | |
13 | <label><%=h l(:search_in_forums) %></label> | |
14 | <br /> | |
15 | <select name="forums[]" size="<%= [5, @forums.size].min %>" multiple="multiple"> | |
16 | <%= options_from_collection_for_select(@forums, :id, :name, @selected_forums) %> | |
17 | </select> | |
18 | <% end %> | |
19 | ||
<br /> | ||
12 | | |
13 | | |
14 | | |
15 | | |
16 | | |
17 | | |
18 | | |
<input type="submit" value="Search" /> | ||
</form> | ||
<% end %> | ||
... | ... | |
<table class="searchresults"> | ||
<% @results.each do |result| %> | ||
<tr> | ||
34 | | |
36 | <td class="subject"><%= link_to result.subject, :controller => 'topic', :action => 'show', :id => result.topic_id, :anchor => result.id %></td> | |
<td class="text"> | ||
<%= searchresult_text_excerpt(result.text, @query) %> | ||
</td> |
rool/rails/rforum/trunk/app/views/layouts/default.rhtml:
prev. | current | |
<link type="text/css" rel="stylesheet" href="/stylesheets/syntax.css" /> | ||
<link type="text/css" rel="stylesheet" media="print" href="/stylesheets/print.css" /> | ||
13 | | |
14 | | |
13 | <% if RForum::CONFIG[:skin] %> | |
14 | <link type="text/css" rel="stylesheet" href="/skins/<%= h RForum::CONFIG[:skin] %>/style.css" /> | |
<% end %> | ||
<link rel="alternate" type="application/atom+xml" title="<%= l(:feed_description_global) %>" href="/feed/global" /> | ||
... | ... | |
</div>--> | ||
</div> | ||
47 | ||
48 | ||
</body> | ||
</html> |
rool/rails/rforum/trunk/app/views/topic/_post.rhtml:
prev. | current | |
1 | ||
1 | <a name="<%=h post.id %>"></a> | |
2 | ||
3 | <% if @last_read_at and post.created_at > @last_read_at %> | |
<a name="new"></a> | ||
3 | | |
<% end %> | ||
<!-- The class "new" is added if this is an unread post. --> | ||
<div class="post box <%= "new-post" if @last_read_at and post.created_at > @last_read_at %> <%= "deleted-post" if post.hidden? %>"> | ||
<div class="subject"> | ||
10 | | |
11 | <strong><%=h post.subject %><%= ' (' + l(:deleted_post) + ')' if post.hidden? %></strong> | |
</div> | ||
<div class="info"> | ||
<div class="author"> | ||
15 | | |
16 | Posted by | |
<span class="name"> | ||
<% if post.user_id == nil %> | ||
<%= h post.get_display_name %> (Guest) | ||
... | ... | |
on <%=h format_datetime(post.created_at) %> | ||
</div> | ||
41 | | |
42 | | |
43 | | |
44 | | |
45 | | |
46 | | |
47 | | |
<% if post.post_method == 'mail' %> | ||
49 | | |
43 | <img src="/images/mail.gif" alt="(<%= l(:received_by_mail) %>)" title="<%= l(:received_by_mail) %>" /> | |
<% end %> | ||
</div> | ||
rool/rails/rforum/trunk/app/views/topic/_postform.rhtml:
prev. | current | |
<div class="postform box"> | ||
<a name="postform"></a> | ||
3 | | |
3 | <form action="<%= url_for(:action => @params['action'], :id => @params['id'], :anchor => 'postform') %>" method="post"> | |
<input type="hidden" name="dummy" value="ie-workaround" /> | ||
<table> | ||
... | ... | |
<% end %> | ||
<%= form_input(:text_field, 'post', 'subject', 'Subject', 'size' => '60', 'maxlength' => '60') %> | ||
26 | | |
<%= form_input(:text_area, 'post', 'text', 'Text', 'cols' => 80, 'rows' => 24, 'wrap' => 'virtual') %> | ||
28 | ||
<%= form_input(:submit_button, 'post', 'submit', 'Submit') %> | ||
</table> | ||
</form> |
rool/rails/rforum/trunk/app/views/user/list.rhtml:
prev. | current | |
1 | ||
2 | ||
1 | <div class="box"> | |
2 | <% if @users.empty? %> | |
<%=l :no_users_registered %> | ||
<% else %> | ||
6 | | |
6 | <table> | |
<tr> | ||
<th class="id">#</th> | ||
<th class="name"><%=l :user_name %></th> | ||
... | ... | |
</table> | ||
<% end %> | ||
31 | ||
31 | </div> | |
rool/rails/rforum/trunk/app/views/user/registration_complete.rhtml:
prev. | current | |
<div class="register"> | ||
2 | | |
3 | | |
4 | | |
5 | | |
2 | <p><%=h l(:registration_complete_text) %></p> | |
3 | <p><%=h l(:registration_email_sent, @new_user.email) %></p> | |
</div> |
rool/rails/rforum/trunk/config/app.rb:
prev. | current | |
# Load site specific parameters | ||
2 | ||
2 | begin | |
3 | require File.join(RAILS_ROOT, 'config/site') | |
4 | rescue LoadError | |
5 | STDERR.puts 'WARNING: config/site.rb not found, using default settings from config/default_site.rb' | |
require File.join(RAILS_ROOT, 'config/default_site') | ||
4 | ||
5 | | |
6 | | |
7 | | |
8 | | |
9 | | |
10 | | |
end | ||
if RForum::CONFIG[:web_charset] == 'utf-8' |
rool/rails/rforum/trunk/config/database.yml:
prev. | current | |
# SQLite is enabled by default. Remember to change the dbfile path. | ||
production: | ||
3 | | |
3 | adapter: sqlite | |
dbfile: /tmp/rforum_prod.db | ||
# Uncomment this section for MySQL: | ||
... | ... | |
# The following settings are only used for testing and development. | ||
development: | ||
24 | | |
24 | adapter: sqlite | |
dbfile: /tmp/rforum_dev.db | ||
test: | ||
28 | | |
29 | | |
28 | adapter: sqlite | |
29 | dbfile: /tmp/rforum_test.db |
rool/rails/rforum/trunk/config/default_site.rb:
prev. | current | |
:db_charset => 'utf-8', | ||
:mail_charset => 'utf-8', | ||
33 | # Configure the forum search function. | |
34 | # Possible values: | |
35 | # - SearchFerret (recommended, needs Ferret extension) | |
36 | # - SearchOdeum (no forum-limited search, needs RubyOdeum extension) | |
37 | # - SearchLike (slow, no additional extensions needed) | |
38 | :search_handler => :SearchLike, | |
:search_results_per_page => 40, | ||
:topics_per_page => 40, | ||
... | ... | |
:accept_mail_from_guests => true, | ||
51 | | |
52 | | |
53 | ||
54 | | |
57 | # Path relative to root directory. This has no effect at the moment. | |
58 | :attachment_path => '/public/attachments', | |
# Formatting of posts with quoting. | ||
# :simple is fixed with and with colored quoting levels | ||
... | ... | |
# added to the URL and sent to the user by email. Such token allows the user to perform certain | ||
# security-sensitive activities without providing a password. This token will expire | ||
# after the number of hours specified by the parameter below. | ||
65 | | |
66 | ||
67 | | |
68 | ||
69 | | |
69 | :security_token_life_hours => 24 | |
} | ||
# Mailer configuration |
rool/rails/rforum/trunk/config/routes.rb:
prev. | current | |
:requirements => {:id => /^[0-9]+$/} | ||
map.connect 'forum/:id', :controller => 'forum', :action => 'forum', | ||
:requirements => {:id => /^[0-9]+$/} | ||
7 | | |
8 | | |
9 | | |
map.connect ':controller/:action/:id' | ||
map.connect ':controller/:action' | ||
end |
rool/rails/rforum/trunk/lang/de.yaml:
prev. | current | |
nav_register: Account erstellen | ||
nav_user_list: Benutzerliste | ||
21 | ||
22 | ||
23 | ||
24 | ||
25 | ||
26 | ||
postmenu_reply_to: Antwort mit Zitat | ||
postmenu_move_topic: Thread verschieben | ||
postmenu_delete_post: Löschen | ||
... | ... | |
no_users_registered: Keine Benutzer registriert. | ||
no_forums_to_search: Es sind keine Foren zum Durchsuchen vorhanden. | ||
120 | ||
114 | search_in_forums: "Suchen in: (Strg oder Command-Taste drücken um mehrere Foren auuszuwählen)" | |
search_no_result: Keine passenden Beiträge gefunden. | ||
create_forum_title: Forum erstellen |
rool/rails/rforum/trunk/lang/en.yaml:
prev. | current | |
nav_register: Register | ||
nav_user_list: User List | ||
19 | ||
20 | ||
21 | ||
22 | ||
23 | ||
24 | ||
postmenu_reply_to: Reply with quote | ||
postmenu_move_topic: Move | ||
postmenu_delete_post: Delete |
rool/rails/rforum/trunk/lib/received_mail.rb:
prev. | current | |
return user | ||
else | ||
name = TMail::Address.parse(self['from'].to_s).phrase | ||
15 | | |
if name.nil? || name.size < 2 | ||
name = 'unknown' | ||
end |
rool/rails/rforum/trunk/public/skins/ruby-forum.com/style.css:
prev. | current | |
.box { | ||
background-repeat: repeat-x; | ||
background-image: url(/skins/ruby-forum.com/images/post-background.png); | ||
12 | -moz-border-radius: 8px; | |
13 | border-radius: 8px; | |
} | ||
.forum .post .text { | ||
... | ... | |
.adfooter { | ||
margin-top: 5ex; | ||
24 | | |
} | ||
.stats .box { |
rool/rails/rforum/trunk/public/stylesheets/main.css:
prev. | current | |
body | ||
{ | ||
font-family: "Lucida Grande", verdana, arial, helvetica, sans-serif; | ||
6 | | |
6 | font-size: 0.83em; | |
padding: 0 3ex 0 3ex; | ||
margin: 0; | ||
text-align: center; | ||
... | ... | |
a, a:link, a:visited { color: #a00000; text-decoration: none; } | ||
a:hover { text-decoration: underline; } | ||
15 | ||
16 | ||
17 | ||
18 | ||
h1#pageName { | ||
margin: 5px 0 0; | ||
padding: 0; | ||
... | ... | |
h2 { font-size: 18px } | ||
h3 { font-size: 16px } | ||
38 | ||
39 | ||
40 | ||
41 | | |
42 | | |
43 | | |
44 | ||
45 | ||
46 | ||
47 | | |
48 | | |
49 | | |
50 | ||
51 | ||
52 | ||
53 | | |
54 | ||
55 | ||
56 | ||
57 | ||
#container { | ||
59 | | |
60 | | |
35 | max-width: 105ex; | |
text-align: left; | ||
margin: 0 auto 0 auto; | ||
} | ||
... | ... | |
padding-left: 5px; | ||
} | ||
104 | ||
105 | | |
106 | | |
107 | ||
108 | ||
109 | ||
79 | .user .show .user_message textarea { | |
width: 80ex; | ||
height: 15em; | ||
} | ||
114 | ||
115 | ||
84 | .forum .list table { | |
85 | width: 100%; | |
86 | border-collapse: collapse; | |
87 | } | |
88 | ||
89 | .forum .list td { | |
90 | padding: 3px; | |
91 | } | |
92 | ||
93 | .forum .list .name { | |
font-weight: bold; | ||
} | ||
119 | ||
97 | .forum .list .description { | |
font-size: 0.8em; | ||
} | ||
123 | ||
101 | .forum .list .edit { | |
font-size: smaller; | ||
font-weight: normal; | ||
} | ||
/* Forum view */ | ||
129 | ||
107 | .forum .forum table { | |
108 | width: 100%; | |
109 | border-collapse: collapse; | |
110 | } | |
111 | ||
112 | .forum .forum td.subject { | |
width: 50%; | ||
} | ||
133 | ||
134 | | |
135 | | |
136 | ||
137 | ||
138 | ||
139 | ||
140 | | |
141 | ||
142 | ||
143 | ||
144 | | |
145 | ||
146 | ||
147 | ||
148 | | |
149 | ||
150 | ||
151 | ||
152 | | |
153 | ||
154 | ||
155 | ||
156 | | |
157 | ||
158 | ||
159 | ||
160 | ||
161 | ||
116 | .forum .forum .topics .last-post { | |
padding-left: 15px; | ||
} | ||
165 | ||
120 | .forum .forum .topics td.replies { | |
text-align: center; | ||
} | ||
169 | ||
124 | .forum .forum .topics .new-posts .subject { | |
font-weight: bold; | ||
} | ||
173 | ||
128 | .forum .forum .topics .deleted-topic * { | |
color: #D0D0D0 ! important; | ||
} | ||
... | ... | |
font-size: 1.1em; | ||
} | ||
198 | ||
199 | | |
200 | ||
201 | ||
.forum .post .info { | ||
font-size: 0.7em; | ||
} | ||
... | ... | |
display: inline; | ||
} | ||
210 | ||
211 | | |
212 | ||
213 | ||
.forum .post .text { | ||
font-size: 1.0em; | ||
} |
rool/rails/rforum/trunk/public/stylesheets/print.css:
prev. | current | |
body { | ||
font-family: serif; | ||
3 | font-size: 12pt; | |
4 | background: #FFFFFF; | |
5 | color: black; | |
} | ||
a { | ||
text-decoration: underline; | ||
} | ||
9 | ||
10 | ||
11 | ||
12 | ||
13 | ||
14 | ||
15 | | |
16 | ||
17 | ||
18 | ||
19 | | |
20 | ||
21 | ||
.navbar { | ||
display: none; | ||
} |
rool/rails/rforum/trunk/script/process_mails:
prev. | current | |
require 'fileutils' | ||
require 'breakpoint' | ||
15 | ||
16 | | |
17 | | |
18 | | |
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | ||
25 | | |
26 | | |
27 | | |
28 | | |
29 | ||
30 | | |
31 | | |
32 | | |
33 | | |
34 | | |
35 | ||
36 | ||
def do_import(maildir) | ||
puts "Checking for new mails" | ||
Dir[File.join(maildir, '*')].each do |file| | ||
... | ... | |
puts "Skipped file #{file} (invalid encoding)" | ||
FileUtils.move(file, RAILS_ROOT + '/mails/rejected/invalid_encoding/') rescue ArgumentError | ||
elsif e.message['messageid : has already been taken'] | ||
52 | | |
53 | | |
30 | puts "Skipped file #{file} (messageid already in database)" | |
31 | FileUtils.move(file, RAILS_ROOT + '/mails/rejected/messageid_duplicate/') rescue ArgumentError | |
elsif e.is_a? RForum::ValidationError | ||
puts "Skipped file #{file} (ValidationError): #{e.inspect}" | ||
FileUtils.move(file, RAILS_ROOT + '/mails/rejected/validation_error/') rescue ArgumentError | ||
... | ... | |
loop do | ||
do_import(maildir) | ||
GC.start | ||
74 | | |
75 | | |
puts "sleeping for #{sleeptime} minutes..." | ||
sleep sleeptime * 60 | ||
end |
rool/rails/rforum/trunk/test/functional/topic_controller_test.rb:
prev. | current | |
GUEST_EMAIL_ANON = /<input name='post\[guest_email\]' .*/ | ||
GUEST_EMAIL_ALEX = /<input name='post\[guest_email\]' .*value='alex@someplace.org'/ | ||
SUBMIT_BUTTON = /<input name='submit'/ | ||
66 | | |
def test_show_reply_form | ||
r = process('show', {'id' => '2', 'reply_to' => '102'}, {:user_id => 1}) | ||
check_post_in_form(r) | ||
71 | | |
70 | assert_matches_all [MS_BUG_WORKAROUND, SELF_ID, PARENT_ID, SUBJECT, TOPIC_ID, SUBMIT_BUTTON], | |
form_inputs(r) | ||
end | ||
def test_show_reply_form_for_anonymous | ||
r = process('show', {'id' => '2', 'reply_to' => '102'}, {:user_id => nil}) | ||
78 | | |
77 | assert_matches_all [MS_BUG_WORKAROUND, GUEST_EMAIL_ANON, GUEST_NAME_ANON, SELF_ID, PARENT_ID, | |
SUBJECT, TOPIC_ID, SUBMIT_BUTTON], form_inputs(r) | ||
end | ||
... | ... | |
r = process('show', {'id' => '2', 'reply_to' => '102'}, | ||
{:user_id => nil, :guest_name => 'Alex'}) | ||
86 | | |
87 | | |
88 | | |
85 | assert_matches_all [MS_BUG_WORKAROUND, GUEST_EMAIL_ANON, GUEST_NAME_ALEX, SELF_ID, PARENT_ID, | |
86 | SUBJECT, TOPIC_ID, SUBMIT_BUTTON], form_inputs(r) | |
end | ||
def test_show_reply_form_for_known_guest_email | ||
r = process('show', {'id' => '2', 'reply_to' => '102'}, | ||
{:user_id => nil, :guest_email => 'alex@someplace.org'}) | ||
95 | | |
93 | assert_matches_all [MS_BUG_WORKAROUND, GUEST_EMAIL_ALEX, GUEST_NAME_ANON, SELF_ID, PARENT_ID, | |
SUBJECT, TOPIC_ID, SUBMIT_BUTTON], form_inputs(r) | ||
end | ||
... | ... | |
def form_inputs(response) | ||
xml = REXML::Document.new(response.body) | ||
377 | | |
375 | form = REXML::XPath.first(xml, '//form[@action="/topic/2#postform"]') | |
376 | assert form, "No form found in the XHTML output" | |
377 | REXML::XPath.match(form, '//input').collect {|i| i.to_s}.sort | |
end | ||
def check_post_in_form(response) |
rool/rails/rforum/trunk/test/functional/user_controller_test.rb:
prev. | current | |
end | ||
def test_login | ||
18 | | |
r = process('login', {'name' => 'a', 'password' => 'a', 'submit' => 'Login'}, | ||
{:return_to => '/forum/forum/1'}) | ||
assert_redirect_url_match '/forum/forum/1' | ||
assert_equal User.find_by_login('a', 'a').id, r.session[:user_id] | ||
23 | | |
end | ||
def test_login_wrong_password |
rool/rails/rforum/trunk/test/test_helper.rb:
prev. | current | |
} | ||
FtaPrototypes::set_prototype :User, { | ||
56 | | |
56 | 'name' => 'ryan', 'firstname' => 'Ryan', 'surname' => 'Platte', | |
'email' => 'ryan.platte@example.com' | ||
} | ||
rool/rails/rforum/trunk/test/unit/attachment_test.rb:
prev. | current | |
end | ||
end | ||
18 | | |
18 | def test_attachment | |
a = Attachment.new | ||
a.data = 'some data' | ||
a.filename = '../../data.txt' | ||
a.save | ||
23 | | |
24 | | |
26 | | |
27 | | |
28 | ||
29 | | |
24 | assert_equal a.filename, '.._.._data.txt' | |
assert_equal 'some data', File.read(a.file_path) | ||
31 | | |
33 | | |
34 | | |
p = Post.find(1) | ||
p.attachments << a | ||
... | ... | |
assert_raises(Errno::ENOENT) { File.stat(a.dir_path) } | ||
end | ||
42 | | |
43 | | |
44 | | |
45 | | |
46 | ||
47 | | |
48 | | |
49 | | |
50 | ||
end |
rool/rails/rforum/trunk/test/unit/forum_test.rb:
prev. | current | |
end | ||
def test_get_last_post | ||
103 | | |
f = Forum.find(1) | ||
p = f.get_last_post | ||
assert_equal 11, p.id |
rool/rails/rforum/trunk/test/unit/localization_test.rb:
prev. | current | |
# TODO: shouldn't use production data for tests | ||
# require File.dirname(__FILE__) + '/../test_helper' | ||
11 | | |
11 | TRANSLATION_TABLE = LOCALIZED_STRINGS[RForum::CONFIG[:default_language]] | |
def test_normal_translation | ||
assert_equal TRANSLATION_TABLE[:available_forums], l(:available_forums) |
rool/rails/rforum/trunk/test/unit/post_test.rb:
prev. | current | |
require File.dirname(__FILE__) + '/../test_helper' | ||
class PostTest < Test::Unit::TestCase | ||
6 | | |
6 | fixtures 'users', 'forums', 'topics', 'posts' | |
def teardown | ||
... | ... | |
assert_equal 0, p.deleted | ||
end | ||
37 | | |
38 | | |
39 | | |
40 | | |
41 | | |
42 | ||
43 | | |
44 | | |
45 | | |
46 | | |
47 | ||
def test_create_with_empty_messageid | ||
p = Post.create(prototype_params(Post, 'messageid' => nil)) | ||
... | ... | |
end | ||
def test_validate_empty_text | ||
74 | | |
63 | [nil, '', '12', "12 "].each { |empty_text_value| | |
assert_raise(RForum::ValidationError, "Text #{empty_text_value.inspect} is accepted") { | ||
Post.create(prototype_params(Post, 'text' => empty_text_value)) | ||
} | ||
... | ... | |
end | ||
def test_validate_empty_subject | ||
82 | | |
71 | [nil, '', '1', '12'].each { |empty_subject_value| | |
assert_raise(RForum::ValidationError, "Subject #{empty_subject_value.inspect} is accepted") { | ||
Post.create(prototype_params(Post, 'subject' => empty_subject_value)) | ||
} | ||
... | ... | |
p = Post.create(prototype_params(Post)) | ||
a = p.attach_file('test.txt', 'testdata') | ||
assert_equal 'testdata', File.read(a.file_path) | ||
352 | | |
end | ||
355 | | |
356 | | |
357 | | |
358 | | |
359 | | |
360 | | |
361 | | |
362 | | |
363 | | |
364 | | |
365 | | |
366 | | |
367 | | |
368 | ||
369 | | |
370 | | |
371 | | |
372 | | |
373 | | |
374 | | |
375 | | |
376 | | |
377 | | |
378 | | |
379 | ||
def test_author_is_guest_without_name | ||
p = Post.create( :guest_name => '', :subject => 'subject foo', :topic_id => '1', :text => 'content' ) | ||
assert p.author.is_a?(Guest) |
rool/rails/rforum/trunk/test/unit/search_ferret_test.rb:
prev. | current | |
fixtures 'posts', 'topics', 'forums', 'users' | ||
def setup | ||
9 | | |
9 | `rm -rf /tmp/ferret-test/*` | |
10 | RForum::CONFIG[:search_handler] = :SearchFerret | |
11 | Post.search_handler = nil | |
12 | @handler = Post.search_handler = SearchFerret.new('/tmp/ferret-test/') | |
13 | @handler.rebuild_index | |
end | ||
def teardown | ||
... | ... | |
end | ||
def test_rebuild_index | ||
17 | | |
18 | | |
19 | | |
21 | assert_equal Post.count('deleted=0'), @handler.index.size | |
22 | @handler.rebuild_index | |
23 | assert_equal Post.count('deleted=0'), @handler.index.size | |
end | ||
def test_search | ||
23 | | |
27 | assert_equal Post.count('deleted = 0'), @handler.search('post').size | |
end | ||
def test_search_by_forum | ||
topics = Forum.find(2).topics.find(:all, :conditions => 'deleted=0') | ||
sum = topics.inject(0) { |n, t| n + t.post_counter } | ||
29 | | |
33 | assert_equal sum, @handler.search('post', [2]).size | |
end | ||
32 | | |
36 | def test_delete | |
Post.find(21).hide | ||
34 | | |
35 | | |
36 | | |
38 | assert_equal Post.count('deleted=0'), @handler.index.size | |
end | ||
end |
rool/rails/rforum/trunk/test/unit/user_test.rb:
prev. | current | |
User.create(prototype_params(User)) | ||
user = User.find_all[0] | ||
assert user | ||
29 | | |
30 | | |
31 | | |
32 | | |
33 | | |
29 | prototype_params(User).each_pair { |k, v| | |
assert_equal v, user[k], "Value of #{k} not as expected" unless k == 'id' | ||
} | ||
end |