ants 0.1.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8c6a614bddaf771cea07967a40889d1906b77bf
4
- data.tar.gz: 2fd8e2ee2a1082cd3553e32a3b339ac82760737f
3
+ metadata.gz: 657a8e90e24c3847912f0ef7fc274c30aab73d5b
4
+ data.tar.gz: 856b34fef9723974bee0caae3df40a85b3ac11a0
5
5
  SHA512:
6
- metadata.gz: 7e274801d1607d7a8183f36900b295a4110db77f3140d4e2102e0cf8d55e1e5b47eb4d850c303fd63e279840d28a8ee8bc74716e0ea5a521571d5b7b4520709d
7
- data.tar.gz: 3d09b56d1833ebd0f47eddbcd97e883b746bd5cf43b4e8b7bc3143324b8deabcc35238322c76747d7caba0da76b27ebdac2dc33ebb5aa137f4dca25b693ae620
6
+ metadata.gz: cfa87fcb807e24fcbc2a92312587a8b6ec344efd3800ab3a0daa969747e2cb9f533440b464e4f654935d2589cda2a6359ccb4027b13ca83a378a7aabf35248c4
7
+ data.tar.gz: f357f1da041400c5b0444fd13eb481fa59e612d7d39864caacd66ed2d6fc61d6bc9254fd10b217d8db35ce18773633db9bfdf4d544c3e744204493f49edde2f2
data/.gitignore CHANGED
@@ -34,4 +34,6 @@ bower.json
34
34
  .powenv
35
35
 
36
36
  # Mac chached files
37
- .DS_Store
37
+ .DS_Store
38
+
39
+ pkg/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ants (0.1.1)
4
+ ants (0.1.4)
5
5
  mongoid (>= 4.0)
6
6
  mongoid-slug (>= 4.0.0)
7
7
 
@@ -44,7 +44,7 @@ GEM
44
44
  thread_safe (~> 0.3, >= 0.3.4)
45
45
  tzinfo (~> 1.1)
46
46
  arel (6.0.0)
47
- bson (2.3.0)
47
+ bson (3.1.2)
48
48
  builder (3.2.2)
49
49
  connection_pool (2.2.0)
50
50
  coveralls (0.8.1)
@@ -79,8 +79,8 @@ GEM
79
79
  mongoid-slug (4.0.0)
80
80
  mongoid (>= 3.0)
81
81
  stringex (~> 2.0)
82
- moped (2.0.4)
83
- bson (~> 2.2)
82
+ moped (2.0.6)
83
+ bson (~> 3.0)
84
84
  connection_pool (~> 2.0)
85
85
  optionable (~> 0.2.0)
86
86
  netrc (0.10.3)
@@ -162,9 +162,12 @@ PLATFORMS
162
162
 
163
163
  DEPENDENCIES
164
164
  ants!
165
- bundler
165
+ bundler (~> 1.9)
166
166
  coveralls
167
167
  rails (>= 4.1)
168
- rake (>= 0.8.7)
168
+ rake (~> 10.0)
169
169
  rspec (>= 2.0)
170
170
  rspec-aspic (>= 0.0.2)
171
+
172
+ BUNDLED WITH
173
+ 1.10.4
data/ants.gemspec CHANGED
@@ -24,9 +24,11 @@ Collection of concerns and helpers for Rails + Mongoid + Character web developme
24
24
  s.add_dependency('mongoid-slug', '>= 4.0.0')
25
25
 
26
26
  s.add_development_dependency('rails', [ '>= 4.1' ])
27
- s.add_development_dependency('rake', [ '>= 0.8.7' ])
28
27
  s.add_development_dependency('rspec', [ '>= 2.0' ])
29
28
  s.add_development_dependency('rspec-aspic', [ '>= 0.0.2' ])
