Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 171
- Log:
Initial import of Beast 0.9 from downloaded Tarball. Beast is a Ruby
On Rails based forum application. The original tarball came from the
following location:http://s3.amazonaws.com/beast-forum/beast-0.9.tar.gz
The forum post which announced this version's availability was at:
http://beast.caboo.se/forums/1/topics/446
- Author:
- rool
- Date:
- Fri Mar 02 15:51:55 +0000 2007
- Size:
- 3559 Bytes
1 | class PostsController < ApplicationController |
2 | before_filter :find_post, :except => [:index, :create, :monitored] |
3 | before_filter :login_required, :except => [:index, :monitored] |
4 | before_filter(:only => [:index, :monitored]) { |c| c.params[:page] = 1 if c.params[:format] == 'rss' } |
5 | |
6 | def index |
7 | conditions = [] |
8 | [:user_id, :forum_id].each { |attr| conditions << Post.send(:sanitize_sql, ["posts.#{attr} = ?", params[attr]]) if params[attr] } |
9 | conditions << Post.send(:sanitize_sql, ['LOWER(posts.body) LIKE ?', "%#{params[:q]}%"]) unless params[:q].blank? |
10 | @post_pages, @posts = paginate(:posts, :per_page => 25, :select => 'posts.*, topics.title as topic_title', :joins => 'inner join topics on posts.topic_id = topics.id', |
11 | :conditions => conditions.any? ? conditions.collect { |c| "(#{c})" }.join(' AND ') : nil, :order => 'posts.created_at desc, posts.id desc') |
12 | render_posts_or_xml |
13 | end |
14 | |
15 | def monitored |
16 | @user = User.find params[:user_id] |
17 | @post_pages, @posts = paginate(:posts, :per_page => 25, :select => 'posts.*, topics.title as topic_title', :joins => 'inner join topics on posts.topic_id = topics.id inner join monitorships on monitorships.topic_id = topics.id', |
18 | :conditions => ['monitorships.user_id = ? and posts.user_id != ?', params[:user_id], @user.id], :order => 'posts.created_at desc, posts.id desc') |
19 | render_posts_or_xml |
20 | end |
21 | |
22 | def create |
23 | @topic = Topic.find_by_id_and_forum_id(params[:topic_id],params[:forum_id], :include => :forum) |
24 | if @topic.locked? |
25 | flash[:notice] = 'This topic is locked.' |
26 | return redirect_to(topic_path(:forum_id => params[:forum_id], :id => params[:topic_id])) |
27 | end |
28 | @forum = @topic.forum |
29 | @post = @topic.posts.build(params[:post]) |
30 | @post.user = current_user |
31 | @post.save! |
32 | redirect_to topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :anchor => @post.dom_id, :page => params[:page] || '1') |
33 | rescue ActiveRecord::RecordInvalid |
34 | flash[:bad_reply] = 'Please post something at least...' |
35 | redirect_to topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :anchor => 'reply-form', :page => params[:page] || '1') |
36 | end |
37 | |
38 | def edit |
39 | respond_to { |format| format.html; format.js } |
40 | end |
41 | |
42 | def update |
43 | @post.attributes = params[:post] |
44 | @post.save! |
45 | rescue ActiveRecord::RecordInvalid |
46 | flash[:bad_reply] = 'An error occurred' |
47 | ensure |
48 | respond_to do |format| |
49 | format.html do |
50 | redirect_to topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :anchor => @post.dom_id, :page => params[:page] || '1') |
51 | end |
52 | format.js |
53 | end |
54 | end |
55 | |
56 | def destroy |
57 | @post.destroy |
58 | flash[:notice] = "Post of '#{CGI::escapeHTML @post.topic.title}' was deleted." |
59 | # check for posts_count == 1 because its cached and counting the currently deleted post |
60 | @post.topic.destroy and redirect_to forum_path(params[:forum_id]) if @post.topic.posts_count == 1 |
61 | redirect_to topic_path(:forum_id => params[:forum_id], :id => params[:topic_id], :page => params[:page]) unless performed? |
62 | end |
63 | |
64 | protected |
65 | def authorized? |
66 | action_name == 'create' || @post.editable_by?(current_user) |
67 | end |
68 | |
69 | def find_post |
70 | @post = Post.find_by_id_and_topic_id_and_forum_id(params[:id], params[:topic_id], params[:forum_id]) || raise(ActiveRecord::RecordNotFound) |
71 | end |
72 | |
73 | def render_posts_or_xml |
74 | respond_to do |format| |
75 | format.html |
76 | format.rss { render :action => "#{action_name}.rxml", :layout => false } |
77 | end |
78 | end |
79 | end |