ish_lib_engine 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/ish_lib_engine/application.js +13 -0
- data/app/assets/javascripts/ish_lib_engine/articles.js +2 -0
- data/app/assets/stylesheets/ish_lib_engine/application.css +15 -0
- data/app/assets/stylesheets/ish_lib_engine/articles.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/ish_lib_engine/application_controller.rb +4 -0
- data/app/controllers/ish_lib_engine/articles_controller.rb +62 -0
- data/app/controllers/ish_lib_engine/manager/cities_controller.rb +95 -0
- data/app/controllers/ish_lib_engine/manager/cities_controller.rb~ +95 -0
- data/app/controllers/ish_lib_engine/manager/features_controller.rb +122 -0
- data/app/controllers/ish_lib_engine/manager/features_controller.rb~ +122 -0
- data/app/controllers/ish_lib_engine/manager/galleries_controller.rb +78 -0
- data/app/controllers/ish_lib_engine/manager/galleries_controller.rb~ +78 -0
- data/app/controllers/ish_lib_engine/manager/manager_controller.rb +31 -0
- data/app/controllers/ish_lib_engine/manager/manager_controller.rb~ +31 -0
- data/app/controllers/ish_lib_engine/manager/newsitems_controller.rb +47 -0
- data/app/controllers/ish_lib_engine/manager/newsitems_controller.rb~ +47 -0
- data/app/controllers/ish_lib_engine/manager/photos_controller.rb +20 -0
- data/app/controllers/ish_lib_engine/manager/photos_controller.rb~ +20 -0
- data/app/controllers/ish_lib_engine/manager/reports_controller.rb +62 -0
- data/app/controllers/ish_lib_engine/manager/reports_controller.rb~ +62 -0
- data/app/controllers/ish_lib_engine/manager/sites_controller.rb +72 -0
- data/app/controllers/ish_lib_engine/manager/sites_controller.rb~ +72 -0
- data/app/controllers/ish_lib_engine/manager/tags_controller.rb +54 -0
- data/app/controllers/ish_lib_engine/manager/tags_controller.rb~ +54 -0
- data/app/controllers/ish_lib_engine/manager/users_controller.rb +13 -0
- data/app/controllers/ish_lib_engine/manager/users_controller.rb~ +13 -0
- data/app/controllers/ish_lib_engine/manager/welcome_controller.rb +8 -0
- data/app/controllers/ish_lib_engine/manager/welcome_controller.rb~ +9 -0
- data/app/helpers/ish_lib_engine/application_helper.rb +4 -0
- data/app/helpers/ish_lib_engine/articles_helper.rb +4 -0
- data/app/models/ability.rb +152 -0
- data/app/models/ability.rb~ +151 -0
- data/app/models/admin_user.rb +113 -0
- data/app/models/app_model2.rb +33 -0
- data/app/models/auth_token.rb +17 -0
- data/app/models/aux_model.rb +22 -0
- data/app/models/cities_user.rb +17 -0
- data/app/models/city.rb +117 -0
- data/app/models/country.rb +13 -0
- data/app/models/day.rb +21 -0
- data/app/models/decoded_auth_token.rb +6 -0
- data/app/models/event.rb +21 -0
- data/app/models/feature.rb +38 -0
- data/app/models/gallery.rb +59 -0
- data/app/models/ish_lib_engine/article.rb +4 -0
- data/app/models/ish_lib_engine/comment.rb +4 -0
- data/app/models/manager.rb +10 -0
- data/app/models/manager_city.rb +4 -0
- data/app/models/manager_feature.rb +4 -0
- data/app/models/manager_gallery.rb +3 -0
- data/app/models/manager_newsitem.rb +5 -0
- data/app/models/manager_photo.rb +3 -0
- data/app/models/manager_report.rb +4 -0
- data/app/models/manager_site.rb +4 -0
- data/app/models/manager_tag.rb +6 -0
- data/app/models/manager_user.rb +3 -0
- data/app/models/manager_venue.rb +4 -0
- data/app/models/message.rb +14 -0
- data/app/models/newsitem.rb +50 -0
- data/app/models/nodeitem.rb +18 -0
- data/app/models/photo.rb +68 -0
- data/app/models/rate_me.rb +13 -0
- data/app/models/report.rb +144 -0
- data/app/models/review.rb +4 -0
- data/app/models/site.rb +83 -0
- data/app/models/tag.rb +78 -0
- data/app/models/user.rb +122 -0
- data/app/models/user_profile.rb +20 -0
- data/app/models/venue.rb +69 -0
- data/app/models/video.rb +48 -0
- data/app/models/welcome.rb +6 -0
- data/app/models/wikitravel_page.rb +19 -0
- data/app/views/application/_flash_messages.haml +24 -0
- data/app/views/application/_flash_messages.haml~ +24 -0
- data/app/views/ish_lib_engine/articles/_form.html.erb +25 -0
- data/app/views/ish_lib_engine/articles/edit.html.erb +6 -0
- data/app/views/ish_lib_engine/articles/index.html.erb +29 -0
- data/app/views/ish_lib_engine/articles/new.html.erb +5 -0
- data/app/views/ish_lib_engine/articles/show.html.erb +14 -0
- data/app/views/layouts/ish_lib_engine/application.html.erb +14 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20160501041837_create_ish_lib_engine_articles.rb +10 -0
- data/db/migrate/20160501041940_create_ish_lib_engine_comments.rb +10 -0
- data/lib/addressbookitems_tasks.rb +33 -0
- data/lib/cities_tasks.rb +143 -0
- data/lib/core_extensions.rb +21 -0
- data/lib/features_tasks.rb +17 -0
- data/lib/float.rb +14 -0
- data/lib/galleries_tasks.rb +91 -0
- data/lib/ish_lib_engine.rb +4 -0
- data/lib/ish_lib_engine/engine.rb +5 -0
- data/lib/ish_lib_engine/version.rb +3 -0
- data/lib/reports_tasks.rb +53 -0
- data/lib/sitemaps_tasks.rb +108 -0
- data/lib/sites_tasks.rb +31 -0
- data/lib/string.rb +15 -0
- data/lib/tags_tasks.rb +104 -0
- data/lib/tasks/cities.rake +29 -0
- data/lib/tasks/galleries.rake +19 -0
- data/lib/tasks/ish_lib_engine_tasks.rake +4 -0
- data/lib/tasks/reports.rake +37 -0
- data/lib/tasks/resque.rake +8 -0
- data/lib/tasks/sitemaps.rake +12 -0
- data/lib/tasks/sites.rake +12 -0
- data/lib/tasks/tags.rake +17 -0
- data/lib/tasks/users.rake +14 -0
- data/lib/tasks/venues.rake +13 -0
- data/lib/tasks/videos.rake +18 -0
- data/lib/tasks/wikitravel_pages.rake +40 -0
- data/lib/test_extensions.rb +9 -0
- data/lib/u.rb +34 -0
- data/lib/users_tasks.rb +88 -0
- data/lib/venues_tasks.rb +15 -0
- data/lib/videos_tasks.rb +71 -0
- data/lib/wikitravel_tasks.rb +139 -0
- data/spec/factories/cities.rb +89 -0
- data/spec/factories/galleries.rb +133 -0
- data/spec/factories/photo.rb +20 -0
- data/spec/factories/reports.rb +379 -0
- data/spec/factories/site.rb +26 -0
- data/spec/factories/tag.rb +42 -0
- data/spec/factories/user.rb +87 -0
- data/spec/factories/user_profiles.rb +33 -0
- data/spec/factories/venues.rb +25 -0
- data/spec/factories/videos.rb +38 -0
- data/test/controllers/ish_lib_engine/articles_controller_test.rb +52 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +30 -0
- data/test/dummy/log/development.log +15 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/fixtures/ish_lib_engine/articles.yml +9 -0
- data/test/fixtures/ish_lib_engine/comments.yml +9 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/ish_lib_engine_test.rb +7 -0
- data/test/models/ish_lib_engine/article_test.rb +9 -0
- data/test/models/ish_lib_engine/comment_test.rb +9 -0
- data/test/test_helper.rb +21 -0
- metadata +361 -0
data/lib/users_tasks.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class UsersTasks
|
4
|
+
|
5
|
+
# arg is:::: username, email, group_id
|
6
|
+
def self.create_from_user arg
|
7
|
+
unless self.where(:username => arg[:username]).exists?
|
8
|
+
NoUser.create :username => arg[:username],
|
9
|
+
:group_id => arg[:group_id],
|
10
|
+
:email => arg[:email]
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.import_old
|
16
|
+
[
|
17
|
+
[ 'becky', 'beckvelez01@hotmail.com'],
|
18
|
+
[ 'Adeel_Ahmed', 'adeelpk_85@yahoo.com'],
|
19
|
+
[ 'dine', 'aldine_33@hotmail.com'],
|
20
|
+
[ 'Carmen', 'carmelein.ilustradora@gmail.com'],
|
21
|
+
[ 'Hassan_Tariq', 'hawkarena@gmail.com'],
|
22
|
+
[ 'lucia_chiappara', 'luciamchiappara@hotmail.com'],
|
23
|
+
[ 'Stefanovski', 'zlio2004@yahoo.com'],
|
24
|
+
[ 'Krysty_McIntyre', 'krystymcintyre@gmail.com'],
|
25
|
+
[ 'Caroline', 'crlnjnsn@yahoo.ca'],
|
26
|
+
[ 'Pavithra', 'pksjce@gmail.com'],
|
27
|
+
[ 'Sulabh', 'sulabhjain.btech.itbhu@gmail.com'],
|
28
|
+
[ 'Naomi_Csiki', 'hvvvj@yahoo.com'],
|
29
|
+
[ 'Lori_Williams', 'suredog@q.com'],
|
30
|
+
[ 'Chris_Henderson', 'thewritechris@usa.com'],
|
31
|
+
[ 'Cherry_Vic_Patalita', 'bickie77@yahoo.com'],
|
32
|
+
[ 'Natalie_Grigson', 'nataliegrigson@yahoo.com'],
|
33
|
+
[ 'Caroline', 'crlnjnsn@yahoo.ca'],
|
34
|
+
[ 'Jennifer_Sommer', 'Jennifer.Sommer1@marist.edu'],
|
35
|
+
[ 'Eli_Terris', 'eliterris@gmail.com'],
|
36
|
+
[ 'Sean_Smith', 'seansmith613@gmail.com'],
|
37
|
+
[ 'Zachary_Kago', 'Zach_kago@yahoo.com'],
|
38
|
+
[ 'Titanium', 'swissbezel@gmail.com'],
|
39
|
+
[ 'Ashley_Shankle', 'polvati@gmail.com'],
|
40
|
+
[ 'Sourya_Biswas', 'sourya.biswas@gmail.com'],
|
41
|
+
[ 'sharon_farrer', 'farrersharon@yahoo.co.uk'],
|
42
|
+
[ 'Kenneth_Okpomo', 'kokpomo@yahoo.com'],
|
43
|
+
[ 'Megan', 'beatlerock9@aol.com'],
|
44
|
+
[ 'kenneth_okpomo', 'kokpomo@yahoo.com'],
|
45
|
+
[ 'macherie', 'charisse.cbl@gmail.com'],
|
46
|
+
[ 'Platinum', 'iluxuryren@gmail.com'],
|
47
|
+
[ 'Elizabeth_Varadan', 'elizabethvaradan@msn.com'],
|
48
|
+
[ 'Mwila', 'mreadith@yahoo.com'],
|
49
|
+
[ 'Siddharth_Sareen', 'sidsareen@gmail.com'],
|
50
|
+
[ 'Nikki', 'nikkitraveling@gmail.com'],
|
51
|
+
[ 'Sinead', 'taibhse7@hotmail.com'],
|
52
|
+
[ 'salevoikerend', 'base18@spamelka.com'],
|
53
|
+
[ 'GerAdegoAriff', 'd.danstrange1@yandex.ru'],
|
54
|
+
[ 'ashutosh_ratnam', 'ashratnam@yahoo.com'],
|
55
|
+
[ 'David_Harrison', 'davidnharrison@gmail.com'],
|
56
|
+
[ 'oglyhytlainab8', 'pikavippi@live.com'],
|
57
|
+
[ 'tating_y', 'tating_y@hotmail.com'],
|
58
|
+
[ 'tarinapaco@msn.com', 'tarinapaco@msn.com'],
|
59
|
+
[ 'bebz209', 'bebz209@gmail.com'],
|
60
|
+
[ 'awarrygroorce', 'nobbiblyvor@gmail.com'],
|
61
|
+
[ 'lizza_faith', 'lizzafaith22@yahoo.com'],
|
62
|
+
[ 'Beauddyuttern', 'marcin.terluterson@gmail.com'],
|
63
|
+
[ 'tamara_arden', 'tamarden@hotmail.com'],
|
64
|
+
[ 'atherton', 'chrisbatherton@gmail.com'],
|
65
|
+
[ 'wordsmith', 'ladyravenheartwordsmith@ladyravenheartwordsmith.org'],
|
66
|
+
[ 'joshua_kean', 'jkean32123@hotmail.com'],
|
67
|
+
[ 'lad', 'ladyravenheart@ladyravenheartwordsmith.org']
|
68
|
+
].each do |user|
|
69
|
+
old = User.where( :email => user[1] ).first
|
70
|
+
if old.blank?
|
71
|
+
u = User.new
|
72
|
+
u.email = user[1]
|
73
|
+
u.username = user[0]
|
74
|
+
u.name = user[0]
|
75
|
+
u.password = "123#{user[1]}#{user[0]}"
|
76
|
+
|
77
|
+
if u.save
|
78
|
+
puts '+' unless Rails.env.test?
|
79
|
+
else
|
80
|
+
puts! u.errors
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
end
|
data/lib/venues_tasks.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class VenuesTasks
|
4
|
+
|
5
|
+
|
6
|
+
def self.generate_name_seo
|
7
|
+
venues = Venue.find :all,
|
8
|
+
:conditions => { :name_seo => nil }
|
9
|
+
|
10
|
+
venues.each do |venue|
|
11
|
+
venue[:name_seo] = venue[:name].downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
12
|
+
venue.save
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/videos_tasks.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class VideosTasks
|
4
|
+
|
5
|
+
|
6
|
+
def self.to_video
|
7
|
+
|
8
|
+
videos = OldVideo.find :all,
|
9
|
+
:include => [ :user, :city ]
|
10
|
+
|
11
|
+
|
12
|
+
videos.each do |v|
|
13
|
+
|
14
|
+
no = Video.new
|
15
|
+
|
16
|
+
# so far names are non-nil
|
17
|
+
no.name = v[:name]
|
18
|
+
no.seo = v[:name].to_simple_string
|
19
|
+
|
20
|
+
no.descr = v[:descr]
|
21
|
+
|
22
|
+
no.youtube_url = v[:youtube_url]
|
23
|
+
no.w = v[:w]
|
24
|
+
no.h = v[:h]
|
25
|
+
|
26
|
+
no.created_at = v[:created_at]
|
27
|
+
no.updated_at = v[:updated_at]
|
28
|
+
|
29
|
+
no.is_public = v[:is_public]
|
30
|
+
no.is_feature = v[:is_feature]
|
31
|
+
no.is_trash = v[:is_trash]
|
32
|
+
|
33
|
+
no.x = v[:x]
|
34
|
+
no.y = v[:y]
|
35
|
+
|
36
|
+
no_user = NoUser.where( :email => v.user[:email] ).first
|
37
|
+
if no_user.blank?
|
38
|
+
no_user = NoUser.new
|
39
|
+
no_user.email = v.user[:email]
|
40
|
+
no_user.save
|
41
|
+
end
|
42
|
+
no.no_user = no_user
|
43
|
+
|
44
|
+
no_city = NoCity.where( :name => v.city.name ).first
|
45
|
+
if no_city.blank?
|
46
|
+
no_city = NoCity.new
|
47
|
+
no_city.name = v.city.name
|
48
|
+
no_city.save
|
49
|
+
end
|
50
|
+
no.no_city = no_city
|
51
|
+
|
52
|
+
no.save
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.title_to_name
|
58
|
+
|
59
|
+
videos = Video.all
|
60
|
+
|
61
|
+
videos.each do |v|
|
62
|
+
v.name = v.title
|
63
|
+
if v.save
|
64
|
+
puts '+'
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'htmlentities'
|
4
|
+
require 'string'
|
5
|
+
|
6
|
+
class WikitravelTasks
|
7
|
+
|
8
|
+
def initialize args = {}
|
9
|
+
args[:lang] ||= 'en'
|
10
|
+
args[:domain] ||= 'travel-guide.mobi'
|
11
|
+
|
12
|
+
@site = Site.where( :domain => args[:domain], :lang => args[:lang] ).first
|
13
|
+
@user = WikitravelTasks.find_or_create_wiki_user
|
14
|
+
end
|
15
|
+
|
16
|
+
def all_pages_to_report_and_newsitems
|
17
|
+
WikitravelPage.all.each do |page|
|
18
|
+
report = Report.where( :name => page[:title] ).first
|
19
|
+
if report.blank?
|
20
|
+
one_page_to_report_and_newsitems( page )
|
21
|
+
else
|
22
|
+
puts "Report already exists: #{report.name}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def random_page_to_newsitem
|
28
|
+
# select a random page
|
29
|
+
begin
|
30
|
+
n_pages = WikitravelPage.all.length
|
31
|
+
random_page = WikitravelPage.all[rand(n_pages-1)]
|
32
|
+
existing_report = Report.where( :name => random_page.title ).first
|
33
|
+
end while !existing_report.blank?
|
34
|
+
|
35
|
+
one_page_to_report_and_newsitems( random_page )
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# all the wikitravel.org stuff should belong to this user.
|
40
|
+
#
|
41
|
+
def self.find_or_create_wiki_user
|
42
|
+
u = User.where( :username => 'wikitraveler' ).first
|
43
|
+
if u.blank?
|
44
|
+
u = User.create({ :username => 'wikitraveler', :name => 'Wikitraveler', :email => 'wiki@traveler.com',
|
45
|
+
:password => 'omg such password you will never guess wow' })
|
46
|
+
end
|
47
|
+
return u
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Take manually precompiled list of pages off of wikitravel.org, and create a WikitravelPage for each one that does not exist.
|
52
|
+
#
|
53
|
+
def self.parse_list_of_pages arg = {}
|
54
|
+
arg[:filename] ||= 'wikitravel.org-popular-pages.htm'
|
55
|
+
puts "Attn. parsing wikitravel.org list of pages with filename '#{arg[:filename]}'" unless Rails.env.test?
|
56
|
+
|
57
|
+
index_html_path = Rails.root.join( 'data', arg[:filename] )
|
58
|
+
page = Nokogiri::HTML(open(index_html_path))
|
59
|
+
links = page.css( "ol.special li > a" )
|
60
|
+
links.each do |link|
|
61
|
+
unless link['href'].include?(':')
|
62
|
+
page = WikitravelPage.new :url => link['href'], :title => link['title']
|
63
|
+
if page.save
|
64
|
+
puts "Saving page '#{page.title}'" unless Rails.env.test?
|
65
|
+
else
|
66
|
+
puts "Maybe the page '#{page.title}' already exists." unless Rails.env.test?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def travel_tag
|
73
|
+
t = Tag.where( :name => 'Travel' ).first
|
74
|
+
if t.blank?
|
75
|
+
t = Tag.create( :site => @site, :name => 'Travel', :name_seo => 'travel' )
|
76
|
+
end
|
77
|
+
return t
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.cleanup_report report
|
81
|
+
text = report.descr
|
82
|
+
|
83
|
+
text = Nokogiri::HTML( report.descr )
|
84
|
+
text.search('.//script').remove
|
85
|
+
text.search('.//noscript').remove
|
86
|
+
text.search(".//span[contains(@class,'editsection')]").remove
|
87
|
+
text.search(".//table[contains(@class,'toc')]").remove
|
88
|
+
text.search(".//ul[contains(@class,'wt-toc')]").remove
|
89
|
+
text.search(".//div[@id='toctitle']").remove
|
90
|
+
report.descr = text
|
91
|
+
|
92
|
+
return report
|
93
|
+
end
|
94
|
+
|
95
|
+
def one_page_to_report_and_newsitems random_page
|
96
|
+
urll = "#{WikitravelPage::DOMAIN}#{random_page.url}"
|
97
|
+
remote_page = Nokogiri::HTML( open( urll ) )
|
98
|
+
text = remote_page.css("#mw-content-text tr > td")
|
99
|
+
|
100
|
+
begin
|
101
|
+
subhead = remote_page.css("#mw-content-text tr > td p")[0].text
|
102
|
+
rescue
|
103
|
+
subhead = ''
|
104
|
+
end
|
105
|
+
|
106
|
+
# create the report
|
107
|
+
r = Report.new
|
108
|
+
r.name = random_page.title
|
109
|
+
r.name_seo = random_page.title.to_simple_string
|
110
|
+
r.subhead = subhead
|
111
|
+
r.descr = text
|
112
|
+
r.site = @site
|
113
|
+
r.user = @user
|
114
|
+
r.tag = travel_tag
|
115
|
+
|
116
|
+
r = WikitravelTasks.cleanup_report r
|
117
|
+
r.save || puts!(r.errors)
|
118
|
+
|
119
|
+
# create newsitem for the city
|
120
|
+
nn = Newsitem.new
|
121
|
+
nn.report = r
|
122
|
+
city = City.where( :name => /#{r.name}/i ).first
|
123
|
+
|
124
|
+
unless city.blank?
|
125
|
+
city.newsitems << nn
|
126
|
+
city.save
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
def puts! args
|
134
|
+
puts '+++ +++'
|
135
|
+
puts args.inspect
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
|
@@ -0,0 +1,89 @@
|
|
1
|
+
|
2
|
+
FactoryGirl.define do
|
3
|
+
|
4
|
+
factory :city, :class => City do
|
5
|
+
name 'city name'
|
6
|
+
name_en 'city name'
|
7
|
+
name_pt 'city name'
|
8
|
+
name_ru 'city name'
|
9
|
+
cityname 'city_name'
|
10
|
+
is_feature false
|
11
|
+
x '1'
|
12
|
+
y '1'
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
factory :sf, :class => City do
|
17
|
+
cityname 'San_Francisco'
|
18
|
+
name 'San Francisco'
|
19
|
+
name_en 'San Francisco'
|
20
|
+
name_pt 'San Francisco'
|
21
|
+
name_ru 'San Francisco'
|
22
|
+
is_feature false
|
23
|
+
x '1'
|
24
|
+
y '1'
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
factory :nyc, :class => City do
|
29
|
+
cityname 'New_York_City'
|
30
|
+
name 'New York City'
|
31
|
+
name_en 'NYC'
|
32
|
+
name_pt 'NYC'
|
33
|
+
name_ru 'NYC'
|
34
|
+
is_feature false
|
35
|
+
x '1'
|
36
|
+
y '1'
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
factory :rio, :class => City do
|
41
|
+
name 'Rio Name'
|
42
|
+
cityname 'rio'
|
43
|
+
name_en 'rio'
|
44
|
+
name_pt 'rio'
|
45
|
+
name_ru 'rio'
|
46
|
+
is_feature false
|
47
|
+
calendar_frame 'calendar'
|
48
|
+
x '1.5'
|
49
|
+
y '1.5'
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
factory :chicago, :class => City do
|
54
|
+
name 'Chicago'
|
55
|
+
name_pt 'chicago'
|
56
|
+
name_en 'chicago'
|
57
|
+
name_ru 'chicago'
|
58
|
+
cityname 'chicago'
|
59
|
+
is_feature true
|
60
|
+
calendar_frame 'calendar frame'
|
61
|
+
x '1.4'
|
62
|
+
y '1.1'
|
63
|
+
end
|
64
|
+
|
65
|
+
factory :city_cccq, :class => City do
|
66
|
+
name 'cccq'
|
67
|
+
name_en 'cccp'
|
68
|
+
name_ru 'cccp'
|
69
|
+
name_pt 'cccp'
|
70
|
+
cityname 'cccq'
|
71
|
+
x '1.0'
|
72
|
+
y '1.2'
|
73
|
+
is_feature false
|
74
|
+
after :build do |city|
|
75
|
+
city.galleries << Gallery.all[0]
|
76
|
+
city.reports << Report.all[0]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
factory :maputo, :class => City do
|
81
|
+
name 'Maputo'
|
82
|
+
name_en 'maputo'
|
83
|
+
name_ru 'maputo'
|
84
|
+
name_pt 'maputo'
|
85
|
+
cityname 'Maputo'
|
86
|
+
is_feature true
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
|
2
|
+
FactoryGirl.define do
|
3
|
+
|
4
|
+
factory :gallery, :class => Gallery do
|
5
|
+
name 'g name'
|
6
|
+
galleryname 'g_name'
|
7
|
+
is_feature false
|
8
|
+
is_public true
|
9
|
+
is_trash false
|
10
|
+
username 'username'
|
11
|
+
after(:build) do |r|
|
12
|
+
r.user = User.first
|
13
|
+
r.site = Site.first
|
14
|
+
r.save
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
factory :pi_gallery, :class => Gallery do
|
19
|
+
name 'g name'
|
20
|
+
galleryname 'g_name'
|
21
|
+
is_feature false
|
22
|
+
is_public true
|
23
|
+
is_trash false
|
24
|
+
username 'username'
|
25
|
+
after(:build) do |r|
|
26
|
+
r.user = User.first
|
27
|
+
r.site = Site.first
|
28
|
+
r.save
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
factory :g1, :class => Gallery do
|
33
|
+
name 'g name11'
|
34
|
+
galleryname 'g_name11'
|
35
|
+
is_feature false
|
36
|
+
is_public true
|
37
|
+
is_trash false
|
38
|
+
username 'username'
|
39
|
+
created_at '2012-01-01'
|
40
|
+
after(:build) do |r|
|
41
|
+
r.user = User.first
|
42
|
+
r.site = Site.first
|
43
|
+
r.save
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
factory :g2, :class => Gallery do
|
48
|
+
name 'g name1234'
|
49
|
+
galleryname 'g_name4s2'
|
50
|
+
is_feature false
|
51
|
+
is_public true
|
52
|
+
is_trash false
|
53
|
+
username 'username'
|
54
|
+
created_at '2012-02-01'
|
55
|
+
after(:build) do |r|
|
56
|
+
r.user = User.first
|
57
|
+
r.site = Site.first
|
58
|
+
r.save
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
factory :g3, :class => Gallery do
|
63
|
+
name 'blah blah 2'
|
64
|
+
user User.all[0]
|
65
|
+
galleryname 'a2'
|
66
|
+
descr 'blah blah'
|
67
|
+
is_feature false
|
68
|
+
is_public true
|
69
|
+
is_trash false
|
70
|
+
username 'username'
|
71
|
+
created_at '2012-01-02'
|
72
|
+
after(:build) do |r|
|
73
|
+
r.user = User.first
|
74
|
+
r.site = Site.first
|
75
|
+
r.save
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
factory :g4, :class => Gallery do
|
80
|
+
name 'blah blah 23'
|
81
|
+
user User.all[0]
|
82
|
+
galleryname 'a3'
|
83
|
+
descr 'blah blah'
|
84
|
+
is_feature false
|
85
|
+
is_public true
|
86
|
+
is_trash false
|
87
|
+
username 'username'
|
88
|
+
after(:build) do |r|
|
89
|
+
r.user = User.first
|
90
|
+
r.site = Site.first
|
91
|
+
r.save
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
factory :g5, :class => Gallery do
|
96
|
+
name 'blah blah 24'
|
97
|
+
user User.all[0]
|
98
|
+
galleryname 'a4'
|
99
|
+
descr 'blah blah'
|
100
|
+
is_feature false
|
101
|
+
is_public true
|
102
|
+
is_trash false
|
103
|
+
username 'username'
|
104
|
+
after(:build) do |r|
|
105
|
+
r.user = User.first
|
106
|
+
r.site = Site.first
|
107
|
+
r.save
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
factory :gallery_anonymous, :parent => :g5 do
|
112
|
+
name 'anonymous gallery'
|
113
|
+
is_anonymous true
|
114
|
+
end
|
115
|
+
|
116
|
+
factory :private_gallery, :class => Gallery do
|
117
|
+
name 'g name private'
|
118
|
+
galleryname 'g_name_private'
|
119
|
+
is_feature false
|
120
|
+
is_public false
|
121
|
+
is_trash false
|
122
|
+
username 'username'
|
123
|
+
after(:build) do |r|
|
124
|
+
r.user = User.first
|
125
|
+
r.site = Site.first
|
126
|
+
r.save
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
|