sample-articles
1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
include Noosfero::SampleDataHelper
profiles = $environment.profiles
categories = $environment.categories
SUBJECTS = ['got a new car', 'release a new version of project X', "doesn't like wales no more", "doesn't use free-software no more"]
TAGS = ['free-software', 'noosfero', 'development', 'rails', 'ruby']
EVENT_SUBJECTS = ['International Conference on %s', '%s day', '%s World Congress', '%s World Forum', '%s Summit', '%s Week']
THEMES = ['Sustainability', 'Free Software', 'Climate Change', 'Environment', 'Agile Development', 'Solidarity Economy', 'Debian', 'Perl']
print "Creating some TinyMce articles: "
for subject in SUBJECTS
rand(20).times do |i|
profile = profiles.rand
article = TinyMceArticle.new(
:name => "%s #{subject}" % profile.name,
:body => "%s #{subject}" % profile.name,
:tag_list => [TAGS.rand, TAGS.rand],
:profile => profile
)
save article do
categories.rand.articles << article
end
end
end
done
print "Creating some galleries: "
for subject in SUBJECTS
rand(20).times do |i|
profile = profiles.rand
save Gallery.new(
:name => "Gallery %s #{subject}" % profile.name,
:body => "Gallery %s #{subject}" % profile.name,
:tag_list => [TAGS.rand, TAGS.rand],
:profile => profile
)
end
end
done
print "Creating some events: "
for subject in EVENT_SUBJECTS
for theme in THEMES
event = Event.new(
:name => subject % theme,
:profile => profiles.rand,
:start_date => Date.today + (-30 + rand(60)).days,
:tag_list => [TAGS.rand, TAGS.rand]
)
save event do
categories.rand.events << event
categories.rand.events << event
categories.rand.events << event
end
end
end
done