faalis 0.25.0 → 0.25.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/faalis/#api_controller.rb# +6 -99
- data/app/models/faalis/user.rb +2 -1
- data/config/routes.rb +0 -24
- data/lib/faalis.rb +1 -0
- data/lib/faalis/generators/concerns/fieldset.rb +0 -1
- data/lib/faalis/generators/fields/#relation.rb# +61 -0
- data/lib/faalis/route.rb +34 -0
- data/lib/faalis/version.rb +1 -1
- data/lib/generators/faalis/install_generator.rb +6 -0
- metadata +25 -34
- data/app/assets/javascripts/faalis/dashboard/gen-doc.sh~ +0 -3
- data/app/controllers/faalis/#1.sh# +0 -0
- data/app/controllers/faalis/api/v1/#conversations_controller.rb# +0 -120
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +0 -15
- data/spec/dummy/tmp/ember-rails/ember-data.js +0 -10204
- data/spec/dummy/tmp/ember-rails/ember.js +0 -36991
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92d6f9b183ece15b72ef85fb3b1c41acb5b83dc3
|
4
|
+
data.tar.gz: b55b02c4d5ac355ab244fa64dddba6250631c730
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a0cb0d117abe8798a466bf7cbab923d0dcff029c66f6782935e62c11ffd31f02910671f989fb058efe1240fd66f4b56781ef68f1774117bd914495619b8b954
|
7
|
+
data.tar.gz: 489820dd820ecef13793baf510587918702649d1d40362aa842bf945119093bc89c6ccf8f70bdb534eeaa4b4f6536da25c66cffcf74827e8c83f4e15218c7a19
|
@@ -19,31 +19,19 @@
|
|
19
19
|
require_dependency "faalis/api_controller"
|
20
20
|
|
21
21
|
|
22
|
-
# This class is the base class of all API controllers in any **Faalis**
|
23
|
-
# host applications. Each host Rails application should have an `APIController`
|
24
|
-
# which inherit from this class.
|
25
22
|
class Faalis::APIController < Faalis::ApplicationController
|
26
|
-
|
27
|
-
@@allowed_fields = []
|
28
|
-
|
29
|
-
# Only support `json` format
|
30
23
|
respond_to :json
|
31
24
|
|
32
|
-
|
33
|
-
before_filter :authenticate_filter
|
34
|
-
|
35
|
-
# Check for any presence of filtering query, In querystring and load
|
36
|
-
# resource using them
|
37
|
-
before_filter :load_resource_by_query, :only => [:index]
|
38
|
-
|
25
|
+
before_filter :authenticate_user!
|
39
26
|
|
40
27
|
protect_from_forgery
|
41
28
|
|
42
|
-
# Set csrf cookie after any action
|
43
29
|
after_filter :set_csrf_cookie_for_ng
|
44
30
|
|
45
|
-
|
46
|
-
|
31
|
+
def set_csrf_cookie_for_ng
|
32
|
+
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
|
33
|
+
end
|
34
|
+
|
47
35
|
rescue_from CanCan::AccessDenied do |exception|
|
48
36
|
|
49
37
|
render :status => 403, :json => {
|
@@ -53,92 +41,11 @@ class Faalis::APIController < Faalis::ApplicationController
|
|
53
41
|
}
|
54
42
|
end
|
55
43
|
|
56
|
-
def set_csrf_cookie_for_ng
|
57
|
-
cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery?
|
58
|
-
end
|
59
|
-
|
60
|
-
# User authentication for API services take place here. By default
|
61
|
-
# **Faalis** uses the authentication method of **Devise** to authenticate
|
62
|
-
# access to API service.
|
63
|
-
#
|
64
|
-
# If you want to change authentication method ? just override this method
|
65
|
-
# in you **APIController**
|
66
|
-
def authenticate_filter
|
67
|
-
authenticate_user!
|
68
|
-
end
|
69
|
-
|
70
|
-
# Load resource by using parameters specified in querystring.
|
71
|
-
def load_resource_by_query
|
72
|
-
# If any query string parameter provided and allow fields specified
|
73
|
-
if not request.query_parameters.empty? and not allowed_fields.empty?
|
74
|
-
|
75
|
-
logger.info ("Load resource by query parameters")
|
76
|
-
# Iterate over parameters in query string
|
77
|
-
request.query_parameters.each do |key, value|
|
78
|
-
# each key can be like filename[__querytype]=value
|
79
|
-
# which `querytype` is string that specify the query type scope
|
80
|
-
# to use in model. For example these is a query type scope called
|
81
|
-
# `gt` which mean the mentioned field should be greater than the
|
82
|
-
# value
|
83
|
-
field, query_type = key.split("__")
|
84
|
-
|
85
|
-
if allowed_fields.include? field
|
86
|
-
# If field name is in the allowed list
|
87
|
-
# If no query type specified we will use assignment scope.
|
88
|
-
if query_type.nil?
|
89
|
-
query_type = "assignment"
|
90
|
-
end
|
91
|
-
|
92
|
-
# If model have an scope with the "#{query_type}_query" name.
|
93
|
-
# Otherwise skip
|
94
|
-
if model_class.respond_to? "#{query_type}_query"
|
95
|
-
|
96
|
-
# If resource already loaded. If there was a instnace variable
|
97
|
-
# with the plural name of the resource exists then resource
|
98
|
-
# already loaded and we should chain new conditions
|
99
|
-
if instance_variable_defined? "@#{controller_name}"
|
100
|
-
instance_variable_get("@#{controller_name}").send("#{query_type}_query".to_sym, field, value)
|
101
|
-
else
|
102
|
-
# Resource did not loaded we make first query
|
103
|
-
# (without touching database) and set the corresponding
|
104
|
-
# instance variables
|
105
|
-
relation_object = model_class.send("#{query_type}_query".to_sym, field, value)
|
106
|
-
instance_variable_set("@#{controller_name}", relation_object)
|
107
|
-
end
|
108
|
-
|
109
|
-
else
|
110
|
-
logger.info "There is no `#{query_type}_query` in `#{model_class.to_s}` model."
|
111
|
-
end
|
112
|
-
else
|
113
|
-
logger.warn "`#{field}` in not in allowed list for `#{self.class.to_s}`."
|
114
|
-
end
|
115
|
-
end
|
116
|
-
else
|
117
|
-
logger.info("Load resource using `load_resource`")
|
118
|
-
#self.class.load_resource
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
# An array of allowed fields for query loading
|
123
|
-
def allowed_fields
|
124
|
-
@@allowed_fields
|
125
|
-
end
|
126
|
-
|
127
|
-
# Using this query you can activate the query loading system
|
128
|
-
# and specify fields which you want to use in query loading
|
129
|
-
def self.allow_query_on(*args)
|
130
|
-
@@allowed_fields = args.to_a.collect { |x| x.to_s }
|
131
|
-
end
|
132
|
-
|
133
44
|
protected
|
134
45
|
|
135
|
-
# Model class related to this controller.
|
136
|
-
def model_class
|
137
|
-
controller_name.singularize.classify.constantize
|
138
|
-
end
|
139
|
-
|
140
46
|
def verified_request?
|
141
47
|
super || form_authenticity_token == request.headers['X-XSRF-TOKEN']
|
142
48
|
end
|
143
49
|
|
50
|
+
:
|
144
51
|
end
|
data/app/models/faalis/user.rb
CHANGED
data/config/routes.rb
CHANGED
@@ -29,28 +29,4 @@ Faalis::Engine.routes.draw do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
|
32
|
-
namespace :api, :defaults => {:format => :json} do
|
33
|
-
namespace :v1 do
|
34
|
-
get 'permissions', :to => 'permissions#index'
|
35
|
-
get 'permissions/user', :to => 'permissions#user_permissions'
|
36
|
-
resources :groups, :except => [:new]
|
37
|
-
resources :users, :except => [:new]
|
38
|
-
resource :profile, :except => [:new, :destroy]
|
39
|
-
|
40
|
-
get 'logs' => 'logs#index'
|
41
|
-
get 'workflows' => 'workflows#index'
|
42
|
-
|
43
|
-
resources :conversations, only: [:index, :show, :create, :destroy] do
|
44
|
-
collection do
|
45
|
-
get ':box/box' => 'conversations#index'
|
46
|
-
post 'trash' => 'conversations#trash'
|
47
|
-
post 'untrash' => 'conversations#untrash'
|
48
|
-
end
|
49
|
-
member do
|
50
|
-
post :reply
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
32
|
end
|
data/lib/faalis.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
module Faalis
|
2
|
+
module Generators
|
3
|
+
class Relation < String
|
4
|
+
attr_accessor :to
|
5
|
+
|
6
|
+
def initialize(value, to, options = "")
|
7
|
+
super(value)
|
8
|
+
@options = options
|
9
|
+
@to = to
|
10
|
+
end
|
11
|
+
|
12
|
+
def resource_name
|
13
|
+
to.split("/").last
|
14
|
+
end
|
15
|
+
|
16
|
+
def to
|
17
|
+
result = "'"
|
18
|
+
if options.include? "parents"
|
19
|
+
field_parents.each do |parent|
|
20
|
+
result = "#{result}/#{parent}/' + $scope.#{parent}_id + '"
|
21
|
+
end
|
22
|
+
result = "#{result}/"
|
23
|
+
end
|
24
|
+
"#{result}#{@to}'"
|
25
|
+
end
|
26
|
+
|
27
|
+
def options
|
28
|
+
unless @options.empty?
|
29
|
+
Hash[@options.split(',').map {|pair| pair.strip.split(':').map(&:strip) }]
|
30
|
+
else
|
31
|
+
{}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def field_parents
|
36
|
+
if options.include? "parents"
|
37
|
+
options["parents"].split(";")
|
38
|
+
else
|
39
|
+
[]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def restangular
|
44
|
+
result = "API"
|
45
|
+
if options.include? "parents"
|
46
|
+
field_parents.each do |parent|
|
47
|
+
result = "#{result}.one('#{parent}', #{}_id)"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
to.split("/").each do |resource|
|
51
|
+
result = "#{result}.all(\"#{resource}\")"
|
52
|
+
end
|
53
|
+
result
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_list
|
57
|
+
"#{restangular}.getList()"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/faalis/route.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Faalis
|
2
|
+
class Routes
|
3
|
+
def self.define_api_routes(routes=Rails.application.routes)
|
4
|
+
|
5
|
+
routes.draw do
|
6
|
+
scope 'module'.to_sym => 'faalis' do
|
7
|
+
namespace :api, :defaults => {:format => :json} do
|
8
|
+
namespace :v1 do
|
9
|
+
get 'permissions', :to => 'permissions#index'
|
10
|
+
get 'permissions/user', :to => 'permissions#user_permissions'
|
11
|
+
resources :groups, :except => [:new]
|
12
|
+
resources :users, :except => [:new]
|
13
|
+
resource :profile, :except => [:new, :destroy]
|
14
|
+
|
15
|
+
get 'logs' => 'logs#index'
|
16
|
+
get 'workflows' => 'workflows#index'
|
17
|
+
|
18
|
+
resources :conversations, only: [:index, :show, :create, :destroy] do
|
19
|
+
collection do
|
20
|
+
get ':box/box' => 'conversations#index'
|
21
|
+
post 'trash' => 'conversations#trash'
|
22
|
+
post 'untrash' => 'conversations#untrash'
|
23
|
+
end
|
24
|
+
member do
|
25
|
+
post :reply
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/faalis/version.rb
CHANGED
@@ -45,12 +45,18 @@ module Faalis
|
|
45
45
|
|
46
46
|
def copy_js_manifest
|
47
47
|
template 'application.js', "#{angularjs_app_path}application.js"
|
48
|
+
empty_directory "#{angularjs_app_path}modules"
|
48
49
|
end
|
49
50
|
|
50
51
|
def copy_scss_manifest
|
51
52
|
directory 'stylesheets', 'app/assets/stylesheets'
|
52
53
|
end
|
53
54
|
|
55
|
+
def install_routes
|
56
|
+
route 'mount Faalis::Engine => "/"'
|
57
|
+
route 'Faalis::Routes.define_api_routes'
|
58
|
+
end
|
59
|
+
|
54
60
|
def show_readme
|
55
61
|
readme 'README' if behavior == :invoke
|
56
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faalis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.25.
|
4
|
+
version: 0.25.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sameer Rahmani
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -379,7 +379,6 @@ files:
|
|
379
379
|
- app/assets/javascripts/faalis/dashboard/app.js
|
380
380
|
- app/assets/javascripts/faalis/dashboard/application.js.erb
|
381
381
|
- app/assets/javascripts/faalis/dashboard/functions.js.erb
|
382
|
-
- app/assets/javascripts/faalis/dashboard/gen-doc.sh~
|
383
382
|
- app/assets/javascripts/faalis/dashboard/init.js
|
384
383
|
- app/assets/javascripts/faalis/dashboard/lib/angular-animate.js
|
385
384
|
- app/assets/javascripts/faalis/dashboard/lib/angular-gettext.js
|
@@ -472,9 +471,7 @@ files:
|
|
472
471
|
- app/assets/stylesheets/faalis/rtl/foundation_and_overrides.css.scss
|
473
472
|
- app/assets/stylesheets/faalis/users.css
|
474
473
|
- app/assets/stylesheets/faalis/variables.css.scss
|
475
|
-
- app/controllers/faalis/#1.sh#
|
476
474
|
- app/controllers/faalis/#api_controller.rb#
|
477
|
-
- app/controllers/faalis/api/v1/#conversations_controller.rb#
|
478
475
|
- app/controllers/faalis/api/v1/conversations_controller.rb
|
479
476
|
- app/controllers/faalis/api/v1/groups_controller.rb
|
480
477
|
- app/controllers/faalis/api/v1/logs_controller.rb
|
@@ -628,6 +625,7 @@ files:
|
|
628
625
|
- lib/faalis/generators/concerns/tabs.rb
|
629
626
|
- lib/faalis/generators/concerns/where.rb
|
630
627
|
- lib/faalis/generators/dashboard_scaffold.rb
|
628
|
+
- lib/faalis/generators/fields/#relation.rb#
|
631
629
|
- lib/faalis/generators/fields/relation.rb
|
632
630
|
- lib/faalis/i18n.rb
|
633
631
|
- lib/faalis/initialize.rb
|
@@ -635,6 +633,7 @@ files:
|
|
635
633
|
- lib/faalis/omniauth/callbacks.rb
|
636
634
|
- lib/faalis/permissions.rb
|
637
635
|
- lib/faalis/plugins.rb
|
636
|
+
- lib/faalis/route.rb
|
638
637
|
- lib/faalis/version.rb
|
639
638
|
- lib/faalis/workflows.rb
|
640
639
|
- lib/faalis/workflows/base.rb
|
@@ -720,14 +719,10 @@ files:
|
|
720
719
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
721
720
|
- spec/dummy/config/locales/en.yml
|
722
721
|
- spec/dummy/config/routes.rb
|
723
|
-
- spec/dummy/log/development.log
|
724
|
-
- spec/dummy/log/test.log
|
725
722
|
- spec/dummy/public/404.html
|
726
723
|
- spec/dummy/public/422.html
|
727
724
|
- spec/dummy/public/500.html
|
728
725
|
- spec/dummy/public/favicon.ico
|
729
|
-
- spec/dummy/tmp/ember-rails/ember-data.js
|
730
|
-
- spec/dummy/tmp/ember-rails/ember.js
|
731
726
|
- spec/factories/faalis_workflows.rb
|
732
727
|
- spec/models/faalis/workflow_spec.rb
|
733
728
|
- spec/spec_helper.rb
|
@@ -757,42 +752,38 @@ specification_version: 4
|
|
757
752
|
summary: Faalis is a ruby on rails engine which provides a very basic web application
|
758
753
|
to use with other ruby on rails applications.
|
759
754
|
test_files:
|
760
|
-
- spec/spec_helper.rb
|
761
755
|
- spec/models/faalis/workflow_spec.rb
|
762
|
-
- spec/
|
763
|
-
- spec/dummy/
|
764
|
-
- spec/dummy/tmp/ember-rails/ember-data.js
|
765
|
-
- spec/dummy/log/development.log
|
766
|
-
- spec/dummy/log/test.log
|
767
|
-
- spec/dummy/public/500.html
|
768
|
-
- spec/dummy/public/404.html
|
769
|
-
- spec/dummy/public/422.html
|
770
|
-
- spec/dummy/public/favicon.ico
|
771
|
-
- spec/dummy/config.ru
|
772
|
-
- spec/dummy/README.rdoc
|
756
|
+
- spec/spec_helper.rb
|
757
|
+
- spec/dummy/app/controllers/application_controller.rb
|
773
758
|
- spec/dummy/app/views/layouts/application.html.erb
|
759
|
+
- spec/dummy/app/helpers/application_helper.rb
|
774
760
|
- spec/dummy/app/assets/javascripts/application.js
|
775
761
|
- spec/dummy/app/assets/stylesheets/application.css
|
776
|
-
- spec/dummy/app/controllers/application_controller.rb
|
777
|
-
- spec/dummy/app/helpers/application_helper.rb
|
778
|
-
- spec/dummy/Rakefile
|
779
|
-
- spec/dummy/bin/rake
|
780
762
|
- spec/dummy/bin/bundle
|
781
763
|
- spec/dummy/bin/rails
|
764
|
+
- spec/dummy/bin/rake
|
765
|
+
- spec/dummy/public/404.html
|
766
|
+
- spec/dummy/public/422.html
|
767
|
+
- spec/dummy/public/500.html
|
768
|
+
- spec/dummy/public/favicon.ico
|
769
|
+
- spec/dummy/config.ru
|
782
770
|
- spec/dummy/config/application.rb
|
783
|
-
- spec/dummy/config/environments/test.rb
|
784
771
|
- spec/dummy/config/environments/development.rb
|
772
|
+
- spec/dummy/config/environments/test.rb
|
785
773
|
- spec/dummy/config/environments/production.rb
|
786
|
-
- spec/dummy/config/
|
774
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
775
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
776
|
+
- spec/dummy/config/initializers/secret_token.rb
|
777
|
+
- spec/dummy/config/initializers/session_store.rb
|
778
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
779
|
+
- spec/dummy/config/initializers/mime_types.rb
|
780
|
+
- spec/dummy/config/initializers/inflections.rb
|
787
781
|
- spec/dummy/config/environment.rb
|
788
782
|
- spec/dummy/config/database.yml
|
789
783
|
- spec/dummy/config/locales/en.yml
|
784
|
+
- spec/dummy/config/routes.rb
|
790
785
|
- spec/dummy/config/boot.rb
|
791
|
-
- spec/dummy/
|
792
|
-
- spec/dummy/
|
793
|
-
- spec/
|
794
|
-
- spec/dummy/config/initializers/inflections.rb
|
795
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
796
|
-
- spec/dummy/config/initializers/mime_types.rb
|
797
|
-
- spec/dummy/config/initializers/secret_token.rb
|
786
|
+
- spec/dummy/README.rdoc
|
787
|
+
- spec/dummy/Rakefile
|
788
|
+
- spec/factories/faalis_workflows.rb
|
798
789
|
has_rdoc:
|