Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 178
- Log:
Hub integration of Beast forum. Completed styling for RISC OS Open site.
Removed reliance on JavaScript. Added Textile hints to various views.
Added bespoke utility code used to port over RForum data for posterity;
note the rather large bug that it ignores the deleted flag on RForum
data.Some amount of testing carried out on Firefox, Opera and Netsurf. Looks
OK so far, but there are definitely some aesthetic kinks to work out
still and doubtless some operational bugs will surface once it goes
live and is subjected to more intensive real world use.
- Author:
- rool
- Date:
- Mon Mar 12 00:19:40 +0000 2007
- Size:
- 3907 Bytes
1 | class RforumtopicsController < ApplicationController |
2 | def extract |
3 | |
4 | # Create the forums (hard-coded, can't be bothered importing this) |
5 | |
6 | forum = Forum.new |
7 | forum.attributes = { :name => 'Announcements', |
8 | :description => 'Announce and discuss new hardware and software releases.' } |
9 | forum.save! |
10 | |
11 | forum = Forum.new |
12 | forum.attributes = { :name => 'Wish lists', |
13 | :description => 'What would you like to see written or changed?' } |
14 | forum.save! |
15 | |
16 | forum = Forum.new |
17 | forum.attributes = { :name => 'Code review', |
18 | :description => 'Developer peer review of proposed code alterations.' } |
19 | forum.save! |
20 | |
21 | forum = Forum.new |
22 | forum.attributes = { :name => 'Bugs', |
23 | :description => "Bug discussions that aren't covered by the bugs database." } |
24 | forum.save! |
25 | |
26 | forum = Forum.new |
27 | forum.attributes = { :name => 'General', |
28 | :description => 'General discussions.' } |
29 | forum.save! |
30 | |
31 | forum = Forum.new |
32 | forum.attributes = { :name => 'Tests', |
33 | :description => 'Test posts.' } |
34 | forum.save! |
35 | |
36 | # Log activity in @info; the view uses it |
37 | |
38 | @info='' |
39 | |
40 | # Add the topics |
41 | |
42 | @rforum_topics = Rforumtopic.find(:all).sort_by { |item| item.id } |
43 | |
44 | @rforum_topics.each do |rforum_topic| |
45 | @forum = Forum.find(rforum_topic.forum_id); |
46 | |
47 | topic = { :title => rforum_topic.subject, |
48 | :body => 'This topic has been imported from the old forum. Due to its use of fixed format text, you may need to make your browser view wider in order to see posts with the correct layout.' } |
49 | |
50 | Topic.transaction do |
51 | @topic = @forum.topics.build(topic) |
52 | @topic.user = User.find_by_id(1); |
53 | @topic.forum_id = rforum_topic.forum_id; |
54 | |
55 | @topic.save! |
56 | @post = @topic.posts.build(topic) |
57 | @post.user = current_user |
58 | @post.save! |
59 | |
60 | @info+="=================\nTOPIC:\n\n"+@topic.inspect+"\n\nPOST:\n\n"+@post.inspect+"\n\n" |
61 | end |
62 | end |
63 | |
64 | # Now add the posts, creating users in passing |
65 | |
66 | @rforum_posts = Rforumpost.find(:all).sort_by { |item| item.id } |
67 | |
68 | @rforum_posts.each do |rfpost| |
69 | if (not rfpost.text.empty?) |
70 | body = body_html = '<notextile><tt>' + rfpost.text.gsub("\n", "<br />") + '</tt></notextile>' |
71 | rfuser = Rforumuser.find_by_id(rfpost.user_id) |
72 | rftopic = Rforumtopic.find_by_id(rfpost.topic_id) |
73 | |
74 | if (rfuser.nil?) |
75 | @info+="\n**** ALERT: User not found for post ID '#{rfpost.id}'****\n"; |
76 | next |
77 | end |
78 | |
79 | # Find the equivalent Beast topic. |
80 | |
81 | topic = Topic.find_by_title(rftopic.subject) |
82 | |
83 | # Find the equivalent Beast user. If not found, make one. |
84 | |
85 | user = User.find_by_login(Digest::SHA1.hexdigest(rfuser.firstname)) |
86 | |
87 | if (user.nil?) |
88 | user = User.new({ |
89 | :login => Digest::SHA1.hexdigest(rfuser.firstname), |
90 | :email => rfuser.email, |
91 | :admin => false, |
92 | :display_name => rfuser.firstname, |
93 | :website => '', |
94 | :bio => '', |
95 | :bio_html => '', |
96 | :activated => true |
97 | }) |
98 | @info+="\n!!!! NEW USER CREATED !!!!\n"; |
99 | user.save! |
100 | end |
101 | |
102 | # Build the post |
103 | |
104 | if ((not topic.nil?) and (not user.nil?)) |
105 | post = topic.posts.build({ |
106 | :body => body, |
107 | :body_html => body_html |
108 | }) |
109 | post.user = user |
110 | post.save! |
111 | end |
112 | |
113 | @info+="=====#{rfpost.id}=========\nUSER:\n\n"+user.inspect+"\n\nPOST:\n\n"+post.inspect+"\n\n" |
114 | |
115 | end |
116 | end |
117 | |
118 | |
119 | end |
120 | end |