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/sites_tasks.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'builder'
|
3
|
+
|
4
|
+
class SitesTasks < ActionController::Base
|
5
|
+
|
6
|
+
def pretty_date args
|
7
|
+
args.strftime('%Y-%m-%d')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.n_reports_galleries
|
11
|
+
Site.each do |site|
|
12
|
+
puts! site
|
13
|
+
save = false
|
14
|
+
if site.n_galleries.blank?
|
15
|
+
site.n_galleries = site.galleries.length
|
16
|
+
save = true
|
17
|
+
end
|
18
|
+
if site.n_reports.blank?
|
19
|
+
site.n_reports = site.reports.length
|
20
|
+
save = true
|
21
|
+
end
|
22
|
+
if save
|
23
|
+
if site.save
|
24
|
+
puts( "+++ +++ Site #{site.domain}/#{site.lang}" )
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
data/lib/string.rb
ADDED
data/lib/tags_tasks.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
|
2
|
+
require 'cgi'
|
3
|
+
|
4
|
+
class TagsTasks
|
5
|
+
|
6
|
+
def self.to_mongodb
|
7
|
+
|
8
|
+
# get all tags
|
9
|
+
old_tags = Tag.find :all
|
10
|
+
|
11
|
+
# put them in mongoid
|
12
|
+
old_tags.each do |old|
|
13
|
+
new = NoTag.new
|
14
|
+
|
15
|
+
new.name = old.name
|
16
|
+
new.name_seo = old.name_seo
|
17
|
+
# new.subhead = old.subhead
|
18
|
+
new.descr = old.descr
|
19
|
+
|
20
|
+
new.domain = 'sedux.local'
|
21
|
+
|
22
|
+
new.created_at = old.created_at
|
23
|
+
new.updated_at = old.updated_at
|
24
|
+
|
25
|
+
new.is_public = 1
|
26
|
+
new.is_feature = 0
|
27
|
+
new.is_trash = 0
|
28
|
+
|
29
|
+
new.lang = 'en'
|
30
|
+
|
31
|
+
new.save
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.name_to_name_en
|
38
|
+
Tag.all.each do |tag|
|
39
|
+
tag.name_en = tag.name
|
40
|
+
if '' == tag.name_pt
|
41
|
+
tag.name_pt = tag.name_en
|
42
|
+
end
|
43
|
+
if '' == tag.name_ru
|
44
|
+
tag.name_ru = tag.name_en
|
45
|
+
end
|
46
|
+
flag = tag.save
|
47
|
+
if flag
|
48
|
+
puts '+'
|
49
|
+
else
|
50
|
+
puts tag.errors.inspect
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
#class NoTag
|
60
|
+
#
|
61
|
+
# include Mongoid::Document
|
62
|
+
#
|
63
|
+
# field :name, :type => String
|
64
|
+
# field :name_seo, :type => String
|
65
|
+
# field :subhead, :type => String
|
66
|
+
# field :descr, :type => String
|
67
|
+
# field :domain, :type => String
|
68
|
+
#
|
69
|
+
# has_many :reports
|
70
|
+
# accepts_nested_attributes_for :reports, :allow_destroy => false
|
71
|
+
#
|
72
|
+
# has_many :galleries
|
73
|
+
# accepts_nested_attributes_for :galleries, :allow_destroy => false
|
74
|
+
#
|
75
|
+
# belongs_to :parent_tag, :class_name => 'Tag', :inverse_of => :children_tags
|
76
|
+
# has_many :children_tags, :class_name => 'Tag', :inverse_of => :parent_tag
|
77
|
+
# accepts_nested_attributes_for :children_tags, :allow_destroy => false
|
78
|
+
# accepts_nested_attributes_for :parent_tag, :allow_destroy => false
|
79
|
+
#
|
80
|
+
# field :created_at, :type => DateTime
|
81
|
+
# field :updated_at, :type => DateTime
|
82
|
+
#
|
83
|
+
# field :is_public, :type => Boolean
|
84
|
+
# field :is_feature, :type => Boolean
|
85
|
+
# field :is_trash, :type => Boolean
|
86
|
+
#
|
87
|
+
#end
|
88
|
+
#
|
89
|
+
#create_table "tags", :force => true do |t|
|
90
|
+
# t.string "name", :limit => 200, :null => false
|
91
|
+
# t.string "name_seo", :limit => 600, :null => false
|
92
|
+
# t.text "descr"
|
93
|
+
# t.integer "parent_id", :default => 1
|
94
|
+
# t.integer "user_id", :default => 0, :null => false
|
95
|
+
# t.timestamp "created_at", :null => false
|
96
|
+
# t.timestamp "updated_at", :null => false
|
97
|
+
# t.integer "is_public", :default => 1, :null => false
|
98
|
+
# t.boolean "is_feature", :default => false, :null => false
|
99
|
+
# t.boolean "is_trash", :default => false, :null => false
|
100
|
+
# t.string "name_pt"
|
101
|
+
# t.string "descr_pt"
|
102
|
+
# t.integer "language_id"
|
103
|
+
# t.string "lang", :default => "en"
|
104
|
+
# end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'reports_tasks'
|
4
|
+
require 'cities_tasks'
|
5
|
+
|
6
|
+
namespace :cities do
|
7
|
+
|
8
|
+
desc 'to mongoid'
|
9
|
+
task :to_mongoid => :environment do
|
10
|
+
CitiesTasks.to_mongoid
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'attach reports to cities'
|
14
|
+
task :attach_reports_to_cities => :environment do
|
15
|
+
CitiesTasks.attach_reports_to_cities
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'refresh_features cityname=some_cityname -OR- cities:refresh_features (all)'
|
19
|
+
task :refresh_features => :environment do
|
20
|
+
CitiesTasks.new.refresh_features ENV['cityname']
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'refresh_newsitems cityname=cityname OR refresh_newsitems'
|
24
|
+
task :refresh_newsitems => :environment do
|
25
|
+
CitiesTasks.new.refresh_newsitems ENV['cityname']
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'galleries_tasks'
|
4
|
+
|
5
|
+
namespace :galleries do
|
6
|
+
|
7
|
+
desc "clean_name_seo"
|
8
|
+
task :clean_name_seo => :environment do
|
9
|
+
GalleriesTasks.clean_name_seo
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
desc 'to_mongoid'
|
14
|
+
task :to_mongoid => :environment do
|
15
|
+
GalleriesTasks.to_mongoid
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'reports_tasks'
|
2
|
+
|
3
|
+
namespace :reports do
|
4
|
+
|
5
|
+
desc 'attached_photos_to_mongoid'
|
6
|
+
task :attached_photos_to_mongoid => :environment do
|
7
|
+
ReportsTasks.attached_photos_to_mongoid
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "migrate some features to mongoid"
|
11
|
+
task :some_features => :environment do
|
12
|
+
ReportsTasks.some_features
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'to mongoid'
|
17
|
+
task :to_mongoid => :environment do
|
18
|
+
ReportsTasks.to_mongoid
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'parse one reuters article'
|
22
|
+
task :parse_reuters_technology_rss => :environment do
|
23
|
+
ReportsTasks.parse_reuters_technology_rss
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'empty trash'
|
27
|
+
task :empty_trash => :environment do
|
28
|
+
ReportsTasks.empty_trash
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'titleize'
|
32
|
+
task :titleize => :environment do
|
33
|
+
;
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
|
2
|
+
require 'resque/tasks'
|
3
|
+
|
4
|
+
task "resque:setup" => :environment do
|
5
|
+
ENV['QUEUE'] ||= '*'
|
6
|
+
# for redistogo on heroku http://stackoverflow.com/questions/2611747/rails-resque-workers-fail-with-pgerror-server-closed-the-connection-unexpectedl
|
7
|
+
# Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
|
8
|
+
end
|
data/lib/tasks/tags.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
require 'tags_tasks'
|
3
|
+
|
4
|
+
namespace :tags do
|
5
|
+
|
6
|
+
desc " put from sql to mongoid "
|
7
|
+
task :to_mongoid => :environment do
|
8
|
+
TagsTasks.to_mongodb
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'name to name en'
|
13
|
+
task :name_to_name_en => :environment do
|
14
|
+
TagsTasks.name_to_name_en
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'videos_tasks'
|
4
|
+
|
5
|
+
namespace :videos do
|
6
|
+
|
7
|
+
desc "To no_video"
|
8
|
+
task :to_no_video => :environment do
|
9
|
+
VideosTasks.to_no_video
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Title to name'
|
13
|
+
task :title_to_name => :environment do
|
14
|
+
VideosTasks.title_to_name
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
require 'wikitravel_tasks'
|
3
|
+
|
4
|
+
namespace :wikitravel do
|
5
|
+
|
6
|
+
desc "deprecated? Usage: be rake wikitravel:random_page_to_newsitem domain='mobi.local'"
|
7
|
+
task :random_page_to_newsitem => :environment do
|
8
|
+
# takes too long
|
9
|
+
WikitravelTasks.parse_list_of_pages
|
10
|
+
|
11
|
+
w = WikitravelTasks.new
|
12
|
+
w.random_page_to_newsitem({ :domain => ENV['domain'] })
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Take manually precompiled list of pages off of wikitravel.org, and create a WikitravelPage for each one that does not exist."
|
16
|
+
task :parse_list_of_pages => :environment do
|
17
|
+
arguments = { :filename => ENV['filename'] }
|
18
|
+
WikitravelTasks.parse_list_of_pages arguments
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "all pages"
|
22
|
+
task :all_pages_to_report_and_newsitems => :environment do
|
23
|
+
arg = { :domain => ENV['domain'], :lang => ENV['lang'] }
|
24
|
+
w = WikitravelTasks.new arg
|
25
|
+
w.all_pages_to_report_and_newsitems
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Cleanup reports"
|
29
|
+
task :cleanup_reports => :environment do
|
30
|
+
mobi = Site.where( :domain => 'travel-guide.mobi', :lang => 'en' ).first
|
31
|
+
reports = Report.where( :site => mobi )
|
32
|
+
reports.each do |r|
|
33
|
+
rr = WikitravelTasks.cleanup_report( r )
|
34
|
+
puts "cleaning up #{rr.name}"
|
35
|
+
rr.save
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
data/lib/u.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
class U
|
4
|
+
|
5
|
+
|
6
|
+
def self.clean_name_seo g
|
7
|
+
|
8
|
+
g[:name_seo] = CGI.escape(g[:name]).strip.
|
9
|
+
gsub('_', '-').
|
10
|
+
gsub('+', '-').
|
11
|
+
gsub('.', '-').
|
12
|
+
gsub("'", '').
|
13
|
+
gsub(",", '')
|
14
|
+
|
15
|
+
if g.save
|
16
|
+
;
|
17
|
+
else
|
18
|
+
flag = false
|
19
|
+
old = g[:name_seo]
|
20
|
+
c = 1
|
21
|
+
while !flag
|
22
|
+
g[:name_seo] += "-#{c.to_s}"
|
23
|
+
flag = g.save
|
24
|
+
c += 1
|
25
|
+
|
26
|
+
break if c > 1000
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|