30
- s.add_development_dependency 'bundler'
31
- s.add_development_dependency 'coveralls'
29
+ s.add_development_dependency('coveralls')
30
+
31
+ s.add_development_dependency('bundler', '~> 1.9')
32
+ s.add_development_dependency('rake', '~> 10.0')
33
+
32
34
  end
@@ -0,0 +1,2 @@
1
+ #= require chr/admins
2
+ #= require chr/redirects
@@ -0,0 +1,39 @@
1
+ @Ants ||= {}
2
+
3
+ Ants.adminsConfig = ->
4
+ showWithParent: true
5
+
6
+ arrayStore: new RailsArrayStore({
7
+ resource: 'admin'
8
+ path: '/admin/admins'
9
+ sortBy: 'name'
10
+ searchable: true
11
+ })
12
+
13
+ formSchema:
14
+ name:
15
+ type: 'string'
16
+ required: true
17
+ label: """Name <small>— to update or add avatar, please register on
18
+ <a href='http://gravatar.com' target='_blank'>Gravatar</a>
19
+ using same email address</small>"""
20
+ placeholder: 'Users full name'
21
+
22
+ email:
23
+ type: 'string'
24
+ required: true
25
+ onInitialize: (input) ->
26
+ if input.object
27
+ input.$el.removeClass 'input-required'
28
+ input.config.disabled = true
29
+ input._add_disabled()
30
+
31
+ password:
32
+ type: 'password'
33
+ required: true
34
+ onInitialize: (input) ->
35
+ if input.object
36
+ input.$el.removeClass 'input-required'
37
+ input.$label.html 'Change Password'
38
+ input.config.placeholder = 'Type new password here to update the current one'
39
+ input._add_placeholder()
@@ -0,0 +1,20 @@
1
+ @Ants ||= {}
2
+
3
+ Ants.redirectsConfig = ->
4
+ showWithParent: true
5
+
6
+ onViewShow: (view) ->
7
+ if view.object
8
+ view.$linkBtn =$ "<a href='#{ view.object.path_from }' class='link open' target='_blank'>Open</a>"
9
+ view.$header.append view.$linkBtn
10
+
11
+ arrayStore: new RailsArrayStore({
12
+ resource: 'redirect'
13
+ path: '/admin/redirects'
14
+ sortBy: 'path_from'
15
+ searchable: true
16
+ })
17
+
18
+ formSchema:
19
+ path_from: { type: 'string', label: 'From', placeholder: '/redirect-from-path', required: true }
20
+ path_to: { type: 'url', label: 'To', placeholder: '/redirect-to-path', required: true }
@@ -0,0 +1 @@
1
+ @import "chr/header";
@@ -0,0 +1,35 @@
1
+
2
+ // Preview & Open view header link
3
+
4
+ .header {
5
+ .link {
6
+ @include header-button($positiveColor);
7
+ @include position(absolute, 0 1em null null);
8
+
9
+ &.open { right : 4em; }
10
+ }
11
+ }
12
+
13
+ // List header CSV button
14
+
15
+ .header {
16
+ .csv + .search { @include position(absolute, 0 40px null null); }
17
+ .csv {
18
+ @extend .icon-base;
19
+ @include position(absolute, 0 0 null null);
20
+
21
+ &:after {
22
+ content : 'csv';
23
+ width : 100%;
24
+ background : transparent;
25
+ text-align : center;
26
+ margin-top : -.7em;
27
+ color : $positiveColor;
28
+ }
29
+ }
30
+ }
31
+
32
+
33
+ .list-search .header {
34
+ .csv + .search { @include position(absolute, 0 0 null 0); }
35
+ }
@@ -0,0 +1,8 @@
1
+ class RedirectsController < ApplicationController
2
+
3
+ def show
4
+ redirect = Redirect.match(request)
5
+ redirect_to redirect.path_to
6
+ end
7
+
8
+ end
@@ -0,0 +1,96 @@
1
+ class Admin
2
+ include Mongoid::Document
3
+ include Mongoid::Timestamps
4
+
5
+ include Mongoid::Search
6
+ include Ants::Id
7
+
8
+
9
+ ## Attributes
10
+ field :name, default: ''
11
+
12
+ # Include default devise modules. Others available are:
13
+ # :confirmable, :lockable, :timeoutable, :registerable, :validatable and :omniauthable
14
+ devise :database_authenticatable, :recoverable, :rememberable, :trackable, :authentication_keys => [ :email ]
15
+
16
+ ## Database authenticatable
17
+ field :email, type: String, default: ""
18
+ field :encrypted_password, type: String, default: ""
19
+
20
+ ## Recoverable
21
+ field :reset_password_token, type: String
22
+ field :reset_password_sent_at, type: Time
23
+
24
+ ## Rememberable
25
+ field :remember_created_at, type: Time
26
+
27
+ ## Trackable
28
+ field :sign_in_count, type: Integer, default: 0
29
+ field :current_sign_in_at, type: Time
30
+ field :last_sign_in_at, type: Time
31
+ field :current_sign_in_ip, type: String
32
+ field :last_sign_in_ip, type: String
33
+
34
+ ## Confirmable
35
+ # field :confirmation_token, type: String
36
+ # field :confirmed_at, type: Time
37
+ # field :confirmation_sent_at, type: Time
38
+ # field :unconfirmed_email, type: String # Only if using reconfirmable
39
+
40
+ ## Lockable
41
+ # field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
42
+ # field :unlock_token, type: String # Only if unlock strategy is :email or :both
43
+ # field :locked_at, type: Time
44
+
45
+
46
+ ## Validations
47
+ validates :name, presence: true
48
+
49
+
50
+ ## Search
51
+ search_in :name, :email
52
+
53
+
54
+ ## Scopes
55
+ default_scope -> { asc(:name) }
56
+
57
+
58
+ ## Indexes
59
+ index({ name: 1 })
60
+
61
+
62
+ # HELPERS
63
+ def devise_mailer
64
+ AdminMailer
65
+ end
66
+
67
+
68
+ def last_sign_in_ago
69
+ if last_sign_in_at
70
+ 'seen ' + ActionController::Base.helpers.time_ago_in_words(last_sign_in_at) + ' ago'
71
+ else
72
+ 'never seen'
73
+ end
74
+ end
75
+
76
+
77
+ def _list_item_title
78
+ name.empty? ? email : name
79
+ end
80
+
81
+
82
+ def _list_item_subtitle
83
+ last_sign_in_ago
84
+ end
85
+
86
+
87
+ def _list_item_thumbnail
88
+ "http://www.gravatar.com/avatar/#{ Digest::MD5.hexdigest(email) }?s=80&d=retro&r=g"
89
+ end
90
+
91
+
92
+ end
93
+
94
+
95
+
96
+
@@ -0,0 +1,71 @@
1
+ class Redirect
2
+ include Mongoid::Document
3
+ include Mongoid::Timestamps
4
+
5
+ include Mongoid::Search
6
+ include Ants::Id
7
+
8
+
9
+ ## Attributes
10
+ field :path_from, type: String
11
+ field :path_to, type: String
12
+
13
+ ## Validations
14
+ validates :path_from, presence: true
15
+ validates :path_to, presence: true
16
+
17
+ ## Search
18
+ search_in :path_from, :path_to
19
+
20
+ ## Scope
21
+ default_scope -> { asc(:path_from) }
22
+
23
+ ## Indexes
24
+ index({ path_from: 1 })
25
+
26
+
27
+ ## Callbacks
28
+ after_validation :downcase_paths!
29
+
30
+
31
+ ## Helpers
32
+ def _list_item_title
33
+ path_from
34
+ end
35
+
36
+
37
+ def _list_item_subtitle
38
+ 'created ' + ActionController::Base.helpers.time_ago_in_words(created_at) + ' ago'
39
+ end
40
+
41
+
42
+ ## Class Methods
43
+ def self.match(request)
44
+ # request.fullpath includes parameters and leading / so
45
+ # add ending slash (Rails skips it) as alternative option
46
+ fullpath = request.fullpath
47
+ fullpath_alt1 = fullpath.gsub('?', '/?')
48
+
49
+ # decode URL to UTF string, e.g. %C3%A9 => é
50
+ fullpath_alt2 = URI.unescape(fullpath)
51
+ fullpath_alt3 = URI.unescape(fullpath_alt1)
52
+
53
+ self.where(:path_from.in => [ fullpath, fullpath_alt1, fullpath_alt2, fullpath_alt3 ]).first
54
+ end
55
+
56
+
57
+ private
58
+
59
+ def downcase_paths!
60
+ self.path_from.downcase!
61
+ self.path_to.downcase!
62
+
63
+ return true
64
+ end
65
+
66
+
67
+ end
68
+
69
+
70
+
71
+
data/lib/ants.rb CHANGED
@@ -14,4 +14,7 @@ module Ants
14
14
  require "concerns/ants/slug"
