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:
- 2615 Bytes
1 | class TopicsController < ApplicationController |
2 | before_filter :find_forum_and_topic, :except => :index |
3 | before_filter :login_required, :only => [:new, :create, :edit, :update, :destroy] |
4 | # before_filter :update_last_seen_at, :only => :show |
5 | |
6 | def index |
7 | redirect_to forum_path(params[:forum_id]) |
8 | end |
9 | |
10 | def new |
11 | @topic = Topic.new |
12 | end |
13 | |
14 | def show |
15 | respond_to do |format| |
16 | format.html do |
17 | # see notes in application.rb on how this works |
18 | update_last_seen_at |
19 | # keep track of when we last viewed this topic for activity indicators |
20 | (session[:topics] ||= {})[@topic.id] = Time.now.utc if logged_in? |
21 | # authors of topics don't get counted towards total hits |
22 | @topic.hit! unless logged_in? and @topic.user == current_user |
23 | @post_pages, @posts = paginate(:posts, :per_page => 25, :order => 'posts.created_at', :include => :user, :conditions => ['posts.topic_id = ?', params[:id]]) |
24 | @voices = @posts.map(&:user) ; @voices.uniq! |
25 | @post = Post.new |
26 | end |
27 | format.rss do |
28 | @posts = @topic.posts.find(:all, :order => 'created_at desc', :limit => 25) |
29 | render :action => 'show.rxml', :layout => false |
30 | end |
31 | end |
32 | end |
33 | |
34 | def create |
35 | # this is icky - move the topic/first post workings into the topic model? |
36 | Topic.transaction do |
37 | @topic = @forum.topics.build(params[:topic]) |
38 | assign_protected |
39 | @topic.save! |
40 | @post = @topic.posts.build(params[:topic]) |
41 | @post.user = current_user |
42 | @post.save! |
43 | end |
44 | redirect_to topic_path(@forum, @topic) |
45 | end |
46 | |
47 | def update |
48 | @topic.attributes = params[:topic] |
49 | assign_protected |
50 | @topic.save! |
51 | redirect_to topic_path(@topic.forum, @topic) |
52 | end |
53 | |
54 | def destroy |
55 | @topic.destroy |
56 | flash[:notice] = "Topic '#{CGI::escapeHTML @topic.title}' was deleted." |
57 | redirect_to forum_path(@forum) |
58 | end |
59 | |
60 | protected |
61 | def assign_protected |
62 | @topic.user = current_user if @topic.new_record? |
63 | # admins and moderators can sticky and lock topics |
64 | return unless admin? or current_user.moderator_of?(@topic.forum) |
65 | @topic.sticky, @topic.locked = params[:topic][:sticky], params[:topic][:locked] |
66 | # only admins can move |
67 | return unless admin? |
68 | @topic.forum_id = params[:topic][:forum_id] if params[:topic][:forum_id] |
69 | end |
70 | |
71 | def find_forum_and_topic |
72 | @forum = Forum.find(params[:forum_id]) |
73 | @topic = @forum.topics.find(params[:id]) if params[:id] |
74 | end |
75 | |
76 | def authorized? |
77 | %w(new create).include?(action_name) || @topic.editable_by?(current_user) |
78 | end |
79 | end |