sample-articles
2.4 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/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 Text articles: "
for subject in SUBJECTS
rand(20).times do |i|
profile = profiles.sample
name = "%s #{subject}" % profile.name
next if profile.articles.where(:slug => name.to_slug).first
article = TextArticle.new(
:name => name,
:body => name,
:tag_list => [TAGS.sample, TAGS.sample],
:profile => profile
)
save article do
article.add_category categories.sample
end
end
end
done
print "Creating some galleries: "
for subject in SUBJECTS
rand(20).times do |i|
profile = profiles.sample
name = "Gallery %s #{subject}" % profile.name
next if profile.articles.where(:slug => name.to_slug).first
save Gallery.new(
:name => name,
:body => name,
:tag_list => [TAGS.sample, TAGS.sample],
:profile => profile
)
end
end
done
print "Creating some events: "
for subject in EVENT_SUBJECTS
for theme in THEMES
profile = profiles.sample
name = subject % theme
next if profile.articles.where(:slug => name.to_slug).first
event = Event.new(
:name => name,
:profile => profile,
:start_date => Date.today + (-30 + rand(60)).days,
:tag_list => [TAGS.sample, TAGS.sample]
)
save event do
3.times do
category = categories.sample
event.add_category category
end
end
end
end
done
print "Creating some posts: "
for subject in SUBJECTS
rand(20).times do |i|
profile = profiles.sample
name = "%s #{subject}" % profile.name
article = TextArticle.new(
:name => name,
:body => name,
:tag_list => [TAGS.sample, TAGS.sample],
:profile => profile,
:parent_id => profile.blog.id
)
save article do
article.add_category categories.sample
end
end
end
done