15
15
  require "concerns/ants/publication"
16
16
  require "concerns/ants/sorted_relations"
17
+ require "concerns/ants/versions"
18
+
19
+ require "constraints/redirects"
17
20
  end
data/lib/ants/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ants
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,25 @@
1
+ module Ants
2
+ module Versions
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ # returns list of available object versions, requires
8
+ # include Mongoid::History::Trackable to be configured
9
+ def _document_versions
10
+ hash = {}
11
+
12
+ history_tracks.only(:created_at, :version).collect do |h|
13
+ hash[h.version] = "Version #{ h.version } — #{ h.created_at }"
14
+ end
15
+
16
+ if hash.empty?
17
+ hash = { '' => '--' }
18
+ end
19
+
20
+ return hash
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ module Constraints
2
+ class Redirects
3
+
4
+ def self.matches?(request)
5
+ Redirect.match(request)
6
+ end
7
+
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ants
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kravets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-14 00:00:00.000000000 Z
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -53,75 +53,75 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.8.7
61
+ version: '2.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.8.7
68
+ version: '2.0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
70
+ name: rspec-aspic
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: 0.0.2
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '2.0'
82
+ version: 0.0.2
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec-aspic
84
+ name: coveralls
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.0.2
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 0.0.2
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '1.9'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '1.9'
111
111
  - !ruby/object:Gem::Dependency
