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
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class AuthToken
|
3
|
+
|
4
|
+
def self.encode(payload, exp=24.hours.from_now)
|
5
|
+
payload[:exp] = exp.to_i
|
6
|
+
JWT.encode(payload, Rails.application.config.secret_key_base)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.decode(token)
|
10
|
+
payload = JWT.decode(token, Rails.application.config.secret_key_base)[0]
|
11
|
+
DecodedAuthToken.new(payload)
|
12
|
+
rescue
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
module AuxModel
|
3
|
+
|
4
|
+
def add_newsitem item
|
5
|
+
n = Newsitem.new
|
6
|
+
case item.class.name
|
7
|
+
when 'Video'
|
8
|
+
n.video_id = item.id
|
9
|
+
when 'Photo'
|
10
|
+
raise 'Not Implemented'
|
11
|
+
when 'Report'
|
12
|
+
raise 'Not Implemented'
|
13
|
+
when 'Gallery'
|
14
|
+
raise 'Not Implmented'
|
15
|
+
else
|
16
|
+
raise 'Not Implemented'
|
17
|
+
end
|
18
|
+
self.newsitems << n
|
19
|
+
self.save
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class CitiesUser
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
field :date, :type => Time
|
8
|
+
field :name, :type => String
|
9
|
+
field :descr, :type => String
|
10
|
+
|
11
|
+
belongs_to :city
|
12
|
+
belongs_to :user
|
13
|
+
|
14
|
+
has_many :reports
|
15
|
+
has_many :galleries
|
16
|
+
|
17
|
+
end
|
data/app/models/city.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
|
2
|
+
class City
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
# this does not have to be validated because I can autogenerate this value, yes?
|
8
|
+
field :name, :type => String
|
9
|
+
|
10
|
+
field :cityname, :type => String
|
11
|
+
validates :cityname, :uniqueness => true, :allow_nil => false, :presence => true
|
12
|
+
|
13
|
+
field :name_en, :type => String, :default => ''
|
14
|
+
validates :name_en, :uniqueness => true, :allow_nil => false, :presence => true
|
15
|
+
|
16
|
+
field :name_ru, :type => String, :default => ''
|
17
|
+
validates :name_ru, :uniqueness => true, :allow_nil => false, :presence => true
|
18
|
+
|
19
|
+
field :name_pt, :type => String, :default => ''
|
20
|
+
validates :name_pt, :uniqueness => true, :allow_nil => false, :presence => true
|
21
|
+
|
22
|
+
field :is_feature, :type => Boolean, :default => false
|
23
|
+
|
24
|
+
field :x, :type => Float
|
25
|
+
field :y, :type => Float
|
26
|
+
|
27
|
+
belongs_to :country
|
28
|
+
|
29
|
+
has_many :events
|
30
|
+
has_many :galleries
|
31
|
+
has_many :photos
|
32
|
+
has_many :reports
|
33
|
+
has_many :venues
|
34
|
+
has_many :videos
|
35
|
+
|
36
|
+
has_one :profile_photo, :class_name => 'Photo', :inverse_of => :profile_city
|
37
|
+
has_one :guide, :class_name => 'User', :inverse_of => :guide_city
|
38
|
+
has_many :current_users, :class_name => 'User', :inverse_of => :current_city
|
39
|
+
|
40
|
+
embeds_many :newsitems, cascade_callbacks: true
|
41
|
+
accepts_nested_attributes_for :newsitems
|
42
|
+
# @TODO @deprecated, I wish I don't use it.
|
43
|
+
field :n_newsitems, :type => Integer, :default => 16
|
44
|
+
|
45
|
+
embeds_many :features
|
46
|
+
# @TODO @deprecated, I wish I don't use it.
|
47
|
+
field :n_features, :type => Integer, :default => 4
|
48
|
+
|
49
|
+
field :calendar_frame, :type => String
|
50
|
+
|
51
|
+
default_scope ->{ order_by({ :name => :asc }) }
|
52
|
+
|
53
|
+
def self.feature
|
54
|
+
where( :is_feature => true )
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.non_feature
|
58
|
+
where( :is_feature => false )
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.list
|
62
|
+
out = self.order_by( :name => :asc )
|
63
|
+
# no_city = City.where( :cityname => 'no_city' ).first || City.create( :cityname => 'no_city', :name => 'No City' )
|
64
|
+
[['', nil]] + out.map { |item| [ item.name, item.id ] }
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.list_citynames lang = 'en'
|
68
|
+
out = self.order_by( :name => :asc )
|
69
|
+
[['', nil]] + out.map { |item| [ item['name_'+lang], item.cityname ] }
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.clear
|
73
|
+
if Rails.env.test?
|
74
|
+
City.all.each { |r| r.remove }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.n_features
|
79
|
+
4
|
80
|
+
end
|
81
|
+
|
82
|
+
def j_reports args = {}
|
83
|
+
out = []
|
84
|
+
self.reports.each do |r| # .page( params[:reports_page]
|
85
|
+
rr = r.clone
|
86
|
+
# rr[:photo_url] = r.photo.photo.url( :mini ) unless r.photo.blank?
|
87
|
+
# rr[:photo_url] ||= '/assets/missing.png'
|
88
|
+
rr[:username] = r.user.username
|
89
|
+
rr.created_at = r.created_at # pretty_date( r.created_at )
|
90
|
+
rr[:tag_name] = r.tag.name unless r.tag.blank?
|
91
|
+
rr[:tag_name] ||= ''
|
92
|
+
out << rr
|
93
|
+
end
|
94
|
+
return out
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.for_homepage
|
98
|
+
cities = City.all.order_by( :name => :asc )
|
99
|
+
cities = cities.delete_if do |c|
|
100
|
+
( false == c.is_feature ) && ( 0 == c.galleries.length ) && ( 0 == c.reports.length )
|
101
|
+
end
|
102
|
+
return cities
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.feature
|
106
|
+
City.where( :is_feature => true )
|
107
|
+
end
|
108
|
+
|
109
|
+
def add_newsitem doc
|
110
|
+
# puts! self.newsitems, "city newsitems are"
|
111
|
+
if 'Video' == doc.class.name
|
112
|
+
self.newsitems << Newsitem.new({ :descr => '', :username => '', :video => doc })
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
data/app/models/day.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
class Day
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
|
6
|
+
field :date, :type => String
|
7
|
+
validates :date, :presence => true, :uniqueness => { :scope => :user }
|
8
|
+
|
9
|
+
belongs_to :user
|
10
|
+
validates :user, :presence => true
|
11
|
+
|
12
|
+
field :a1, :type => String
|
13
|
+
field :a2, :type => String
|
14
|
+
field :a3, :type => String
|
15
|
+
field :a4, :type => String
|
16
|
+
field :a5, :type => String
|
17
|
+
|
18
|
+
field :work, :type => String
|
19
|
+
field :dream, :type => String
|
20
|
+
|
21
|
+
end
|
data/app/models/event.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
class Event
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
field :name, :type => String
|
8
|
+
validates :name, :presence => true, :uniqueness => true
|
9
|
+
|
10
|
+
field :name_seo, :type => String
|
11
|
+
validates :name_seo, :presence => true, :uniqueness => true
|
12
|
+
|
13
|
+
field :descr, :type => String
|
14
|
+
|
15
|
+
field :date, :type => DateTime
|
16
|
+
validates :date, :presence => true
|
17
|
+
|
18
|
+
belongs_to :city
|
19
|
+
validates :city, :presence => true
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
|
2
|
+
class Feature
|
3
|
+
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Timestamps
|
6
|
+
|
7
|
+
field :name, :type => String
|
8
|
+
field :subhead, :type => String
|
9
|
+
|
10
|
+
field :image_path, :type => String
|
11
|
+
field :link_path, :type => String
|
12
|
+
field :partial_name, :type => String, :default => nil
|
13
|
+
|
14
|
+
field :weight, :type => Integer, :default => 10
|
15
|
+
|
16
|
+
belongs_to :photo
|
17
|
+
belongs_to :report
|
18
|
+
belongs_to :gallery
|
19
|
+
belongs_to :video
|
20
|
+
# has_one :photo
|
21
|
+
# has_one :report
|
22
|
+
# has_one :gallery
|
23
|
+
# has_one :video
|
24
|
+
|
25
|
+
embedded_in :venue
|
26
|
+
embedded_in :site
|
27
|
+
embedded_in :city
|
28
|
+
embedded_in :tag
|
29
|
+
|
30
|
+
def self.all
|
31
|
+
self.order_by( :created_at => :desc )
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.n_features
|
35
|
+
4
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
require_relative '../../lib/string'
|
3
|
+
|
4
|
+
class Gallery < AppModel2
|
5
|
+
|
6
|
+
belongs_to :site
|
7
|
+
validates :site, :presence => true
|
8
|
+
|
9
|
+
belongs_to :user
|
10
|
+
validates :user, :presence => true
|
11
|
+
field :username, :type => String
|
12
|
+
|
13
|
+
field :name, :type => String
|
14
|
+
validates :name, :uniqueness => true # , :allow_nil => false
|
15
|
+
|
16
|
+
field :galleryname, :type => String
|
17
|
+
validates :galleryname, :uniqueness => true # , :allow_nil => false
|
18
|
+
|
19
|
+
field :subhead, :type => String
|
20
|
+
field :descr, :type => String
|
21
|
+
field :lang, :type => String, :default => 'en'
|
22
|
+
|
23
|
+
# not necessary because AppModel2
|
24
|
+
# default_scope ->{ where( :is_public => true, :is_trash => false ).order_by( :created_at => :desc ) }
|
25
|
+
|
26
|
+
has_many :photos
|
27
|
+
|
28
|
+
belongs_to :tag
|
29
|
+
belongs_to :city
|
30
|
+
belongs_to :venue
|
31
|
+
|
32
|
+
set_callback(:create, :before) do |doc|
|
33
|
+
doc.username = doc.user.username
|
34
|
+
doc.galleryname = doc.name.to_simple_string
|
35
|
+
|
36
|
+
# for the homepage
|
37
|
+
if doc.is_public && doc.site
|
38
|
+
n = Newsitem.new {}
|
39
|
+
n.gallery = doc
|
40
|
+
n.username = doc.user.username
|
41
|
+
sites = Site.where( :domain => doc.site.domain )
|
42
|
+
sites.each do |site|
|
43
|
+
site.newsitems << n
|
44
|
+
flag = site.save
|
45
|
+
if !flag
|
46
|
+
puts! site.errors
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# @deprecated, use Gallery::ACTIONS
|
53
|
+
def self.actions
|
54
|
+
[ 'show_mini', 'show_long', 'show' ]
|
55
|
+
end
|
56
|
+
ACTIONS = [ 'show_mini', 'show_long', 'show' ]
|
57
|
+
|
58
|
+
end
|
59
|
+
|