112
- name: coveralls
112
+ name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '10.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '10.0'
125
125
  description: |
126
126
  Collection of concerns and helpers for Rails + Mongoid + Character web development
127
127
  email: alex@slatestudio.com
@@ -139,6 +139,14 @@ files:
139
139
  - README.md
140
140
  - Rakefile
141
141
  - ants.gemspec
142
+ - app/assets/javascripts/ants.coffee
143
+ - app/assets/javascripts/chr/admins.coffee
144
+ - app/assets/javascripts/chr/redirects.coffee
145
+ - app/assets/stylesheets/ants.scss
146
+ - app/assets/stylesheets/chr/header.scss
147
+ - app/controllers/redirects_controller.rb
148
+ - app/models/admin.rb
149
+ - app/models/redirect.rb
142
150
  - lib/ants.rb
143
151
  - lib/ants/engine.rb
144
152
  - lib/ants/version.rb
@@ -150,6 +158,8 @@ files:
150
158
  - lib/concerns/ants/publication.rb
151
159
  - lib/concerns/ants/slug.rb
152
160
  - lib/concerns/ants/sorted_relations.rb
161
+ - lib/concerns/ants/versions.rb
162
+ - lib/constraints/redirects.rb
153
163
  - lib/mongoid/fake_criteria.rb
154
164
  - spec/mongoid/fake_criteria_spec.rb
155
165
  - spec/mongoid/sorted_relations_spec.rb